boolean TextManip::HandleKey (Event& e) { World* world = GetViewer()->GetWorld(); char c = e.keystring[0]; boolean manipulating = true; switch (c) { case '\007': world->RingBell(1); break; case '\001': BeginningOfLine(); break; case '\005': EndOfLine(); break; case '\006': ForwardCharacter(1); break; case '\002': BackwardCharacter(1); break; case '\016': ForwardLine(1); break; case '\020': BackwardLine(1); break; case '\013': DeleteLine(); break; case '\004': DeleteCharacter(1); break; case '\010': DeleteCharacter(-1); break; case '\177': DeleteCharacter(-1); break; case '\011': InsertCharacter('\t'); break; case '\015': if (_multiline) InsertCharacter('\n'); break; case '\033': manipulating = false; break; default: if (!iscntrl(c & 0x7f)) { InsertCharacter(c); } break; } return manipulating; }
void TextEditor::ForwardPage (int count) { int pagesize = perspective->curheight / perspective->sy; ForwardLine(pagesize * count); }
boolean ClassEditor::HandleChar (char c) { boolean done = false; int lines = display->LineNumber(0) - display->LineNumber(ymax) + 1; int i; switch (c) { case FirstLine: BeginningOfText(); ScrollToSelection(); break; case LastLine: EndOfText(); ScrollToSelection(); break; case PrevLine: BackwardLine(); ScrollToSelection(); break; case NextLine: ForwardLine(); ScrollToSelection(); break; case PageDown: ForwardPage(); ScrollToSelection(); break; case PageUp: BackwardPage(1); ScrollToSelection(); break; case HalfPageDown: ForwardLine(lines/2); ScrollToSelection(); break; case HalfPageUp: BackwardLine(lines/2); ScrollToSelection(); break; case ScrollDown: ScrollBy(1); break; case ScrollUp: ScrollBy(-1); break; default: for (i = 0; _done[i] != '\0'; ++i) { if (c == _done[i]) { _state->SetValue(c); done = true; } } break; } return done; }