"SfR Fresh" - the SfR Freeware/Shareware Archive

Member "see_bekijk-1.1/bekijk.c" of archive see_bekijk-1.1.tgz:


As a special service "SfR Fresh" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting with prefixed line numbers. Alternatively you can here view or download the uninterpreted source code file. That can be also achieved for any archive member file by clicking within an archive contents listing on the first character of the file(path) respectively on the according byte size field.
    1 /* ------------------------------------------------------------------------ */
    2 /* Bekijk.c 1.1                  	     (GPL) 1997,98  Belgie  Belgium */
    3 /*							    Staf Wagemakers */
    4 /* ------------------------------------------------------------------------ */
    5 #define TAB 9
    6 #include <ncurses.h>
    7 #include <malloc.h>
    8 #include <string.h>
    9 #include <signal.h>
   10 #include <libio.h>
   11 #include <errno.h>
   12 #include <unistd.h>
   13 #include <sys/types.h>
   14 #include <sys/time.h>
   15 #include "input.h"
   16 #include "win.h"
   17 #include "view.h"
   18 #ifdef _NED
   19 #include "ned.h"
   20 #endif
   21 #ifdef _ENG
   22 #include "eng.h"
   23 #endif
   24 WINDOW *win1,*win2,*w;          /* Midden scherm, Onderscherm + alg. venster*/
   25 char s[100]={'\0'};		/* String voor de te-zoeken-tekst	    */
   26 char ss[100]={'\0'};
   27 chtype kleur[12];		/* Array voor het bewaren van de kleuren    */
   28 char free_vb=0;
   29 unsigned brol,zoek_offset=0;
   30 unsigned long zoek_y;
   31 int  zoek_mode;			/* Ondersheid tussen G & k ?????	    */
   32 MENU m_ok,m_jn;
   33 VIEW_PAR bv;
   34 /* ------------------------------------------- */
   35 /* Procedure voor het sluiten van menu venster */
   36 /* ------------------------------------------- */
   37 void m_close(MENU *m)
   38 {
   39 delwin(m->w);
   40 wrefresh(win1);
   41 }
   42 /* --------------------------------------------------- */
   43 /* Procedure voor het openen van het bestandsmenu .... */
   44 /* --------------------------------------------------- */
   45 void open_bm (MENU *m)
   46 {
   47 m->w=open_win(4,m->l+2,1,1);
   48 m_open(m,win1);
   49 }
   50 /* ----------------------------------------- */
   51 /* Procedure voor het openen van het ga-menu */
   52 /* ----------------------------------------- */
   53 void open_gm (MENU *m)
   54 {
   55 m->w=open_win(7,m->l+2,1,(m->parent)->place[3]);
   56 m_open(m,win1);
   57 }
   58 /* ------------------------------------------- */
   59 /* Procedure voor het openen van het zoek-menu */
   60 /* ------------------------------------------- */
   61 void open_zm (MENU *m)
   62 {
   63 m->w=open_win(5,m->l+2,1,(m->parent)->place[5]);
   64 m_open(m,win1);
   65 }
   66 /* ------------------------------------------- */
   67 /* Procedure voor het openen van het help-menu */
   68 /* ------------------------------------------- */
   69 void open_hlpm (MENU *m)
   70 {
   71 m->w=open_win(5,m->l+2,1,COLS-m->l-2);
   72 m_open(m,win1);
   73 }
   74 /* ----------------------------------------- */
   75 /* Open van best. selektie menu              */
   76 /*                                           */
   77 /* Geeft terug: 0 -> ok 1 -> ESC             */
   78 /* ----------------------------------------- */
   79 int open_best()
   80 {
   81 int i;
   82 char *vb;
   83 chtype kl[3]={kleur[1],kleur[4],kleur[2]};
   84 vb=bv.filename;
   85 bv.filename=open_filewin(win2,txt_bo,kl,win1);
   86 if (bv.filename) {
   87   if (view_load()) {
   88     free(bv.filename);
   89     bv.filename=vb;
   90     }
   91     else {
   92      if(free_vb) free(vb);
   93      bv.y=0;bv.x=0;
   94      view_refresh();
   95      };
   96   free_vb=1;
   97 }
   98 else {bv.filename=vb;return(1);}
   99 return(0);
  100 }
  101 /* --------------------------------------------	*/
  102 /* Openen van het zoek venster			*/
  103 /*						*/
  104 /* char     *s = pointer naar string		*/
  105 /* char *titel = pointer naar venster-titel	*/
  106 /* char *tekst = pointer naar info-tekst	*/
  107 /*						*/
  108 /* Geeft terug 0 -> geen onderscheid G & k	*/
  109 /*             1 -> ondersheid G & k		*/
  110 /*	       2 -> break			*/
  111 /* --------------------------------------------	*/
  112 int open_zoek_venster (char *s,char *titel,char *tekst)
  113 {
  114 MENU m;
  115 int brol;
  116 int toetsen[]={27,9,0};
  117 int pl_ok[]={4,7,6,15,6,35};
  118 int key_m[]={0,9,'\n',' ','\n','\n'};
  119 w=open_cwin(8,60);
  120 m.w=w;
  121 m.amount=3;
  122 m.l=0;
  123 m.txt=txt_m_zoek;
  124 m.place=pl_ok;
  125 m.color1=kleur[2];
  126 m.color2=kleur[4];
  127 m.color3=kleur[7];
  128 m.color4=kleur[6];
  129 m.sel=m.used=0;
  130 m.key=key_m;
  131 m.hkey=hkey_zoek;
  132 m.hplace=hplace_zoek;
  133 wbkgdset(w,kleur[2]);
  134 werase(w);
  135 box(w,0,0);
  136 wbkgdset(w,kleur[2]);
  137 echo();
  138 leaveok(w,FALSE);
  139 mvwaddstr(w,0,2,titel);
  140 mvwaddstr(w,2,2,tekst);
  141 mvwaddstr(w,4,6,txt_ondersheid_g);
  142 wmove (w,2,22);
  143 wbkgdset(w,kleur[11]);
  144 for (brol=0;brol<=32;brol++) waddch(w,' ');
  145 do {
  146   menu_print(&m);
  147   m.sel=0;
  148   wbkgdset(w,kleur[11]);
  149   if (brol!=1) brol=input(w,2,22,s,32,0,toetsen);
  150     else brol=2;
  151   leaveok(w,TRUE);
  152   if (!brol) {
  153    if (m.txt[0]==txt_spacie)  return(0);
  154    return(1);
  155    };
  156   if (brol!=2) return(2);
  157   do {
  158     brol=menu_key(&m);
  159     if ((brol==2)&&(m.sel==0)) break;
  160    } while(brol<3);
  161   if ((m.sel==0)&&(brol>2)) {
  162     if (m.txt[0]==txt_spacie) m.txt[0]=txt_X;
  163       else m.txt[0]=txt_spacie;
  164     brol=1;
  165     };
  166 } while(brol<3);
  167 if (m.sel==1) {
  168   if (m.txt[0]==txt_spacie) return(0);
  169   return(1);
  170   };
  171 return (2);
  172 }
  173 /* --------------------------------------------	*/
  174 /* Konverteert een string naar grootte letters	*/
  175 /* -------------------------------------------- */
  176 void str_toupper (char *c)
  177 {
  178 int i=0;
  179 do {c[i]=toupper(c[i]);++i;} while (c[i]!=0);
  180 }
  181 /* --------------------------------------------	*/
  182 /* Print de gevonden tekst in de juiste kleur	*/
  183 /* -------------------------------------------- */
  184 void print_zoek (char *c,char *cp,char *sp,char *rp,unsigned i)
  185 {
  186   int brol;
  187   brol=cp-c;
  188   cp=rp+brol;
  189   strncpy(sp,cp,strlen(s));
  190   zoek_y=bv.y=i;
  191   zoek_offset=bv.x=cp-rp;
  192   ++zoek_offset;
  193   bv.x+=strlen(s);
  194   if (bv.x<COLS) brol=bv.x=0;
  195     else {brol=TRUE;bv.x-=COLS;}
  196   view_refresh();
  197   wbkgdset(win1,kleur[1]);
  198   if (brol) brol=COLS-strlen(s);
  199     else brol=cp-rp;
  200   wmove (win1,0,brol);
  201   view_addstr(sp);
  202   wbkgdset(win1,kleur[10]);
  203   touchwin(win1);
  204   free(rp);
  205 }
  206 /* --------------------------------------------	*/
  207 /* Funktie voor het zoeken van tekst ...	*/
  208 /*						*/
  209 /* unsigned long start = bestand te-zoeken-van	*/
  210 /* int mode  = 0 -> geen ondersheid G & k	*/
  211 /*           = 1 -> ondersheid G & k		*/
  212 /* --------------------------------------------	*/
  213 void zoek(unsigned long start,int mode)
  214 {
  215 char *cp,*rp;
  216 char *c=NULL;
  217 char *sp=NULL;
  218 unsigned i;
  219 if (zoek_y!=start) zoek_offset=0;
  220 for (i=start;i<bv.y_max;i++) {
  221   rp=view_getstr(i);
  222   c=realloc(c,strlen(rp)+1);
  223   sp=realloc(sp,strlen(s)+1);
  224   strcpy(c,rp);
  225   strcpy(sp,s);
  226   if (txt_m_zoek[0]==txt_spacie) {
  227     str_toupper(sp);
  228     str_toupper(c);
  229     };
  230   wrefresh(win2);
  231   cp=strstr(c+zoek_offset,sp);
  232   if (cp!=NULL) break;
  233   zoek_offset=0;
  234   free(rp);
  235   }
  236 if (cp!=NULL) {
  237   print_zoek(c,cp,sp,rp,i);
  238  }
  239   else {
  240     char *txt[]={txt_t_nt_gevonden,NULL};
  241     open_okwin(6,40,&m_ok,txt,win1);
  242     }
  243 free(c);
  244 }
  245 /* -------------------------------------------- */
  246 /* Funktie voor het inlezen van te-zoeken-tekst */
  247 /* char  mode :  0 -> huidige positie		*/
  248 /*               1 -> van begin			*/
  249 /* -------------------------------------------- */
  250 void zoek_tekst (char mode)
  251 {
  252 zoek_mode=open_zoek_venster(s,txt_z_v_tekst,txt_geef_de_tekst);
  253 delwin(w);
  254 wrefresh(win1);
  255 if (!strcmp(s,ss)) zoek_offset=0;
  256 if (zoek_mode<2) {
  257   if (mode) zoek(0,zoek_mode);
  258     else zoek(bv.y-(LINES-2),zoek_mode);
  259   }
  260   else zoek_mode=1;
  261 strcpy(ss,s);
  262 }
  263 /* -------------------------------------------- */
  264 /* Funktie om naar de lijnnr. te gaan ...       */
  265 /* -------------------------------------------- */
  266 ga_lijn ()
  267 {
  268 MENU m;
  269 int brol;
  270 char s[100],*txt[]={txt_ga_lijn,txt_geef_lijnnr};
  271 s[0]=0;
  272 m.txt=txt_ok_anu;
  273 m.hkey=hkey_ok_anu;
  274 m.hplace=hplace_ok_anu;
  275 m.color1=kleur[2];
  276 m.color2=kleur[4];
  277 m.color3=kleur[7];
  278 m.color4=kleur[6];
  279 brol=open_inputwin(7,60,&m,kleur[11],s,txt,1,win1);
  280 if (strlen(s)&&!brol) {
  281    sscanf(s,"%d",&bv.y);
  282    if (bv.y) --bv.y;
  283      else bv.y=0;
  284    view_refresh();
  285    }
  286 }
  287 void cp2stdout(FILE *fp)
  288 {
  289 char c;
  290 while(1) {
  291 	 if ((c=getc(fp))==EOF) break;
  292 	 fputc(c,stdout);
  293 	 }
  294 fclose(fp);
  295 fclose(stdout);
  296 }
  297 /* ---------------------------------------------------- */
  298 /* Hoofdprg ...						*/
  299 /* ---------------------------------------------------- */
  300 main(int arg1,char *arg2[])
  301 {
  302 VIEW_PAR *vp;
  303 int i,ii,c;
  304 WINDOW *hm_win,*sub_win;
  305 char **cp;
  306 int  pl_hm[]={0,1,0,9,0,12,0,17};
  307 int  pl_bm[]={1,1,2,1,};
  308 int  pl_gm[]={1,1,2,1,3,1,4,1,5,1,};
  309 int  pl_zm[]={1,1,2,1,3,1,};
  310 int  pl_hlpm[]={1,1,2,1,3,1,};
  311 int key_sub[]={KEY_UP,KEY_DOWN,'\n',KEY_LEFT,KEY_RIGHT,27};
  312 int key_hm[]={KEY_LEFT,KEY_RIGHT,'\n',KEY_UP,KEY_DOWN,27};
  313 MENU hm,bm,gm,zm,hlpm;
  314 MENU *sub_hm[]={&bm,&gm,&zm,&hlpm};
  315 MENU *sub_NULL[]={NULL,NULL,NULL,NULL,NULL};
  316 set_memerr(txt_f_geh);
  317 s[0]=0;
  318 bv.file=NULL;
  319 bv.filename=NULL;
  320 bv.cmd=1;
  321 bv.load=0;
  322 bv.txt_f_open2=txt_f_open2;
  323 bv.txt_f_open1=txt_f_open1;
  324 bv.txt_f_load=txt_f_laden;
  325 bv.txt_f_fseek=txt_f_fseek;
  326 if (!(initscr())) {
  327    fprintf(stderr,txt_f_initscr);exit(1);
  328    }
  329 bv.lines=LINES-2;
  330 bv.cols=COLS;
  331 view_par(&bv);
  332 if (!isatty(STDIN_FILENO)) {
  333    if (!isatty(STDOUT_FILENO)) {
  334       cp2stdout(stdin);
  335       fclose(stdin);
  336       fclose(stdout);
  337       wexit(0);
  338       }
  339    bv.cmd=2;
  340    bv.filename=(char *)malloc(strlen("STDIN"));
  341    strcpy(bv.filename,"STDIN");
  342    view_load();
  343    freopen("/dev/tty","r",stdin);
  344    arg1=2;
  345    }
  346 else {
  347 if (arg1>=2) {
  348 if (!strcmp(arg2[1],"--help")) {
  349    fprintf(stderr,"%s",txt_help);
  350    wexit(0);
  351    };
  352 if (chdir(arg2[1])==-1) {
  353       bv.filename=(char *)xmalloc(strlen(arg2[1])+1);
  354       strcpy(bv.filename,arg2[1]);
  355       if (isatty(STDOUT_FILENO)) view_load();
  356         else {
  357 	 FILE *fp;
  358 	 if ((fp=fopen(bv.filename,"r"))==NULL) {
  359 	    fprintf(stderr,"%s %s %s",txt_f_open1,bv.filename,txt_f_open2);
  360 	    fclose(stdout);
  361 	    wexit(1);
  362 	 }
  363          cp2stdout(fp);
  364 	 wexit(0);
  365 	}
  366       }
  367       else arg1=1;
  368     }
  369 }
  370 if (!isatty(STDOUT_FILENO)) wexit(1);
  371 bv.cmd=0;
  372 cp=bv.file;bv.x=0;s[0]=0;
  373 win_set_errmesg(txt_f_venster);
  374 win1=open_win(LINES-2,COLS,1,0);
  375 win2=open_win(1,COLS,LINES-1,0);
  376 hm_win=open_win(1,COLS,0,0);
  377 hm.w=hm_win;
  378 keypad(hm.w,TRUE);
  379 start_color();
  380 if(has_colors()) {
  381   init_pair(1,COLOR_BLACK,COLOR_CYAN);
  382   init_pair(2,COLOR_BLACK,COLOR_WHITE);
  383   init_pair(3,COLOR_WHITE,COLOR_BLUE);
  384   init_pair(4,COLOR_WHITE,COLOR_BLACK);
  385   init_pair(5,COLOR_YELLOW,COLOR_CYAN);
  386   init_pair(6,COLOR_YELLOW,COLOR_BLACK);
  387   init_pair(7,COLOR_YELLOW,COLOR_WHITE);
  388   init_pair(8,COLOR_YELLOW,COLOR_BLUE);
  389   init_pair(9,COLOR_RED,COLOR_BLUE);
  390   kleur[1]=COLOR_PAIR(1);
  391   kleur[2]=COLOR_PAIR(2);
  392   kleur[3]=COLOR_PAIR(3);
  393   kleur[4]=COLOR_PAIR(4)|A_BOLD;
  394   kleur[5]=COLOR_PAIR(5)|A_BOLD;
  395   kleur[6]=COLOR_PAIR(6)|A_BOLD;
  396   kleur[7]=COLOR_PAIR(7)|A_BOLD;
  397   kleur[8]=COLOR_PAIR(8)|A_BOLD;
  398   kleur[9]=COLOR_PAIR(9)|A_BOLD;
  399   kleur[10]=A_BOLD|kleur[3];
  400   kleur[11]=kleur[1];
  401   wbkgdset(win1,kleur[10]);
  402   }
  403  else{
  404   	 init_pair(1,COLOR_WHITE,COLOR_BLACK);
  405 	 kleur[1]=COLOR_PAIR(1)|A_REVERSE;
  406          kleur[2]=COLOR_PAIR(1)|A_REVERSE;
  407 	 kleur[3]=COLOR_PAIR(1);                    /* achtergrond win1 */
  408 	 kleur[4]=COLOR_PAIR(1);
  409 	 kleur[5]=kleur[1]|A_BOLD;
  410 	 kleur[6]=kleur[4]|A_BOLD;
  411 	 kleur[7]=kleur[2];
  412 	 kleur[8]=kleur[9]=COLOR_PAIR(1)|A_BOLD;
  413 	 kleur[10]=kleur[3];
  414 	 kleur[11]=kleur[3];
  415 	 wbkgdset(win1,kleur[10]);
  416          };
  417 wbkgdset(win2,kleur[1]);
  418 wbkgdset(hm_win,kleur[1]);
  419 werase(win1);
  420 werase(win2);
  421 werase(hm_win);
  422 signal(SIGINT,SIG_IGN);
  423 freopen("/dev/null","w",stderr);
  424 /* ------------------------------------------------------------------------- */
  425 /* START MENU INIT							     */
  426 /* ------------------------------------------------------------------------- */
  427 m_jn.txt=txt_jn;
  428 m_jn.color1=kleur[1];
  429 m_jn.color2=kleur[4];
  430 m_jn.color3=kleur[5];
  431 m_jn.color4=kleur[6];
  432 m_jn.hkey=hkey_jn;
  433 m_jn.hplace=hplace_jn;
  434 m_ok.txt=txt_ok;
  435 m_ok.color1=kleur[2];
  436 m_ok.color2=kleur[4];
  437 m_ok.color3=kleur[5];
  438 m_ok.color4=kleur[6];
  439 m_ok.hkey=hkey_ok;
  440 m_ok.hplace=hplace_ok;
  441 hm.sel=0;
  442 hm.amount=4;
  443 hm.place=pl_hm;
  444 hm.txt=txt_hm;
  445 hm.key=key_hm;
  446 hm.hkey=NULL;
  447 hm.next=sub_hm;
  448 hm.parent=NULL;
  449 hm.call_open=NULL;
  450 hm.call_close=NULL;
  451 hm.color1=bm.color1=gm.color1=zm.color1=hlpm.color1=kleur[1];
  452 hm.color2=bm.color2=gm.color2=zm.color2=hlpm.color2=kleur[4];
  453 hm.color3=bm.color3=gm.color3=zm.color3=hlpm.color3=kleur[5];
  454 hm.color4=bm.color4=gm.color4=zm.color4=hlpm.color4=kleur[6];
  455 bm.sel=gm.sel=zm.sel=hlpm.sel=0;
  456 bm.place=pl_bm;
  457 gm.place=pl_gm;
  458 zm.place=pl_zm;
  459 hlpm.place=pl_hlpm;
  460 bm.txt=txt_bm;
  461 gm.txt=txt_gm;
  462 zm.txt=txt_zm;
  463 hlpm.txt=txt_hlpm;
  464 bm.next=gm.next=zm.next=hlpm.next=sub_NULL;
  465 bm.parent=gm.parent=zm.parent=hlpm.parent=&hm;
  466 bm.key=gm.key=zm.key=hlpm.key=key_sub;
  467 bm.call_open=open_bm;
  468 gm.call_open=open_gm;
  469 zm.call_open=open_zm;
  470 hlpm.call_open=open_hlpm;
  471 bm.call_close=gm.call_close=zm.call_close=hlpm.call_close=m_close;
  472 bm.w=gm.w=zm.w=hlpm.w=sub_win;
  473 bm.amount=2;
  474 hlpm.amount=3;
  475 zm.amount=3;
  476 gm.amount=5;
  477 hm.l=bm.l=gm.l=zm.l=hlpm.l=0;
  478 bm.hkey=hkey_bm;
  479 gm.hkey=hkey_gm;
  480 zm.hkey=hkey_zm;
  481 hlpm.hkey=hkey_hlp;
  482 hm.hplace=hplace_hm;
  483 bm.hplace=hplace_bm;
  484 gm.hplace=hplace_gm;
  485 zm.hplace=hplace_zm;
  486 hlpm.hplace=hplace_hlpm;
  487 
  488 pl_hm[3]=strlen(txt_hm[0])+2;
  489 pl_hm[5]=strlen(txt_hm[0])+strlen(txt_hm[1])+3;
  490 pl_hm[7]=COLS-strlen(txt_hm[3])-2;
  491 for (i=0;i<bm.amount;i++)
  492   if (strlen(bm.txt[i])>bm.l) bm.l=strlen(bm.txt[i]);
  493 for (i=0;i<gm.amount;i++)
  494   if (strlen(gm.txt[i])>gm.l) gm.l=strlen(gm.txt[i]);
  495 for (i=0;i<zm.amount;i++)
  496   if (strlen(zm.txt[i])>zm.l) zm.l=strlen(zm.txt[i]);
  497 for (i=0;i<hlpm.amount;i++)
  498   if (strlen(hlpm.txt[i])>hlpm.l) hlpm.l=strlen(hlpm.txt[i]);
  499 /* ------------------------------------------------------------------------- */
  500 /* EINDE MENU INIT						             */
  501 /* ------------------------------------------------------------------------- */
  502 bv.m_ok=&m_ok;
  503 bv.color=kleur;
  504 bv.win=win1;
  505 menu_print(&hm);
  506 meta(win1,TRUE);
  507 noecho();
  508 cbreak();
  509 leaveok(win1,TRUE);
  510 keypad(win1,TRUE);
  511 nodelay(win1,FALSE);
  512 nodelay(hm_win,FALSE);
  513 /* nodelay(w,FALSE); */
  514 leaveok(stdscr,TRUE);
  515 /* leaveok(w,TRUE); */
  516 leaveok(hm_win,TRUE);
  517 keypad(stdscr,TRUE);
  518 nodelay(stdscr,TRUE);
  519 keypad(hm_win,TRUE);
  520 wrefresh(win1);
  521 wrefresh(win2);
  522 if (arg1<2) {
  523   do {
  524     if (open_best()) {
  525       delwin(win1);
  526       delwin(win2);
  527       refresh();
  528       wexit(0);
  529       };
  530     } while (bv.file==NULL);
  531 };
  532 bv.y=0;view_refresh();
  533 wrefresh(win1);
  534 wrefresh(win2);
  535 do {
  536 do {
  537    werase(win2);
  538    mvwprintw(win2,0,0,"%s %4d / %4d  %s %4d %s %ld",
  539 	txt_lijn,(bv.y-LINES+3),bv.y_max,txt_kol,bv.x,txt_Grootte,bv.size);
  540    mvwprintw(win2,0,COLS-strlen(bv.filename)-3,"%s",bv.filename);
  541    wrefresh(win2);
  542    wrefresh(win1);
  543    c=wgetch(win1);
  544    if ((c==KEY_F(9))||(c==27)) {
  545       int m_sel=0;
  546       if (c==27) {
  547 	nodelay(win1,TRUE);
  548         c=wgetch(win1);
  549 	if (c==ERR) c=27;
  550 	  else c=tolower(c);
  551 	nodelay(win1,FALSE);
  552 	if (c==sel_bm) m_sel=1;
  553 	 else
  554 	  if (c==sel_gm) m_sel=2;
  555 	   else
  556 	    if (c==sel_zm) m_sel=3;
  557              else
  558               if (c==sel_hm) m_sel=4;
  559 	       else m_sel=5;
  560       };
  561       if (m_sel<5) {
  562         c=0;
  563         werase(win2);
  564         mvwaddstr(win2,0,0,txt_maak_sel);
  565         wrefresh(win2);
  566         for (i=0;i<4;i++) sub_hm[i]->used=0;
  567         menu_pull(&hm,m_sel);
  568         for (i=0;i<hm.amount;i++) if (sub_hm[i]->used) break;
  569         menu_print(&hm);
  570         werase(win2);
  571         wrefresh(win2);
  572 	if (hm.used==2) c=0;
  573 	  else {
  574             switch (hm.sel) {
  575               case 0: switch (sub_hm[i]->sel) {
  576 		        case 0:  c='o';
  577 		                 break;
  578 		         case 1:  c='q';
  579                                  break;
  580 		         default: break;
  581 		         }
  582 		      break;
  583                case 1: switch (sub_hm[i]->sel) {
  584 		      case 0: c='b';
  585 	                      break;
  586 	              case 1: c='e';
  587                               break;
  588 		      case 2: ga_lijn();
  589 	                      break;
  590 	              case 3: c=KEY_END;
  591 	                      break;
  592 	              case 4: c=KEY_HOME;
  593                               break;
  594 	              default: break;
  595 	              }
  596 	              break;
  597               case 2: switch (sub_hm[i]->sel) {
  598 		      case 0: c='z';
  599 		              break;
  600 	              case 1: zoek_tekst(1);
  601 		              c=0;
  602 			      break;
  603                       case 2: c=KEY_F(3);
  604 		              break;
  605 	              }
  606 		      break;
  607 	      case 3:
  608                       switch (sub_hm[i]->sel) {
  609 	                case 0: c='?';
  610 		                break;
  611 		        case 1: m_ok.color1=kleur[1];
  612 			        open_okwin(21,60,&m_ok,txt_t,win1);
  613 			        m_ok.color1=kleur[2];
  614 			        break;
  615  		        case 2: open_animwin(10,60,&m_ok,txt_over,txt_bedank,win1,0);
  616 		                break;
  617 	                default:break;
  618 		       }
  619 		       break;
  620 	      default: c=0;
  621                        break;
  622          }
  623     }
  624     }
  625     }
  626     switch (c) {
  627     case '<'      :
  628     case 'b'      :
  629     case 'B'      :  bv.y=0;bv.x=0;view_refresh();
  630                      break;
  631     case '>'      :
  632     case 'E'      :
  633     case 'e'      :  bv.y=bv.y_max;bv.x=0;view_refresh();break;
  634     case 14       :
  635     case 'J'      :
  636     case 'j'      :
  637     case KEY_DOWN :  view_down();
  638                      break;
  639     case 16       :
  640     case 'K'      :
  641     case 'k'      :
  642     case KEY_UP   :  view_up();
  643 		     break;
  644     case 'd'      :
  645     case 'D'      :
  646     case KEY_NPAGE: view_refresh();
  647 		    break;
  648     case 'u'      :
  649     case 'U'      :
  650     case KEY_PPAGE: view_previous();
  651 		    break;
  652     case 6        :
  653     case 'L'      :
  654     case 'l'      :
  655     case KEY_RIGHT: view_right();
  656                     break;
  657     case 2        :
  658     case KEY_LEFT : view_left();
  659                     break;
  660     case 'g'      :
  661     case 'G'      :  ga_lijn();
  662 		     break;
  663     case '/'      :
  664     case 'z'      :
  665     case 'Z'      :
  666     case 's'      :
  667     case 'S'      :
  668     case 'F'      :
  669     case 'f'      :  zoek_tekst(0);
  670 		     break;
  671     case 'v'      :
  672     case 'V'      :
  673     case 'c'      :
  674     case 'C'      :
  675     case KEY_F(3) :  if (s[0]) zoek(bv.y-(LINES-2),1);
  676                        else zoek_tekst(0);
  677 		     break;
  678     case KEY_HOME :  bv.x=0;
  679 		     bv.y-=(LINES-2);
  680                      view_refresh();
  681 		     break;
  682     case KEY_END  :  bv.y-=(LINES-2);
  683 		     bv.x=strlen(bv.file[bv.y]);
  684 		     if (bv.x<COLS) bv.x=0;
  685 		       else bv.x-=COLS;
  686 		     view_refresh();
  687                      break;
  688     case 'o'      :
  689     case 'O'      :
  690 		     open_best();
  691 		     cp=bv.file;bv.x=0;s[0]=0;
  692 		     break;
  693     case 'r'      :  bv.y-=(LINES-2);
  694 	             view_refresh();
  695 	             break;
  696     case 'h'      :
  697     case 'H'      :
  698     case '?'      :
  699     case KEY_F(1) : { char *vb;
  700                       vb=bv.filename;
  701 		      bv.filename=