X-Git-Url: https://git.deb.at/?a=blobdiff_plain;f=estr.c;h=3f2d25e9b766c07bab0b5c07da95672567f2363b;hb=ceba9214d8bebe32d0c34c7a82916bcb9d798d69;hp=9f8d7f074c6259b12410b0d96e921e563f309aa9;hpb=0d3c17d9ab127e5596c8fb97d65122b3b90f6b11;p=pkg%2Fabook.git diff --git a/estr.c b/estr.c index 9f8d7f0..3f2d25e 100644 --- a/estr.c +++ b/estr.c @@ -1,12 +1,10 @@ /* - * - * estr.c + * $Id$ * - * by JH + * by JH * * Copyright (C) Jaakko Heinonen - * */ @@ -80,16 +78,16 @@ wenter_string(WINDOW *win, const int maxlen, const int flags) int size = maxlen > 0 ? maxlen + 1 : INITIAL_BUFSIZE; getyx(win, y, x); - str = MALLOC(size); + str = (char *)MALLOC(size); for( ;; ) { /* main loop */ - if(flags & ESTR_DONT_WRAP && x+i>COLS-2) { + if(flags & ESTR_DONT_WRAP && x+i > COLS-2) { mvwaddnstr(win, y, x, str+(1+x+i-COLS), COLS-x-1); wmove(win, y, COLS-1); - wclrtoeol(win); } else wmove(win, y, x + i); + wclrtoeol(win); wrefresh(win); switch( (ch = getch()) ) { @@ -105,6 +103,9 @@ wenter_string(WINDOW *win, const int maxlen, const int flags) case CANCEL_KEY: free(str); return NULL; + case XCTRL('u'): + i = 0; + break; #ifdef USE_FILESEL case TAB_KEY: if( ! (flags & ESTR_USE_FILESEL) ) @@ -120,10 +121,8 @@ wenter_string(WINDOW *win, const int maxlen, const int flags) continue; str[i++] = ch; waddch(win,ch); - if( i + 1 > size ) - str = REALLOC( str, size *= 2 ); - if( maxlen > 0 && i > maxlen) - break; + if( i + 1 >= size ) + str = (char *)REALLOC( str, size *= 2 ); } out: if( i >= 0 && str != NULL ) @@ -137,7 +136,7 @@ out: /* * filesel.c - * by JH + * by JH * * Copyright (C) Jaakko Heinonen */ @@ -259,7 +258,8 @@ filesel_add_filesel_list_item(struct filesel_list_item item) if( ++filesel_items > filesel_list_capacity) { filesel_list_capacity = filesel_list_capacity < 1 ? 30:filesel_list_capacity << 1; - lst = REALLOC(lst, filesel_list_capacity * + lst = (struct filesel_list_item *)REALLOC(lst, + filesel_list_capacity * sizeof(struct filesel_list_item) ); } @@ -318,7 +318,7 @@ filesel_sort_list() qsort((void *)lst, fdp, sizeof(struct filesel_list_item), filenamecmp ); - qsort((void *)lst + fdp * sizeof(struct filesel_list_item), + qsort((void *)(&lst[fdp]), FILESEL_LAST_ITEM - fdp + 1, sizeof(struct filesel_list_item), filenamecmp ); @@ -358,8 +358,12 @@ filesel_highlight_line(WINDOW *win, int line) static void filesel_print_list_line(int i, int line) { - if( lst[i].type == FLSL_TYPE_DIR ) + if( lst[i].type == FLSL_TYPE_DIR ) { + mvwaddch(filesel_list, line, 3, 'd'); +#ifdef A_BOLD wattron(filesel_list, A_BOLD); +#endif + } mvwaddnstr(filesel_list, line, 5, lst[i].filename, COLS - 5); } @@ -516,7 +520,8 @@ filesel_enter() if(lst[filesel_curitem].type == FLSL_TYPE_DIR) { dir = my_getcwd(); - newdir = MALLOC(strlen(dir)+strlen(lst[filesel_curitem].filename) +2 ); + newdir = (char *)MALLOC(strlen(dir) + + strlen(lst[filesel_curitem].filename) +2 ); strcpy(newdir, dir); strcat(newdir, "/"); strcat(newdir,lst[filesel_curitem].filename); @@ -592,7 +597,8 @@ filesel() if( !filesel_loop() ) { dir = my_getcwd(); - tmp = MALLOC(strlen(dir) + strlen(lst[filesel_curitem].filename) + 2); + tmp = (char *)MALLOC(strlen(dir) + + strlen(lst[filesel_curitem].filename) + 2); strcpy(tmp,dir); strcat(tmp, "/"); strcat(tmp, lst[filesel_curitem].filename);