Commit 893549e7 authored by deuce's avatar deuce
Browse files

Fix numerous minor issues with showbuf(), remove debug output from ulist()

Enable mouse during uifcini32.
parent 930e76a8
OBJS = $(OBJODIR)$(DIRSEP)uifcx$(OFILE)
MT_OBJS = $(MTOBJODIR)$(DIRSEP)uifc32$(OFILE) \
$(MTOBJODIR)$(DIRSEP)filepick$(OFILE) \
$(MTOBJODIR)$(DIRSEP)uifcx$(OFILE)
......@@ -158,7 +158,7 @@ int uifcini32(uifcapi_t* uifcapi)
api=uifcapi;
/* install function handlers */
/* install function handlers */
api->bail=uifcbail;
api->scrn=uscrn;
api->msg=umsg;
......@@ -283,8 +283,10 @@ int uifcini32(uifcapi_t* uifcapi)
cursor=_NOCURSOR;
_setcursortype(cursor);
if(cio_api.mouse)
if(cio_api.mouse) {
api->mode|=UIFC_MOUSE;
uifc_mouse_enable();
}
return(0);
}
......@@ -537,8 +539,6 @@ int ulist(int mode, int left, int top, int width, int *cur, int *bar
opts++;
height=opts+hbrdrsize+2;
if(mode&WIN_FIXEDHEIGHT) {
gotoxy(30,1);
cprintf("Height is: %d",api->list_height);
height=api->list_height;
}
if(top+height>s_bottom)
......@@ -2246,9 +2246,11 @@ void showbuf(int mode, int left, int top, int width, int height, char *title, ch
tmp_buffer2[i]=(hclr|(bclr<<4));
tmp_buffer2[0]='';
j=title_len;
if(j>width-6)
if(j>width-6) {
*(title+width-6)=0;
for(i=2;i<((width-6)/2-(j/2))*2;i+=2)
j=width-6;
}
for(i=2;i<(width-j);i+=2)
tmp_buffer2[i]='';
if(api->mode&UIFC_MOUSE && !mode&WIN_DYN) {
tmp_buffer2[2]='[';
......@@ -2304,7 +2306,7 @@ void showbuf(int mode, int left, int top, int width, int height, char *title, ch
tmp_buffer2[k]=''; k+=2;
for(j=k;j<k+(((width-4)/2-12)*2);j+=2)
tmp_buffer2[j]='';
}
}
else {
for(k=j;k<j+((width-2)*2);k+=2)
tmp_buffer2[k]='';
......@@ -2344,7 +2346,7 @@ void showbuf(int mode, int left, int top, int width, int height, char *title, ch
for(j=i;j<len;j++,i+=2) {
if(hbuf[j]==LF) {
i+=2;
while(i%((width-2-pad-pad)*2)) i++; i-=2;
while(i%((width-2-pad-pad)*2)) i++; i-=2;
}
else if(mode&WIN_HLP && (hbuf[j]==2 || hbuf[j]=='~')) { /* Ctrl-b toggles inverse */
inverse=!inverse;
......@@ -2357,7 +2359,9 @@ void showbuf(int mode, int left, int top, int width, int height, char *title, ch
else if(hbuf[j]!=CR) {
textbuf[i]=hbuf[j];
textbuf[i+1]=inverse ? (bclr|(cclr<<4))
: high ? (hclr|(bclr<<4)) : (lclr|(bclr<<4));
: high ? (hclr|(bclr<<4)) : (lclr|(bclr<<4));
if((i+2)%((width-2-pad-pad)*2)==0 && (hbuf[j+1]==LF) || (hbuf[j+1]==CR && hbuf[j+1]==LF))
i-=2;
}
}
i=0;
......@@ -2368,8 +2372,8 @@ void showbuf(int mode, int left, int top, int width, int height, char *title, ch
else {
while(i==0) {
if(p!=oldp) {
if(p > textbuf+(lines-(height-2-pad-pad))*(width-4)*2)
p=textbuf+(lines-(height-2-pad-pad))*(width-4)*2;
if(p > textbuf+(lines-(height-2-pad-pad))*(width-2-pad-pad)*2)
p=textbuf+(lines-(height-2-pad-pad))*(width-2-pad-pad)*2;
if(p<textbuf)
p=textbuf;
if(p!=oldp) {
......@@ -2388,7 +2392,7 @@ void showbuf(int mode, int left, int top, int width, int height, char *title, ch
&& mevnt.starty>=top+pad+1
&& mevnt.starty<=top+pad+(height/2)-2
&& mevnt.event==CIOLIB_BUTTON_1_CLICK) {
p = p-((width-4)*2*(height-5));
p = p-((width-2-pad-pad)*2*(height-5));
continue;
}
/* Clicked Scroll Down */
......@@ -2397,7 +2401,7 @@ void showbuf(int mode, int left, int top, int width, int height, char *title, ch
&& mevnt.starty<=top+pad+height-2
&& mevnt.starty>=top+pad+height-(height/2+1)-2
&& mevnt.event==CIOLIB_BUTTON_1_CLICK) {
p=p+(width-4)*2*(height-5);
p=p+(width-2-pad-pad)*2*(height-5);
continue;
}
i=1;
......@@ -2410,23 +2414,23 @@ void showbuf(int mode, int left, int top, int width, int height, char *title, ch
break;
case CIO_KEY_UP: /* up arrow */
p = p-((width-4)*2);
p = p-((width-2-pad-pad)*2);
break;
case CIO_KEY_PPAGE: /* PgUp */
p = p-((width-4)*2*(height-5));
p = p-((width-2-pad-pad)*2*(height-5));
break;
case CIO_KEY_NPAGE: /* PgDn */
p=p+(width-4)*2*(height-5);
p=p+(width-2-pad-pad)*2*(height-5);
break;
case CIO_KEY_END: /* end */
p=textbuf+(lines-height+1)*(width-4)*2;
p=textbuf+(lines-height+1)*(width-2-pad-pad)*2;
break;
case CIO_KEY_DOWN: /* dn arrow */
p = p+((width-4)*2);
p = p+((width-2-pad-pad)*2);
break;
default:
......
......@@ -38,6 +38,7 @@
#include <signal.h>
#include <stdio.h>
/* #include "curs_fix.h" */
#include "filepick.h"
#include "uifc.h"
/********************/
......@@ -61,6 +62,7 @@ int main(int argc, char** argv) {
int last;
int edtuser=0;
char longtitle[1024];
struct file_pick fper;
/******************/
/* Ini file stuff */
/******************/
......@@ -138,7 +140,8 @@ int main(int argc, char** argv) {
strcpy(mopt[0],"Long Title");
strcpy(mopt[1],"String Input");
mopt[2][0]=0;
strcpy(mopt[2],"File picker");
mopt[3][0]=0;
uifc.helpbuf= "`Test Suite:`\n"
"\nToDo: Add Help";
......@@ -167,8 +170,12 @@ int main(int argc, char** argv) {
if(j==1) {
/* String input */
strcpy(longtitle,"This is a test if string input... enter/edit this field");
uifc.input(WIN_MID,0,0,"Input",longtitle,sizeof(longtitle),K_EDIT);
uifc.input(WIN_MID|WIN_NOBRDR,0,0,"Input",longtitle,sizeof(longtitle),K_EDIT);
uifc.showbuf(WIN_MID, 0, 0, uifc.scrn_width-4, uifc.scrn_len-4, "Result:", longtitle, NULL, NULL);
}
if(j==2) {
/* File picker */
filepick(&uifc, "Bob", &fper, NULL, NULL, 0);
}
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment