diff --git a/src/uifc/filepick.c b/src/uifc/filepick.c index dfd1f2a648c7dfc7f78736e5c3455105532d893b..091439e624216496f28a47c534ec6f3340fe6257 100644 --- a/src/uifc/filepick.c +++ b/src/uifc/filepick.c @@ -205,9 +205,11 @@ void display_current_path(uifcapi_t *api, char *path) api->printf(SCRN_LEFT+2, SCRN_TOP+height-2, api->lclr|(api->bclr<<4), "%-*s", width, dpath); } -int mousetofield(int currfield, int opts, int height, int width, int listheight, int listwidth) +int mousetofield(int currfield, int opts, int height, int width, int listheight, int listwidth, int *dcur, int *dbar, int *fcur, int *fbar) { int newfield; + int nbar; + int bardif; struct mouse_event mevnt; newfield=currfield; @@ -217,27 +219,41 @@ int mousetofield(int currfield, int opts, int height, int width, int listheight, && mevnt.endy >= SCRN_TOP + 3 && mevnt.endy <= SCRN_TOP + 2 + listheight) { newfield = DIR_LIST; + if(mevnt.endx == SCRN_LEFT + 1) + ungetmouse(&mevnt); + else { + bardif = (mevnt.starty - SCRN_TOP - 3) - *dbar; + *dbar += bardif; + *dcur += bardif; + } } if(mevnt.endx >= SCRN_LEFT + 1 + listwidth + 1 && mevnt.endx <= SCRN_LEFT + 1 + listwidth * 2 && mevnt.endy >= SCRN_TOP + 3 && mevnt.endy <= SCRN_TOP + 2 + listheight) { newfield = FILE_LIST; + if(mevnt.endx == SCRN_LEFT + 1 + listwidth + 1) + ungetmouse(&mevnt); + else { + bardif = (mevnt.starty - SCRN_TOP - 3) - *fbar; + *fbar += bardif; + *fcur += bardif; + } } if(!(opts & UIFC_FP_MSKNOCHG) && (mevnt.endx >= SCRN_LEFT + 1 && mevnt.endx <= SCRN_LEFT + width - 2 && mevnt.endy == SCRN_TOP + height - 3)) { newfield = MASK_FIELD; + ungetmouse(&mevnt); } if(opts & UIFC_FP_ALLOWENTRY && mevnt.endx >= SCRN_LEFT + 1 && mevnt.endx <= SCRN_LEFT + width - 2 && mevnt.endy == SCRN_TOP + height - 2) { newfield = CURRENT_PATH; - } - if(newfield != currfield) ungetmouse(&mevnt); + } } return(newfield); } @@ -393,7 +409,7 @@ int filepick(uifcapi_t *api, char *title, struct file_pick *fp, char *dir, char if(i==-3842) /* Backtab */ fieldmove=-1; if(i==-2-CIO_KEY_MOUSE) - currfield=mousetofield(currfield, opts, height, width, api->list_height, listwidth); + currfield=mousetofield(currfield, opts, height, width, api->list_height, listwidth, &dircur, &dirbar, &filecur, &filebar); if(i>=0) { FREE_AND_NULL(lastpath); lastpath=strdup(cpath); @@ -434,7 +450,7 @@ int filepick(uifcapi_t *api, char *title, struct file_pick *fp, char *dir, char if(i==-3842) /* Backtab */ fieldmove=-1; if(i==-2-CIO_KEY_MOUSE) - currfield=mousetofield(currfield, opts, height, width, api->list_height, listwidth); + currfield=mousetofield(currfield, opts, height, width, api->list_height, listwidth, &dircur, &dirbar, &filecur, &filebar); break; case CURRENT_PATH: FREE_AND_NULL(tmplastpath); @@ -457,7 +473,7 @@ int filepick(uifcapi_t *api, char *title, struct file_pick *fp, char *dir, char continue; } if(i==CIO_KEY_MOUSE) - currfield=mousetofield(currfield, opts, height, width, api->list_height, listwidth); + currfield=mousetofield(currfield, opts, height, width, api->list_height, listwidth, &dircur, &dirbar, &filecur, &filebar); if(i==3840) fieldmove=-1; else { @@ -537,7 +553,7 @@ int filepick(uifcapi_t *api, char *title, struct file_pick *fp, char *dir, char p=strdup(cmsk); api->getstrxy(SCRN_LEFT+8, SCRN_TOP+height-3, width-7, cmsk, sizeof(cmsk)-1, K_EDIT|K_TABEXIT|K_MOUSEEXIT, &i); if(i==CIO_KEY_MOUSE) - currfield=mousetofield(currfield, opts, height, width, api->list_height, listwidth); + currfield=mousetofield(currfield, opts, height, width, api->list_height, listwidth, &dircur, &dirbar, &filecur, &filebar); if(i==ESC) { retval=fp->files=0; goto cleanup;