fixed scrolling issue on insert mode

development
Michael Ochmann 8 years ago
parent 1f675cf276
commit b509cb6d50
  1. 4
      src/Buffer.hpp
  2. 4
      src/Editor.cpp
  3. 4
      src/Editor.hpp

@ -48,6 +48,10 @@ namespace groove {
std::string& at(int line) {
return this->lines.at(line);
}
unsigned long size() {
return this->lines.size();
}
};
}

@ -110,6 +110,7 @@ namespace groove {
this->y++;
this->buffer->linebuffer().at(this->y) += appendix;
this->x = 0;
this->scrollDown();
}
break;
case KEY_BACKSPACE:
@ -133,6 +134,7 @@ namespace groove {
}
}
}
scrollUp();
break;
case KEY_DC:
if (this->buffer->at(this->y).length() > this->x)
@ -198,7 +200,7 @@ namespace groove {
int space = Editor::Digits(this->buffer->linebuffer().size()) + 2;
clear();
for (int i = 0; i < LINES - 1 + this->offset; i++) {
int ln = std::sqrt(std::pow(static_cast<double>(this->y - linenumber), 2));
int ln = static_cast<int>(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);

@ -31,7 +31,7 @@ namespace groove {
this->offset--;
}
void scrollDown() {
if (this->y >= LINES - 1)
if (this->y - this->offset >= LINES - 1 && this->y < this->buffer->size())
this->offset++;
}
void left() {
@ -55,7 +55,7 @@ namespace groove {
this->scrollUp();
}
void down() {
if (this->y + 1 < this->buffer->linebuffer().size())
if (this->y + 1 < this->buffer->linebuffer().size() )
this->y++;
else {
return;

Loading…
Cancel
Save