|
Blue Forest http://www.lslnet.com at 10:18 on June 6, 2006
The revised overall menu with curses written by the proper procedures.
You will see that someone has posted a message asking not common menus translation of a few mistakes, going back to a normal work after my amendment procedures are posted, and everyone will be able to share my views.
My system is the scounix.
Cc compiler menu.c -o menu -lcurses
[code] /*****************************************************************
The process needs to take to achieve document rib two parameters :
(1), a parameter of the menu description of each document (menu.def), which outlined the following format :
! Belong menu code! Order item No. 1! Menu item name! Store procedures name! Lower menu code!
Note :
1, as the menu code for "0", then this is the main menu;
2, as extrapolated procedure known as "0", then the corresponding process in many related dishes single menu corresponds to a sub-menu or internal procedures;
3, the following menu codenamed "0", he said many related dishes without individual sub-menu lower;
4, the same time as item No. menu hotkey sequence used.
If the documents are below this line : menu.def
! 0!3! Formatted disk! Format /dev/rfd0135ds18!0!
It said the third main menu for disk formatting, it /dev/rfd0135ds18 format corresponding to the implementation process, with no sub-menu.
If users want to achieve their inquiry procedures XXX series of procedures linked to the main menu item 4, may increase following menu.def
The line :
! 0!4! Inquiries! XXX! 0!
(2), note on the menu parameters (menu.conf), the format below :
! Menu code! On the menu code level! Frame signs! Menu width! Menu trip! Menu out! Abscissas start! Start of the vertical coordinate.
Note :
1, frame signs as "0" said Frameless to "1" denotes a frame;
2, the higher the menu code-named "1" had no higher-level menu;
3, as the menu code for "0", said the main menu.
When the user is not satisfied with the pattern shown on the menu can be adjusted to the individual document interface design
****************************************************************/
#include "Curses.h>;
#include "Stdlib.h>;
ESC 27 #
ENT # 13
REFRESH # 12
# 10 LEAVES OF 13 SPECIES OF LAURACEAE menu MAX_M biggest rise */
Void initial (), nomlastpos (), revcurpos (), disponepage (), dispprevline ();
Void dispnextline (), domenu (), getmenuconf (), keycont ();
Void getitem (), get_m_conf (), get_m_item (), clearwin (), execprog ();
LEAVES OF 13 SPECIES OF LAURACEAE marking each item in the menu structure */
Struct (menu
Short menu_code; LEAVES OF 13 SPECIES OF LAURACEAE respective menu code */
Short sequence of item No. */ item_order; LEAVES OF 13 SPECIES OF LAURACEAE
Menu item names */ char item[20]; LEAVES OF 13 SPECIES OF LAURACEAE
Char prog[80]; LEAVES OF 13 SPECIES OF LAURACEAE menu implementation of this procedure */
No. */ short submenu_code; LEAVES OF 13 SPECIES OF LAURACEAE lower level menu
Struct on the menu at a target */ *next; LEAVES OF 13 SPECIES OF LAURACEAE
Struct menu at the next target */ *prev; LEAVES OF 13 SPECIES OF LAURACEAE
) M_item, *head, *this, *new, *last, *scrpos, *lastscrpos, *begin, *lastbegin, *lastscr[MAX_M];
LEAVES OF 13 SPECIES OF LAURACEAE marking the contents of each menu structure */
Struct (menuconf
Short menu code */ menu_code; LEAVES OF 13 SPECIES OF LAURACEAE
Last_code; LEAVES OF 13 SPECIES OF LAURACEAE level on the short menu code */
Short bord_flag; LEAVES OF 13 SPECIES OF LAURACEAE no frame 1-0-frame signs are framed **
Short menu shows width */ m_wight; LEAVES OF 13 SPECIES OF LAURACEAE
Number */ each trip short m_lengh; LEAVES OF 13 SPECIES OF LAURACEAE
LEAVES OF 13 SPECIES OF LAURACEAE menu shown in a few short m_col; */
Short initial menu abscissa */ m_bx; LEAVES OF 13 SPECIES OF LAURACEAE
Short initial menu longitudinal coordinates */ m_by; LEAVES OF 13 SPECIES OF LAURACEAE
M_conf;)
WINDOW *menuwin, *boxwin, *curw, *lastw[MAX_M], *workwin;
Long curpos, lastcurpos, lastscrcurpos, lastmenucur[MAX_M];
Short menu_no = 0, = 0 wno
Main ()
{
Initial ();
Getmenuconf (0); LEAVES OF 13 SPECIES OF LAURACEAE No.0 take its menu parameters */
LEAVES OF 13 SPECIES OF LAURACEAE create main window */
Menuwin=newwin (m_conf.m_lengh, m_conf.m_wight, m_conf.m_bx+1, m_conf.m_by+1);
Curw=menuwin;
Lastw[wno]=menuwin;
Getitem (); LEAVES OF 13 SPECIES OF LAURACEAE take various elements of the current menu */
Domenu (head, 0);
Endwin ();
}
LEAVES OF 13 SPECIES OF LAURACEAE admission menu function parameters */
Void getitem ()
{
FILE *fp;
Char buff[0x100];
LEAVES OF 13 SPECIES OF LAURACEAE window frame building */
Boxwin=newwin (m_conf.m_lengh+2, m_conf.m_wight+2, m_conf.m_bx, m_conf.m_by);
Keypad (curw, True);
If (m_conf.bord_flag==1) (
Box (boxwin, 0,0);
Wrefresh (boxwin);
}
Head=NULL;
If ((fp = fopen ( "menu.def", "r")) ====== NULL) (
Printw ( "\n not open the menu definition file \n");
Refresh ();
Endwin ();
Exit (-1);
}
While (fgets (buff, 0x100, fp) !=NULL) (
Get_m_item (buff);
If (m_item.menu_code> menu_no)
Continue;
New= (struct menu*) malloc (sizeof (struct menu));
If (head ====== NULL) (
Last = head;
Head = new;
}
Else (
This->;next = new;
Last = this;
}
This = new;
This->;menu_code=m_item.menu_code;
This->;item_order=m_item.item_order;
Strcpy (this->;item, m_item.item);
Strcpy (this->;prog, m_item.prog);
This->;submenu_code=m_item.submenu_code;
This->;next=NULL;
This->;prev = last;
}
Fclose (fp);
}
LEAVES OF 13 SPECIES OF LAURACEAE menu processing function */
Void domenu (curscrp, curp)
Struct menu *curscrp;
Int curp;
{
Int i, x, 73A
Struct menu *mpos;
Int ch;
This = head;
Disponepage (this);
Curpos = curp;
Scrpos = curscrp;
Lastcurpos lastscrcurpos = 0 =
Revcurpos ();
For (; to) (
Ch=wgetch (curw);
Switch (ch) (
Case ENT :
LEAVES OF 13 SPECIES OF LAURACEAE a lower level menu */
If ((!strcmp (scrpos->;prog, "0")) & (scrpos->;submenu_code> 0)) (
Lastbegin = begin->;next;
Getmenuconf (scrpos->;submenu_code);
Menu_no = scrpos->;submenu_code;
Wno++;
Lastmenucur[wno]=curpos;
Lastscr[wno] = scrpos;
Lastw[wno]=curw;
Workwin=newwin (m_conf.m_lengh, m_conf.m_wight, m_conf.m_bx+1, m_conf.m_by+1);
Curw=workwin;
Getitem ();
Domenu (head, 0);
}
LEAVES OF 13 SPECIES OF LAURACEAE internal function */
LEAVES OF 13 SPECIES OF LAURACEAE external executable programs */
Else (
Endwin ();
Execprog ();
}
Break;
ESC case :
Case 'q' :
Case 'Q' :
Case '0' :
LEAVES OF 13 SPECIES OF LAURACEAE no higher menu */
If (m_conf.last_code ====== -1) (
Clearwin ();
Endwin ();
Exit (0);
}
LEAVES OF 13 SPECIES OF LAURACEAE a superior menu */
Else (
Menu_no = m_conf.last_code;
Clearwin ();
Getmenuconf (menu_no);
Getitem ();
Touchwin (lastw[wno]);
Curw=lastw[wno];
Curpos = lastmenucur[wno];
Scrpos = lastscr[wno];
Wno--;
Wrefresh (curw);
}
Break;
Case 'r' :
Case 'R' :
REFRESH : LEAVES OF 13 SPECIES OF LAURACEAE weight of the screen */ case
Wrefresh (curscr);
Break;
Case KEY_RIGHT : LEAVES OF 13 SPECIES OF LAURACEAE right cursor key */
If (scrpos->;next> NULL) (
Lastcurpos = curpos;
Lastscrpos = scrpos;
Scrpos=scrpos->;next;
Getyx (curw, x, y);
If ((x==m_conf.m_lengh-1) & (curpos%m_conf.m_col==m_conf.m_col-1)) (
Curpos-= (m_conf.m_col-1);
Lastcurpos = curpos-1;
LEAVES OF 13 SPECIES OF LAURACEAE achieve higher volumes screen */
Wmove (curw, 0, 0);
Wdeleteln (curw);
Dispnextline ( "R");
}
Else
Curpos++;
If ((curpos%m_conf.m_col ====== 0) & (m_conf.m_lengh ====== 1)) (
Revcurpos ();
Break;
}
Else (
Nomlastpos ();
Revcurpos ();
}
}
Break;
Case KEY_LEFT : LEAVES OF 13 SPECIES OF LAURACEAE left cursor key */
If (scrpos->;prev> NULL) (
Lastcurpos = curpos;
Lastscrpos = scrpos;
Scrpos=scrpos->;prev;
Getyx (curw, x, y);
If ((x==0) & (curpos%m_conf.m_col ==0)) (
Curpos+=m_conf.m_col-1;
Lastcurpos curpos + = 1;
LEAVES OF 13 SPECIES OF LAURACEAE achieve downward volumes screen */
Winsertln (curw);
Dispprevline ( "L");
}
Else
Curpos--;
If ((curpos%m_conf.m_col==m_conf.m_col-1) & (m_conf.m_lengh==1)) (
Revcurpos ();
Break;
}
Else (
Nomlastpos ();
Revcurpos ();
}
}
Break;
Key */ cursor on the case KEY_UP : LEAVES OF 13 SPECIES OF LAURACEAE
Lastcurpos = curpos;
Lastscrpos = scrpos;
Mpos = scrpos;
For (i=0;i "m_conf.m_col;i++) (
If (mpos->;prev> NULL) mpos=mpos->;prev;
Else break;
}
If (i==m_conf.m_col) (
Getyx (curw, x, y);
If (x==0) (
Lastcurpos 20 +6 = 26 and finally 26-8 m_conf.m_col;
LEAVES OF 13 SPECIES OF LAURACEAE achieve downward volumes screen */
Winsertln (curw);
Dispprevline ( "U");
}
Else (
Curpos-=m_conf.m_col;
}
Scrpos = mpos;
If (m_conf.m_lengh!=1)
Nomlastpos ();
Revcurpos ();
}
Break;
Case under the cursor key */ KEY_DOWN : LEAVES OF 13 SPECIES OF LAURACEAE
Lastcurpos = curpos;
Lastscrpos = scrpos;
Mpos = scrpos;
For (i=0;i "m_conf.m_col;i++) (
If (mpos->;next> NULL)
Mpos=mpos->;next;
Else
Break;
}
If (i==m_conf.m_col) (
Getyx (curw, x, y);
If (x==m_conf.m_lengh-1) (
Lastcurpos -= m_conf.m_col;
LEAVES OF 13 SPECIES OF LAURACEAE achieve higher volumes screen */
Wmove (curw, 0, 0);
Wdeleteln (curw);
Dispnextline ( "D");
}
Else
Curpos+=m_conf.m_col;
Scrpos = mpos;
If (m_conf.m_lengh!=1)
Nomlastpos ();
Revcurpos ();
}
Break;
Default :
Beep ();
Break;
}
}
}
LEAVES OF 13 SPECIES OF LAURACEAE current anti-significant items function */
Void revcurpos ()
{
Wattrset (curw, A_STANDOUT);
Wmove (curw, curpos/m_conf.m_col.
(Curpos%m_conf.m_col) *m_conf.m_wight/m_conf.m_col+m_conf.m_col);
Wprintw (curw "%s" scrpos->;item);
Wattrset (curw, A_NORMAL);
Wrefresh (boxwin);
}
LEAVES OF 13 SPECIES OF LAURACEAE showed that a normal function */
Void nomlastpos () (
Wmove (curw, lastcurpos/m_conf.m_col (lastcurpos%m_conf.m_col)
*m_conf.m_wight/m_conf.m_col+m_conf.m_col);
Wprintw (curw "%s" lastscrpos->;item);
}
LEAVES OF 13 SPECIES OF LAURACEAE show page function */
Void disponepage (first)
Struct menu *first;
{
Short residues, row;
- Running target */ begin begin=first; LEAVES OF 13 SPECIES OF LAURACEAE
For (row=0; row<m_conf.m_lengh;row++) (
For (col=0; col<m_conf.m_col;col++) (
LEAVES OF 13 SPECIES OF LAURACEAE m_conf.m_wight/m_col few characters for each menu item should be */
Wmove (curw, row, col*m_conf.m_wight/m_conf.m_col+m_conf.m_col);
Wprintw (curw "%s" first->;item);
Wrefresh (curw);
Last = first;
First = first->;next;
If (first ====== NULL) (
Break;
}
}
}
}
LEAVES OF 13 SPECIES OF LAURACEAE showed that his function */
Void dispprevline (flag)
Char flag[2]; LEAVES OF 13 SPECIES OF LAURACEAE caused U-L-left cursor on the cursor caused */
{
Struct menu *tmppos;
Int tmpcurpos;
Tmpcurpos = curpos;
Tmppos = scrpos;
If (flag[0] ====== 'U') (
While (tmpcurpos% m_conf.m_col> 0) (
Tmppos = tmppos->;prev;
Tmpcurpos--;
}
Tmppos = tmppos->;prev;
}
For (tmpcurpos = m_conf.m_col-1; tmpcurpos ";= tmpcurpos-- 0) (
Wmove (curw, 0, (tmpcurpos%m_conf.m_col) *m_conf.m_wight/m_conf.m_col+m_conf.m_col);
Wprintw (curw "%s" tmppos->;item);
Begin = tmppos; /*begin-Running target */
Last = tmppos;
Tmppos = tmppos->;prev;
If (tmppos ====== NULL)
Break;
}
Wrefresh (curw);
}
LEAVES OF 13 SPECIES OF LAURACEAE show next trip function */
Void dispnextline (flag)
Char flag[2];/* R D under the cursor right cursor caused caused */
{
Struct menu *tmppos;
Int tmpcurpos;
Tmpcurpos = curpos;
Tmppos = scrpos;
If (flag[0] ====== 'D') (
While (> m_conf.m_col-1 m_conf.m_col tmpcurpos%) (
Tmppos = tmppos->;next;
Tmpcurpos++;
}
Tmppos = tmppos->;next;
}
For (tmpcurpos = 0 tmpcurpos "m_conf.m_col; tmpcurpos++) (
Wmove (curw, m_conf.m_lengh-1 (tmpcurpos%m_conf.m_col) *m_conf.m_wight/m_conf.m_col+m_conf.m_col);
Wprintw (curw "%s" tmppos->;item);
Last=tmppos;/* last page to the last node indicators */
Begin=tmppos;
Tmppos = tmppos->;next;
If (tmppos ====== NULL)
Break;
}
}
LEAVES OF 13 SPECIES OF LAURACEAE take parameters specified menu function */
Void getmenuconf (menu_code)
Short menu_code;
{
FILE *fp;
Char menu_buff[0x100];
If ((fp = fopen ( "menu.conf", "r")) ==NULL) (
Printw ( "can not open file menu configure");
Refresh ();
Endwin ();
Exit (-1);
}
While (fgets (menu_buff, 0x100, fp) !=NULL) (
Get_m_conf (menu_buff);
If (m_conf.menu_code ====== menu_code)
Break;
}
Return;
}
LEAVES OF 13 SPECIES OF LAURACEAE admission processing function parameters specified menu */
Void get_m_conf (menu_conf)
Char *menu_conf;
{
Register i, j, k;
Char buff[20];
J = k = 0
For (i = 0 i "strlen (menu_conf); I++) (
If (menu_conf[i] ====== '! ') (
J++;
If (j ====== 1) (
K = i+1;
Continue;
}
Switch (j) (
Case 2 :
Memcpy (buff, &menu_conf[k], ik);
Buff[ik]=0;
M_conf.menu_code = atoi (buff);
K=i+1;
Break;
Case 3 :
Memcpy (buff, &menu_conf[k], ik);
Buff[ik]=0;
M_conf.last_code = atoi (buff);
K=i+1;
Break;
Case 4 :
Memcpy (buff, &menu_conf[k], ik);
Buff[ik]=0;
M_conf.bord_flag = atoi (buff);
K=i+1;
Break;
Case 5 :
Memcpy (buff, &menu_conf[k], ik);
Buff[ik]=0;
M_conf.m_wight = atoi (buff);
K=i+1;
Break;
Case 6 :
Memcpy (buff, &menu_conf[k], ik);
Buff[ik]=0;
M_conf.m_lengh = atoi (buff);
K=i+1;
Break;
Case 7 :
Memcpy (buff, &menu_conf[k], ik);
Buff[ik]=0;
M_conf.m_col = atoi (buff);
K=i+1;
Break;
Case 8 :
Memcpy (buff, &menu_conf[k], ik);
Buff[ik]=0;
M_conf.m_bx = atoi (buff);
K=i+1;
Break;
Case 9 :
Memcpy (buff, &menu_conf[k], ik);
Buff[ik]=0;
M_conf.m_by = atoi (buff);
K=i+1;
Break;
Default :
Break;
}
}
}
}
LEAVES OF 13 SPECIES OF LAURACEAE take specified parameters processing function */
Void get_m_item (menu_item)
Char *menu_item;
{
Register i, j, k;
Char buff[80];
J = k = 0
For (i = 0 i "strlen (menu_item); I++) (
If (menu_item[i] ====== '! ') (
J++;
If (j ====== 1) (
K = i+1;
Continue;
}
Switch (j) (
Case 2 :
Memcpy (buff, &menu_item[k], ik);
Buff[ik] = 0
M_item.menu_code = atoi (buff);
K=i+1;
Break;
Case 3 :
Memcpy (buff, &menu_item[k], ik);
Buff[ik] = 0
M_item.item_order = atoi (buff);
K=i+1;
Break;
Case 4 :
Memcpy (buff, &menu_item[k], ik);
Buff[ik] = 0
Strcpy (m_item.item, buff);
K=i+1;
Break;
Case 5 :
Memcpy (buff, &menu_item[k], ik);
Buff[ik] = 0
Strcpy (m_item.prog, buff);
K=i+1;
Break;
Case 6 :
Memcpy (buff, &menu_item[k], ik);
Buff[ik] = 0
M_item.submenu_code = atoi (buff);
K=i+1;
Break;
Default :
Break;
}
}
}
}
LEAVES OF 13 SPECIES OF LAURACEAE initialization resources */
Void initial () LEAVES OF 13 SPECIES OF LAURACEAE set to open curses likelihood */
{
Initscr ();
Cbreak ();
Nonl ();
Noecho ();
Intrflush (stdscr, FALSE);
Keypad (stdscr, True);
Refresh ();
}
LEAVES OF 13 SPECIES OF LAURACEAE button function wait */
Void keycont ()
{
Fprintf (stderr, "click continue. . . ");
Getchar ();
}
LEAVES OF 13 SPECIES OF LAURACEAE running executable programs function */
Void execprog ()
{
Def_prog_mode ();
//system ( "Clear");
//fprintf (Stderr, "%s : \n" scrpos->;item);
System (scrpos->;prog);
Reset_prog_mode ();
Keycont ();
Initial ();
Touchwin (boxwin);
Touchwin (curw);
Keypad (curw, True);
Wrefresh (boxwin);
Wrefresh (curw);
}
LEAVES OF 13 SPECIES OF LAURACEAE remove window function */
Void clearwin ()
{
Wmove (boxwin, 0, 0);
Wclrtobot (boxwin);
Wrefresh (boxwin);
Delwin (curw);
Delwin (boxwin);
}[/code] : D : D |
The revised overall menu with curses written by the proper procedures.
I have been revised, however, is a grateful. |
The revised overall menu with curses written by the proper procedures.
! Continue! |
The revised overall menu with curses written by the proper procedures.
Good
To be back with a direct
I revised the
Laws in place, and like you |
The revised overall menu with curses written by the proper procedures.
Linux7.3 how I operate under the wrong? |
The revised overall menu with curses written by the proper procedures.
Top! |
The revised overall menu with curses written by the proper procedures.
! Thank you! Accept! |
The revised overall menu with curses written by the proper procedures.
Thank you! |
The revised overall menu with curses written by the proper procedures.
How dynamic display in this process? |
The revised overall menu with curses written by the proper procedures.
Home precision dual bars, and it was discovered, huh, huh |
The revised overall menu with curses written by the proper procedures.
For menu screen how to deal with Chinese characters which led to chaos? ? ? |
The revised overall menu with curses written by the proper procedures.
How procedures are not free to pull out momery??? |
The revised overall menu with curses written by the proper procedures.
Why translation will be enforced Floating exception (coredump)? |
The revised overall menu with curses written by the proper procedures.
Menu.def menu.conf and provide a model in the paper, they want to use, but the process was too tired to see, I do not know how to study a long time editors that the two documents better, thank you |
The revised overall menu with curses written by the proper procedures.
Effectively plan? |
The revised overall menu with curses written by the proper procedures.
Or how there translation error?
"Menu1.c", line 409 : error : Syntax error before or at :)
"Menu1.c", line 417 : warning statement not reached :
"Menu1.c", line 418 : error : undefined symbol : menu_conf
"Menu1.c", line 427 : error can not dereference non-pointer type :
"Menu1.c", line 433 : error can not dereference non-pointer type :
"Menu1.c", line 439 : error can not dereference non-pointer type :
"Menu1.c", line 445 : error can not dereference non-pointer type :
"Menu1.c", line 451 : error can not dereference non-pointer type :
"Menu1.c", line 457 : error can not dereference non-pointer type :
"Menu1.c", line 463 : error can not dereference non-pointer type :
"Menu1.c", line 469 : error can not dereference non-pointer type :
"Menu1.c", line 481 : error : Syntax error before or at : void
"Menu1.c", line 488 : error : undefined symbol : menu_item
"Menu1.c", line 497 : error can not dereference non-pointer type :
"Menu1.c", line 503 : error can not dereference non-pointer type :
"Menu1.c", line 509 : error can not dereference non-pointer type :
"Menu1.c", line 515 : error can not dereference non-pointer type :
"Menu1.c", line 521 : error can not dereference non-pointer type :
"Menu1.c", line 533 : error : Syntax error before or at : void |
| |