Skip to content
Snippets Groups Projects
Commit 919fae88 authored by deuce's avatar deuce
Browse files

Added helptitle to the UIFC api to set the title for help windows.

umonitor now uses showhelp() to display error log.
parent 6c297c8b
No related branches found
No related tags found
No related merge requests found
CFLAGS += -I../ -I../../xpdev -I../../uifc -DUSE_CURSES -DUSE_SIGNALS CFLAGS += -I../ -I../../xpdev -I../../uifc -DUSE_CURSES -DUSE_SIGNALS -g
LFLAGS += -lcurses LFLAGS += -lcurses
CC ?= gcc CC ?= gcc
LD ?= gcc LD ?= gcc
vpath %.c ../../xpdev ../../uifc vpath %.c ../../xpdev ../../uifc
OBJS := filewrap.o uifcc.o uifcx.o umonitor.o sockwrap.o OBJS := filewrap.o uifcc.o uifcx.o umonitor.o sockwrap.o dirwrap.o genwrap.o
umonitor: $(OBJS) umonitor: $(OBJS)
$(CC) $(LFLAGS) $(OBJS) -o umonitor $(CC) $(LFLAGS) $(OBJS) -o umonitor
......
...@@ -8,8 +8,10 @@ ...@@ -8,8 +8,10 @@
#include "uifc.h" #include "uifc.h"
#include "sbbsdefs.h" #include "sbbsdefs.h"
#include "genwrap.h" /* stricmp */ #include "genwrap.h" /* stricmp */
#include "dirwrap.h" /* lock/unlock/sopen */
#include "filewrap.h" /* lock/unlock/sopen */ #include "filewrap.h" /* lock/unlock/sopen */
#include "sockwrap.h" #include "sockwrap.h"
#include "genwrap.h"
enum { enum {
MODE_LIST MODE_LIST
...@@ -531,12 +533,15 @@ int main(int argc, char** argv) { ...@@ -531,12 +533,15 @@ int main(int argc, char** argv) {
int server=0; int server=0;
char revision[16]; char revision[16];
char str[256],ctrl_dir[41],*p,debug=0; char str[256],ctrl_dir[41],*p,debug=0;
char title[256];
int sys_nodes,node_num=0,onoff=0; int sys_nodes,node_num=0,onoff=0;
int i,j,mode=0,misc; int i,j,mode=0,misc;
int modify=0; int modify=0;
int loop=0; int loop=0;
long value=0; long value=0;
node_t node; node_t node;
char *buf;
int buffile;
sscanf("$Revision$", "%*s %s", revision); sscanf("$Revision$", "%*s %s", revision);
...@@ -619,8 +624,8 @@ int main(int argc, char** argv) { ...@@ -619,8 +624,8 @@ int main(int argc, char** argv) {
if((mopt[i]=(char *)MALLOC(MAX_OPLN))==NULL) if((mopt[i]=(char *)MALLOC(MAX_OPLN))==NULL)
allocfail(MAX_OPLN); allocfail(MAX_OPLN);
sprintf(str,"Synchronet UNIX Monitor %s-%s",revision,PLATFORM_DESC); sprintf(title,"Synchronet UNIX Monitor %s-%s",revision,PLATFORM_DESC);
if(uifc.scrn(str)) { if(uifc.scrn(title)) {
printf(" USCRN (len=%d) failed!\n",uifc.scrn_len+1); printf(" USCRN (len=%d) failed!\n",uifc.scrn_len+1);
bail(1); bail(1);
} }
...@@ -636,8 +641,37 @@ int main(int argc, char** argv) { ...@@ -636,8 +641,37 @@ int main(int argc, char** argv) {
"\nToDo: Add help."; "\nToDo: Add help.";
j=uifc.list(WIN_ORG|WIN_MID|WIN_ESC|WIN_ACT|WIN_DYN,0,0,70,&main_dflt,&main_bar j=uifc.list(WIN_ORG|WIN_MID|WIN_ESC|WIN_ACT|WIN_DYN,0,0,70,&main_dflt,&main_bar
,str,mopt); ,title,mopt);
if(j==-2)
if(j==-7) { /* CTRL-E */
/* ToDo must get the logs dir from the config */
sprintf(str,"%s../data/error.log",ctrl_dir);
if(fexist(str)) {
if((buffile=sopen(str,O_RDONLY,SH_DENYRW))>=0) {
j=filelength(buffile);
if((buf=(char *)MALLOC(j+1))!=NULL) {
read(buffile,buf,j);
close(buffile);
*(buf+j)=0;
uifc.helpbuf=buf;
uifc.helptitle="Error Log";
uifc.showhelp();
uifc.helptitle=NULL;
free(buf);
continue;
}
close(buffile);
continue;
}
uifc.msg("Error reading error log");
}
else {
uifc.msg("Error log does not exist");
}
continue;
}
if(j <= -2)
continue; continue;
if(j==-1) { if(j==-1) {
......
...@@ -351,6 +351,11 @@ typedef struct { ...@@ -351,6 +351,11 @@ typedef struct {
/* Shows the current help text */ /* Shows the current help text */
/****************************************************************************/ /****************************************************************************/
void (*showhelp)(void); void (*showhelp)(void);
/****************************************************************************/
/* Shows help title text */
/****************************************************************************/
char *helptitle;
#endif #endif
} uifcapi_t; } uifcapi_t;
......
...@@ -135,11 +135,18 @@ static void upop(char *str); ...@@ -135,11 +135,18 @@ static void upop(char *str);
static void sethelp(int line, char* file); static void sethelp(int line, char* file);
/* Dynamic menu support */ /* Dynamic menu support */
static int *last_menu_cur; static int *last_menu_cur=NULL;
static int *last_menu_bar; static int *last_menu_bar=NULL;
static int save_menu_cur=-1; static int save_menu_cur=-1;
static int save_menu_bar=-1; static int save_menu_bar=-1;
void reset_dynamic(void) {
*last_menu_cur=NULL;
*last_menu_bar=NULL;
save_menu_cur=-1;
save_menu_bar=-1;
}
int inkey(int mode) int inkey(int mode)
{ {
if(mode) if(mode)
...@@ -175,6 +182,7 @@ int uifcinic(uifcapi_t* uifcapi) ...@@ -175,6 +182,7 @@ int uifcinic(uifcapi_t* uifcapi)
api->sethelp=sethelp; api->sethelp=sethelp;
#ifdef __unix__ #ifdef __unix__
api->showhelp=help; api->showhelp=help;
api->helptitle=NULL;
#endif #endif
#if defined(LOCALE) #if defined(LOCALE)
...@@ -341,6 +349,7 @@ int uscrn(char *str) ...@@ -341,6 +349,7 @@ int uscrn(char *str)
gotoxy(1,api->scrn_len+1); gotoxy(1,api->scrn_len+1);
clrtoeol(); clrtoeol();
refresh(); refresh();
reset_dynamic();
return(0); return(0);
} }
...@@ -1631,6 +1640,7 @@ void upop(char *str) ...@@ -1631,6 +1640,7 @@ void upop(char *str)
char buf[26*3*2]; char buf[26*3*2];
int i,j,k; int i,j,k;
reset_dynamic();
hidemouse(); hidemouse();
if(!str) { if(!str) {
puttext(28,12,53,14,sav); puttext(28,12,53,14,sav);
...@@ -1707,22 +1717,40 @@ void help() ...@@ -1707,22 +1717,40 @@ void help()
for(i=1;i<76*21*2;i+=2) for(i=1;i<76*21*2;i+=2)
buf[i]=(hclr|(bclr<<4)); buf[i]=(hclr|(bclr<<4));
buf[0]=''; buf[0]='';
for(i=2;i<30*2;i+=2) if(api->helptitle==NULL) {
buf[i]=''; for(i=2;i<30*2;i+=2)
buf[i]=''; i+=4; buf[i]='';
buf[i]='O'; i+=2; buf[i]=''; i+=4;
buf[i]='n'; i+=2; buf[i]='O'; i+=2;
buf[i]='l'; i+=2; buf[i]='n'; i+=2;
buf[i]='i'; i+=2; buf[i]='l'; i+=2;
buf[i]='n'; i+=2; buf[i]='i'; i+=2;
buf[i]='e'; i+=4; buf[i]='n'; i+=2;
buf[i]='H'; i+=2; buf[i]='e'; i+=4;
buf[i]='e'; i+=2; buf[i]='H'; i+=2;
buf[i]='l'; i+=2; buf[i]='e'; i+=2;
buf[i]='p'; i+=4; buf[i]='l'; i+=2;
buf[i]=''; i+=2; buf[i]='p'; i+=4;
for(j=i;j<i+(30*2);j+=2) buf[i]=''; i+=2;
buf[j]=''; for(j=i;j<i+(30*2);j+=2)
buf[j]='';
}
else {
j=strlen(api->helptitle);
if(j>70)
*(api->helptitle+70)=0;
for(i=2;i<(35-(j/2))*2;i+=2)
buf[i]='';
buf[i]=''; i+=4;
for(p=api->helptitle;*p;p++) {
buf[i]=*p;
i+=2;
}
i+=2;
buf[i]=''; i+=2;
for(j=i;j<(75*2);j+=2)
buf[j]='';
}
i=j; i=j;
buf[i]=''; i+=2; buf[i]=''; i+=2;
j=i; /* leave i alone */ j=i; /* leave i alone */
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment