📄 apjjhhel.c
字号:
/***** 联机帮助系统 1998/11** ** 说明: 从HELPFILE读取信息生成联机帮助 ** ** ** ***/#include "apmenu.h"#define HELPFILE "/usr/oracle/user/bin/HELP"#define HELPMSG "提示:[End]退出,[Home]菜单,光标移到<<..>>按回车进入该主题"#define MENUHELPMSG "提示:[BackSpace] 退出一层菜单, [回车] 进行选择 "#define Y 3#define X 9#define WIDTH 60#define HEIGHT 18char text[500][82];char Nxt_Topic[80];int NREC;char NextTopic[80];int tFlags; struct Help_link { /*******联机帮助系统主题跳转链表*******/ char topic[82]; int ny; int nx; int nrec; int nline; int nrow; struct Help_link *nxtlink; struct Help_link *prvlink;};struct Help_link *Link_head,*Link_cur;struct menu_item_code menu_bar[]={ 1, "0", "主题[T] ~打印[P] ~帮助[H] ", "tph", 2, "1", "主题选择[S] ~上个主题[B] ~退出[E]", "sbe", 2, "2", "打印本主题[O] " , "o", 2, "3", "帮助[H] ~关于[A]" , "ha", };int Max_item= sizeof(menu_bar)/sizeof(struct menu_item_code);struct Proc_Init_Table { char *trans_code; /* 交易码 */ int (*initproc)(); /* 入口函数 */ char *bpath; /* 处理页路径 */ char *proc_name; /* 处理摘要 */ char *perm; /* 操作权限 */};extern struct Proc_Init_Table PIT1[];extern struct Proc_Init_Table PIT2[];extern struct Proc_Init_Table PIT3[];extern struct Proc_Init_Table PIT4[];extern struct Proc_Init_Table PIT5[];/***** SQL*AP 触发器调用接口***/int Select_show_help( ap )struct SQLAP_DEFINE *ap;{ int i; char *s,topic[82]; char sys[20], jym[10]; int y,x,width,height; extern int Disp_Help(); extern int Get_jym_topic(); SAVESCR *scr; WINDOW *w; /*** tFlags = 1 表示终端为ansi ****/ if ( strcmp( "ansi", getenv( "TERM" ) ) == 0 ) tFlags= 1; else tFlags = 0; w = getcpagdes(ap)->pwin; Link_head=NULL; Link_cur=NULL; if( getpagno( ap ) == 1) strcpy( topic, "操作员登录" ); else if( getpagno( ap ) == 2){ if ( getblkno( ap ) == 1) strcpy( topic, "选择进入系统" ); if ( getblkno( ap ) == 2) strcpy( topic, "选择交易码" ); else { fldtostr(ap, ":柜面操作.登录信息.系统选择", sys ); fldtostr(ap, ":柜面操作.操作选择块.交易码",jym); /** 获取交易码的主题 **/ Get_jym_topic( jym , sys , topic); } } else { fldtostr(ap, ":柜面操作.登录信息.系统选择", sys ); fldtostr(ap, ":柜面操作.操作选择块.交易码",jym); /** 获取交易码的主题 **/ Get_jym_topic( jym , sys, topic); } y = Y; x = X; width = WIDTH; height = HEIGHT; scr = Saverect(w,height,width,y,x); while( 1 ){ if ( Disp_Help(stdscr, y,x,height,width,topic, 7) == FALSE ) break; } Putrect(w,y,x,scr); Free(scr); return (0);}/***** 获取交易码的主题*****/int Get_jym_topic( jym, sys ,topic)char *jym;char *sys;char *topic;{ int i=0; char str[82]; extern int MAX_PIT; if ( strcmp ( sys, SYSTEM1 ) == 0 ){ while(i<MAX_PIT) { if ( strcmp( PIT1[i].trans_code,jym ) == 0 ){ strcpy( topic, PIT1[i].proc_name ) ; return TRUE; } i++; } } else if ( strcmp ( sys, SYSTEM2 ) == 0 ){ while(i<MAX_PIT) { if (strcmp( PIT2[i].trans_code,jym ) == 0 ){ strcpy( topic, PIT2[i].proc_name ) ; return TRUE; } i++; } } else if ( strcmp ( sys, SYSTEM3 ) == 0 ){ while(i<MAX_PIT) { if (strcmp( PIT3[i].trans_code,jym ) == 0 ){ strcpy( topic, PIT3[i].proc_name ) ; return TRUE; } i++; } } else if ( strcmp ( sys, SYSTEM4 ) == 0 ){ while(i<MAX_PIT) { if (strcmp( PIT4[i].trans_code,jym ) == 0 ){ strcpy( topic, PIT4[i].proc_name ) ; return TRUE; } i++; } } else if ( strcmp ( sys, SYSTEM5 ) == 0 ){ while(i<MAX_PIT) { if (strcmp( PIT5[i].trans_code,jym ) == 0 ){ strcpy( topic, PIT5[i].proc_name ) ; return TRUE; } i++; } } else return FALSE; }/***** 联机帮助系统循环主体***/int Disp_Help( w, y, x, height, width, topic, bkcolor ) WINDOW *w; int y;int x; int height; int width; char *topic;int bkcolor;{ int TopicColor,result; char topic_bak[80]; int ny,nx; int fontcolor=WHITE,fontbkcolor=BLACK; int ch,nrec=0,nline=0,nrow=0,i; SAVESCR *scr; char mesg[256]; extern int Initarry(); extern int Show_arry(); extern int Do_menu(); extern int Show_Mainmenu(); extern int Print_Cur_Topic(); extern int p(); ny=y+2;nx=x+2; if ( bkcolor != GRAY) bkcolor = GRAY ; else bkcolor = YELLOW; TopicColor = BLUE; scr = Saverect( w, height, width, y, x ); if ( tFlags != 1) { wstandout( w ); for( i=x;i<x+width;i++ ) mvwaddstr( w, y,i," " ); for( i=x;i<x+width;i++ ) mvwaddstr( w, y+height-2,i," " ); for( i=y;i<y+height-1;i++) mvwaddstr( w, i,x," " ); for( i=y;i<y+height-1;i++) mvwaddstr( w, i,x+width-2," " ); for( i=x+2;i<x+width-2;i++) mvwaddstr( w, y+1, i, " "); mvwaddstr( w, Y+HEIGHT-2, X+2, HELPMSG ); Show_Mainmenu(w, y+1, x+2, bkcolor); wstandend( w ); } else { wsetcolor( w,TopicColor, bkcolor); for( i=x;i<x+width;i++ ) mvwaddstr( w, y,i," " ); for( i=x;i<x+width;i++ ) mvwaddstr( w, y+height-2,i," " ); for( i=y;i<y+height-1;i++) mvwaddstr( w, i,x," " ); for( i=y;i<y+height-1;i++) mvwaddstr( w, i,x+width-2," " ); for( i=x+2;i<x+width-2;i++) mvwaddstr( w, y+1, i, " "); Show_Mainmenu(w, y+1, x+2, bkcolor); wsetcolor( w, CYAN, GRAY ); mvwaddstr( w, Y+HEIGHT-2, X+2, HELPMSG ); } wrefresh(w); /******** 进入前分配显示数组 *********/ if( Initarry ( w, width-4 , topic, HELPFILE )==TRUE ){ Add_link( topic, ny, nx, nrec, nline, nrow ); } else { Free_link(); return (FALSE); } /*** 主题循环 ***/ while( 1 ){ if ( tFlags != 1 ) { wstandout(w); for( i=x+1;i<x+width-1;i++) mvwaddstr( w, y, i, "-"); mvwaddstr( w, y, x+width/2-strlen(topic)/2-2, topic); for( i=y+1;i<y+height-1;i++)mvwaddstr( w, i, x, "│"); for(i=y+1;i<y+height-1;i++)mvwaddstr(w,i,x+width-2,"│"); mvwaddstr( w, y, x, "┌"); mvwaddstr( w, y, x+width-2, "┐"); mvwaddstr( w, y+height-2, x, "└"); mvwaddstr( w, y+height-2, x+width-2, "┘"); wstandend(w); } else { wsetcolor( w, TopicColor,GRAY); for( i=x+1;i<x+width-1;i++) mvwaddstr( w, y, i, "="); mvwaddstr( w, y, x+width/2-strlen(topic)/2-2, topic); /* for( i=y+1;i<y+height-1;i++)mvwaddstr( w, i, x, "│"); for(i=y+1;i<y+height-1;i++)mvwaddstr(w,i,x+width-2,"│"); mvwaddstr( w, y, x, "┌"); mvwaddstr( w, y, x+width-2, "┐"); mvwaddstr( w, y+height-2, x, "└"); mvwaddstr( w, y+height-2, x+width-2, "┘"); */ } Clear( w, height-5, width-4, y+2, x+2, fontbkcolor ); Show_arry(w, y+2,x+2,height-4, width-4, nrec, fontcolor, fontbkcolor ); wmove( w, ny, nx); wrefresh( w ); /*** 键盘循环 ***/ while ( 1 ){ ch = (int)getch(); if ( ch == Key_esc && getch()==91) { ch = getch(); if ( ch == Key_up ){ if ( nline > 0 ){ nline --; ny=w->_cury-1; nx=w->_curx; Show_NxtTopic(w,ny,x+2,ny+1,nrec+nline, nrec+nline+1, nrow,fontcolor,fontbkcolor); wmove(w,ny,nx ); wrefresh( w ); } else if (nrec !=0){ nrec --; Show_arry(w,y+2,x+2,height-4, width-4, nrec,fontcolor, fontbkcolor); Show_NxtTopic(w,ny,x+2,-1, nrec+nline, nrec+nline+1, nrow,fontcolor,fontbkcolor); wmove(w,ny,nx ); wrefresh( w ); } } if ( ch == Key_down ) { if ( nline < (height -5 ) ){ nline ++; ny=w->_cury+1; nx=w->_curx; Show_NxtTopic(w,ny,x+2,ny-1,nrec+nline, nrec+nline-1, nrow,fontcolor,fontbkcolor); wmove(w,ny,nx ); wrefresh( w ); } else if ( nrec+height-3 < NREC ){ nrec ++; Show_arry(w, y+2,x+2,height-4, width-4, nrec, fontcolor, fontbkcolor ); Show_NxtTopic(w,ny,x+2,ny-1, nrec+nline, nrec+nline-1, nrow,fontcolor,fontbkcolor); wmove(w,ny,nx ); wrefresh( w ); } } if ( ch == Key_right ) { if ( nrow < ( width - 5 ) ){ nrow ++; ny=w->_cury; nx=w->_curx+1; Show_NxtTopic(w,ny,x+2,ny,nrec+nline, nrec+nline, nrow,fontcolor,fontbkcolor); wmove(w,ny,nx ); wrefresh( w ); } } if ( ch == Key_left ) { if ( nrow >0 ){ nrow --; ny=w->_cury; nx=w->_curx-1; Show_NxtTopic(w,ny,x+2,ny,nrec+nline, nrec+nline, nrow,fontcolor,fontbkcolor); wmove(w,ny,nx ); wrefresh( w ); } } if ( ch == Key_pageup ) { if ( nrec > height-5 ){ nrec = nrec - height + 5 ; Show_arry(w, y+2,x+2,height-4, width-4, nrec, fontcolor, fontbkcolor ); Show_NxtTopic(w,ny,x+2,-1, nrec+nline, nrec+height-5+nline, nrow,fontcolor,fontbkcolor); wmove(w,ny,nx ); wrefresh( w ); } else { nrec= 0; Show_arry(w, y+2,x+2,height-4, width-4, 0, fontcolor, fontbkcolor ); Show_NxtTopic(w,ny,x+2,-1,0+nline, nrec+nline, nrow,fontcolor,fontbkcolor); wmove(w,ny,nx ); wrefresh( w ); } } if ( ch == Key_pagedown ) { if ( nrec+height-3+height-6 < NREC ){ nrec = nrec + height - 5 ; Show_arry(w, y+2,x+2,height-4, width-4, nrec, fontcolor, fontbkcolor ); Show_NxtTopic(w,ny,x+2,-1,nrec+nline, nrec-height+5+nline, nrow,fontcolor,fontbkcolor); wmove(w,ny,nx ); wrefresh( w ); } else { nrec=NREC-(height-5); if( nrec < 0 ) nrec = 0; Show_arry(w, y+2,x+2,height-4, width-4, nrec, fontcolor, fontbkcolor ); Show_NxtTopic(w,ny,x+2,-1, nrec+nline, nrec+nline, nrow,fontcolor,fontbkcolor); wmove(w,ny,nx ); wrefresh( w ); } } if ( ch==Key_end ) { Free_link(); return (FALSE); } } if ( ch == Key_tab ) { if ( nrow + 9 <= width - 5 ){ nrow = nrow + 9; ny=w->_cury; nx=w->_curx+9; Show_NxtTopic(w,ny,x+2,ny,nrec+nline, nrec+nline, nrow,fontcolor,fontbkcolor); wmove(w,ny,nx ); wrefresh( w ); } else { nrow = width-5 ; ny=w->_cury; nx= width-3+x ; Show_NxtTopic(w,ny,x+2,ny,nrec+nline, nrec+nline, nrow,fontcolor,fontbkcolor); wmove(w,ny,nx ); wrefresh( w ); } } if (ch == Key_backspace ) { if ( Link_cur!=Link_head ){ /** 删除当前链表 **/ Del_link(); /** 获取当前链表环境 **/ strcpy(topic,Link_cur->topic); ny=Link_cur->ny; nx=Link_cur->nx; nrec=Link_cur->nrec; nline=Link_cur->nline; nrow=Link_cur->nrow; Initarry ( w, width-4 , topic, HELPFILE ) ; break; } } if (ch == Key_enter) { if ( Nxt_Topic[0]!='\x0') { strcpy ( topic_bak, topic ); strcpy ( topic, Nxt_Topic ); if( Initarry ( w, width-4 , topic, HELPFILE ) ==TRUE ){ /** 保存当前的环境 **/ Link_cur->ny=ny; Link_cur->nx=nx; Link_cur->nrec=nrec; Link_cur->nline=nline; Link_cur->nrow=nrow; /** 设置新的环境 **/ nrec=0;nline=0;nrow=0; ny=y+2; nx=x+2; Add_link( topic, ny, nx, nrec, nline, nrow ); }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -