|
|
|
@ -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<unsigned long>(std::sqrt(std::pow(static_cast<double>(this->y - linenumber), 2))); |
|
|
|
|
for (int i = this->offset; i < LINES - 1 + this->offset; i++) { |
|
|
|
|
long ln = static_cast<long>(std::sqrt(std::pow(static_cast<double>(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<int, std::pair<int, ncurses::Colors>> hilist = highlighter.get(); |
|
|
|
|
int x = this->vspace; |
|
|
|
|
int found = -1; |
|
|
|
|
int len = -1; |
|
|
|
|
std::unordered_map<long, std::pair<long, ncurses::Colors>> 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<unsigned long>(log10 ((double) number) + 1) : 1; |
|
|
|
|
long Editor::Digits(long number) { |
|
|
|
|
return number > 0 ? static_cast<long>(log10 ((double) number) + 1) : 1; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |