Changeset 3895e23 for functions.c
- Timestamp:
- Dec 25, 2003, 12:05:02 AM (21 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:
- 280ddc6
- Parents:
- 330bcec
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
functions.c
r40458b9 r3895e23 2250 2250 } 2251 2251 2252 #if 0 2253 void owl_function_change_view_old(char *filtname) 2252 void owl_function_change_currentview_filter(char *filtname) 2254 2253 { 2255 2254 owl_view *v; … … 2259 2258 2260 2259 v=owl_global_get_current_view(&g); 2260 2261 2261 curmsg=owl_global_get_curmsg(&g); 2262 2262 if (curmsg==-1) { … … 2270 2270 } 2271 2271 2272 /* grab the filter */;2273 2272 f=owl_global_get_filter(&g, filtname); 2274 2273 if (!f) { … … 2277 2276 } 2278 2277 2279 /* free the existing view and create a new one based on the filter */ 2280 owl_view_free(v); 2281 owl_view_create(v, f); 2278 owl_view_new_filter(v, f); 2282 2279 2283 2280 /* Figure out what to set the current message to. … … 2293 2290 2294 2291 owl_global_set_curmsg(&g, newpos); 2295 2296 2292 owl_function_calculate_topmsg(OWL_DIRECTION_DOWNWARDS); 2297 2293 owl_mainwin_redisplay(owl_global_get_mainwin(&g)); 2298 2294 owl_global_set_direction_downwards(&g); 2299 2295 } 2300 #endif2301 2302 void owl_function_change_view(char *filtname)2303 {2304 owl_view *v;2305 owl_filter *f;2306 int curid=-1, newpos, curmsg;2307 owl_message *curm=NULL;2308 2309 v=owl_global_get_current_view(&g);2310 2311 curmsg=owl_global_get_curmsg(&g);2312 if (curmsg==-1) {2313 owl_function_debugmsg("Hit the curmsg==-1 case in change_view");2314 } else {2315 curm=owl_view_get_element(v, curmsg);2316 if (curm) {2317 curid=owl_message_get_id(curm);2318 owl_view_save_curmsgid(v, curid);2319 }2320 }2321 2322 f=owl_global_get_filter(&g, filtname);2323 if (!f) {2324 owl_function_error("Unknown filter %s", filtname);2325 return;2326 }2327 2328 owl_view_new_filter(v, f);2329 2330 /* Figure out what to set the current message to.2331 * - If the view we're leaving has messages in it, go to the closest message2332 * to the last message pointed to in that view.2333 * - If the view we're leaving is empty, try to restore the position2334 * from the last time we were in the new view. */2335 if (curm) {2336 newpos = owl_view_get_nearest_to_msgid(v, curid);2337 } else {2338 newpos = owl_view_get_nearest_to_saved(v);2339 }2340 2341 owl_global_set_curmsg(&g, newpos);2342 owl_function_calculate_topmsg(OWL_DIRECTION_DOWNWARDS);2343 owl_mainwin_redisplay(owl_global_get_mainwin(&g));2344 owl_global_set_direction_downwards(&g);2345 }2346 2296 2347 2297 void owl_function_create_filter(int argc, char **argv) … … 2355 2305 return; 2356 2306 } 2307 2308 owl_function_debugmsg("owl_function_create_filter: starting to create filter named %s", argv[1]); 2357 2309 2358 2310 v=owl_global_get_current_view(&g); … … 2405 2357 /* if it was in use by the current view then update */ 2406 2358 if (inuse) { 2407 owl_function_change_ view(argv[1]);2359 owl_function_change_currentview_filter(argv[1]); 2408 2360 } 2409 2361 owl_global_set_needrefresh(&g); 2410 2362 owl_mainwin_redisplay(owl_global_get_mainwin(&g)); 2363 } 2364 2365 /* If 'filtername' does not start with 'not-' create a filter named 2366 * 'not-<filtername>' defined as "not filter <filtername>". If the 2367 * filter 'not-<filtername>' already exists, do not overwrite it. If 2368 * 'filtername' begins with 'not-' and a filter 'filtername' already 2369 * exists, then do nothing. If the filter 'filtername' does not 2370 * exist, create it and define it as 'not filter <filtername>' 2371 * 2372 * Returns the name of the negated filter, which the caller must free. 2373 */ 2374 char *owl_function_create_negative_filter(char *filtername) 2375 { 2376 char *newname; 2377 owl_filter *tmpfilt; 2378 char *argv[5]; 2379 2380 owl_function_debugmsg("owl_function_create_negative_filter"); 2381 2382 if (!strncmp(filtername, "not-", 4)) { 2383 newname=owl_strdup(filtername+4); 2384 } else { 2385 newname=owl_sprintf("not-%s", filtername); 2386 } 2387 2388 tmpfilt=owl_global_get_filter(&g, newname); 2389 if (!tmpfilt) { 2390 argv[0]="filter"; /* anything is fine here */ 2391 argv[1]=newname; 2392 argv[2]="not"; 2393 argv[3]="filter"; 2394 argv[4]=filtername; 2395 owl_function_create_filter(5, argv); 2396 } 2397 2398 owl_function_debugmsg("owl_function_create_negative_filter: returning with %s", newname); 2399 return(newname); 2411 2400 } 2412 2401
Note: See TracChangeset
for help on using the changeset viewer.