Migrate esc-b/f sequences to Linux

develop
lethosor 2014-05-25 22:10:40 -04:00
parent 1fcaac9d2e
commit 58b9c02ce5
1 changed files with 34 additions and 2 deletions

@ -480,14 +480,46 @@ namespace DFHack
break; break;
case 27: // escape sequence case 27: // escape sequence
lock->unlock(); lock->unlock();
if(!read_char(seq[0]) || !read_char(seq[1])) if (!read_char(seq[0]))
{ {
lock->lock(); lock->lock();
return -2; return -2;
} }
lock->lock(); 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') if (seq[1] == 'D')
{ {
left_arrow: left_arrow: