|
|
1.1 ! root 1: /* uedit.c */ ! 2: ! 3: /* Synchronet for *nix user editor */ ! 4: ! 5: /* $Id: uifctest.c,v 1.7 2005/06/04 01:54:48 deuce Exp $ */ ! 6: ! 7: /**************************************************************************** ! 8: * @format.tab-size 4 (Plain Text/Source Code File Header) * ! 9: * @format.use-tabs true (see http://www.synchro.net/ptsc_hdr.html) * ! 10: * * ! 11: * Copyright 2003 Rob Swindell - http://www.synchro.net/copyright.html * ! 12: * * ! 13: * This program is free software; you can redistribute it and/or * ! 14: * modify it under the terms of the GNU General Public License * ! 15: * as published by the Free Software Foundation; either version 2 * ! 16: * of the License, or (at your option) any later version. * ! 17: * See the GNU General Public License for more details: gpl.txt or * ! 18: * http://www.fsf.org/copyleft/gpl.html * ! 19: * * ! 20: * Anonymous FTP access to the most recent released source is available at * ! 21: * ftp://vert.synchro.net, ftp://cvs.synchro.net and ftp://ftp.synchro.net * ! 22: * * ! 23: * Anonymous CVS access to the development source and modification history * ! 24: * is available at cvs.synchro.net:/cvsroot/sbbs, example: * ! 25: * cvs -d :pserver:[email protected]:/cvsroot/sbbs login * ! 26: * (just hit return, no password is necessary) * ! 27: * cvs -d :pserver:[email protected]:/cvsroot/sbbs checkout src * ! 28: * * ! 29: * For Synchronet coding style and modification guidelines, see * ! 30: * http://www.synchro.net/source.html * ! 31: * * ! 32: * You are encouraged to submit any modifications (preferably in Unix diff * ! 33: * format) via e-mail to [email protected] * ! 34: * * ! 35: * Note: If this box doesn't appear square, then you need to fix your tabs. * ! 36: ****************************************************************************/ ! 37: ! 38: #include <signal.h> ! 39: #include <stdio.h> ! 40: /* #include "curs_fix.h" */ ! 41: #include "filepick.h" ! 42: #include "uifc.h" ! 43: ! 44: /********************/ ! 45: /* Global Variables */ ! 46: /********************/ ! 47: uifcapi_t uifc; /* User Interface (UIFC) Library API */ ! 48: char YesStr[]="Yes"; ! 49: char NoStr[]="No"; ! 50: char *ok[2]={"OK",""}; ! 51: ! 52: int main(int argc, char** argv) { ! 53: char** opt; ! 54: char** mopt; ! 55: int main_dflt=0; ! 56: int main_bar=0; ! 57: char revision[16]; ! 58: char str[256],ctrl_dir[41],*p; ! 59: char title[256]; ! 60: int i,j; ! 61: int done; ! 62: int last; ! 63: int edtuser=0; ! 64: char longtitle[1024]; ! 65: struct file_pick fper; ! 66: /******************/ ! 67: /* Ini file stuff */ ! 68: /******************/ ! 69: char ini_file[MAX_PATH+1]; ! 70: FILE* fp; ! 71: ! 72: sscanf("$Revision: 1.7 $", "%*s %s", revision); ! 73: ! 74: printf("\nSynchronet UIFC Test Suite Copyright 2004 " ! 75: "Rob Swindell\n"); ! 76: ! 77: memset(&uifc,0,sizeof(uifc)); ! 78: ! 79: uifc.esc_delay=500; ! 80: ! 81: for(i=1;i<argc;i++) { ! 82: if(argv[i][0]=='-') ! 83: switch(toupper(argv[i][1])) { ! 84: case 'C': ! 85: uifc.mode|=UIFC_COLOR; ! 86: break; ! 87: case 'L': ! 88: uifc.scrn_len=atoi(argv[i]+2); ! 89: break; ! 90: case 'E': ! 91: uifc.esc_delay=atoi(argv[i]+2); ! 92: break; ! 93: case 'I': ! 94: /* Set up ex-ascii codes */ ! 95: uifc.mode|=UIFC_IBM; ! 96: break; ! 97: default: ! 98: printf("\nusage: %s [ctrl_dir] [options]" ! 99: "\n\noptions:\n\n" ! 100: "-c = force color mode\n" ! 101: "-e# = set escape delay to #msec\n" ! 102: "-i = force IBM charset\n" ! 103: "-l# = set screen lines to #\n" ! 104: ,argv[0] ! 105: ); ! 106: exit(0); ! 107: } ! 108: if(atoi(argv[i])) ! 109: edtuser=atoi(argv[i]); ! 110: } ! 111: ! 112: #ifdef __unix__ ! 113: signal(SIGPIPE, SIG_IGN); ! 114: #endif ! 115: ! 116: uifc.size=sizeof(uifc); ! 117: #ifdef USE_CURSES ! 118: i=uifcinic(&uifc); /* curses */ ! 119: #else ! 120: i=uifcini32(&uifc); /* curses */ ! 121: #endif ! 122: if(i!=0) { ! 123: printf("uifc library init returned error %d\n",i); ! 124: exit(1); ! 125: } ! 126: ! 127: opt=(char **)malloc(sizeof(char *)*(MAX_OPTS+1)); ! 128: for(i=0;i<(MAX_OPTS+1);i++) ! 129: opt[i]=(char *)malloc(MAX_OPLN); ! 130: ! 131: mopt=(char **)malloc(sizeof(char *)*MAX_OPTS); ! 132: for(i=0;i<MAX_OPTS;i++) ! 133: mopt[i]=(char *)malloc(MAX_OPLN); ! 134: ! 135: sprintf(title,"Synchronet Test Suite"); ! 136: if(uifc.scrn(title)) { ! 137: printf(" USCRN (len=%d) failed!\n",uifc.scrn_len+1); ! 138: return(1); ! 139: } ! 140: ! 141: strcpy(mopt[0],"Long Title"); ! 142: strcpy(mopt[1],"String Input"); ! 143: strcpy(mopt[2],"File picker"); ! 144: mopt[3][0]=0; ! 145: ! 146: uifc.helpbuf= "`Test Suite:`\n" ! 147: "\nToDo: Add Help"; ! 148: ! 149: while(1) { ! 150: j=uifc.list(WIN_L2R|WIN_ESC|WIN_ACT|WIN_DYN|WIN_ORG,0,5,70,&main_dflt,&main_bar ! 151: ,title,mopt); ! 152: ! 153: if(j <= -2) ! 154: continue; ! 155: ! 156: if(j==-1) { ! 157: uifc.bail(); ! 158: return(0); ! 159: } ! 160: ! 161: if(j==0) { ! 162: /* Long Title */ ! 163: strcpy(longtitle,"This is a long title..."); ! 164: for(p=strchr(longtitle,0);p<longtitle+sizeof(longtitle)-1;p++) ! 165: *p='.'; ! 166: *p=0; ! 167: done=0; ! 168: uifc.list(WIN_ORG|WIN_MID|WIN_ACT,0,0,0,&i,0,longtitle,ok); ! 169: } ! 170: if(j==1) { ! 171: /* String input */ ! 172: strcpy(longtitle,"This is a test if string input... enter/edit this field"); ! 173: uifc.input(WIN_MID|WIN_NOBRDR,0,0,"Input",longtitle,sizeof(longtitle),K_EDIT); ! 174: uifc.showbuf(WIN_MID, 0, 0, uifc.scrn_width-4, uifc.scrn_len-4, "Result:", longtitle, NULL, NULL); ! 175: } ! 176: if(j==2) { ! 177: /* File picker */ ! 178: if(filepick(&uifc, "Bob", &fper, NULL, NULL, UIFC_FP_ALLOWENTRY)!=-1) { ! 179: if(fper.files==1) { ! 180: sprintf(str,"File selected: %-.200s",fper.selected[0]); ! 181: uifc.msg(str); ! 182: } ! 183: filepick_free(&fper); ! 184: } ! 185: } ! 186: } ! 187: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.