degesch: a bit of cleanup

This commit is contained in:
Přemysl Eric Janouch 2015-05-07 18:39:43 +02:00
parent 5271bfb1ee
commit a15a48ac25

View File

@ -1548,14 +1548,15 @@ log_message_attributed (void *user_data, const char *quote, const char *fmt,
va_list ap) va_list ap)
{ {
FILE *stream = stderr; FILE *stream = stderr;
struct app_context *ctx = g_ctx;
input_hide (&g_ctx->input); input_hide (&ctx->input);
print_attributed (g_ctx, stream, (intptr_t) user_data, "%s", quote); print_attributed (ctx, stream, (intptr_t) user_data, "%s", quote);
vprint_attributed (g_ctx, stream, (intptr_t) user_data, fmt, ap); vprint_attributed (ctx, stream, (intptr_t) user_data, fmt, ap);
fputs ("\n", stream); fputs ("\n", stream);
input_show (&g_ctx->input); input_show (&ctx->input);
} }
static void static void
@ -5414,40 +5415,40 @@ on_readline_return (int count, int key)
(void) count; (void) count;
(void) key; (void) key;
struct input *self = &g_ctx->input; struct app_context *ctx = g_ctx;
// Let readline pass the line to our input handler // Let readline pass the line to our input handler
rl_done = 1; rl_done = 1;
// Hide the line, don't redisplay it // Hide the line, don't redisplay it
input_hide (self); input_hide (&ctx->input);
input_restore (self); input_restore (&ctx->input);
return 0; return 0;
} }
static void static void
on_readline_input (char *line) on_readline_input (char *line)
{ {
struct input *self = &g_ctx->input; struct app_context *ctx = g_ctx;
if (line) if (line)
{ {
if (*line) if (*line)
add_history (line); add_history (line);
process_input (g_ctx, line); process_input (ctx, line);
free (line); free (line);
} }
else else
{ {
input_hide (self); input_hide (&ctx->input);
input_restore (self); input_restore (&ctx->input);
input_ding (self); input_ding (&ctx->input);
} }
if (self->active) if (ctx->input.active)
// Readline automatically redisplays it // Readline automatically redisplays it
self->prompt_shown = 1; ctx->input.prompt_shown = 1;
} }
static void static void
@ -5610,7 +5611,7 @@ static unsigned char
on_editline_return (EditLine *editline, int key) on_editline_return (EditLine *editline, int key)
{ {
(void) key; (void) key;
struct input *self = &g_ctx->input; struct app_context *ctx = g_ctx;
const LineInfoW *info = el_wline (editline); const LineInfoW *info = el_wline (editline);
int len = info->lastchar - info->buffer; int len = info->lastchar - info->buffer;
@ -5624,7 +5625,7 @@ on_editline_return (EditLine *editline, int key)
if (*line) if (*line)
{ {
HistEventW ev; HistEventW ev;
history_w (self->current->history, &ev, H_ENTER, line); history_w (ctx->input.current->history, &ev, H_ENTER, line);
print_debug ("history: %d %ls", ev.num, ev.str); print_debug ("history: %d %ls", ev.num, ev.str);
} }
free (line); free (line);
@ -5634,7 +5635,7 @@ on_editline_return (EditLine *editline, int key)
char copy[info_mb->lastchar - info_mb->buffer + 1]; char copy[info_mb->lastchar - info_mb->buffer + 1];
memcpy (copy, info_mb->buffer, sizeof copy - 1); memcpy (copy, info_mb->buffer, sizeof copy - 1);
copy[sizeof copy - 1] = '\0'; copy[sizeof copy - 1] = '\0';
process_input (g_ctx, copy); process_input (ctx, copy);
el_cursor (editline, len - point); el_cursor (editline, len - point);
el_wdeletestr (editline, len); el_wdeletestr (editline, len);