diff options
| author | Gerd Moellmann | 2002-03-06 15:55:11 +0000 |
|---|---|---|
| committer | Gerd Moellmann | 2002-03-06 15:55:11 +0000 |
| commit | 678e9d18b9e753e23ebac4fa7a8f14f91807b09f (patch) | |
| tree | 6a0c92d8f4d74c6dfabb59cb1726d3734f9b3ab9 /src | |
| parent | a35bdffa1707b31e65f5e0f4bd085260efe22c51 (diff) | |
| download | emacs-678e9d18b9e753e23ebac4fa7a8f14f91807b09f.tar.gz emacs-678e9d18b9e753e23ebac4fa7a8f14f91807b09f.zip | |
(echo_prompt, echo_char, echo_dash, echo_now)
(cancel_echoing, echo_length, echo_truncate): Changed to
work with new kboard definition.
(echo_now): Use message3_nolog instead of message2_nolog.
Diffstat (limited to 'src')
| -rw-r--r-- | src/keyboard.c | 137 |
1 files changed, 67 insertions, 70 deletions
diff --git a/src/keyboard.c b/src/keyboard.c index 0e777a6bd07..8187659c818 100644 --- a/src/keyboard.c +++ b/src/keyboard.c | |||
| @@ -706,38 +706,8 @@ void | |||
| 706 | echo_prompt (str) | 706 | echo_prompt (str) |
| 707 | Lisp_Object str; | 707 | Lisp_Object str; |
| 708 | { | 708 | { |
| 709 | int nbytes = STRING_BYTES (XSTRING (str)); | 709 | current_kboard->echo_string = str; |
| 710 | int multibyte_p = STRING_MULTIBYTE (str); | 710 | current_kboard->echo_after_prompt = XSTRING (str)->size; |
| 711 | |||
| 712 | if (nbytes > ECHOBUFSIZE - 4) | ||
| 713 | { | ||
| 714 | if (multibyte_p) | ||
| 715 | { | ||
| 716 | /* Have to find the last character that fit's into the | ||
| 717 | echo buffer. */ | ||
| 718 | unsigned char *p = XSTRING (str)->data; | ||
| 719 | unsigned char *pend = p + ECHOBUFSIZE - 4; | ||
| 720 | int char_len; | ||
| 721 | |||
| 722 | do | ||
| 723 | { | ||
| 724 | PARSE_MULTIBYTE_SEQ (p, pend - p, char_len); | ||
| 725 | p += char_len; | ||
| 726 | } | ||
| 727 | while (p < pend); | ||
| 728 | |||
| 729 | nbytes = p - XSTRING (str)->data - char_len; | ||
| 730 | } | ||
| 731 | else | ||
| 732 | nbytes = ECHOBUFSIZE - 4; | ||
| 733 | } | ||
| 734 | |||
| 735 | nbytes = copy_text (XSTRING (str)->data, current_kboard->echobuf, nbytes, | ||
| 736 | STRING_MULTIBYTE (str), 1); | ||
| 737 | current_kboard->echoptr = current_kboard->echobuf + nbytes; | ||
| 738 | *current_kboard->echoptr = '\0'; | ||
| 739 | current_kboard->echo_after_prompt = nbytes; | ||
| 740 | |||
| 741 | echo_now (); | 711 | echo_now (); |
| 742 | } | 712 | } |
| 743 | 713 | ||
| @@ -751,43 +721,64 @@ echo_char (c) | |||
| 751 | { | 721 | { |
| 752 | if (current_kboard->immediate_echo) | 722 | if (current_kboard->immediate_echo) |
| 753 | { | 723 | { |
| 754 | char *ptr = current_kboard->echoptr; | 724 | int size = KEY_DESCRIPTION_SIZE + 100; |
| 755 | 725 | char *buffer = (char *) alloca (size); | |
| 756 | if (ptr != current_kboard->echobuf) | 726 | char *ptr = buffer; |
| 757 | *ptr++ = ' '; | 727 | Lisp_Object echo_string; |
| 758 | 728 | ||
| 759 | /* If someone has passed us a composite event, use its head symbol. */ | 729 | /* If someone has passed us a composite event, use its head symbol. */ |
| 760 | c = EVENT_HEAD (c); | 730 | c = EVENT_HEAD (c); |
| 761 | 731 | ||
| 762 | if (INTEGERP (c)) | 732 | if (INTEGERP (c)) |
| 763 | { | 733 | { |
| 764 | int ch = XINT (c); | 734 | ptr = push_key_description (XINT (c), ptr, 1); |
| 765 | |||
| 766 | if (ptr - current_kboard->echobuf | ||
| 767 | > ECHOBUFSIZE - KEY_DESCRIPTION_SIZE) | ||
| 768 | return; | ||
| 769 | |||
| 770 | ptr = push_key_description (ch, ptr, 1); | ||
| 771 | } | 735 | } |
| 772 | else if (SYMBOLP (c)) | 736 | else if (SYMBOLP (c)) |
| 773 | { | 737 | { |
| 774 | struct Lisp_String *name = XSYMBOL (c)->name; | 738 | struct Lisp_String *name = XSYMBOL (c)->name; |
| 775 | if ((ptr - current_kboard->echobuf) + STRING_BYTES (name) + 4 | 739 | |
| 776 | > ECHOBUFSIZE) | 740 | if (size - (ptr - buffer) < STRING_BYTES (name)) |
| 777 | return; | 741 | { |
| 742 | int offset = ptr - buffer; | ||
| 743 | size = max (2 * size, size + STRING_BYTES (name)); | ||
| 744 | buffer = (char *) alloca (size); | ||
| 745 | ptr = buffer + offset; | ||
| 746 | } | ||
| 747 | |||
| 778 | ptr += copy_text (name->data, ptr, STRING_BYTES (name), | 748 | ptr += copy_text (name->data, ptr, STRING_BYTES (name), |
| 779 | name->size_byte >= 0, 1); | 749 | name->size_byte >= 0, 1); |
| 780 | } | 750 | } |
| 781 | 751 | ||
| 782 | if (current_kboard->echoptr == current_kboard->echobuf | 752 | if ((NILP (current_kboard->echo_string) |
| 753 | || XSTRING (current_kboard->echo_string)->size == 0) | ||
| 783 | && help_char_p (c)) | 754 | && help_char_p (c)) |
| 784 | { | 755 | { |
| 785 | strcpy (ptr, " (Type ? for further options)"); | 756 | const char *text = " (Type ? for further options)"; |
| 786 | ptr += strlen (ptr); | 757 | int len = strlen (text); |
| 758 | |||
| 759 | if (size - (ptr - buffer) < len) | ||
| 760 | { | ||
| 761 | int offset = ptr - buffer; | ||
| 762 | size += len; | ||
| 763 | buffer = (char *) alloca (size); | ||
| 764 | ptr = buffer + offset; | ||
| 765 | } | ||
| 766 | |||
| 767 | bcopy (text, ptr, len); | ||
| 768 | ptr += len; | ||
| 787 | } | 769 | } |
| 788 | 770 | ||
| 789 | *ptr = 0; | 771 | echo_string = current_kboard->echo_string; |
| 790 | current_kboard->echoptr = ptr; | 772 | |
| 773 | /* Replace a dash from echo_dash with a space. */ | ||
| 774 | if (STRINGP (echo_string) | ||
| 775 | && (size = STRING_BYTES (XSTRING (echo_string)), | ||
| 776 | (size > 0 | ||
| 777 | && XSTRING (echo_string)->data[size - 1] == '-'))) | ||
| 778 | XSTRING (echo_string)->data[size - 1] = ' '; | ||
| 779 | |||
| 780 | current_kboard->echo_string | ||
| 781 | = concat2 (echo_string, make_string (buffer, ptr - buffer)); | ||
| 791 | 782 | ||
| 792 | echo_now (); | 783 | echo_now (); |
| 793 | } | 784 | } |
| @@ -799,22 +790,23 @@ echo_char (c) | |||
| 799 | void | 790 | void |
| 800 | echo_dash () | 791 | echo_dash () |
| 801 | { | 792 | { |
| 793 | /* Do nothing if not echoing at all. */ | ||
| 794 | if (NILP (current_kboard->echo_string)) | ||
| 795 | return; | ||
| 796 | |||
| 802 | if (!current_kboard->immediate_echo | 797 | if (!current_kboard->immediate_echo |
| 803 | && current_kboard->echoptr == current_kboard->echobuf) | 798 | && XSTRING (current_kboard->echo_string)->size == 0) |
| 804 | return; | 799 | return; |
| 800 | |||
| 805 | /* Do nothing if we just printed a prompt. */ | 801 | /* Do nothing if we just printed a prompt. */ |
| 806 | if (current_kboard->echo_after_prompt | 802 | if (current_kboard->echo_after_prompt |
| 807 | == current_kboard->echoptr - current_kboard->echobuf) | 803 | == XSTRING (current_kboard->echo_string)->size) |
| 808 | return; | ||
| 809 | /* Do nothing if not echoing at all. */ | ||
| 810 | if (current_kboard->echoptr == 0) | ||
| 811 | return; | 804 | return; |
| 812 | 805 | ||
| 813 | /* Put a dash at the end of the buffer temporarily, | 806 | /* Put a dash at the end of the buffer temporarily, |
| 814 | but make it go away when the next character is added. */ | 807 | but make it go away when the next character is added. */ |
| 815 | current_kboard->echoptr[0] = '-'; | 808 | current_kboard->echo_string = concat2 (current_kboard->echo_string, |
| 816 | current_kboard->echoptr[1] = 0; | 809 | build_string ("-")); |
| 817 | |||
| 818 | echo_now (); | 810 | echo_now (); |
| 819 | } | 811 | } |
| 820 | 812 | ||
| @@ -841,8 +833,9 @@ echo_now () | |||
| 841 | } | 833 | } |
| 842 | 834 | ||
| 843 | echoing = 1; | 835 | echoing = 1; |
| 844 | message2_nolog (current_kboard->echobuf, strlen (current_kboard->echobuf), | 836 | message3_nolog (current_kboard->echo_string, |
| 845 | 1); | 837 | STRING_BYTES (XSTRING (current_kboard->echo_string)), |
| 838 | STRING_MULTIBYTE (current_kboard->echo_string)); | ||
| 846 | echoing = 0; | 839 | echoing = 0; |
| 847 | 840 | ||
| 848 | /* Record in what buffer we echoed, and from which kboard. */ | 841 | /* Record in what buffer we echoed, and from which kboard. */ |
| @@ -859,8 +852,8 @@ void | |||
| 859 | cancel_echoing () | 852 | cancel_echoing () |
| 860 | { | 853 | { |
| 861 | current_kboard->immediate_echo = 0; | 854 | current_kboard->immediate_echo = 0; |
| 862 | current_kboard->echoptr = current_kboard->echobuf; | ||
| 863 | current_kboard->echo_after_prompt = -1; | 855 | current_kboard->echo_after_prompt = -1; |
| 856 | current_kboard->echo_string = Qnil; | ||
| 864 | ok_to_echo_at_next_pause = NULL; | 857 | ok_to_echo_at_next_pause = NULL; |
| 865 | echo_kboard = NULL; | 858 | echo_kboard = NULL; |
| 866 | echo_message_buffer = Qnil; | 859 | echo_message_buffer = Qnil; |
| @@ -871,7 +864,9 @@ cancel_echoing () | |||
| 871 | static int | 864 | static int |
| 872 | echo_length () | 865 | echo_length () |
| 873 | { | 866 | { |
| 874 | return current_kboard->echoptr - current_kboard->echobuf; | 867 | return (STRINGP (current_kboard->echo_string) |
| 868 | ? XSTRING (current_kboard->echo_string)->size | ||
| 869 | : 0); | ||
| 875 | } | 870 | } |
| 876 | 871 | ||
| 877 | /* Truncate the current echo message to its first LEN chars. | 872 | /* Truncate the current echo message to its first LEN chars. |
| @@ -879,12 +874,14 @@ echo_length () | |||
| 879 | switches frames while entering a key sequence. */ | 874 | switches frames while entering a key sequence. */ |
| 880 | 875 | ||
| 881 | static void | 876 | static void |
| 882 | echo_truncate (len) | 877 | echo_truncate (nchars) |
| 883 | int len; | 878 | int nchars; |
| 884 | { | 879 | { |
| 885 | current_kboard->echobuf[len] = '\0'; | 880 | if (STRINGP (current_kboard->echo_string)) |
| 886 | current_kboard->echoptr = current_kboard->echobuf + len; | 881 | current_kboard->echo_string |
| 887 | truncate_echo_area (len); | 882 | = Fsubstring (current_kboard->echo_string, |
| 883 | make_number (0), make_number (nchars)); | ||
| 884 | truncate_echo_area (nchars); | ||
| 888 | } | 885 | } |
| 889 | 886 | ||
| 890 | 887 | ||
| @@ -10130,7 +10127,7 @@ init_kboard (kb) | |||
| 10130 | kb->kbd_queue = Qnil; | 10127 | kb->kbd_queue = Qnil; |
| 10131 | kb->kbd_queue_has_data = 0; | 10128 | kb->kbd_queue_has_data = 0; |
| 10132 | kb->immediate_echo = 0; | 10129 | kb->immediate_echo = 0; |
| 10133 | kb->echoptr = kb->echobuf; | 10130 | kb->echo_string = Qnil; |
| 10134 | kb->echo_after_prompt = -1; | 10131 | kb->echo_after_prompt = -1; |
| 10135 | kb->kbd_macro_buffer = 0; | 10132 | kb->kbd_macro_buffer = 0; |
| 10136 | kb->kbd_macro_bufsize = 0; | 10133 | kb->kbd_macro_bufsize = 0; |