diff --git a/src/Editor.cpp b/src/Editor.cpp index faa6482..54b6c54 100644 --- a/src/Editor.cpp +++ b/src/Editor.cpp @@ -9,7 +9,7 @@ namespace groove { Editor::Editor(std::string filename) : x(0), y(0), buffer(std::make_unique()), mode_(Mode::EDIT), filename(filename), offset(0), voffset(0), lineMode(LineMode::RELATIVE), - history(History()) { + history(History()), inComment(false) { this->modes.emplace(Mode::INSERT, std::make_unique(*this)); this->modes.emplace(Mode::EDIT, std::make_unique(*this)); this->modes.emplace(Mode::QUIT, std::make_unique(*this)); @@ -95,6 +95,10 @@ namespace groove { } for (auto& car : line) { + if (car == '*' && this->lastChar == '/') + this->inComment = true; + if (car == '/' && this->lastChar == '*') + this->inComment = false; if (hilist.find(x - this->vspace) != hilist.end()) { found = x - this->vspace; len = hilist.at(x - this->vspace).first; @@ -108,8 +112,11 @@ namespace groove { len = -1; } } + if (inComment) + attron(COLOR_PAIR(ncurses::Colors::ORANGE)); mvaddch(i - this->offset, x , car); attron(COLOR_PAIR(ncurses::Colors::MAIN)); + this->lastChar = car; x++; } //mvprintw(i - this->offset, 0, line.c_str()); diff --git a/src/Editor.hpp b/src/Editor.hpp index 29dbd7e..d85d50d 100644 --- a/src/Editor.hpp +++ b/src/Editor.hpp @@ -38,6 +38,7 @@ namespace groove { int offset; int voffset; long vspace; + bool inComment; char lastChar = 0; History history; LineMode lineMode; diff --git a/src/modes/Edit.cpp b/src/modes/Edit.cpp index e1a5559..7703bf0 100644 --- a/src/modes/Edit.cpp +++ b/src/modes/Edit.cpp @@ -89,6 +89,13 @@ namespace groove { break; case 'r': this->editor.history.redo(); + break; + case '^': + this->editor.x = 0; + break; + case '$': + this->editor.x = this->editor.buffer->at(this->editor.y).size(); + break; } } }