#include "everything.hpp" // Substitute tab characters into regular tabs string substitute_tabs(string s) { string ret = ""; for(count_type i = 0; i < s.size(); ++i) { if(s[i] == '\t') { ret += ' '; while(ret.size() % TAB_SIZE != 0) ret += ' '; } else ret += s[i]; } return ret; } // Get how much tabs changed position on a row count_type get_tab_offset(count_type c, string text) { count_type tab_offset = 0; for(count_type i = 0; i + tab_offset < c; ++i) { if(text[i] == '\t') tab_offset += TAB_SIZE - (i+tab_offset) % TAB_SIZE - 1; if(i + tab_offset > c) tab_offset -= i + tab_offset - c; } return tab_offset; } int main(int argc, char* argv[]) { // Check argument if(argc <= 1) { std::cerr << "No input filename\n"; return 1; } string filename = argv[1]; // Check existing file std::ifstream infile(filename); if(!infile.good()) { std::cerr << "Bad input filename\n"; return 1; } // Load file Treap file; string line; while (std::getline(infile, line)) file.insert(file.size(), line); // Init initscr(); refresh(); Editor ed(filename, file); // Main loop while(ed.take_action()) refresh(); // End endwin(); return 0; }