OS X Console: Implement back/forward one word escape sequences

develop
lethosor 2014-05-25 21:52:16 -04:00
parent e4a6f13347
commit 1fcaac9d2e
1 changed files with 34 additions and 2 deletions

@ -478,14 +478,46 @@ namespace DFHack
break;
case 27: // escape sequence
lock->unlock();
if(!read_char(seq[0]) || !read_char(seq[1]))
if (!read_char(seq[0]))
{
lock->lock();
return -2;
}
lock->lock();
if(seq[0] == '[')
if (seq[0] == 'b')
{
// Back one word
if (raw_cursor == 0)
break;
raw_cursor--;
while (raw_cursor > 0 && !isalnum(raw_buffer[raw_cursor]))
raw_cursor--;
while (raw_cursor > 0 && isalnum(raw_buffer[raw_cursor]))
raw_cursor--;
if (!isalnum(raw_buffer[raw_cursor]))
raw_cursor++;
prompt_refresh();
}
else if (seq[0] == 'f')
{
// Forward one word
int len = raw_buffer.size();
if (raw_cursor == len)
break;
raw_cursor++;
while (raw_cursor <= len && !isalnum(raw_buffer[raw_cursor]))
raw_cursor++;
while (raw_cursor <= len && isalnum(raw_buffer[raw_cursor]))
raw_cursor++;
prompt_refresh();
}
else if(seq[0] == '[')
{
if (!read_char(seq[1]))
{
lock->lock();
return -2;
}
if (seq[1] == 'D')
{
left_arrow: