text.c (136644) | text.c (157184) |
---|---|
1/* text.c -- text handling commands for readline. */ 2 | 1/* text.c -- text handling commands for readline. */ 2 |
3/* Copyright (C) 1987-2004 Free Software Foundation, Inc. | 3/* Copyright (C) 1987-2005 Free Software Foundation, Inc. |
4 5 This file is part of the GNU Readline Library, a library for 6 reading lines of text with interactive input and history editing. 7 8 The GNU Readline Library is free software; you can redistribute it 9 and/or modify it under the terms of the GNU General Public License 10 as published by the Free Software Foundation; either version 2, or 11 (at your option) any later version. --- 45 unchanged lines hidden (view full) --- 57#include "rlprivate.h" 58#include "rlshell.h" 59#include "xmalloc.h" 60 61/* Forward declarations. */ 62static int rl_change_case PARAMS((int, int)); 63static int _rl_char_search PARAMS((int, int, int)); 64 | 4 5 This file is part of the GNU Readline Library, a library for 6 reading lines of text with interactive input and history editing. 7 8 The GNU Readline Library is free software; you can redistribute it 9 and/or modify it under the terms of the GNU General Public License 10 as published by the Free Software Foundation; either version 2, or 11 (at your option) any later version. --- 45 unchanged lines hidden (view full) --- 57#include "rlprivate.h" 58#include "rlshell.h" 59#include "xmalloc.h" 60 61/* Forward declarations. */ 62static int rl_change_case PARAMS((int, int)); 63static int _rl_char_search PARAMS((int, int, int)); 64 |
65#if defined (READLINE_CALLBACKS) 66static int _rl_insert_next_callback PARAMS((_rl_callback_generic_arg *)); 67static int _rl_char_search_callback PARAMS((_rl_callback_generic_arg *)); 68#endif 69 |
|
65/* **************************************************************** */ 66/* */ 67/* Insert and Delete */ 68/* */ 69/* **************************************************************** */ 70 71/* Insert a string of text into the line at point. This is the only 72 way that you should do insertion. _rl_insert_char () calls this --- 342 unchanged lines hidden (view full) --- 415int 416rl_end_of_line (count, key) 417 int count, key; 418{ 419 rl_point = rl_end; 420 return 0; 421} 422 | 70/* **************************************************************** */ 71/* */ 72/* Insert and Delete */ 73/* */ 74/* **************************************************************** */ 75 76/* Insert a string of text into the line at point. This is the only 77 way that you should do insertion. _rl_insert_char () calls this --- 342 unchanged lines hidden (view full) --- 420int 421rl_end_of_line (count, key) 422 int count, key; 423{ 424 rl_point = rl_end; 425 return 0; 426} 427 |
423/* XXX - these might need changes for multibyte characters */ 424/* Move forward a word. We do what Emacs does. */ | 428/* Move forward a word. We do what Emacs does. Handles multibyte chars. */ |
425int 426rl_forward_word (count, key) 427 int count, key; 428{ 429 int c; 430 431 if (count < 0) 432 return (rl_backward_word (-count, key)); 433 434 while (count) 435 { 436 if (rl_point == rl_end) 437 return 0; 438 439 /* If we are not in a word, move forward until we are in one. 440 Then, move forward until we hit a non-alphabetic character. */ | 429int 430rl_forward_word (count, key) 431 int count, key; 432{ 433 int c; 434 435 if (count < 0) 436 return (rl_backward_word (-count, key)); 437 438 while (count) 439 { 440 if (rl_point == rl_end) 441 return 0; 442 443 /* If we are not in a word, move forward until we are in one. 444 Then, move forward until we hit a non-alphabetic character. */ |
441 c = rl_line_buffer[rl_point]; 442 if (rl_alphabetic (c) == 0) | 445 c = _rl_char_value (rl_line_buffer, rl_point); 446 447 if (_rl_walphabetic (c) == 0) |
443 { | 448 { |
444 while (++rl_point < rl_end) | 449 rl_point = MB_NEXTCHAR (rl_line_buffer, rl_point, 1, MB_FIND_NONZERO); 450 while (rl_point < rl_end) |
445 { | 451 { |
446 c = rl_line_buffer[rl_point]; 447 if (rl_alphabetic (c)) | 452 c = _rl_char_value (rl_line_buffer, rl_point); 453 if (_rl_walphabetic (c)) |
448 break; | 454 break; |
455 rl_point = MB_NEXTCHAR (rl_line_buffer, rl_point, 1, MB_FIND_NONZERO); |
|
449 } 450 } 451 452 if (rl_point == rl_end) 453 return 0; 454 | 456 } 457 } 458 459 if (rl_point == rl_end) 460 return 0; 461 |
455 while (++rl_point < rl_end) | 462 rl_point = MB_NEXTCHAR (rl_line_buffer, rl_point, 1, MB_FIND_NONZERO); 463 while (rl_point < rl_end) |
456 { | 464 { |
457 c = rl_line_buffer[rl_point]; 458 if (rl_alphabetic (c) == 0) | 465 c = _rl_char_value (rl_line_buffer, rl_point); 466 if (_rl_walphabetic (c) == 0) |
459 break; | 467 break; |
468 rl_point = MB_NEXTCHAR (rl_line_buffer, rl_point, 1, MB_FIND_NONZERO); |
|
460 } | 469 } |
470 |
|
461 --count; 462 } 463 464 return 0; 465} 466 | 471 --count; 472 } 473 474 return 0; 475} 476 |
467/* Move backward a word. We do what Emacs does. */ | 477/* Move backward a word. We do what Emacs does. Handles multibyte chars. */ |
468int 469rl_backward_word (count, key) 470 int count, key; 471{ | 478int 479rl_backward_word (count, key) 480 int count, key; 481{ |
472 int c; | 482 int c, p; |
473 474 if (count < 0) 475 return (rl_forward_word (-count, key)); 476 477 while (count) 478 { | 483 484 if (count < 0) 485 return (rl_forward_word (-count, key)); 486 487 while (count) 488 { |
479 if (!rl_point) | 489 if (rl_point == 0) |
480 return 0; 481 482 /* Like rl_forward_word (), except that we look at the characters 483 just before point. */ 484 | 490 return 0; 491 492 /* Like rl_forward_word (), except that we look at the characters 493 just before point. */ 494 |
485 c = rl_line_buffer[rl_point - 1]; 486 if (rl_alphabetic (c) == 0) | 495 p = MB_PREVCHAR (rl_line_buffer, rl_point, MB_FIND_NONZERO); 496 c = _rl_char_value (rl_line_buffer, p); 497 498 if (_rl_walphabetic (c) == 0) |
487 { | 499 { |
488 while (--rl_point) | 500 rl_point = p; 501 while (rl_point > 0) |
489 { | 502 { |
490 c = rl_line_buffer[rl_point - 1]; 491 if (rl_alphabetic (c)) | 503 p = MB_PREVCHAR (rl_line_buffer, rl_point, MB_FIND_NONZERO); 504 c = _rl_char_value (rl_line_buffer, p); 505 if (_rl_walphabetic (c)) |
492 break; | 506 break; |
507 rl_point = p; |
|
493 } 494 } 495 496 while (rl_point) 497 { | 508 } 509 } 510 511 while (rl_point) 512 { |
498 c = rl_line_buffer[rl_point - 1]; 499 if (rl_alphabetic (c) == 0) | 513 p = MB_PREVCHAR (rl_line_buffer, rl_point, MB_FIND_NONZERO); 514 c = _rl_char_value (rl_line_buffer, p); 515 if (_rl_walphabetic (c) == 0) |
500 break; 501 else | 516 break; 517 else |
502 --rl_point; | 518 rl_point = p; |
503 } 504 505 --count; 506 } 507 508 return 0; 509} 510 --- 240 unchanged lines hidden (view full) --- 751 rl_insert_text (str); 752 count -= decreaser; 753 } 754#endif /* !HANDLE_MULTIBYTE */ 755 756 return 0; 757 } 758 | 519 } 520 521 --count; 522 } 523 524 return 0; 525} 526 --- 240 unchanged lines hidden (view full) --- 767 rl_insert_text (str); 768 count -= decreaser; 769 } 770#endif /* !HANDLE_MULTIBYTE */ 771 772 return 0; 773 } 774 |
759#if defined (HANDLE_MULTIBYTE) | |
760 if (MB_CUR_MAX == 1 || rl_byte_oriented) 761 { | 775 if (MB_CUR_MAX == 1 || rl_byte_oriented) 776 { |
762#endif | |
763 /* We are inserting a single character. 764 If there is pending input, then make a string of all of the 765 pending characters that are bound to rl_insert, and insert 766 them all. */ 767 if (_rl_any_typein ()) 768 _rl_insert_typein (c); 769 else 770 { 771 /* Inserting a single character. */ 772 char str[2]; 773 774 str[1] = '\0'; 775 str[0] = c; 776 rl_insert_text (str); 777 } | 777 /* We are inserting a single character. 778 If there is pending input, then make a string of all of the 779 pending characters that are bound to rl_insert, and insert 780 them all. */ 781 if (_rl_any_typein ()) 782 _rl_insert_typein (c); 783 else 784 { 785 /* Inserting a single character. */ 786 char str[2]; 787 788 str[1] = '\0'; 789 str[0] = c; 790 rl_insert_text (str); 791 } |
778#if defined (HANDLE_MULTIBYTE) | |
779 } | 792 } |
793#if defined (HANDLE_MULTIBYTE) |
|
780 else 781 { 782 rl_insert_text (incoming); 783 stored_count = 0; 784 } 785#endif 786 787 return 0; --- 40 unchanged lines hidden (view full) --- 828rl_insert (count, c) 829 int count, c; 830{ 831 return (rl_insert_mode == RL_IM_INSERT ? _rl_insert_char (count, c) 832 : _rl_overwrite_char (count, c)); 833} 834 835/* Insert the next typed character verbatim. */ | 794 else 795 { 796 rl_insert_text (incoming); 797 stored_count = 0; 798 } 799#endif 800 801 return 0; --- 40 unchanged lines hidden (view full) --- 842rl_insert (count, c) 843 int count, c; 844{ 845 return (rl_insert_mode == RL_IM_INSERT ? _rl_insert_char (count, c) 846 : _rl_overwrite_char (count, c)); 847} 848 849/* Insert the next typed character verbatim. */ |
836int 837rl_quoted_insert (count, key) 838 int count, key; | 850static int 851_rl_insert_next (count) 852 int count; |
839{ 840 int c; 841 | 853{ 854 int c; 855 |
842#if defined (HANDLE_SIGNALS) 843 _rl_disable_tty_signals (); 844#endif 845 | |
846 RL_SETSTATE(RL_STATE_MOREINPUT); 847 c = rl_read_key (); 848 RL_UNSETSTATE(RL_STATE_MOREINPUT); 849 850#if defined (HANDLE_SIGNALS) | 856 RL_SETSTATE(RL_STATE_MOREINPUT); 857 c = rl_read_key (); 858 RL_UNSETSTATE(RL_STATE_MOREINPUT); 859 860#if defined (HANDLE_SIGNALS) |
851 _rl_restore_tty_signals (); | 861 if (RL_ISSTATE (RL_STATE_CALLBACK) == 0) 862 _rl_restore_tty_signals (); |
852#endif 853 854 return (_rl_insert_char (count, c)); 855} 856 | 863#endif 864 865 return (_rl_insert_char (count, c)); 866} 867 |
868#if defined (READLINE_CALLBACKS) 869static int 870_rl_insert_next_callback (data) 871 _rl_callback_generic_arg *data; 872{ 873 int count; 874 875 count = data->count; 876 877 /* Deregister function, let rl_callback_read_char deallocate data */ 878 _rl_callback_func = 0; 879 _rl_want_redisplay = 1; 880 881 return _rl_insert_next (count); 882} 883#endif 884 885int 886rl_quoted_insert (count, key) 887 int count, key; 888{ 889 /* Let's see...should the callback interface futz with signal handling? */ 890#if defined (HANDLE_SIGNALS) 891 if (RL_ISSTATE (RL_STATE_CALLBACK) == 0) 892 _rl_disable_tty_signals (); 893#endif 894 895#if defined (READLINE_CALLBACKS) 896 if (RL_ISSTATE (RL_STATE_CALLBACK)) 897 { 898 _rl_callback_data = _rl_callback_data_alloc (count); 899 _rl_callback_func = _rl_insert_next_callback; 900 return (0); 901 } 902#endif 903 904 return _rl_insert_next (count); 905} 906 |
|
857/* Insert a tab character. */ 858int 859rl_tab_insert (count, key) 860 int count, key; 861{ 862 return (_rl_insert_char (count, '\t')); 863} 864 --- 118 unchanged lines hidden (view full) --- 983 return (rl_delete (-count, key)); 984 985 if (rl_point == 0) 986 { 987 rl_ding (); 988 return -1; 989 } 990 | 907/* Insert a tab character. */ 908int 909rl_tab_insert (count, key) 910 int count, key; 911{ 912 return (_rl_insert_char (count, '\t')); 913} 914 --- 118 unchanged lines hidden (view full) --- 1033 return (rl_delete (-count, key)); 1034 1035 if (rl_point == 0) 1036 { 1037 rl_ding (); 1038 return -1; 1039 } 1040 |
1041 orig_point = rl_point; |
|
991 if (count > 1 || rl_explicit_arg) 992 { | 1042 if (count > 1 || rl_explicit_arg) 1043 { |
993 orig_point = rl_point; 994#if defined (HANDLE_MULTIBYTE) 995 if (MB_CUR_MAX > 1 && rl_byte_oriented == 0) 996 rl_backward_char (count, key); 997 else 998#endif 999 rl_backward_byte (count, key); | 1044 rl_backward_char (count, key); |
1000 rl_kill_text (orig_point, rl_point); 1001 } | 1045 rl_kill_text (orig_point, rl_point); 1046 } |
1002 else | 1047 else if (MB_CUR_MAX == 1 || rl_byte_oriented) |
1003 { | 1048 { |
1004#if defined (HANDLE_MULTIBYTE) 1005 if (MB_CUR_MAX == 1 || rl_byte_oriented) 1006 { 1007#endif 1008 c = rl_line_buffer[--rl_point]; 1009 rl_delete_text (rl_point, rl_point + 1); 1010#if defined (HANDLE_MULTIBYTE) 1011 } 1012 else 1013 { 1014 int orig_point; 1015 1016 orig_point = rl_point; 1017 rl_point = _rl_find_prev_mbchar (rl_line_buffer, rl_point, MB_FIND_NONZERO); 1018 c = rl_line_buffer[rl_point]; 1019 rl_delete_text (rl_point, orig_point); 1020 } 1021#endif /* HANDLE_MULTIBYTE */ 1022 1023 /* I don't think that the hack for end of line is needed for 1024 multibyte chars. */ 1025#if defined (HANDLE_MULTIBYTE) 1026 if (MB_CUR_MAX == 1 || rl_byte_oriented) 1027#endif | 1049 c = rl_line_buffer[--rl_point]; 1050 rl_delete_text (rl_point, orig_point); 1051 /* The erase-at-end-of-line hack is of questionable merit now. */ |
1028 if (rl_point == rl_end && ISPRINT (c) && _rl_last_c_pos) 1029 { 1030 int l; 1031 l = rl_character_len (c, rl_point); 1032 _rl_erase_at_end_of_line (l); 1033 } 1034 } | 1052 if (rl_point == rl_end && ISPRINT (c) && _rl_last_c_pos) 1053 { 1054 int l; 1055 l = rl_character_len (c, rl_point); 1056 _rl_erase_at_end_of_line (l); 1057 } 1058 } |
1059 else 1060 { 1061 rl_point = _rl_find_prev_mbchar (rl_line_buffer, rl_point, MB_FIND_NONZERO); 1062 rl_delete_text (rl_point, orig_point); 1063 } |
|
1035 1036 return 0; 1037} 1038 1039/* Delete the character under the cursor. Given a numeric argument, 1040 kill that many characters instead. */ 1041int 1042rl_delete (count, key) --- 8 unchanged lines hidden (view full) --- 1051 { 1052 rl_ding (); 1053 return -1; 1054 } 1055 1056 if (count > 1 || rl_explicit_arg) 1057 { 1058 int orig_point = rl_point; | 1064 1065 return 0; 1066} 1067 1068/* Delete the character under the cursor. Given a numeric argument, 1069 kill that many characters instead. */ 1070int 1071rl_delete (count, key) --- 8 unchanged lines hidden (view full) --- 1080 { 1081 rl_ding (); 1082 return -1; 1083 } 1084 1085 if (count > 1 || rl_explicit_arg) 1086 { 1087 int orig_point = rl_point; |
1059#if defined (HANDLE_MULTIBYTE) | |
1060 if (MB_CUR_MAX > 1 && rl_byte_oriented == 0) 1061 rl_forward_char (count, key); 1062 else | 1088 if (MB_CUR_MAX > 1 && rl_byte_oriented == 0) 1089 rl_forward_char (count, key); 1090 else |
1063#endif | |
1064 rl_forward_byte (count, key); 1065 1066 r = rl_kill_text (orig_point, rl_point); 1067 rl_point = orig_point; 1068 return r; 1069 } 1070 else 1071 { 1072 int new_point; | 1091 rl_forward_byte (count, key); 1092 1093 r = rl_kill_text (orig_point, rl_point); 1094 rl_point = orig_point; 1095 return r; 1096 } 1097 else 1098 { 1099 int new_point; |
1073 if (MB_CUR_MAX > 1 && rl_byte_oriented == 0) 1074 new_point = _rl_find_next_mbchar (rl_line_buffer, rl_point, 1, MB_FIND_NONZERO); 1075 else 1076 new_point = rl_point + 1; 1077 | 1100 1101 new_point = MB_NEXTCHAR (rl_line_buffer, rl_point, 1, MB_FIND_NONZERO); |
1078 return (rl_delete_text (rl_point, new_point)); 1079 } 1080} 1081 1082/* Delete the character under the cursor, unless the insertion 1083 point is at the end of the line, in which case the character 1084 behind the cursor is deleted. COUNT is obeyed and may be used 1085 to delete forward or backward that many characters. */ --- 22 unchanged lines hidden (view full) --- 1108 while (rl_point < rl_end && whitespace (rl_line_buffer[rl_point])) 1109 rl_point++; 1110 1111 if (start != rl_point) 1112 { 1113 rl_delete_text (start, rl_point); 1114 rl_point = start; 1115 } | 1102 return (rl_delete_text (rl_point, new_point)); 1103 } 1104} 1105 1106/* Delete the character under the cursor, unless the insertion 1107 point is at the end of the line, in which case the character 1108 behind the cursor is deleted. COUNT is obeyed and may be used 1109 to delete forward or backward that many characters. */ --- 22 unchanged lines hidden (view full) --- 1132 while (rl_point < rl_end && whitespace (rl_line_buffer[rl_point])) 1133 rl_point++; 1134 1135 if (start != rl_point) 1136 { 1137 rl_delete_text (start, rl_point); 1138 rl_point = start; 1139 } |
1140 1141 if (rl_point < 0) 1142 rl_point = 0; 1143 |
|
1116 return 0; 1117} 1118 1119/* Like the tcsh editing function delete-char-or-list. The eof character 1120 is caught before this is invoked, so this really does the same thing as 1121 delete-char-or-list-or-eof, as long as it's bound to the eof character. */ 1122int 1123rl_delete_or_show_completions (count, key) --- 77 unchanged lines hidden (view full) --- 1201 Change the case of COUNT words, performing OP on them. 1202 OP is one of UpCase, DownCase, or CapCase. 1203 If a negative argument is given, leave point where it started, 1204 otherwise, leave it where it moves to. */ 1205static int 1206rl_change_case (count, op) 1207 int count, op; 1208{ | 1144 return 0; 1145} 1146 1147/* Like the tcsh editing function delete-char-or-list. The eof character 1148 is caught before this is invoked, so this really does the same thing as 1149 delete-char-or-list-or-eof, as long as it's bound to the eof character. */ 1150int 1151rl_delete_or_show_completions (count, key) --- 77 unchanged lines hidden (view full) --- 1229 Change the case of COUNT words, performing OP on them. 1230 OP is one of UpCase, DownCase, or CapCase. 1231 If a negative argument is given, leave point where it started, 1232 otherwise, leave it where it moves to. */ 1233static int 1234rl_change_case (count, op) 1235 int count, op; 1236{ |
1209 register int start, end; 1210 int inword, c; | 1237 int start, next, end; 1238 int inword, c, nc, nop; 1239#if defined (HANDLE_MULTIBYTE) 1240 wchar_t wc, nwc; 1241 char mb[MB_LEN_MAX+1]; 1242 int mblen, p; 1243 mbstate_t ps; 1244#endif |
1211 1212 start = rl_point; 1213 rl_forward_word (count, 0); 1214 end = rl_point; 1215 | 1245 1246 start = rl_point; 1247 rl_forward_word (count, 0); 1248 end = rl_point; 1249 |
1250 if (op != UpCase && op != DownCase && op != CapCase) 1251 { 1252 rl_ding (); 1253 return -1; 1254 } 1255 |
|
1216 if (count < 0) 1217 SWAP (start, end); 1218 | 1256 if (count < 0) 1257 SWAP (start, end); 1258 |
1259#if defined (HANDLE_MULTIBYTE) 1260 memset (&ps, 0, sizeof (mbstate_t)); 1261#endif 1262 |
|
1219 /* We are going to modify some text, so let's prepare to undo it. */ 1220 rl_modifying (start, end); 1221 | 1263 /* We are going to modify some text, so let's prepare to undo it. */ 1264 rl_modifying (start, end); 1265 |
1222 for (inword = 0; start < end; start++) | 1266 inword = 0; 1267 while (start < end) |
1223 { | 1268 { |
1224 c = rl_line_buffer[start]; 1225 switch (op) | 1269 c = _rl_char_value (rl_line_buffer, start); 1270 /* This assumes that the upper and lower case versions are the same width. */ 1271 next = MB_NEXTCHAR (rl_line_buffer, start, 1, MB_FIND_NONZERO); 1272 1273 if (_rl_walphabetic (c) == 0) |
1226 { | 1274 { |
1227 case UpCase: 1228 rl_line_buffer[start] = _rl_to_upper (c); 1229 break; | 1275 inword = 0; 1276 start = next; 1277 continue; 1278 } |
1230 | 1279 |
1231 case DownCase: 1232 rl_line_buffer[start] = _rl_to_lower (c); 1233 break; 1234 1235 case CapCase: 1236 rl_line_buffer[start] = (inword == 0) ? _rl_to_upper (c) : _rl_to_lower (c); 1237 inword = rl_alphabetic (rl_line_buffer[start]); 1238 break; 1239 1240 default: 1241 rl_ding (); 1242 return -1; | 1280 if (op == CapCase) 1281 { 1282 nop = inword ? DownCase : UpCase; 1283 inword = 1; |
1243 } | 1284 } |
1285 else 1286 nop = op; 1287 if (MB_CUR_MAX == 1 || rl_byte_oriented || isascii (c)) 1288 { 1289 nc = (nop == UpCase) ? _rl_to_upper (c) : _rl_to_lower (c); 1290 rl_line_buffer[start] = nc; 1291 } 1292#if defined (HANDLE_MULTIBYTE) 1293 else 1294 { 1295 mbrtowc (&wc, rl_line_buffer + start, end - start, &ps); 1296 nwc = (nop == UpCase) ? _rl_to_wupper (wc) : _rl_to_wlower (wc); 1297 if (nwc != wc) /* just skip unchanged characters */ 1298 { 1299 mblen = wcrtomb (mb, nwc, &ps); 1300 if (mblen > 0) 1301 mb[mblen] = '\0'; 1302 /* Assume the same width */ 1303 strncpy (rl_line_buffer + start, mb, mblen); 1304 } 1305 } 1306#endif 1307 1308 start = next; |
|
1244 } | 1309 } |
1310 |
|
1245 rl_point = end; 1246 return 0; 1247} 1248 1249/* **************************************************************** */ 1250/* */ 1251/* Transposition */ 1252/* */ --- 63 unchanged lines hidden (view full) --- 1316/* Transpose the characters at point. If point is at the end of the line, 1317 then transpose the characters before point. */ 1318int 1319rl_transpose_chars (count, key) 1320 int count, key; 1321{ 1322#if defined (HANDLE_MULTIBYTE) 1323 char *dummy; | 1311 rl_point = end; 1312 return 0; 1313} 1314 1315/* **************************************************************** */ 1316/* */ 1317/* Transposition */ 1318/* */ --- 63 unchanged lines hidden (view full) --- 1382/* Transpose the characters at point. If point is at the end of the line, 1383 then transpose the characters before point. */ 1384int 1385rl_transpose_chars (count, key) 1386 int count, key; 1387{ 1388#if defined (HANDLE_MULTIBYTE) 1389 char *dummy; |
1324 int i, prev_point; | 1390 int i; |
1325#else 1326 char dummy[2]; 1327#endif | 1391#else 1392 char dummy[2]; 1393#endif |
1328 int char_length; | 1394 int char_length, prev_point; |
1329 1330 if (count == 0) 1331 return 0; 1332 1333 if (!rl_point || rl_end < 2) 1334 { 1335 rl_ding (); 1336 return -1; 1337 } 1338 1339 rl_begin_undo_group (); 1340 1341 if (rl_point == rl_end) 1342 { | 1395 1396 if (count == 0) 1397 return 0; 1398 1399 if (!rl_point || rl_end < 2) 1400 { 1401 rl_ding (); 1402 return -1; 1403 } 1404 1405 rl_begin_undo_group (); 1406 1407 if (rl_point == rl_end) 1408 { |
1343 if (MB_CUR_MAX > 1 && rl_byte_oriented == 0) 1344 rl_point = _rl_find_prev_mbchar (rl_line_buffer, rl_point, MB_FIND_NONZERO); 1345 else 1346 --rl_point; | 1409 rl_point = MB_PREVCHAR (rl_line_buffer, rl_point, MB_FIND_NONZERO); |
1347 count = 1; 1348 } 1349 | 1410 count = 1; 1411 } 1412 |
1350#if defined (HANDLE_MULTIBYTE) | |
1351 prev_point = rl_point; | 1413 prev_point = rl_point; |
1352 if (MB_CUR_MAX > 1 && rl_byte_oriented == 0) 1353 rl_point = _rl_find_prev_mbchar (rl_line_buffer, rl_point, MB_FIND_NONZERO); 1354 else 1355#endif 1356 rl_point--; | 1414 rl_point = MB_PREVCHAR (rl_line_buffer, rl_point, MB_FIND_NONZERO); |
1357 1358#if defined (HANDLE_MULTIBYTE) 1359 char_length = prev_point - rl_point; 1360 dummy = (char *)xmalloc (char_length + 1); 1361 for (i = 0; i < char_length; i++) 1362 dummy[i] = rl_line_buffer[rl_point + i]; 1363 dummy[i] = '\0'; 1364#else --- 117 unchanged lines hidden (view full) --- 1482 1483 if (count < 0) 1484 return (_rl_char_search_internal (-count, bdir, c)); 1485 else 1486 return (_rl_char_search_internal (count, fdir, c)); 1487} 1488#endif /* !HANDLE_MULTIBYTE */ 1489 | 1415 1416#if defined (HANDLE_MULTIBYTE) 1417 char_length = prev_point - rl_point; 1418 dummy = (char *)xmalloc (char_length + 1); 1419 for (i = 0; i < char_length; i++) 1420 dummy[i] = rl_line_buffer[rl_point + i]; 1421 dummy[i] = '\0'; 1422#else --- 117 unchanged lines hidden (view full) --- 1540 1541 if (count < 0) 1542 return (_rl_char_search_internal (-count, bdir, c)); 1543 else 1544 return (_rl_char_search_internal (count, fdir, c)); 1545} 1546#endif /* !HANDLE_MULTIBYTE */ 1547 |
1548#if defined (READLINE_CALLBACKS) 1549static int 1550_rl_char_search_callback (data) 1551 _rl_callback_generic_arg *data; 1552{ 1553 _rl_callback_func = 0; 1554 _rl_want_redisplay = 1; 1555 1556 return (_rl_char_search (data->count, data->i1, data->i2)); 1557} 1558#endif 1559 |
|
1490int 1491rl_char_search (count, key) 1492 int count, key; 1493{ | 1560int 1561rl_char_search (count, key) 1562 int count, key; 1563{ |
1564#if defined (READLINE_CALLBACKS) 1565 if (RL_ISSTATE (RL_STATE_CALLBACK)) 1566 { 1567 _rl_callback_data = _rl_callback_data_alloc (count); 1568 _rl_callback_data->i1 = FFIND; 1569 _rl_callback_data->i2 = BFIND; 1570 _rl_callback_func = _rl_char_search_callback; 1571 return (0); 1572 } 1573#endif 1574 |
|
1494 return (_rl_char_search (count, FFIND, BFIND)); 1495} 1496 1497int 1498rl_backward_char_search (count, key) 1499 int count, key; 1500{ | 1575 return (_rl_char_search (count, FFIND, BFIND)); 1576} 1577 1578int 1579rl_backward_char_search (count, key) 1580 int count, key; 1581{ |
1582#if defined (READLINE_CALLBACKS) 1583 if (RL_ISSTATE (RL_STATE_CALLBACK)) 1584 { 1585 _rl_callback_data = _rl_callback_data_alloc (count); 1586 _rl_callback_data->i1 = BFIND; 1587 _rl_callback_data->i2 = FFIND; 1588 _rl_callback_func = _rl_char_search_callback; 1589 return (0); 1590 } 1591#endif 1592 |
|
1501 return (_rl_char_search (count, BFIND, FFIND)); 1502} 1503 1504/* **************************************************************** */ 1505/* */ 1506/* The Mark and the Region. */ 1507/* */ 1508/* **************************************************************** */ --- 39 unchanged lines hidden --- | 1593 return (_rl_char_search (count, BFIND, FFIND)); 1594} 1595 1596/* **************************************************************** */ 1597/* */ 1598/* The Mark and the Region. */ 1599/* */ 1600/* **************************************************************** */ --- 39 unchanged lines hidden --- |