/[ofm]/ofm/iface.c
ViewVC logotype

Diff of /ofm/iface.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.8 by MarcusvA, Sat Jan 11 10:28:46 2003 UTC revision 1.9 by eses, Sat Jan 11 23:42:24 2003 UTC
# Line 77  char *men2_desc[] = Line 77  char *men2_desc[] =
77      "F2",  (char *)NULL      "F2",  (char *)NULL
78  };  };
79    
80  /* SCREEN *ofm_term; */  //SCREEN *ofm_term;
81    
82  /* console size */  /* console size */
83    
# Line 102  char workdir[2][PATH_MAX]; Line 102  char workdir[2][PATH_MAX];
102  char cmd_buffer[PATH_MAX+1];  char cmd_buffer[PATH_MAX+1];
103  int cmd_size=0;  int cmd_size=0;
104    
105    /*bookmarks stuff*/
106    int bookmark_is_active=0;
107    /*pointers replaced by bookmarks*/
108    DirStruct *bb_dir, *bb_sel_ds, *bb_first ;
109    char *bb_sel_name;
110    /*bookmarks pointers*/
111    DirStruct *b_sel_ds=NULL, *b_first=NULL ;
112    char *b_sel_name=NULL;
113    DirStruct *Bookmarks=NULL;
114    
115    
116  /* ***** ***** ***** */  /* ***** ***** ***** */
117    
118    DirStruct *bookmarkInsert(DirStruct *bm){
119        DirStruct *tmp;
120        int ti;
121        
122        tmp=NULL;
123        if (bm!=NULL) {
124            tmp=dirDuplicate(bm);
125            if (tmp!=NULL) {
126                tmp->path=NULL;
127                ti=strlen(workdir[opanelActive]);
128                tmp->path=(char *)xmalloc(ti+1);
129                if (tmp->path!=NULL) strcpy(tmp->path,workdir[opanelActive]);
130                if (Bookmarks==NULL) {
131                    tmp->last=tmp;
132                    tmp->first=tmp;
133                    tmp->index=1;
134                    Bookmarks=tmp;
135                } else {
136                    tmp->prev=Bookmarks->last;
137                    tmp->index=Bookmarks->last->index+1;
138                    tmp->last=tmp;
139                    tmp->first=Bookmarks->first;
140                    Bookmarks->last->next=tmp;
141                    Bookmarks->last=tmp;
142                }
143                if (tmp->dir) Bookmarks->dir_count++;
144                else Bookmarks->files_count++;
145                tmp=Bookmarks;
146                while (tmp->next!=NULL) {
147                    tmp->next->dir_count=tmp->dir_count;
148                    tmp->next->files_count=tmp->files_count;
149                    tmp=tmp->next;
150                }
151                tmp=Bookmarks->last;
152            }
153            
154        }
155        return tmp;
156    }
157    
158    int bookmarkSaveState(OPANEL *op)
159    {
160        bb_dir=op->dir;
161        bb_sel_ds=op->sel_ds;
162        bb_sel_name=op->sel_name;
163        bb_first=op->first;
164        op->dir=Bookmarks;
165        op->sel_ds=b_sel_ds;
166        op->sel_name=b_sel_name;
167        op->first=b_first;
168        op->virtual_dir=1;
169        return 0;
170    }
171    
172    int bookmarkRestoreState(OPANEL *op)
173    {
174        bookmark_is_active=0;
175        b_sel_ds=op->sel_ds;
176        b_sel_name=op->sel_name;
177        b_first=op->first;
178        op->dir=bb_dir;
179        op->sel_ds=bb_sel_ds;
180        op->sel_name=bb_sel_name;
181        op->first=bb_first;
182        op->virtual_dir=0;
183        return 0;
184    }
185    
186    
187  /* creates two panels, windows with information, gets the path of the inactive  /* creates two panels, windows with information, gets the path of the inactive
188     panel (the path of the active panel is read from opanelRefresh */     panel (the path of the active panel is read from opanelRefresh */
189    
# Line 152  void viewportDelete() Line 232  void viewportDelete()
232  {  {
233      opanelDelete(opanels[0]);      opanelDelete(opanels[0]);
234      opanelDelete(opanels[1]);      opanelDelete(opanels[1]);
235        if (bookmark_is_active) Bookmarks=bb_dir;  //opanelDelete cleared bookmarks' dir so we clear real dir
236      delwin(up_info);      delwin(up_info);
237      delwin(down_info);      delwin(down_info);
238      menuDelete(ofm_menu[0]);      menuDelete(ofm_menu[0]);
# Line 159  void viewportDelete() Line 240  void viewportDelete()
240      menuBarDelete();      menuBarDelete();
241      stackFree(stack[0]);      stackFree(stack[0]);
242      stackFree(stack[1]);      stackFree(stack[1]);
243        if (Bookmarks!=NULL) dirFree(Bookmarks);    
244      clear();      clear();
245  }  }
246    
# Line 170  OPANEL *opanelCreate(int x,int y,int wid Line 252  OPANEL *opanelCreate(int x,int y,int wid
252            
253      tmp=(OPANEL*)xmalloc(sizeof(OPANEL));      tmp=(OPANEL*)xmalloc(sizeof(OPANEL));
254      if (tmp!=NULL) {      if (tmp!=NULL) {
255          /* tmp->path="./"; */          //tmp->path="./";
256          tmp->dir=(DirStruct*)NULL;          tmp->dir=(DirStruct*)NULL;
257            tmp->virtual_dir=0;
258          tmp->columns=2;          tmp->columns=2;
259          tmp->width=width;          tmp->width=width;
260          tmp->height=height;          tmp->height=height;
# Line 206  int opanelRefresh(OPANEL *p) Line 289  int opanelRefresh(OPANEL *p)
289  {  {
290    
291          /* artificial variable */          /* artificial variable */
   
292      int tmp;      int tmp;
293    
294          /* char before the name */          /* char before the name */
           
295      char prefix;      char prefix;
296    
297          /* string dependent on the column length */          /* string dependent on the column length */
           
298      char *tstr;      char *tstr;
299    
300          /* artificial string */          /* artificial string */
           
301      char tname[FILENAME_MAX];      char tname[FILENAME_MAX];
302    
303          /* current cursor position */          /* current cursor position */
           
304      int x=1,y=1;      int x=1,y=1;
305    
306          /* current structure */          /* current structure */
           
307      DirStruct *ds, *dstmp;      DirStruct *ds, *dstmp;
308    
309          /* column width */          /* column width */
           
310      int colw;      int colw;
311    
312          /* color */          /* color */
           
313      int col;      int col;
314    
315          /* number of current panel */          /* number of current panel */
           
316      int opanel_nr;      int opanel_nr;
317    
318          /* artificial variable */          /* artificial variable */
   
319      unsigned long tsize;      unsigned long tsize;
320    
321          /* artificial variable */          /* artificial variable */
           
322      int t;      int t;
323    
       
324      if (p==NULL) return 0;      if (p==NULL) return 0;
325            
326      /* draws windows and seperators */      /* draws windows and seperators */
327    
328          /* color */          /* color */
   
329      col=5;      col=5;
330    
331          /* if the panel is active... */          /* if the panel is active... */
           
332      if (p->active) col=1;      if (p->active) col=1;
333      wbkgd(p->win,COLOR_PAIR(col));      wbkgd(p->win,COLOR_PAIR(col));
334      wattrset(p->win,COLOR_PAIR(col));        wattrset(p->win,COLOR_PAIR(col));  
# Line 279  int opanelRefresh(OPANEL *p) Line 348  int opanelRefresh(OPANEL *p)
348      else opanel_nr=! opanelActive;      else opanel_nr=! opanelActive;
349      tmp=chdir(workdir[opanel_nr]);      tmp=chdir(workdir[opanel_nr]);
350      if (tmp) {      if (tmp) {
351  /*      fprintf(stderr,"Error changing to workdir[%d]: %s\n",opanel_nr,workdir[opanel_nr]); */  //      fprintf(stderr,"Error changing to workdir[%d]: %s\n",opanel_nr,workdir[opanel_nr]);
352          tmp=chdir("/");          tmp=chdir("/");
353          p->reread=1;          p->reread=1;
354      }      }
# Line 292  int opanelRefresh(OPANEL *p) Line 361  int opanelRefresh(OPANEL *p)
361          /* if the directory isn't read yet, then we should do it */          /* if the directory isn't read yet, then we should do it */
362    
363      if (p->dir==NULL) {      if (p->dir==NULL) {
364          /* while ( ((p->dir=dirSuck("./"))==NULL) && (! chdir("..")) ); */          //while ( ((p->dir=dirSuck("./"))==NULL) && (! chdir("..")) );
365          p->dir=dirSuck("./");          p->dir=dirSuck("./");
366          if (p->dir==NULL) return 1;          if (p->dir==NULL) return 1;
367          dirSort(p->dir,p->sort_mode);          p->dir->next=dirSort(p->dir->next,p->sort_mode,1);
368          p->first=p->dir->first;          p->first=p->dir->first;
369          if (p->sel_name!=NULL) p->reread=1;          if (p->sel_name!=NULL) p->reread=1;
370          getcwd(workdir[opanel_nr],PATH_MAX);          getcwd(workdir[opanel_nr],PATH_MAX);
# Line 305  int opanelRefresh(OPANEL *p) Line 374  int opanelRefresh(OPANEL *p)
374    
375      if (p->reread) {      if (p->reread) {
376          p->reread=0;          p->reread=0;
377            ds=NULL;
378          /* lazy check */          if (p->virtual_dir) ds=p->dir;
379                    else ds=dirSuck("./");
         /* while ( ((ds=dirSuck("./"))==NULL) && (! chdir("..")) ); */  
         ds=dirSuck("./");  
380          if (ds!=NULL){          if (ds!=NULL){
381              dirSort(ds,p->sort_mode);              if (p->virtual_dir) {
382                    ds=dirSort(ds,p->sort_mode,0);
383                    p->first=ds;
384                    p->dir=ds;
385                    Bookmarks=ds;
386                }
387                else ds->next=dirSort(ds->next,p->sort_mode,1);
388              if (p->sel_ds!=NULL) strcpy(tname,p->sel_ds->name);              if (p->sel_ds!=NULL) strcpy(tname,p->sel_ds->name);
389              else if (p->sel_name!=NULL) strcpy(tname,p->sel_name);              else if (p->sel_name!=NULL) strcpy(tname,p->sel_name);
390    
# Line 322  int opanelRefresh(OPANEL *p) Line 395  int opanelRefresh(OPANEL *p)
395                  p->first=ds->first;                  p->first=ds->first;
396                  p->sel_ds=ds->first;                  p->sel_ds=ds->first;
397              }              }
398              else {              else {   //we found selected node
399                  p->sel_ds=dstmp;                  p->sel_ds=dstmp;
400                  if ((dstmp=dirFind(ds,p->first->name))==NULL) p->first=p->sel_ds;                  if ((dstmp=dirFind(ds,p->first->name))==NULL)  //if our previous first node disappear
401                        p->first=p->sel_ds;
402                  else                  else
403                      if (dstmp->index>p->sel_ds->index) p->first=p->sel_ds;                      if (dstmp->index>p->sel_ds->index) //if previous node is  after selected node
404                            p->first=p->sel_ds;
405                      else {                      else {
406                          tmp=p->sel_ds->index - dstmp->index - p->columns*(p->height - 2) + 1;                          tmp=p->sel_ds->index - dstmp->index - p->columns*(p->height - 2) + 1;
407                          if (tmp>0) while ((dstmp->next!=NULL) && tmp--) dstmp=dstmp->next;                          if (tmp>0) while ((dstmp->next!=NULL) && tmp--) dstmp=dstmp->next;
408                          p->first=dstmp;                          p->first=dstmp;
409                      }                      }
410              }              }
411              dirFree(p->dir);              
412              p->dir=ds;              p->sel_size=0;
413              getcwd(workdir[opanel_nr],PATH_MAX);              p->sel_count=0;
414  /*          fprintf(stderr,"REREAD: %s refreshed\n",workdir[opanel_nr]); */              if (! p->virtual_dir) {
415                    dirFree(p->dir);
416                    p->dir=ds;
417                    getcwd(workdir[opanel_nr],PATH_MAX);
418                } else {
419                    ds=p->dir;
420                    while (ds!=NULL) {
421                        if (ds->selected) {
422                            p->sel_size+=ds->size;
423                            p->sel_count++;
424                        }
425                        ds=ds->next;
426                    }
427                }
428          } else return 1;          } else return 1;
429      }      }
430            
# Line 355  int opanelRefresh(OPANEL *p) Line 443  int opanelRefresh(OPANEL *p)
443      if (tstr==NULL) return 2;      if (tstr==NULL) return 2;
444      wmove(p->win,y,x);      wmove(p->win,y,x);
445      ds=p->first;      ds=p->first;
446      /* selcount=selsize=0; */      //selcount=selsize=0;
447    
448      tmp=0;      tmp=0;
449    
# Line 408  int opanelRefresh(OPANEL *p) Line 496  int opanelRefresh(OPANEL *p)
496                    
497          /* write out the prefix and the filename */          /* write out the prefix and the filename */
498    
499          t=colw-2;   /* maximum name length */          t=colw-2;   //maximum name length
500          if ((tsize=strlen(ds->name))<=t) sprintf(tstr,"%-*.*s",t,t,ds->name);          if ((tsize=strlen(ds->name))<=t) sprintf(tstr,"%-*.*s",t,t,ds->name);
501          else {          else {
502              t/=2;              t/=2;
# Line 416  int opanelRefresh(OPANEL *p) Line 504  int opanelRefresh(OPANEL *p)
504          }          }
505          mvwprintw(p->win,y,x,"%c%.*s",prefix,colw-2,tstr);          mvwprintw(p->win,y,x,"%c%.*s",prefix,colw-2,tstr);
506    
507          y++;    /* next row */          y++;    //next row
508          if (y>p->height-2) {    /* if need to jump to next column */          if (y>p->height-2) {    //if need to jump to next column
509              y=1;              y=1;
510              x+=colw;              x+=colw;
511              wmove(p->win,y,x);              wmove(p->win,y,x);
512          }          }
513          ds=ds->next;            /* next node */          ds=ds->next;            //next node
514      }        }  
515      ds=p->first->first;         /* get first node */      ds=p->first->first;         //get first node
516      xfree(tstr);      xfree(tstr);
517    
518          /* arrow */          /* arrow */
519    
520      wattrset(p->win,COLOR_PAIR(col));      wattrset(p->win,COLOR_PAIR(col));
521      t=ds->dir_count+ds->files_count;      t=ds->dir_count+ds->files_count;
522      if ((p->first->index+p->columns*(p->height-2))<t)      if ((p->first->index-1+p->columns*(p->height-2))<t)
523          mvwprintw(p->win,p->height-1,p->width-2,"=>");          mvwprintw(p->win,p->height-1,p->width-2,"=>");
524    
525      wrefresh(p->win);      wrefresh(p->win);
# Line 445  int opanelRefresh(OPANEL *p) Line 533  int opanelRefresh(OPANEL *p)
533    
534  int cursesInit()  int cursesInit()
535  {  {
536  /*      ofm_term=newterm(NULL,stdout,stdin);  //      ofm_term=newterm(NULL,stdout,stdin);
537   *      if (ofm_term==NULL) printf("Couldn't initialize!");  //      if (ofm_term==NULL) printf("Couldn't initialize!");
538   *      set_term(ofm_term);      //      set_term(ofm_term);    
539   */  
540          initscr();          initscr();
541          start_color();          start_color();
542                    
# Line 511  int cursesInit() Line 599  int cursesInit()
599          /* char/block file (non-active) */          /* char/block file (non-active) */
600                    
601          init_pair(14,COLOR_MAGENTA,COLOR_BLACK);          init_pair(14,COLOR_MAGENTA,COLOR_BLACK);
602  /*      init_pair(15,COLOR_BLACK,COLOR_BLUE); */  //      init_pair(15,COLOR_BLACK,COLOR_BLUE);
603          init_pair(15,COLOR_YELLOW,COLOR_WHITE);          init_pair(15,COLOR_YELLOW,COLOR_WHITE);
604                    
605                    
# Line 527  void cursesDestroy() Line 615  void cursesDestroy()
615          clear();          clear();
616          refresh();          refresh();
617          endwin();          endwin();
618  /*      delscreen(ofm_term);   */  //      delscreen(ofm_term);  
619  }  }
620    
621  /* ***** ***** ***** */  /* ***** ***** ***** */
# Line 556  int writeinfo(int mode)  { Line 644  int writeinfo(int mode)  {
644          /* write out the current path */          /* write out the current path */
645          wattrset(down_info,COLOR_PAIR(0)|A_BOLD);          wattrset(down_info,COLOR_PAIR(0)|A_BOLD);
646          wmove(down_info,1,1);wclrtoeol(down_info);          wmove(down_info,1,1);wclrtoeol(down_info);
647          wprintw(down_info,"%s",workdir[opanelActive]);          if (opanelActive==bookmark_is_active-1)
648          t=strlen(workdir[opanelActive]);              wprintw(down_info,"Bookmarks' directory (%s)",tmp->sel_ds->path);
649          if (t!=1) {          else {
650              wprintw(down_info,"/");              wprintw(down_info,"%s",workdir[opanelActive]);
651              t++;              t=strlen(workdir[opanelActive]);
652          }              if (t!=1) {
653          wattron(down_info,A_REVERSE);                  wprintw(down_info,"/");
654          if (cmd_size>0) {                  t++;
655              t+=cmd_size+2;              }
656              if (t<COLS)              wattron(down_info,A_REVERSE);
657                  wprintw(down_info,"%s",cmd_buffer);              if (cmd_size>0) {
658              else                  t+=cmd_size+2;
659                  wprintw(down_info,"%s",cmd_buffer+(t-COLS));                  if (t<COLS)
660                        wprintw(down_info,"%s",cmd_buffer);
661                    else
662                        wprintw(down_info,"%s",cmd_buffer+(t-COLS));
663                }
664                wattroff(down_info,A_REVERSE);
665          }          }
         wattroff(down_info,A_REVERSE);  
666    
667          wattrset(down_info,COLOR_PAIR(0));          wattrset(down_info,COLOR_PAIR(0));
668          wmove(down_info,0,1);wclrtoeol(down_info);          wmove(down_info,0,1);wclrtoeol(down_info);
# Line 582  int writeinfo(int mode)  { Line 674  int writeinfo(int mode)  {
674          if (tmp->sel_count>0) wprintw(down_info,"%d%s in %d directory node%c",tsize,xb[t],tmp->sel_count,(tmp->sel_count>1) ? 's':' ');          if (tmp->sel_count>0) wprintw(down_info,"%d%s in %d directory node%c",tsize,xb[t],tmp->sel_count,(tmp->sel_count>1) ? 's':' ');
675          else if ((! tmp->sel_ds->corrupt)&&(! tmp->sel_ds->link)){          else if ((! tmp->sel_ds->corrupt)&&(! tmp->sel_ds->link)){
676              t=tmp->sel_ds->mode;              t=tmp->sel_ds->mode;
677              wprintw(down_info,"%c%c%c%c%c%c%c%c%c%c (%o)",\              wprintw(down_info,"%c%c%c%c%c%c%c%c%c%c (%.6o)\t%s",\
678                  ((t&S_IFBLK)==S_IFBLK) ? 'b': (((t&S_IFCHR)==S_IFCHR) ? 'c': (((t&S_IFDIR)==S_IFDIR) ? 'd': (((t&S_IFIFO)==S_IFIFO) ? 'p':'-'))),\                  ((t&S_IFBLK)==S_IFBLK) ? 'b': (((t&S_IFCHR)==S_IFCHR) ? 'c': (((t&S_IFDIR)==S_IFDIR) ? 'd': (((t&S_IFIFO)==S_IFIFO) ? 'p':'-'))),\
679                  ((t&S_IRUSR)==S_IRUSR) ? 'r':'-',\                  ((t&S_IRUSR)==S_IRUSR) ? 'r':'-',\
680                  ((t&S_IWUSR)==S_IWUSR) ? 'w':'-',\                  ((t&S_IWUSR)==S_IWUSR) ? 'w':'-',\
# Line 593  int writeinfo(int mode)  { Line 685  int writeinfo(int mode)  {
685                  ((t&S_IROTH)==S_IROTH) ? 'r':'-',\                  ((t&S_IROTH)==S_IROTH) ? 'r':'-',\
686                  ((t&S_IWOTH)==S_IWOTH) ? 'w':'-',\                  ((t&S_IWOTH)==S_IWOTH) ? 'w':'-',\
687                  ((t&S_IXOTH)==S_IXOTH) ? 'x':'-',\                  ((t&S_IXOTH)==S_IXOTH) ? 'x':'-',\
688                  tmp->sel_ds->mode&0xffff);                  tmp->sel_ds->mode&0xffff,ctime(&(tmp->sel_ds->mtime)));
689          }          }
690                                    
691          /* write out the filename and the filesize */          /* write out the filename and the filesize */
# Line 642  int ODelete() Line 734  int ODelete()
734  {  {
735      OPANEL      *tmp=opanels[opanelActive];      OPANEL      *tmp=opanels[opanelActive];
736      int         result=0;      int         result=0;
737        char        *wd;
738            
739      if (tmp->sel_ds->index>1 || tmp->sel_count>0) {      if (strcmp(tmp->sel_ds->name,"..") || tmp->sel_count>0) {
740          if (dlgMessageBox(B_YES|B_NO,NULL,"Delete","Are You Sure?")==B_YES) {          if (dlgMessageBox(B_YES|B_NO,NULL,"Delete","Are You Sure?")==B_YES) {
741                if (tmp->sel_ds->path!=NULL) wd=tmp->sel_ds->path;
742                else wd=workdir[opanelActive];
743              dlgDelete(tmp);              dlgDelete(tmp);
744              tmp->reread=1;              tmp->reread=1;
745              if (strcmp(workdir[0],workdir[1])==0) {              if (strcmp(wd,workdir[! opanelActive])==0) {
746                  opanels[! opanelActive]->reread=1;                  opanels[! opanelActive]->reread=1;
747              }                            }              
748          }          }
# Line 663  int OCopy() Line 758  int OCopy()
758      int         result=0;      int         result=0;
759      char        buff[PATH_MAX+1];      char        buff[PATH_MAX+1];
760            
761      if (tmp->sel_ds->index>1 || tmp->sel_count) {      if (strcmp(tmp->sel_ds->name,"..") || tmp->sel_count) {
762          sprintf(buff,"%s/",workdir[! opanelActive]);          sprintf(buff,"%s/",workdir[! opanelActive]);
763          if (dlgMessageBox(B_OK|B_CANCEL,buff,"CopyTo","Destination:")==B_OK){          if (dlgMessageBox(B_OK|B_CANCEL,buff,"CopyTo","Destination:")==B_OK){
764              dlgCopy(tmp,buff);              dlgCopy(tmp,buff);
765              tmp->reread=1;      /* have to check it */              tmp->reread=1;      //have to check it
766              opanels[! opanelActive]->reread=1;              opanels[! opanelActive]->reread=1;
767          }          }
768          result=1;;                result=1;;      
# Line 682  int ORename() Line 777  int ORename()
777      int         result=0;      int         result=0;
778      char        buff[PATH_MAX+1];      char        buff[PATH_MAX+1];
779      int         itmp;      int         itmp;
780        char        *wd;
781    
782      if (tmp->sel_ds->index>1) {      if (strcmp(tmp->sel_ds->name,"..")) {
783          result=1;          result=1;
784          if (strlen(workdir[opanelActive])==1)   /* if root dir */          if (tmp->sel_ds->path!=NULL) wd=tmp->sel_ds->path;
785            else wd=workdir[opanelActive];
786            if (strlen(wd)==1)      //if root dir  
787              sprintf(buff,"/%s",tmp->sel_ds->name);              sprintf(buff,"/%s",tmp->sel_ds->name);
788          else          else
789              sprintf(buff,"%s/%s",workdir[opanelActive],tmp->sel_ds->name);              sprintf(buff,"%s/%s",wd,tmp->sel_ds->name);
790          if (dlgMessageBox(B_OK|B_CANCEL,buff,"Rename","New Name:")==B_OK){          if (dlgMessageBox(B_OK|B_CANCEL,buff,"Rename","New Name:")==B_OK){
791                  itmp=rename(tmp->sel_ds->name,buff);                  itmp=rename(tmp->sel_ds->name,buff);
792                  if (itmp) dlgMessageBox(B_OK,NULL,"Error",strerror(errno));                  if (itmp) dlgMessageBox(B_OK,NULL,"Error",strerror(errno));
793                  /* we should really check this! rename could be into another directory -                  /* we should really check this! rename could be into another directory -
794                     FIXME */                     FIXME */
795                  tmp->reread=1;                  tmp->reread=1;
796                  if (strcmp(workdir[0],workdir[1])==0) opanels[! opanelActive]->reread=1;                  if (strcmp(wd,workdir[! opanelActive])==0) opanels[! opanelActive]->reread=1;
797          }          }
798      }      }
799      return result;      return result;
# Line 738  int keyReact(int i) Line 836  int keyReact(int i)
836            
837      tmp=opanels[opanelActive];      tmp=opanels[opanelActive];
838            
839      if (i==KEY_F(9)) {                  /* MENU PULL DOWN */      if (i==KEY_F(9)) {                  //MENU PULL DOWN
840          menuPost(ofm_menu[activem]);          menuPost(ofm_menu[activem]);
841          box(ofm_menu[activem]->win,0,0);          box(ofm_menu[activem]->win,0,0);
842          menuBarRefresh(activem);          menuBarRefresh(activem);
# Line 748  int keyReact(int i) Line 846  int keyReact(int i)
846              if (i==KEY_RIGHT) {              if (i==KEY_RIGHT) {
847                  menuUnpost(ofm_menu[activem]);                  menuUnpost(ofm_menu[activem]);
848                  viewportRefresh();                  viewportRefresh();
849                  activem=(activem+1)%2;          /* choose next menu */                  activem=(activem+1)%2;          //choose next menu
850                  menuPost(ofm_menu[activem]);                  menuPost(ofm_menu[activem]);
851                  box(ofm_menu[activem]->win,0,0);                  box(ofm_menu[activem]->win,0,0);
852                  menuBarRefresh(activem);                  menuBarRefresh(activem);
# Line 756  int keyReact(int i) Line 854  int keyReact(int i)
854              } else if (i==KEY_LEFT) {              } else if (i==KEY_LEFT) {
855                  menuUnpost(ofm_menu[activem]);                  menuUnpost(ofm_menu[activem]);
856                  viewportRefresh();                  viewportRefresh();
857                  activem=(activem+2+1)%2;        /* choose previous menu */                  activem=(activem+2+1)%2;        //choose previous menu
858                  menuPost(ofm_menu[activem]);                  menuPost(ofm_menu[activem]);
859                  box(ofm_menu[activem]->win,0,0);                  box(ofm_menu[activem]->win,0,0);
860                  menuBarRefresh(activem);                  menuBarRefresh(activem);
# Line 806  int keyReact(int i) Line 904  int keyReact(int i)
904      }      }
905    
906      else if (i=='\n') {      else if (i=='\n') {
907          if (cmd_size>0) {  /* if there is some command to execute */          if (cmd_size>0) {  //if there is some command to execute
908              erase();              erase();
909              refresh();              refresh();
910              def_prog_mode();              def_prog_mode();
# Line 820  int keyReact(int i) Line 918  int keyReact(int i)
918              viewportRefresh();              viewportRefresh();
919              curs_set(0);              curs_set(0);
920          } else          } else
921          if (tmp->sel_ds->dir){  /* if we want to change dir */          if (tmp->sel_ds->dir){  //if we want to change dir
922              if ( strcmp(workdir[opanelActive],"/") || strcmp(tmp->sel_ds->name,"..") ){              if ( strcmp(workdir[opanelActive],"/") || strcmp(tmp->sel_ds->name,"..") ){
923                  itmp=chdir(tmp->sel_ds->name);                  itmp=0;
924                    if (tmp->virtual_dir && tmp->sel_ds->path!=NULL) {
925                        itmp=chdir(tmp->sel_ds->path);
926                    }
927                    itmp+=chdir(tmp->sel_ds->name);
928                  if (itmp) {                  if (itmp) {
929                      dlgMessageBox(B_OK,NULL,"Error",strerror(errno));                      dlgMessageBox(B_OK,NULL,"Error",strerror(errno));
930                      opanelRefresh(opanels[! opanelActive]);                      opanelRefresh(opanels[! opanelActive]);
931                  }                  }
932                  else {  /* if we changed dir */                  else {  //if we changed dir
933                      if (tmp->sel_name!=NULL) xfree(tmp->sel_name);                      if (tmp->sel_name!=NULL) xfree(tmp->sel_name);
934                      tmp->sel_name=NULL;                      tmp->sel_name=NULL;
935                      if (strcmp(tmp->sel_ds->name,"..")) /* if we're going down in dir tree */                      if (strcmp(tmp->sel_ds->name,"..")) //if we're going down in dir tree
936                          stackPush(stack[opanelActive],tmp->sel_ds->name);                          stackPush(stack[opanelActive],tmp->sel_ds->name);
937                      else tmp->sel_name=stackPop(stack[opanelActive]);                      else tmp->sel_name=stackPop(stack[opanelActive]);
938    
939                          /* resets the stack, if link */                          /* resets the stack, if link */
940                                                    
941                      if (tmp->sel_ds->link) {                      if (tmp->sel_ds->link || tmp->virtual_dir) {
942                          tmpch=NULL;                          tmpch=NULL;
943                          while ((tmpch=stackPop(stack[opanelActive]))!=NULL) xfree(tmpch);                          while ((tmpch=stackPop(stack[opanelActive]))!=NULL) xfree(tmpch);
944                      }                      }
945                        if (tmp->virtual_dir) bookmarkRestoreState(tmp);
946                      getcwd(workdir[opanelActive],PATH_MAX);                      getcwd(workdir[opanelActive],PATH_MAX);
947                      tmp->sel_ds=NULL;                      tmp->sel_ds=NULL;
948                      tmp->first=NULL;                      tmp->first=NULL;
# Line 1011  int keyReact(int i) Line 1114  int keyReact(int i)
1114          viewportRefresh();          viewportRefresh();
1115          curs_set(0);          curs_set(0);
1116      }      }
1117        else if (i==CTRL('b') && Bookmarks!=NULL) {
1118            if (bookmark_is_active) {
1119                if (bookmark_is_active-1==opanelActive) {
1120                    bookmarkRestoreState(tmp);
1121                    tmp->reread=1;
1122                }
1123            } else {
1124                bookmark_is_active=opanelActive+1;
1125                bookmarkSaveState(tmp);
1126                tmp->reread=1;
1127            }
1128            opanelRefresh(tmp);
1129        }
1130        else if (i==CTRL('a')) {
1131            if (opanelActive+1!=bookmark_is_active) {
1132                bookmarkInsert(tmp->sel_ds);
1133                if (bookmark_is_active) {
1134                    opanels[bookmark_is_active-1]->reread=1;
1135                    opanelRefresh(opanels[bookmark_is_active-1]);
1136                }
1137            }
1138        }
1139      else if (isascii(i)) {      else if (isascii(i)) {
1140          if (cmd_size<sizeof(cmd_buffer)) {          if (cmd_size<sizeof(cmd_buffer)) {
1141              cmd_buffer[cmd_size++]=(char)i;              cmd_buffer[cmd_size++]=(char)i;
1142              writeinfo(2); /* refresh bottom info */              writeinfo(2); //refresh bottom info
1143          }              }    
1144      }      }
1145      else if (i==KEY_BACKSPACE && cmd_size>0) {      else if (i==KEY_BACKSPACE && cmd_size>0) {

Legend:
Removed from v.1.8  
changed lines
  Added in v.1.9

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26