Changeset b950088 for functions.c
- Timestamp:
- Jun 29, 2002, 11:55:06 AM (22 years ago)
- Branches:
- master, barnowl_perlaim, debian, owl, release-1.10, release-1.4, release-1.5, release-1.6, release-1.7, release-1.8, release-1.9
- Children:
- 855ebe7
- Parents:
- 61d27fb
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
functions.c
r1aee7d9 rb950088 176 176 177 177 178 /* If filter is non-null, looks for the next message matching 179 * that filter. If skip_deleted, skips any deleted messages. 180 * If last_if_none, will stop at the last message in the view 181 * if no matching messages are found. */ 182 void owl_function_nextmsg_full(char *filter, int skip_deleted, int last_if_none) { 183 int curmsg, i, viewsize, found; 184 owl_view *v; 185 owl_filter *f = NULL; 186 owl_message *m; 187 188 v=owl_global_get_current_view(&g); 189 190 if (filter) { 191 f=owl_global_get_filter(&g, filter); 192 if (!f) { 193 owl_function_makemsg("No %s filter defined", filter); 194 return; 195 } 196 } 197 198 curmsg=owl_global_get_curmsg(&g); 199 viewsize=owl_view_get_size(v); 200 found=0; 201 202 /* just check to make sure we're in bounds... */ 203 if (curmsg>viewsize-1) curmsg=viewsize-1; 204 if (curmsg<0) curmsg=0; 205 206 for (i=curmsg+1; i<viewsize; i++) { 207 m=owl_view_get_element(v, i); 208 if (skip_deleted && owl_message_is_delete(m)) continue; 209 if (f && !owl_filter_message_match(f, m)) continue; 210 found = 1; 211 break; 212 } 213 214 if (i>owl_view_get_size(v)-1) i=owl_view_get_size(v)-1; 215 216 if (!found) { 217 owl_function_makemsg("already at last%s message%s%s", 218 skip_deleted?" non-deleted":"", 219 filter?" in ":"", filter?filter:""); 220 owl_function_beep(); 221 } 222 223 if (last_if_none || found) { 224 owl_global_set_curmsg(&g, i); 225 owl_function_calculate_topmsg(OWL_DIRECTION_DOWNWARDS); 226 owl_mainwin_redisplay(owl_global_get_mainwin(&g)); 227 owl_global_set_direction_downwards(&g); 228 } 229 } 230 231 void owl_function_prevmsg_full(char *filter, int skip_deleted, int first_if_none) { 232 int curmsg, i, viewsize, found; 233 owl_view *v; 234 owl_filter *f = NULL; 235 owl_message *m; 236 237 v=owl_global_get_current_view(&g); 238 239 if (filter) { 240 f=owl_global_get_filter(&g, filter); 241 if (!f) { 242 owl_function_makemsg("No %s filter defined", filter); 243 return; 244 } 245 } 246 247 curmsg=owl_global_get_curmsg(&g); 248 viewsize=owl_view_get_size(v); 249 found=0; 250 251 /* just check to make sure we're in bounds... */ 252 if (curmsg>viewsize-1) curmsg=viewsize-1; 253 if (curmsg<0) curmsg=0; 254 255 for (i=curmsg-1; i>=0; i--) { 256 m=owl_view_get_element(v, i); 257 if (skip_deleted && owl_message_is_delete(m)) continue; 258 if (f && !owl_filter_message_match(f, m)) continue; 259 found = 1; 260 break; 261 } 262 263 if (i<0) i=0; 264 265 if (!found) { 266 owl_function_makemsg("already at first%s message%s%s", 267 skip_deleted?" non-deleted":"", 268 filter?" in ":"", filter?filter:""); 269 owl_function_beep(); 270 } 271 272 if (first_if_none || found) { 273 owl_global_set_curmsg(&g, i); 274 owl_function_calculate_topmsg(OWL_DIRECTION_UPWARDS); 275 owl_mainwin_redisplay(owl_global_get_mainwin(&g)); 276 owl_global_set_direction_upwards(&g); 277 } 278 } 178 279 179 280 void owl_function_nextmsg() { 180 int curmsg; 181 owl_view *v; 182 183 v=owl_global_get_current_view(&g); 184 185 curmsg=owl_global_get_curmsg(&g); 186 curmsg++; 187 if (curmsg>owl_view_get_size(v)-1) { 188 curmsg=owl_view_get_size(v)-1; 189 if (curmsg<0) curmsg=0; 190 owl_function_beep(); 191 owl_function_makemsg("already at last message"); 192 } 193 owl_global_set_curmsg(&g, curmsg); 194 owl_function_calculate_topmsg(OWL_DIRECTION_DOWNWARDS); 195 196 owl_mainwin_redisplay(owl_global_get_mainwin(&g)); 197 owl_global_set_direction_downwards(&g); 281 owl_function_nextmsg_full(NULL, 0, 1); 198 282 } 199 283 200 284 201 285 void owl_function_prevmsg() { 202 int curmsg; 203 204 curmsg=owl_global_get_curmsg(&g); 205 curmsg--; 206 if (curmsg<0) { 207 curmsg=0; 208 owl_function_beep(); 209 owl_function_makemsg("already at first message"); 210 } 211 owl_global_set_curmsg(&g, curmsg); 212 owl_function_calculate_topmsg(OWL_DIRECTION_UPWARDS); 213 owl_mainwin_redisplay(owl_global_get_mainwin(&g)); 214 owl_global_set_direction_upwards(&g); 215 } 216 286 owl_function_prevmsg_full(NULL, 0, 1); 287 } 217 288 218 289 void owl_function_nextmsg_notdeleted() { 219 int curmsg; 220 owl_message *m; 221 owl_view *v; 222 223 v=owl_global_get_current_view(&g); 224 225 curmsg=owl_global_get_curmsg(&g); 226 while (1) { 227 curmsg++; 228 229 /* if we're out of bounds get in bounds and stop */ 230 if (curmsg>owl_view_get_size(v)-1) { 231 curmsg=owl_view_get_size(v)-1; 232 if (curmsg<0) curmsg=0; 233 owl_function_makemsg("already at last non-deleted message"); 234 break; 235 } 236 237 /* if this one is not deleted we can stop where we are */ 238 m=owl_view_get_element(v, curmsg); 239 if (!owl_message_is_delete(m)) { 240 break; 241 } 242 } 243 244 owl_global_set_curmsg(&g, curmsg); 245 owl_function_calculate_topmsg(OWL_DIRECTION_DOWNWARDS); 246 owl_mainwin_redisplay(owl_global_get_mainwin(&g)); 247 owl_global_set_direction_downwards(&g); 290 owl_function_nextmsg_full(NULL, 1, 1); 248 291 } 249 292 250 293 251 294 void owl_function_prevmsg_notdeleted() { 252 int curmsg; 253 owl_message *m; 254 owl_view *v; 255 256 v=owl_global_get_current_view(&g); 257 258 curmsg=owl_global_get_curmsg(&g); 259 while(1) { 260 curmsg--; 261 262 /* if we're out of bounds get in bounds and stop */ 263 if (curmsg<0) { 264 curmsg=0; 265 owl_function_makemsg("already at first non-deleted message"); 266 break; 267 } 268 269 /* if this one is not deleted we can stop where we are */ 270 m=owl_view_get_element(v, curmsg); 271 if (!owl_message_is_delete(m)) { 272 break; 273 } 274 } 275 276 owl_global_set_curmsg(&g, curmsg); 277 owl_function_calculate_topmsg(OWL_DIRECTION_UPWARDS); 278 owl_mainwin_redisplay(owl_global_get_mainwin(&g)); 279 owl_global_set_direction_upwards(&g); 280 } 281 282 283 void owl_function_deletecur() { 295 owl_function_prevmsg_full(NULL, 1, 1); 296 } 297 298 299 void owl_function_nextmsg_personal() { 300 owl_function_nextmsg_full("personal", 0, 0); 301 } 302 303 void owl_function_prevmsg_personal() { 304 owl_function_prevmsg_full("personal", 0, 0); 305 } 306 307 308 /* if move_after is 1, moves after the delete */ 309 void owl_function_deletecur(int move_after) { 284 310 int curmsg; 285 311 owl_view *v; … … 297 323 owl_view_delete_element(v, curmsg); 298 324 299 /* move the poiner in the appropriate direction to the next undeleted msg */ 300 if (owl_global_get_direction(&g)==OWL_DIRECTION_UPWARDS) { 301 owl_command_prev_notdeleted(); 302 } else { 303 owl_command_next_notdeleted(); 304 } 305 } 306 307 308 void owl_function_undeletecur() { 325 if (move_after) { 326 /* move the poiner in the appropriate direction 327 * to the next undeleted msg */ 328 if (owl_global_get_direction(&g)==OWL_DIRECTION_UPWARDS) { 329 owl_function_prevmsg_notdeleted(); 330 } else { 331 owl_function_nextmsg_notdeleted(); 332 } 333 } 334 } 335 336 337 void owl_function_undeletecur(int move_after) { 309 338 int curmsg; 310 339 owl_view *v; … … 320 349 owl_view_undelete_element(v, curmsg); 321 350 322 if (owl_global_get_direction(&g)==OWL_DIRECTION_UPWARDS) { 323 if (curmsg>0) { 324 owl_command_prev(); 351 if (move_after) { 352 if (owl_global_get_direction(&g)==OWL_DIRECTION_UPWARDS) { 353 if (curmsg>0) { 354 owl_function_prevmsg(); 355 } else { 356 owl_function_nextmsg(); 357 } 325 358 } else { 326 owl_command_next(); 327 } 328 } else { 329 owl_command_next(); 359 owl_function_nextmsg(); 360 } 330 361 } 331 362 … … 1259 1290 owl_function_makemsg(buff); 1260 1291 owl_global_set_needrefresh(&g); 1261 }1262 1263 void owl_function_next_personal() {1264 int i, j, curmsg, found;1265 owl_view *v;1266 1267 v=owl_global_get_current_view(&g);1268 j=owl_view_get_size(v);1269 curmsg=owl_global_get_curmsg(&g);1270 found=0;1271 for (i=curmsg+1; i<j; i++) {1272 if (owl_message_is_personal(owl_view_get_element(v, i))) {1273 owl_global_set_curmsg(&g, i);1274 owl_function_calculate_topmsg(OWL_DIRECTION_DOWNWARDS);1275 owl_mainwin_redisplay(owl_global_get_mainwin(&g));1276 owl_global_set_direction_downwards(&g);1277 found=1;1278 break;1279 }1280 }1281 if (!found) {1282 owl_function_makemsg("No next personal message found");1283 }1284 }1285 1286 void owl_function_prev_personal() {1287 int i, curmsg, found;1288 owl_view *v;1289 1290 v=owl_global_get_current_view(&g);1291 curmsg=owl_global_get_curmsg(&g);1292 found=0;1293 for (i=curmsg-1; i>=0; i--) {1294 if (owl_message_is_personal(owl_view_get_element(v, i))) {1295 owl_global_set_curmsg(&g, i);1296 owl_function_calculate_topmsg(OWL_DIRECTION_UPWARDS);1297 owl_mainwin_redisplay(owl_global_get_mainwin(&g));1298 owl_global_set_direction_upwards(&g);1299 found=1;1300 break;1301 }1302 }1303 if (!found) {1304 owl_function_makemsg("No previous personal message found");1305 }1306 1292 } 1307 1293
Note: See TracChangeset
for help on using the changeset viewer.