Changeset 1fd0b25
- Timestamp:
- Aug 17, 2002, 10:31:35 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:
- 37c27cf
- Parents:
- 8509c08
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
ChangeLog
r8509c08 r1fd0b25 1 1 $Id$ 2 3 1.2.2 4 Added the 'search' command. 5 '/' is a keybinding for 'search' 6 '?' is a keybinding for 'search -r' 7 Fixed stristr, which was completely broken 8 renamed owl_fmtext_ztext_stylestrip to owl_function_ztext_styletsrip 9 and put it in functions.c 2 10 3 11 1.2.1 -
commands.c
rf2e36b5 r1fd0b25 497 497 "returns the value of a variable", 498 498 "getvar <varname>", ""), 499 500 OWLCMD_ARGS("search", owl_command_search, OWL_CTX_INTERACTIVE, 501 "search messages for a particular string", 502 "search [-r] [<string>]", 503 "The search command will find messages that contain the\n" 504 "specified string and move the cursor there. If no string\n" 505 "argument is supplied then the previous one is used. By\n" 506 "default searches are done fowards, if -r is used the search\n" 507 "is performed backwards"), 499 508 500 509 /****************************************************************/ … … 1478 1487 } 1479 1488 1489 char *owl_command_search(int argc, char **argv, char *buff) { 1490 int direction; 1491 char *buffstart; 1492 1493 direction=OWL_DIRECTION_DOWNWARDS; 1494 buffstart=skiptokens(buff, 1); 1495 if (argc>1 && !strcmp(argv[1], "-r")) { 1496 direction=OWL_DIRECTION_UPWARDS; 1497 buffstart=skiptokens(buff, 2); 1498 } 1499 1500 if (argc==1 || (argc==2 && !strcmp(argv[1], "-r"))) { 1501 owl_function_search_continue(direction); 1502 } else { 1503 owl_function_search_start(buffstart, direction); 1504 } 1505 1506 return(NULL); 1507 } 1508 1480 1509 /*********************************************************************/ 1481 1510 /************************** EDIT SPECIFIC ****************************/ -
fmtext.c
re1c4636 r1fd0b25 19 19 for (i=first; i<=last; i++) { 20 20 f->fmbuff[i]=(unsigned char) attr; 21 } 22 } 23 24 void _owl_fmtext_add_attr(owl_fmtext *f, int attr, int first, int last) { 25 int i; 26 for (i=first; i<=last; i++) { 27 f->fmbuff[i]|=(unsigned char) attr; 21 28 } 22 29 } … … 332 339 } 333 340 334 /* strips formatting from ztext and returns the unformatted text.335 * caller is responsible for freeing. */336 char *owl_fmtext_ztext_stylestrip(char *zt) {337 owl_fmtext fm;338 char *plaintext;339 340 owl_fmtext_init_null(&fm);341 owl_fmtext_append_ztext(&fm, zt);342 plaintext = owl_fmtext_print_plain(&fm);343 owl_fmtext_free(&fm);344 return(plaintext);345 }346 347 341 348 342 void owl_fmtext_curs_waddstr(owl_fmtext *f, WINDOW *w) { … … 516 510 memcpy(dst->colorbuff, src->colorbuff, src->textlen); 517 511 } 512 513 514 int owl_fmtext_search_and_highlight(owl_fmtext *f, char *string) { 515 /* highlight all instance of "string". Return the number of 516 * instances found. This is case insensitive. */ 517 518 int found, len; 519 char *ptr1, *ptr2; 520 521 len=strlen(string); 522 found=0; 523 ptr1=f->textbuff; 524 while (ptr1-f->textbuff <= f->textlen) { 525 ptr2=stristr(ptr1, string); 526 if (!ptr2) return(found); 527 528 found++; 529 _owl_fmtext_add_attr(f, OWL_FMTEXT_ATTR_REVERSE, 530 ptr2 - f->textbuff, 531 ptr2 - f->textbuff + len - 1); 532 533 ptr1=ptr2+len; 534 } 535 return(found); 536 } 537 538 int owl_fmtext_search(owl_fmtext *f, char *string) { 539 /* return 1 if the string is found, 0 if not. This is case 540 * insensitive */ 541 542 if (stristr(f->textbuff, string)) return(1); 543 return(0); 544 } -
functions.c
rf2e36b5 r1fd0b25 1597 1597 1598 1598 if (argc<2) { 1599 owl_function_makemsg("Wrong number of arguments to the pexec command");1599 owl_function_makemsg("Wrong number of arguments to the exec command"); 1600 1600 return NULL; 1601 1601 } … … 2182 2182 /* TODO: implement for real */ 2183 2183 void owl_function_show_keymap(char *name) { 2184 owl_fmtext 2184 owl_fmtext fm; 2185 2185 owl_keymap *km; 2186 2186 … … 2198 2198 2199 2199 void owl_function_help_for_command(char *cmdname) { 2200 owl_fmtext 2200 owl_fmtext fm; 2201 2201 2202 2202 owl_fmtext_init_null(&fm); … … 2205 2205 owl_fmtext_free(&fm); 2206 2206 } 2207 2208 void owl_function_search_start(char *string, int direction) { 2209 /* direction is OWL_DIRECTION_DOWNWARDS or OWL_DIRECTION_UPWARDS */ 2210 owl_global_set_search_active(&g, string); 2211 owl_function_search_helper(0, direction); 2212 } 2213 2214 void owl_function_search_continue(int direction) { 2215 /* direction is OWL_DIRECTION_DOWNWARDS or OWL_DIRECTION_UPWARDS */ 2216 owl_function_search_helper(1, direction); 2217 } 2218 2219 void owl_function_search_helper(int mode, int direction) { 2220 /* move to a message that contains the string. If direction is 2221 * OWL_DIRECTION_DOWNWARDS then search fowards, if direction is 2222 * OWL_DIRECTION_UPWARDS then search backwards. 2223 * 2224 * If mode==0 then it will stay on the current message if it 2225 * contains the string. 2226 */ 2227 2228 owl_view *v; 2229 int viewsize, i, curmsg, start; 2230 owl_message *m; 2231 2232 v=owl_global_get_current_view(&g); 2233 viewsize=owl_view_get_size(v); 2234 curmsg=owl_global_get_curmsg(&g); 2235 2236 if (viewsize==0) { 2237 owl_function_makemsg("No messages present"); 2238 return; 2239 } 2240 2241 if (mode==0) { 2242 start=curmsg; 2243 } else if (direction==OWL_DIRECTION_DOWNWARDS) { 2244 start=curmsg+1; 2245 } else { 2246 start=curmsg-1; 2247 } 2248 2249 /* bounds check */ 2250 if (start>=viewsize || start<0) { 2251 owl_function_makemsg("No further matches found"); 2252 return; 2253 } 2254 2255 for (i=start; i<viewsize && i>=0;) { 2256 m=owl_view_get_element(v, i); 2257 if (owl_message_search(m, owl_global_get_search_string(&g))) { 2258 owl_global_set_curmsg(&g, i); 2259 owl_function_calculate_topmsg(direction); 2260 owl_mainwin_redisplay(owl_global_get_mainwin(&g)); 2261 if (direction==OWL_DIRECTION_DOWNWARDS) { 2262 owl_global_set_direction_downwards(&g); 2263 } else { 2264 owl_global_set_direction_upwards(&g); 2265 } 2266 return; 2267 } 2268 if (direction==OWL_DIRECTION_DOWNWARDS) { 2269 i++; 2270 } else { 2271 i--; 2272 } 2273 } 2274 owl_function_makemsg("No matches found"); 2275 } 2276 2277 2278 /* strips formatting from ztext and returns the unformatted text. 2279 * caller is responsible for freeing. */ 2280 char *owl_function_ztext_stylestrip(char *zt) { 2281 owl_fmtext fm; 2282 char *plaintext; 2283 2284 owl_fmtext_init_null(&fm); 2285 owl_fmtext_append_ztext(&fm, zt); 2286 plaintext = owl_fmtext_print_plain(&fm); 2287 owl_fmtext_free(&fm); 2288 return(plaintext); 2289 } -
global.c
re1c4636 r1fd0b25 58 58 g->colorpairs=COLOR_PAIRS; 59 59 g->debug=OWL_DEBUG; 60 g->searchactive=0; 61 g->searchstring=NULL; 60 62 g->starttime=time(NULL); /* assumes we call init only a start time */ 61 63 strcpy(g->buffercommand, ""); … … 593 595 return(0); 594 596 } 597 598 int owl_global_is_search_active(owl_global *g) { 599 if (g->searchactive) return(1); 600 return(0); 601 } 602 603 void owl_global_set_search_active(owl_global *g, char *string) { 604 g->searchactive=1; 605 if (g->searchstring != NULL) owl_free(g->searchstring); 606 g->searchstring=owl_strdup(string); 607 } 608 609 void owl_global_set_search_inactive(owl_global *g) { 610 g->searchactive=0; 611 } 612 613 char *owl_global_get_search_string(owl_global *g) { 614 if (g->searchstring==NULL) return(""); 615 return(g->searchstring); 616 } -
keys.c
rf2e36b5 r1fd0b25 203 203 BIND_CMD("M-n", "smartnarrow", "narrow to a view based on the current message"); 204 204 BIND_CMD("M-N", "smartnarrow -i", "narrow to a view based on the current message, and consider instance pair"); 205 206 BIND_CMD("/", "start-command search ", "start a search command"); 207 BIND_CMD("?", "start-command search -r ", "start a revrerse search command"); 205 208 206 209 BIND_CMD("LEFT", "recv:shiftleft", ""); -
message.c
re50cd56 r1fd0b25 460 460 owl_fmtext_colorize(&b, color); 461 461 } 462 463 if (owl_global_is_search_active(&g)) { 464 owl_fmtext_search_and_highlight(&b, owl_global_get_search_string(&g)); 465 } 466 462 467 owl_fmtext_curs_waddstr(&b, win); 463 468 … … 626 631 } 627 632 633 int owl_message_search(owl_message *m, char *string) { 634 /* return 1 if the message contains "string", 0 otherwise. This is 635 * case insensitive because the functions it uses are */ 636 637 return (owl_fmtext_search(&(m->fmtext), string)); 638 } -
owl.h
r8509c08 r1fd0b25 12 12 static const char owl_h_fileIdent[] = "$Id$"; 13 13 14 #define OWL_VERSION 1.2. 115 #define OWL_VERSION_STRING "1.2. 1"14 #define OWL_VERSION 1.2.2 15 #define OWL_VERSION_STRING "1.2.2" 16 16 17 17 #define OWL_DEBUG 0 … … 384 384 int hascolors; 385 385 int colorpairs; 386 int searchactive; 387 char *searchstring; 386 388 owl_filterelement fe_true; 387 389 owl_filterelement fe_false; -
perlglue.xs
re1c4636 r1fd0b25 9 9 extern void owl_free(void *); 10 10 extern int owl_zwrite_create_and_send_from_line(char *, char *); 11 extern char *owl_f mtext_ztext_stylestrip(char *);11 extern char *owl_function_ztext_stylestrip(char *); 12 12 13 13 MODULE = owl PACKAGE = owl … … 41 41 char *rv = NULL; 42 42 CODE: 43 rv = owl_f mtext_ztext_stylestrip(ztext);43 rv = owl_function_ztext_stylestrip(ztext); 44 44 RETVAL = rv; 45 45 OUTPUT: -
util.c
re50cd56 r1fd0b25 294 294 downstr(y); 295 295 ret=strstr(x, y); 296 if (ret==NULL) { 297 owl_free(x); 298 owl_free(y); 299 return(NULL); 300 } 301 ret=ret-x+a; 296 302 owl_free(x); 297 303 owl_free(y); … … 337 343 int i; 338 344 for (i=0; s[i]; i++) { 339 if (!isspace( s[i])) return(0);345 if (!isspace((int) s[i])) return(0); 340 346 } 341 347 return(1);
Note: See TracChangeset
for help on using the changeset viewer.