Mercurial > ~mikael > mcabber > hg
comparison mcabber/src/screen.c @ 175:7b7dd6d69f58
[/trunk] Changeset 187 by mikael
* Change shoortcuts:
- PgUP/PgDown ==> move in roster
- Up/Down ==> move in history (input line)
- C-p/C-n ==> move in chat history buffer
author | mikael |
---|---|
date | Thu, 05 May 2005 06:25:52 +0000 |
parents | 6354625e8fb2 |
children | cfefae4b6de9 |
comparison
equal
deleted
inserted
replaced
174:6354625e8fb2 | 175:7b7dd6d69f58 |
---|---|
964 cmdhisto = g_list_append(cmdhisto, g_strdup(line)); | 964 cmdhisto = g_list_append(cmdhisto, g_strdup(line)); |
965 } | 965 } |
966 | 966 |
967 // scr_cmdhisto_prev() | 967 // scr_cmdhisto_prev() |
968 // Look for previous line beginning w/ the given mask in the inputLine history | 968 // Look for previous line beginning w/ the given mask in the inputLine history |
969 // Returns NULL if none found | |
969 const char *scr_cmdhisto_prev(char *mask, guint len) | 970 const char *scr_cmdhisto_prev(char *mask, guint len) |
970 { | 971 { |
971 GList *hl; | 972 GList *hl; |
972 if (!cmdhisto_cur) { | 973 if (!cmdhisto_cur) { |
973 hl = g_list_last(cmdhisto); | 974 hl = g_list_last(cmdhisto); |
988 return NULL; | 989 return NULL; |
989 } | 990 } |
990 | 991 |
991 // scr_cmdhisto_next() | 992 // scr_cmdhisto_next() |
992 // Look for next line beginning w/ the given mask in the inputLine history | 993 // Look for next line beginning w/ the given mask in the inputLine history |
994 // Returns NULL if none found | |
993 const char *scr_cmdhisto_next(char *mask, guint len) | 995 const char *scr_cmdhisto_next(char *mask, guint len) |
994 { | 996 { |
995 GList *hl; | 997 GList *hl; |
996 if (!cmdhisto_cur) return NULL; | 998 if (!cmdhisto_cur) return NULL; |
997 hl = cmdhisto_cur; | 999 hl = cmdhisto_cur; |
999 if (!strncmp((char*)hl->data, mask, len)) { | 1001 if (!strncmp((char*)hl->data, mask, len)) { |
1000 // Found a match | 1002 // Found a match |
1001 cmdhisto_cur = hl; | 1003 cmdhisto_cur = hl; |
1002 return (const char*)hl->data; | 1004 return (const char*)hl->data; |
1003 } | 1005 } |
1004 if (strncmp(cmdhisto_backup, mask, len)) | 1006 // If the "backuped" line matches, we'll use it |
1005 return NULL; | 1007 if (strncmp(cmdhisto_backup, mask, len)) return NULL; // No match |
1006 cmdhisto_cur = NULL; | 1008 cmdhisto_cur = NULL; |
1007 return cmdhisto_backup; | 1009 return cmdhisto_backup; |
1008 } | 1010 } |
1009 | 1011 |
1010 // which_row() | 1012 // which_row() |
1216 ptr_inputline = inputLine; | 1218 ptr_inputline = inputLine; |
1217 *ptr_inputline = 0; | 1219 *ptr_inputline = 0; |
1218 inputline_offset = 0; | 1220 inputline_offset = 0; |
1219 break; | 1221 break; |
1220 case KEY_UP: | 1222 case KEY_UP: |
1221 scr_RosterUp(); | |
1222 break; | |
1223 case KEY_DOWN: | |
1224 scr_RosterDown(); | |
1225 break; | |
1226 case KEY_PPAGE: | |
1227 scr_ScrollUp(); | |
1228 break; | |
1229 case KEY_NPAGE: | |
1230 scr_ScrollDown(); | |
1231 break; | |
1232 case KEY_HOME: | |
1233 case 1: | |
1234 ptr_inputline = inputLine; | |
1235 inputline_offset = 0; | |
1236 break; | |
1237 case KEY_END: | |
1238 case 5: | |
1239 for (; *ptr_inputline; ptr_inputline++) ; | |
1240 check_offset(1); | |
1241 break; | |
1242 case 21: // Ctrl-u | |
1243 strcpy(inputLine, ptr_inputline); | |
1244 ptr_inputline = inputLine; | |
1245 inputline_offset = 0; | |
1246 break; | |
1247 case KEY_EOL: | |
1248 case 11: // Ctrl-k | |
1249 *ptr_inputline = 0; | |
1250 break; | |
1251 case 16: // Ctrl-p | |
1252 { | 1223 { |
1253 const char *l = scr_cmdhisto_prev(inputLine, | 1224 const char *l = scr_cmdhisto_prev(inputLine, |
1254 ptr_inputline-inputLine); | 1225 ptr_inputline-inputLine); |
1255 if (l) { | 1226 if (l) { |
1256 strcpy(inputLine, l); | 1227 strcpy(inputLine, l); |
1257 } | 1228 } |
1258 } | 1229 } |
1259 break; | 1230 break; |
1260 case 14: // Ctrl-n | 1231 case KEY_DOWN: |
1261 { | 1232 { |
1262 const char *l = scr_cmdhisto_next(inputLine, | 1233 const char *l = scr_cmdhisto_next(inputLine, |
1263 ptr_inputline-inputLine); | 1234 ptr_inputline-inputLine); |
1264 if (l) { | 1235 if (l) { |
1265 strcpy(inputLine, l); | 1236 strcpy(inputLine, l); |
1266 } | 1237 } |
1267 } | 1238 } |
1239 break; | |
1240 case KEY_PPAGE: | |
1241 scr_RosterUp(); | |
1242 break; | |
1243 case KEY_NPAGE: | |
1244 scr_RosterDown(); | |
1245 break; | |
1246 case KEY_HOME: | |
1247 case 1: | |
1248 ptr_inputline = inputLine; | |
1249 inputline_offset = 0; | |
1250 break; | |
1251 case KEY_END: | |
1252 case 5: | |
1253 for (; *ptr_inputline; ptr_inputline++) ; | |
1254 check_offset(1); | |
1255 break; | |
1256 case 21: // Ctrl-u | |
1257 strcpy(inputLine, ptr_inputline); | |
1258 ptr_inputline = inputLine; | |
1259 inputline_offset = 0; | |
1260 break; | |
1261 case KEY_EOL: | |
1262 case 11: // Ctrl-k | |
1263 *ptr_inputline = 0; | |
1264 break; | |
1265 case 16: // Ctrl-p | |
1266 scr_ScrollUp(); | |
1267 break; | |
1268 case 14: // Ctrl-n | |
1269 scr_ScrollDown(); | |
1268 break; | 1270 break; |
1269 case 27: // ESC | 1271 case 27: // ESC |
1270 currentWindow = NULL; | 1272 currentWindow = NULL; |
1271 chatmode = FALSE; | 1273 chatmode = FALSE; |
1272 if (current_buddy) | 1274 if (current_buddy) |