Deleted Added
full compact
text.c (157191) text.c (165670)
1/* text.c -- text handling commands for readline. */
2
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

--- 1057 unchanged lines hidden (view full) ---

1066}
1067
1068/* Delete the character under the cursor. Given a numeric argument,
1069 kill that many characters instead. */
1070int
1071rl_delete (count, key)
1072 int count, key;
1073{
1/* text.c -- text handling commands for readline. */
2
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

--- 1057 unchanged lines hidden (view full) ---

1066}
1067
1068/* Delete the character under the cursor. Given a numeric argument,
1069 kill that many characters instead. */
1070int
1071rl_delete (count, key)
1072 int count, key;
1073{
1074 int xpoint;
1075
1074 if (count < 0)
1075 return (_rl_rubout_char (-count, key));
1076
1077 if (rl_point == rl_end)
1078 {
1079 rl_ding ();
1080 return -1;
1081 }
1082
1083 if (count > 1 || rl_explicit_arg)
1084 {
1076 if (count < 0)
1077 return (_rl_rubout_char (-count, key));
1078
1079 if (rl_point == rl_end)
1080 {
1081 rl_ding ();
1082 return -1;
1083 }
1084
1085 if (count > 1 || rl_explicit_arg)
1086 {
1085 int orig_point = rl_point;
1087 xpoint = rl_point;
1086 if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
1087 rl_forward_char (count, key);
1088 else
1089 rl_forward_byte (count, key);
1090
1088 if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
1089 rl_forward_char (count, key);
1090 else
1091 rl_forward_byte (count, key);
1092
1091 rl_kill_text (orig_point, rl_point);
1092 rl_point = orig_point;
1093 rl_kill_text (xpoint, rl_point);
1094 rl_point = xpoint;
1093 }
1094 else
1095 {
1095 }
1096 else
1097 {
1096 int new_point;
1097
1098 new_point = MB_NEXTCHAR (rl_line_buffer, rl_point, 1, MB_FIND_NONZERO);
1099 rl_delete_text (rl_point, new_point);
1098 xpoint = MB_NEXTCHAR (rl_line_buffer, rl_point, 1, MB_FIND_NONZERO);
1099 rl_delete_text (rl_point, xpoint);
1100 }
1101 return 0;
1102}
1103
1104/* Delete the character under the cursor, unless the insertion
1105 point is at the end of the line, in which case the character
1106 behind the cursor is deleted. COUNT is obeyed and may be used
1107 to delete forward or backward that many characters. */

--- 124 unchanged lines hidden (view full) ---

1232rl_change_case (count, op)
1233 int count, op;
1234{
1235 int start, next, end;
1236 int inword, c, nc, nop;
1237#if defined (HANDLE_MULTIBYTE)
1238 wchar_t wc, nwc;
1239 char mb[MB_LEN_MAX+1];
1100 }
1101 return 0;
1102}
1103
1104/* Delete the character under the cursor, unless the insertion
1105 point is at the end of the line, in which case the character
1106 behind the cursor is deleted. COUNT is obeyed and may be used
1107 to delete forward or backward that many characters. */

--- 124 unchanged lines hidden (view full) ---

1232rl_change_case (count, op)
1233 int count, op;
1234{
1235 int start, next, end;
1236 int inword, c, nc, nop;
1237#if defined (HANDLE_MULTIBYTE)
1238 wchar_t wc, nwc;
1239 char mb[MB_LEN_MAX+1];
1240 int mblen, p;
1241 mbstate_t ps;
1240 int mlen;
1241 mbstate_t mps;
1242#endif
1243
1244 start = rl_point;
1245 rl_forward_word (count, 0);
1246 end = rl_point;
1247
1248 if (op != UpCase && op != DownCase && op != CapCase)
1249 {
1250 rl_ding ();
1251 return -1;
1252 }
1253
1254 if (count < 0)
1255 SWAP (start, end);
1256
1257#if defined (HANDLE_MULTIBYTE)
1242#endif
1243
1244 start = rl_point;
1245 rl_forward_word (count, 0);
1246 end = rl_point;
1247
1248 if (op != UpCase && op != DownCase && op != CapCase)
1249 {
1250 rl_ding ();
1251 return -1;
1252 }
1253
1254 if (count < 0)
1255 SWAP (start, end);
1256
1257#if defined (HANDLE_MULTIBYTE)
1258 memset (&ps, 0, sizeof (mbstate_t));
1258 memset (&mps, 0, sizeof (mbstate_t));
1259#endif
1260
1261 /* We are going to modify some text, so let's prepare to undo it. */
1262 rl_modifying (start, end);
1263
1264 inword = 0;
1265 while (start < end)
1266 {

--- 18 unchanged lines hidden (view full) ---

1285 if (MB_CUR_MAX == 1 || rl_byte_oriented || isascii (c))
1286 {
1287 nc = (nop == UpCase) ? _rl_to_upper (c) : _rl_to_lower (c);
1288 rl_line_buffer[start] = nc;
1289 }
1290#if defined (HANDLE_MULTIBYTE)
1291 else
1292 {
1259#endif
1260
1261 /* We are going to modify some text, so let's prepare to undo it. */
1262 rl_modifying (start, end);
1263
1264 inword = 0;
1265 while (start < end)
1266 {

--- 18 unchanged lines hidden (view full) ---

1285 if (MB_CUR_MAX == 1 || rl_byte_oriented || isascii (c))
1286 {
1287 nc = (nop == UpCase) ? _rl_to_upper (c) : _rl_to_lower (c);
1288 rl_line_buffer[start] = nc;
1289 }
1290#if defined (HANDLE_MULTIBYTE)
1291 else
1292 {
1293 mbrtowc (&wc, rl_line_buffer + start, end - start, &ps);
1293 mbrtowc (&wc, rl_line_buffer + start, end - start, &mps);
1294 nwc = (nop == UpCase) ? _rl_to_wupper (wc) : _rl_to_wlower (wc);
1295 if (nwc != wc) /* just skip unchanged characters */
1296 {
1294 nwc = (nop == UpCase) ? _rl_to_wupper (wc) : _rl_to_wlower (wc);
1295 if (nwc != wc) /* just skip unchanged characters */
1296 {
1297 mblen = wcrtomb (mb, nwc, &ps);
1298 if (mblen > 0)
1299 mb[mblen] = '\0';
1297 mlen = wcrtomb (mb, nwc, &mps);
1298 if (mlen > 0)
1299 mb[mlen] = '\0';
1300 /* Assume the same width */
1300 /* Assume the same width */
1301 strncpy (rl_line_buffer + start, mb, mblen);
1301 strncpy (rl_line_buffer + start, mb, mlen);
1302 }
1303 }
1304#endif
1305
1306 start = next;
1307 }
1308
1309 rl_point = end;

--- 328 unchanged lines hidden ---
1302 }
1303 }
1304#endif
1305
1306 start = next;
1307 }
1308
1309 rl_point = end;

--- 328 unchanged lines hidden ---