diff --git a/CMakeLists.txt b/CMakeLists.txt index 5a85fa1..b8fb007 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -23,4 +23,6 @@ include_directories( add_executable(groove main.cpp ${SOURCE_FILES} ${HEADER_FILES}) -target_link_libraries(groove ncursesw) \ No newline at end of file +target_link_libraries(groove ncursesw) + +install(TARGETS groove DESTINATION /usr/bin) \ No newline at end of file diff --git a/src/Editor.cpp b/src/Editor.cpp index 07bbfeb..5544aab 100644 --- a/src/Editor.cpp +++ b/src/Editor.cpp @@ -55,11 +55,11 @@ namespace groove { } void Editor::render() { - int linenumber = 0; + long linenumber = this->offset; this->vspace = Editor::Digits(this->buffer->linebuffer().size()) + 2; clear(); - for (int i = 0; i < LINES - 1 + this->offset; i++) { - unsigned long ln = static_cast(std::sqrt(std::pow(static_cast(this->y - linenumber), 2))); + for (int i = this->offset; i < LINES - 1 + this->offset; i++) { + long ln = static_cast(std::sqrt(std::pow(static_cast(this->y - linenumber), 2))); ln = ln == 0 ? linenumber : ln; if(i >= this->buffer->linebuffer().size()) { move(i - this->offset, 0); @@ -68,15 +68,15 @@ namespace groove { else { std::string line = this->buffer->at(i); Highlighter highlighter(line); - std::unordered_map> hilist = highlighter.get(); - int x = this->vspace; - int found = -1; - int len = -1; + std::unordered_map> hilist = highlighter.get(); + long x = this->vspace; + long found = -1; + long len = -1; std::string label = std::string(x - Editor::Digits(ln) - 1, ' '); label += std::to_string(ln) + ' '; if (linenumber != this->y) attron(A_REVERSE); - mvprintw(i - this->offset, 0, label.c_str()); + mvprintw(i - offset, 0, label.c_str()); if (linenumber != this->y) attroff(A_REVERSE); for (auto& car : line) { @@ -119,8 +119,8 @@ namespace groove { attroff(COLOR_PAIR(ncurses::Colors::STATUSBAR)); } - unsigned long Editor::Digits(unsigned long number) { - return number > 0 ? static_cast(log10 ((double) number) + 1) : 1; + long Editor::Digits(long number) { + return number > 0 ? static_cast(log10 ((double) number) + 1) : 1; } } \ No newline at end of file diff --git a/src/Editor.hpp b/src/Editor.hpp index 30e68d5..b74fe12 100644 --- a/src/Editor.hpp +++ b/src/Editor.hpp @@ -25,9 +25,9 @@ namespace groove { friend class modes::Quit; friend class modes::Save; private: - unsigned long x, y; + long x, y; int offset; - unsigned long vspace; + long vspace; char lastChar = 0; std::unique_ptr buffer; Mode mode_; @@ -73,7 +73,7 @@ namespace groove { return; } if (this->x >= this->buffer->linebuffer().at(this->y).length()) { - unsigned long length = this->buffer->linebuffer().at(this->y).length(); + long length = this->buffer->linebuffer().at(this->y).length(); this->x = length > 0 ? length - 1 : 0; } this->scrollUp(); @@ -85,7 +85,7 @@ namespace groove { return; } if (this->x >= this->buffer->linebuffer().at(this->y).length()) { - unsigned long length = this->buffer->linebuffer().at(this->y).length(); + long length = this->buffer->linebuffer().at(this->y).length(); this->x = length > 0 ? length - 1 : 0; } this->scrollDown(); @@ -116,7 +116,7 @@ namespace groove { } void input(int c); void render(); - static unsigned long Digits(unsigned long number); + static long Digits(long number); }; } \ No newline at end of file diff --git a/src/Highlighter.cpp b/src/Highlighter.cpp index 48c5c2a..09c52fb 100644 --- a/src/Highlighter.cpp +++ b/src/Highlighter.cpp @@ -14,11 +14,11 @@ namespace groove { make_pair("\\\".*\\\"", ncurses::Colors::ORANGE), make_pair("/\\*.*\\*//*", ncurses::Colors::ORANGE), make_pair("(//.*)", ncurses::Colors::ORANGE), - make_pair("(^#.*)", ncurses::Colors::ORANGE) + make_pair("(#.*<.*>$)", ncurses::Colors::ORANGE) }; - std::unordered_map> groove::Highlighter::get() { - std::unordered_map> list; + std::unordered_map> groove::Highlighter::get() { + std::unordered_map> list; for (auto& keyword : Highlighter::list) { try { diff --git a/src/Highlighter.hpp b/src/Highlighter.hpp index bebc66d..a6308aa 100644 --- a/src/Highlighter.hpp +++ b/src/Highlighter.hpp @@ -18,7 +18,7 @@ namespace groove { static std::vector> list; public: Highlighter(std::string line) : line(line) {} - std::unordered_map> get(); + std::unordered_map> get(); }; } \ No newline at end of file diff --git a/src/modes/Edit.cpp b/src/modes/Edit.cpp index 6191a33..cd76315 100644 --- a/src/modes/Edit.cpp +++ b/src/modes/Edit.cpp @@ -28,7 +28,7 @@ namespace groove { this->editor.clipboard = this->editor.buffer->at(this->editor.y); this->editor.buffer->remove(this->editor.y); break; - case 'p': + case 'v': this->editor.buffer->insert(this->editor.clipboard, this->editor.y); this->editor.y++; this->editor.x = this->editor.buffer->at(this->editor.y).size(); diff --git a/src/modes/Edit.hpp b/src/modes/Edit.hpp index a1d1649..a3bd890 100644 --- a/src/modes/Edit.hpp +++ b/src/modes/Edit.hpp @@ -9,7 +9,7 @@ namespace groove { public: using Mode::Mode; std::string status() { - return "[E]" + this->status_; + return this->status_; } void input(int c); }; diff --git a/src/modes/Insert.hpp b/src/modes/Insert.hpp index a0999d3..9e07f3e 100644 --- a/src/modes/Insert.hpp +++ b/src/modes/Insert.hpp @@ -9,7 +9,7 @@ namespace groove { public: using Mode::Mode; std::string status() { - return "[I]" + this->status_; + return " -- INSERT --" + this->status_; } void input(int c); };