#include "owl.h" #include #include #include #include static const char fileIdent[] = "$Id$"; void sepbar(char *in) { char buff[1024]; WINDOW *sepwin; owl_messagelist *ml; owl_view *v; int x, y, i; char *foo, *appendtosepbar; sepwin=owl_global_get_curs_sepwin(&g); ml=owl_global_get_msglist(&g); v=owl_global_get_current_view(&g); werase(sepwin); wattron(sepwin, A_REVERSE); whline(sepwin, ACS_HLINE, owl_global_get_cols(&g)); wmove(sepwin, 0, 2); if (owl_messagelist_get_size(ml)==0) { strcpy(buff, " (-/-) "); } else { sprintf(buff, " (%i/%i/%i) ", owl_global_get_curmsg(&g)+1, owl_view_get_size(v), owl_messagelist_get_size(ml)); } waddstr(sepwin, buff); foo=owl_view_get_filtname(v); if (strcmp(foo, "all")) wattroff(sepwin, A_REVERSE); waddstr(sepwin, " "); waddstr(sepwin, owl_view_get_filtname(v)); waddstr(sepwin, " "); if (strcmp(foo, "all")) wattron(sepwin, A_REVERSE); if (owl_mainwin_is_curmsg_truncated(owl_global_get_mainwin(&g))) { getyx(sepwin, y, x); wmove(sepwin, y, x+2); wattron(sepwin, A_BOLD); waddstr(sepwin, " "); wattroff(sepwin, A_BOLD); } i=owl_mainwin_get_last_msg(owl_global_get_mainwin(&g)); if ((i != -1) && (i < owl_view_get_size(v)-1)) { getyx(sepwin, y, x); wmove(sepwin, y, x+2); wattron(sepwin, A_BOLD); waddstr(sepwin, " "); wattroff(sepwin, A_BOLD); } if (owl_global_get_rightshift(&g)>0) { getyx(sepwin, y, x); wmove(sepwin, y, x+2); sprintf(buff, " right: %i ", owl_global_get_rightshift(&g)); waddstr(sepwin, buff); } if (owl_global_is_zaway(&g)) { getyx(sepwin, y, x); wmove(sepwin, y, x+2); wattron(sepwin, A_BOLD); wattroff(sepwin, A_REVERSE); waddstr(sepwin, " ZAWAY "); wattron(sepwin, A_REVERSE); wattroff(sepwin, A_BOLD); } if (owl_global_get_curmsg_vert_offset(&g)) { getyx(sepwin, y, x); wmove(sepwin, y, x+2); wattron(sepwin, A_BOLD); wattroff(sepwin, A_REVERSE); waddstr(sepwin, " SCROLL "); wattron(sepwin, A_REVERSE); wattroff(sepwin, A_BOLD); } if (in) { getyx(sepwin, y, x); wmove(sepwin, y, x+2); waddstr(sepwin, in); } appendtosepbar = owl_global_get_appendtosepbar(&g); if (appendtosepbar && *appendtosepbar) { getyx(sepwin, y, x); wmove(sepwin, y, x+2); waddstr(sepwin, " "); waddstr(sepwin, owl_global_get_appendtosepbar(&g)); waddstr(sepwin, " "); } getyx(sepwin, y, x); wmove(sepwin, y, owl_global_get_cols(&g)-1); wattroff(sepwin, A_BOLD); wattroff(sepwin, A_REVERSE); wnoutrefresh(sepwin); } void pophandler_quit(int ch) { if (ch=='q') { owl_popwin_close(owl_global_get_popwin(&g)); } } char **atokenize(char *buffer, char *sep, int *i) { /* each element of return must be freed by user */ char **args; char *workbuff, *foo; int done=0, first=1, count=0; workbuff=owl_malloc(strlen(buffer)+1); memcpy(workbuff, buffer, strlen(buffer)+1); args=NULL; while (!done) { if (first) { first=0; foo=(char *)strtok(workbuff, sep); } else { foo=(char *)strtok(NULL, sep); } if (foo==NULL) { done=1; } else { args=(char **)owl_realloc(args, sizeof(char *) * (count+1)); args[count]=owl_malloc(strlen(foo)+1); strcpy(args[count], foo); count++; } } *i=count; owl_free(workbuff); return(args); } /* skips n tokens and returns where that would be. * TODO: handle quotes. */ char *skiptokens(char *buff, int n) { int inquotes=0; while (*buff && n>0) { while (*buff == ' ') buff++; while (*buff && (inquotes || *buff != ' ')) { if (*buff == '"') inquotes=!inquotes; buff++; } while (*buff == ' ') buff++; n--; } return buff; } void atokenize_free(char **tok, int nels) { int i; for (i=0; i