[tyndur-devel] [PATCH 3/4] libc: Wortweise Navigation fuer readline()
Kevin Wolf ·
Am Sonntag, 17. Mai 2009 18:19 schrieb Antoine Kaufmann: > + libc: Wortweise Navigation fuer readline() > > Signed-off-by: Antoine Kaufmann <toni at tyndur.org> > --- > src/modules/lib/readline.c | 72 > ++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 72 > insertions(+), 0 deletions(-) > > diff --git a/src/modules/lib/readline.c b/src/modules/lib/readline.c > index e740f22..93cd0b9 100644 > --- a/src/modules/lib/readline.c > +++ b/src/modules/lib/readline.c > @@ -32,6 +32,7 @@ > #include <stdint.h> > #include <collections.h> > #include <wchar.h> > +#include <wctype.h> > > #include <readline/readline.h> > > @@ -51,6 +52,10 @@ typedef enum { > BEGINNING_OF_LINE, > /// Cursor an das Ende der Zeile bewegen > END_OF_LINE, > + /// Cursor ans Ende des aktuellen/naechsten Worts bewegen > + FORWARD_WORD, > + /// Cursor an den Anfang des aktuellen/vorherigen Worts bewegen > + BACKWARD_WORD, > > // Text editieren > /// Zeile abschliessen > @@ -82,6 +87,10 @@ static struct { > { L"\033[H", BEGINNING_OF_LINE }, > /// Ende > { L"\033[F", END_OF_LINE }, > + /// Alt + Pfeil rechts > + { L"\033\033[C", FORWARD_WORD }, > + /// Alt + Pfeil links > + { L"\033\033[D", BACKWARD_WORD }, > > /// Enter > { L"\n", ACCEPT_LINE }, > @@ -181,6 +190,53 @@ static int count_visible_chars(wchar_t* buffer, int > start, int size) } > > /** > + * Position des naechsten Wortendes suchen Strenggenommen das nächste Zeichen hinter dem Wortende. Ansonsten fällt mir im Moment nicht direkt auf, was daran kaputt ist.