comparison mcabber/src/screen.c @ 238:8e30b2bb380e

[/trunk] Changeset 251 by mikael * Add /msay command (multi-line messages)
author mikael
date Sat, 11 Jun 2005 19:12:25 +0000
parents 72fd1273f2b7
children cb7f944741e4
comparison
equal deleted inserted replaced
237:c8df64f43625 238:8e30b2bb380e
41 static PANEL *logPanel, *logPanel_border; 41 static PANEL *logPanel, *logPanel_border;
42 static int maxY, maxX; 42 static int maxY, maxX;
43 static window_entry_t *currentWindow; 43 static window_entry_t *currentWindow;
44 44
45 static int chatmode; 45 static int chatmode;
46 static int multimode;
47 static char *multiline;
46 int update_roster; 48 int update_roster;
47 int utf8_mode = 0; 49 int utf8_mode = 0;
48 50
49 static char inputLine[INPUTLINE_LENGTH+1]; 51 static char inputLine[INPUTLINE_LENGTH+1];
50 static char *ptr_inputline; 52 static char *ptr_inputline;
1084 inline void scr_set_chatmode(int enable) 1086 inline void scr_set_chatmode(int enable)
1085 { 1087 {
1086 chatmode = enable; 1088 chatmode = enable;
1087 } 1089 }
1088 1090
1091 // scr_get_multimode()
1092 // Public fonction to get multimode status...
1093 inline int scr_get_multimode()
1094 {
1095 return multimode;
1096 }
1097
1098 // scr_set_multimode()
1099 // Public fonction to (un)set multimode...
1100 inline void scr_set_multimode(int enable)
1101 {
1102 if (multiline) {
1103 g_free(multiline);
1104 multiline = NULL;
1105 }
1106 if (enable)
1107 multimode = TRUE;
1108 else
1109 multimode = FALSE;
1110 }
1111
1112 // scr_get_multiline()
1113 // Public fonction to get multimode status...
1114 inline const char *scr_get_multiline()
1115 {
1116 if (multimode && multiline)
1117 return multiline;
1118 else
1119 return "";
1120 }
1121
1122 // scr_append_multiline(line)
1123 // Public function to append a line to the current multi-line message.
1124 // Skip empty leading lines.
1125 void scr_append_multiline(const char *line)
1126 {
1127 static int num;
1128
1129 if (!multimode) {
1130 scr_LogPrint("Error: Not in multi-line message mode!");
1131 return;
1132 }
1133 if (multiline) {
1134 int len = strlen(multiline)+strlen(line)+2;
1135 if (len >= HBB_BLOCKSIZE) {
1136 // We don't handle single messages with size > HBB_BLOCKSIZE
1137 // (see hbuf)
1138 scr_LogPrint("Your multi-line message is too big, this line has "
1139 "not been added.");
1140 scr_LogPrint("Please send this part now...");
1141 return;
1142 }
1143 multiline = g_renew(char, multiline, len);
1144 strcat(multiline, "\n");
1145 strcat(multiline, line);
1146 num++;
1147 } else {
1148 // First message line (we skip leading empty lines)
1149 num = 0;
1150 if (line[0]) {
1151 multiline = g_new(char, strlen(line)+1);
1152 strcpy(multiline, line);
1153 num++;
1154 } else
1155 return;
1156 }
1157 scr_LogPrint("Multi-line mode: line #%d added [%.25s...", num, line);
1158 }
1159
1089 // scr_cmdhisto_addline() 1160 // scr_cmdhisto_addline()
1090 // Add a line to the inputLine history 1161 // Add a line to the inputLine history
1091 inline void scr_cmdhisto_addline(char *line) 1162 inline void scr_cmdhisto_addline(char *line)
1092 { 1163 {
1093 if (!line || !*line) return; 1164 if (!line || !*line) return;
1369 for ( ; *c ; c++) 1440 for ( ; *c ; c++)
1370 *c = *(c+1); 1441 *c = *(c+1);
1371 check_offset(-1); 1442 check_offset(-1);
1372 } 1443 }
1373 break; 1444 break;
1374 case KEY_DC: 1445 case KEY_DC:// Del
1375 if (*ptr_inputline) 1446 if (*ptr_inputline)
1376 strcpy(ptr_inputline, ptr_inputline+1); 1447 strcpy(ptr_inputline, ptr_inputline+1);
1377 break; 1448 break;
1378 case KEY_LEFT: 1449 case KEY_LEFT:
1379 if (ptr_inputline != (char*)&inputLine) { 1450 if (ptr_inputline != (char*)&inputLine) {