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. 11
      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::EDIT, std::make_unique<modes::Edit>(*this));
this->modes.emplace(Mode::QUIT, std::make_unique<modes::Quit>(*this)); this->modes.emplace(Mode::QUIT, std::make_unique<modes::Quit>(*this));
this->modes.emplace(Mode::SAVE, std::make_unique<modes::Save>(*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()) { if (!this->load()) {
std::cerr << "Could not open file: '" << this->filename << "', creating it on save.\n"; std::cerr << "Could not open file: '" << this->filename << "', creating it on save.\n";
this->buffer->insert(""); this->buffer->insert("");
@ -126,6 +130,8 @@ namespace groove {
} }
this->status(); this->status();
move(static_cast<int>(this->y - this->offset), static_cast<int>(this->x + this->vspace)); move(static_cast<int>(this->y - this->offset), static_cast<int>(this->x + this->vspace));
this->renderOverlay();
} }
void Editor::status() { void Editor::status() {

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

@ -1,5 +1,6 @@
#include <modes/Edit.hpp> #include <modes/Edit.hpp>
#include <Editor.hpp> #include <Editor.hpp>
#include <ncurses.h>
namespace groove { namespace groove {
namespace modes { namespace modes {
@ -104,6 +105,16 @@ namespace groove {
this->editor.y = this->editor.buffer->size() - 1; this->editor.y = this->editor.buffer->size() - 1;
this->editor.offset = this->editor.buffer->size() - LINES + 1; this->editor.offset = this->editor.buffer->size() - LINES + 1;
break; 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 { class ncurses {
private:
WINDOW* overlay;
public: public:
ncurses() {}; ncurses() {
};
void init() { void init() {
setlocale(LC_ALL, ""); setlocale(LC_ALL, "");
initscr(); // Start ncurses mode initscr(); // Start ncurses mode

Loading…
Cancel
Save