|
|
@ -307,6 +307,33 @@ namespace DFHack
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/// beep. maybe?
|
|
|
|
/// beep. maybe?
|
|
|
|
//void beep (void);
|
|
|
|
//void beep (void);
|
|
|
|
|
|
|
|
void back_word()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if (raw_cursor == 0)
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
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 != 0)
|
|
|
|
|
|
|
|
raw_cursor++;
|
|
|
|
|
|
|
|
prompt_refresh();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
void forward_word()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
int len = raw_buffer.size();
|
|
|
|
|
|
|
|
if (raw_cursor == len)
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
raw_cursor++;
|
|
|
|
|
|
|
|
while (raw_cursor <= len && !isalnum(raw_buffer[raw_cursor]))
|
|
|
|
|
|
|
|
raw_cursor++;
|
|
|
|
|
|
|
|
while (raw_cursor <= len && isalnum(raw_buffer[raw_cursor]))
|
|
|
|
|
|
|
|
raw_cursor++;
|
|
|
|
|
|
|
|
if (raw_cursor > len)
|
|
|
|
|
|
|
|
raw_cursor = len;
|
|
|
|
|
|
|
|
prompt_refresh();
|
|
|
|
|
|
|
|
}
|
|
|
|
/// A simple line edit (raw mode)
|
|
|
|
/// A simple line edit (raw mode)
|
|
|
|
int lineedit(const std::string& prompt, std::string& output, recursive_mutex * lock, CommandHistory & ch)
|
|
|
|
int lineedit(const std::string& prompt, std::string& output, recursive_mutex * lock, CommandHistory & ch)
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -488,30 +515,11 @@ namespace DFHack
|
|
|
|
lock->lock();
|
|
|
|
lock->lock();
|
|
|
|
if (seq[0] == 'b')
|
|
|
|
if (seq[0] == 'b')
|
|
|
|
{
|
|
|
|
{
|
|
|
|
// Back one word
|
|
|
|
back_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')
|
|
|
|
else if (seq[0] == 'f')
|
|
|
|
{
|
|
|
|
{
|
|
|
|
// Forward one word
|
|
|
|
forward_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] == '[')
|
|
|
|
else if(seq[0] == '[')
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -579,6 +587,7 @@ namespace DFHack
|
|
|
|
else if (seq[1] > '0' && seq[1] < '7')
|
|
|
|
else if (seq[1] > '0' && seq[1] < '7')
|
|
|
|
{
|
|
|
|
{
|
|
|
|
// extended escape
|
|
|
|
// extended escape
|
|
|
|
|
|
|
|
unsigned char seq3[3];
|
|
|
|
lock->unlock();
|
|
|
|
lock->unlock();
|
|
|
|
if(!read_char(seq2))
|
|
|
|
if(!read_char(seq2))
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -595,6 +604,24 @@ namespace DFHack
|
|
|
|
prompt_refresh();
|
|
|
|
prompt_refresh();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!read_char(seq3[0]) || !read_char(seq3[1]))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
lock->lock();
|
|
|
|
|
|
|
|
return -2;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (seq2 == ';')
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
// Format: esc [ n ; n DIRECTION
|
|
|
|
|
|
|
|
// Ignore first character (second "n")
|
|
|
|
|
|
|
|
if (seq3[1] == 'C')
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
forward_word();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else if (seq3[1] == 'D')
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
back_word();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|