From 02d66e1b1d7de9a0510994b93b2f83bf16d86bdb Mon Sep 17 00:00:00 2001 From: Oliver Kiehl Date: Sat, 14 Dec 2002 22:25:09 +0000 Subject: fixed ctrl-w and added ctrl-d and svn-id: r5970 --- gui/console.cpp | 24 +++++++++++++++++++++++- gui/console.h | 1 + 2 files changed, 24 insertions(+), 1 deletion(-) (limited to 'gui') diff --git a/gui/console.cpp b/gui/console.cpp index 5e9316bd21..432c4db2ee 100644 --- a/gui/console.cpp +++ b/gui/console.cpp @@ -163,6 +163,10 @@ void ConsoleDialog::handleKeyDown(uint16 ascii, int keycode, int modifiers) scrollToCurrent(); draw(); // FIXME - not nice to redraw the full console just for one char! break; + case 127: + killChar(); + draw(); + break; /* case 256+24: // pageup _selectedItem -= _entriesPerPage - 1; @@ -231,6 +235,10 @@ void ConsoleDialog::specialKeys(int keycode) _currentPos = _promptStartPos; draw(); break; + case 'd': + killChar(); + draw(); + break; case 'e': _currentPos = _promptEndPos; draw(); @@ -246,6 +254,14 @@ void ConsoleDialog::specialKeys(int keycode) } } +void ConsoleDialog::killChar() +{ + for (int i = _currentPos; i < _promptEndPos; i++) + _buffer[i % kBufferSize] = _buffer[(i+1) % kBufferSize]; + _buffer[_promptEndPos % kBufferSize] = ' '; + _promptEndPos--; +} + void ConsoleDialog::killLine() { for (int i = _currentPos; i < _promptEndPos; i++) @@ -256,14 +272,20 @@ void ConsoleDialog::killLine() void ConsoleDialog::killLastWord() { int pos; + int cnt = 0; while (_currentPos > _promptStartPos) { _currentPos--; pos = getBufferPos(); if (_buffer[pos] != ' ') - _buffer[pos] = ' '; + cnt++; else break; } + + for (int i = _currentPos; i < _promptEndPos; i++) + _buffer[i % kBufferSize] = _buffer[(i+cnt+1) % kBufferSize]; + _buffer[_promptEndPos % kBufferSize] = ' '; + _promptEndPos--; } void ConsoleDialog::nextLine() diff --git a/gui/console.h b/gui/console.h index ad764aff5d..fd0042e9df 100644 --- a/gui/console.h +++ b/gui/console.h @@ -82,6 +82,7 @@ protected: // Line editing void specialKeys(int keycode); + void killChar(); void killLine(); void killLastWord(); }; -- cgit v1.2.3