Mercurial > ~mikael > mcabber > hg
comparison mcabber/mcabber/screen.c @ 2164:038c4d601011
Simplify handling of command '/quit'
author | franky |
---|---|
date | Fri, 17 Oct 2014 22:31:03 +0200 |
parents | 798baf5db4eb |
children | db6ca1e1e082 |
comparison
equal
deleted
inserted
replaced
2163:0ac8eea728d1 | 2164:038c4d601011 |
---|---|
3678 } | 3678 } |
3679 | 3679 |
3680 // readline_accept_line(down_history) | 3680 // readline_accept_line(down_history) |
3681 // Validate current command line. | 3681 // Validate current command line. |
3682 // If down_history is true, load the next history line. | 3682 // If down_history is true, load the next history line. |
3683 int readline_accept_line(int down_history) | 3683 void readline_accept_line(int down_history) |
3684 { | 3684 { |
3685 scr_check_auto_away(TRUE); | 3685 scr_check_auto_away(TRUE); |
3686 last_activity_buddy = current_buddy; | 3686 last_activity_buddy = current_buddy; |
3687 if (process_line(inputLine)) | 3687 process_line(inputLine); |
3688 return 255; | |
3689 // Add line to history | 3688 // Add line to history |
3690 scr_cmdhisto_addline(inputLine); | 3689 scr_cmdhisto_addline(inputLine); |
3691 // Reset the line | 3690 // Reset the line |
3692 ptr_inputline = inputLine; | 3691 ptr_inputline = inputLine; |
3693 *ptr_inputline = 0; | 3692 *ptr_inputline = 0; |
3701 cmdhisto_backup[0] = 0; | 3700 cmdhisto_backup[0] = 0; |
3702 } else { | 3701 } else { |
3703 // Reset history line pointer | 3702 // Reset history line pointer |
3704 cmdhisto_cur = NULL; | 3703 cmdhisto_cur = NULL; |
3705 } | 3704 } |
3706 return 0; | |
3707 } | 3705 } |
3708 | 3706 |
3709 // readline_clear_history() | 3707 // readline_clear_history() |
3710 // Clear command line history. | 3708 // Clear command line history. |
3711 void readline_clear_history(void) | 3709 void readline_clear_history(void) |
4333 if (colors_stalled) | 4331 if (colors_stalled) |
4334 parse_colors(); | 4332 parse_colors(); |
4335 doupdate(); | 4333 doupdate(); |
4336 } | 4334 } |
4337 | 4335 |
4338 static int bindcommand(keycode kcode) | 4336 static void bindcommand(keycode kcode) |
4339 { | 4337 { |
4340 gchar asciikey[16], asciicode[16]; | 4338 gchar asciikey[16], asciicode[16]; |
4341 const gchar *boundcmd; | 4339 const gchar *boundcmd; |
4342 | 4340 |
4343 if (kcode.utf8) | 4341 if (kcode.utf8) |
4357 boundcmd = settings_get(SETTINGS_TYPE_BINDING, asciikey); | 4355 boundcmd = settings_get(SETTINGS_TYPE_BINDING, asciikey); |
4358 | 4356 |
4359 if (boundcmd) { | 4357 if (boundcmd) { |
4360 gchar *cmdline = from_utf8(boundcmd); | 4358 gchar *cmdline = from_utf8(boundcmd); |
4361 scr_check_auto_away(TRUE); | 4359 scr_check_auto_away(TRUE); |
4362 if (process_command(cmdline, TRUE)) | 4360 process_command(cmdline, TRUE); |
4363 return 255; // Quit | |
4364 g_free(cmdline); | 4361 g_free(cmdline); |
4365 return 0; | 4362 return; |
4366 } | 4363 } |
4367 | 4364 |
4368 scr_LogPrint(LPRINT_NORMAL, "Unknown key=%s", asciikey); | 4365 scr_LogPrint(LPRINT_NORMAL, "Unknown key=%s", asciikey); |
4369 #ifndef UNICODE | 4366 #ifndef UNICODE |
4370 if (utf8_mode) | 4367 if (utf8_mode) |
4371 scr_LogPrint(LPRINT_NORMAL, | 4368 scr_LogPrint(LPRINT_NORMAL, |
4372 "WARNING: Compiled without full UTF-8 support!"); | 4369 "WARNING: Compiled without full UTF-8 support!"); |
4373 #endif | 4370 #endif |
4374 return -1; | |
4375 } | 4371 } |
4376 | 4372 |
4377 // scr_process_key(key) | 4373 // scr_process_key(key) |
4378 // Handle the pressed key, in the command line (bottom). | 4374 // Handle the pressed key, in the command line (bottom). |
4379 void scr_process_key(keycode kcode) | 4375 void scr_process_key(keycode kcode) |
4390 case MKEY_EQUIV: | 4386 case MKEY_EQUIV: |
4391 // key = kcode.value; | 4387 // key = kcode.value; |
4392 break; | 4388 break; |
4393 case MKEY_META: | 4389 case MKEY_META: |
4394 default: | 4390 default: |
4395 if (bindcommand(kcode) == 255) { | 4391 bindcommand(kcode); |
4396 mcabber_set_terminate_ui(); | |
4397 return; | |
4398 } | |
4399 key = ERR; // Do not process any further | 4392 key = ERR; // Do not process any further |
4400 } | 4393 } |
4401 | 4394 |
4402 if (kcode.utf8) { | 4395 if (kcode.utf8) { |
4403 if (key != ERR && !kcode.mcode) | 4396 if (key != ERR && !kcode.mcode) |
4415 case 353: // Shift-Tab | 4408 case 353: // Shift-Tab |
4416 readline_do_completion(FALSE); // Backward-completion | 4409 readline_do_completion(FALSE); // Backward-completion |
4417 break; | 4410 break; |
4418 case 13: // Enter | 4411 case 13: // Enter |
4419 case 343: // Enter on Maemo | 4412 case 343: // Enter on Maemo |
4420 if (readline_accept_line(FALSE) == 255) { | 4413 readline_accept_line(FALSE); |
4421 mcabber_set_terminate_ui(); | |
4422 return; | |
4423 } | |
4424 break; | 4414 break; |
4425 case 3: // Ctrl-C | 4415 case 3: // Ctrl-C |
4426 scr_handle_CtrlC(); | 4416 scr_handle_CtrlC(); |
4427 break; | 4417 break; |
4428 case KEY_RESIZE: | 4418 case KEY_RESIZE: |
4465 ptr_inputline = put_char(ptr_inputline, key); | 4455 ptr_inputline = put_char(ptr_inputline, key); |
4466 strcpy(ptr_inputline, tmpLine); | 4456 strcpy(ptr_inputline, tmpLine); |
4467 check_offset(1); | 4457 check_offset(1); |
4468 } else { | 4458 } else { |
4469 // Look for a key binding. | 4459 // Look for a key binding. |
4470 if (!kcode.utf8 && (bindcommand(kcode) == 255)) { | 4460 if (!kcode.utf8) |
4471 mcabber_set_terminate_ui(); | 4461 bindcommand(kcode); |
4472 return; | |
4473 } | |
4474 } | 4462 } |
4475 } | 4463 } |
4476 | 4464 |
4477 if (completion_started && key != 9 && key != 353 && key != KEY_RESIZE) | 4465 if (completion_started && key != 9 && key != 353 && key != KEY_RESIZE) |
4478 scr_end_current_completion(); | 4466 scr_end_current_completion(); |