added pageup/down support; tried help screen, not working yet, though

development
Michael Ochmann 8 years ago
parent 7d2b26de68
commit 0b66d839be
  1. 6
      src/Editor.cpp
  2. 10
      src/Editor.hpp
  3. 13
      src/modes/Edit.cpp
  4. 5
      src/ncurses/ncurses.hpp

@ -14,6 +14,10 @@ namespace groove {
this->modes.emplace(Mode::EDIT, std::make_unique<modes::Edit>(*this));
this->modes.emplace(Mode::QUIT, std::make_unique<modes::Quit>(*this));
this->modes.emplace(Mode::SAVE, std::make_unique<modes::Save>(*this));
this->overlay = newwin(LINES * 0.9, COLS * 0.9, (LINES * 0.1f) / 2.0f, (COLS * 0.1f) / 2.0f);
box(this->overlay, 0, 0);
if (!this->load()) {
std::cerr << "Could not open file: '" << this->filename << "', creating it on save.\n";
this->buffer->insert("");
@ -126,6 +130,8 @@ namespace groove {
}
this->status();
move(static_cast<int>(this->y - this->offset), static_cast<int>(this->x + this->vspace));
this->renderOverlay();
}
void Editor::status() {

@ -40,6 +40,7 @@ namespace groove {
long vspace;
bool inComment;
char lastChar = 0;
WINDOW* overlay;
History history;
LineMode lineMode;
std::unique_ptr<Buffer> buffer;
@ -126,11 +127,20 @@ namespace groove {
return false;
}
}
void renderOverlay() {
wbkgd(this->overlay, COLOR_PAIR(ncurses::Colors::STATUSBAR));
mvwaddstr(this->overlay, 3, 3, "Hallo win");
refresh();
wrefresh(this->overlay);
}
public:
Editor(std::string file = "ubenannt");
Mode mode() {
return this->mode_;
}
~Editor() {
delete this->overlay;
}
void input(int c);
void render();
static long Digits(long number);

@ -1,9 +1,10 @@
#include <modes/Edit.hpp>
#include <Editor.hpp>
#include <ncurses.h>
namespace groove {
namespace modes {
void Edit::input(int c) {
if (this->editor.movement(c))
return;
@ -104,6 +105,16 @@ namespace groove {
this->editor.y = this->editor.buffer->size() - 1;
this->editor.offset = this->editor.buffer->size() - LINES + 1;
break;
case KEY_NPAGE:
for (int i = 0; i < LINES; i++) {
this->editor.down();
}
break;
case KEY_PPAGE:
for (int i = 0; i < LINES; i++) {
this->editor.up();
}
break;
}
}
}

@ -30,8 +30,11 @@ namespace groove {
};
class ncurses {
private:
WINDOW* overlay;
public:
ncurses() {};
ncurses() {
};
void init() {
setlocale(LC_ALL, "");
initscr(); // Start ncurses mode

Loading…
Cancel
Save