X-Git-Url: https://git.proxmox.com/?a=blobdiff_plain;f=readline.c;h=1c0f7ee26b2de0d19c7da8c1a4752422f0922792;hb=685ee2d940738e771c96de33a3cbd85abfbbb3c5;hp=540cd8a025d145dd3fe28e538bd79f9198e9c5fc;hpb=23797df3d9f08031d19aaaa1d2863d5feebe3d8b;p=qemu.git diff --git a/readline.c b/readline.c index 540cd8a02..1c0f7ee26 100644 --- a/readline.c +++ b/readline.c @@ -21,12 +21,13 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ -#include "readline.h" -#include "monitor.h" +#include "monitor/readline.h" +#include "monitor/monitor.h" #define IS_NORM 0 #define IS_ESC 1 #define IS_CSI 2 +#define IS_SS3 3 #undef printf #define printf do_not_use_printf @@ -247,14 +248,14 @@ static void readline_hist_add(ReadLineState *rs, const char *cmdline) } if (idx == READLINE_MAX_CMDS) { /* Need to get one free slot */ - free(rs->history[0]); - memcpy(rs->history, &rs->history[1], - (READLINE_MAX_CMDS - 1) * sizeof(char *)); + g_free(rs->history[0]); + memmove(rs->history, &rs->history[1], + (READLINE_MAX_CMDS - 1) * sizeof(char *)); rs->history[READLINE_MAX_CMDS - 1] = NULL; idx = READLINE_MAX_CMDS - 1; } if (new_entry == NULL) - new_entry = strdup(cmdline); + new_entry = g_strdup(cmdline); rs->history[idx] = new_entry; rs->hist_entry = -1; } @@ -397,6 +398,9 @@ void readline_handle_byte(ReadLineState *rs, int ch) if (ch == '[') { rs->esc_state = IS_CSI; rs->esc_param = 0; + } else if (ch == 'O') { + rs->esc_state = IS_SS3; + rs->esc_param = 0; } else { rs->esc_state = IS_NORM; } @@ -439,6 +443,17 @@ void readline_handle_byte(ReadLineState *rs, int ch) rs->esc_state = IS_NORM; the_end: break; + case IS_SS3: + switch(ch) { + case 'F': + readline_eol(rs); + break; + case 'H': + readline_bol(rs); + break; + } + rs->esc_state = IS_NORM; + break; } readline_update(rs); }