Mercurial > ~mikael > mcabber > hg
comparison mcabber/src/screen.c @ 195:cdaa53d5ef70
[/trunk] Changeset 207 by mikael
* Add readline_transpose_chars() (bound to Ctrl-t)
* Rename backward_kill_word() to readline_backward_kill_word()
author | mikael |
---|---|
date | Sat, 07 May 2005 06:26:46 +0000 |
parents | a05d5c3876ec |
children | 58eb8ad9ef74 |
comparison
equal
deleted
inserted
replaced
194:a05d5c3876ec | 195:cdaa53d5ef70 |
---|---|
1068 if (strncmp(cmdhisto_backup, mask, len)) return NULL; // No match | 1068 if (strncmp(cmdhisto_backup, mask, len)) return NULL; // No match |
1069 cmdhisto_cur = NULL; | 1069 cmdhisto_cur = NULL; |
1070 return cmdhisto_backup; | 1070 return cmdhisto_backup; |
1071 } | 1071 } |
1072 | 1072 |
1073 // backward_kill_word() | 1073 // readline_transpose_chars() |
1074 // Drag the character before point forward over the character at | |
1075 // point, moving point forward as well. If point is at the end of | |
1076 // the line, then this transposes the two characters before point. | |
1077 void readline_transpose_chars() | |
1078 { | |
1079 char swp; | |
1080 | |
1081 if (ptr_inputline == inputLine) return; | |
1082 | |
1083 if (!*ptr_inputline) { // We're at EOL | |
1084 // If line is only 1 char long, nothing to do... | |
1085 if (ptr_inputline == inputLine+1) return; | |
1086 // Transpose the two previous characters | |
1087 swp = *(ptr_inputline-2); | |
1088 *(ptr_inputline-2) = *(ptr_inputline-1); | |
1089 *(ptr_inputline-1) = swp; | |
1090 } else { | |
1091 swp = *(ptr_inputline-1); | |
1092 *(ptr_inputline-1) = *ptr_inputline; | |
1093 *ptr_inputline++ = swp; | |
1094 check_offset(1); | |
1095 } | |
1096 } | |
1097 | |
1098 // readline_backward_kill_word() | |
1074 // Kill the word before the cursor, in input line | 1099 // Kill the word before the cursor, in input line |
1075 void backward_kill_word() | 1100 void readline_backward_kill_word() |
1076 { | 1101 { |
1077 char *c, *old = ptr_inputline; | 1102 char *c, *old = ptr_inputline; |
1078 int spaceallowed = 1; | 1103 int spaceallowed = 1; |
1079 | 1104 |
1080 if (ptr_inputline == inputLine) return; | 1105 if (ptr_inputline == inputLine) return; |
1093 ptr_inputline = c; | 1118 ptr_inputline = c; |
1094 for (;;) { | 1119 for (;;) { |
1095 *c = *old++; | 1120 *c = *old++; |
1096 if (!*c++) break; | 1121 if (!*c++) break; |
1097 } | 1122 } |
1123 check_offset(-1); | |
1098 } | 1124 } |
1099 | 1125 |
1100 // which_row() | 1126 // which_row() |
1101 // Tells which row our cursor is in, in the command line. | 1127 // Tells which row our cursor is in, in the command line. |
1102 // -1 -> normal text | 1128 // -1 -> normal text |
1354 scr_ScrollUp(); | 1380 scr_ScrollUp(); |
1355 break; | 1381 break; |
1356 case 14: // Ctrl-n | 1382 case 14: // Ctrl-n |
1357 scr_ScrollDown(); | 1383 scr_ScrollDown(); |
1358 break; | 1384 break; |
1385 case 20: // Ctrl-t | |
1386 readline_transpose_chars(); | |
1387 break; | |
1359 case 23: // Ctrl-w | 1388 case 23: // Ctrl-w |
1360 backward_kill_word(); | 1389 readline_backward_kill_word(); |
1361 check_offset(-1); | |
1362 break; | 1390 break; |
1363 case 27: // ESC | 1391 case 27: // ESC |
1364 currentWindow = NULL; | 1392 currentWindow = NULL; |
1365 chatmode = FALSE; | 1393 chatmode = FALSE; |
1366 if (current_buddy) | 1394 if (current_buddy) |