藍森林首頁 | 返回主頁 | 本站地圖 | 站內搜索 | 聯繫信箱 |
 您目前的位置:首頁 > 自由軟件 > 技術交流 > 應用編程


    

藍森林 http://www.lslnet.com 2006年6月6日 10:18


curses有沒操作當前屏幕上的字符保存

雖然看了不少資料,但還是沒找到
有沒有能對當前屏幕上的字符保存的函數,並能夠保存字體的屬性。
另一個就是如果當前屏幕newwin了二塊,怎麼樣從一個屏幕的操作跳轉到對另一屏幕的操作( 我是在寫一個改變字體顏色的函數,但只能對第一塊屏幕操作)。程序如下,請指教
void dcolor(char a)                        //顯示顏色
{
       
        attrset(A_NORMAL);
        switch(a)
        {
                case '0':wattron(stdscr,COLOR_PAIR(1));break;//黑底白字
                case '1':wattron(stdscr,COLOR_PAIR(2));break;//白底藍字
                case '2':wattron(stdscr,COLOR_PAIR(3));break;//白底紅字
                case '3':wattron(stdscr,COLOR_PAIR(4));break;//黑底紅字
                case '4':wattron(stdscr,COLOR_PAIR(5));break;//藍第紅字
                case '5':wattron(stdscr,COLOR_PAIR(6));break;//紅底白字
        }
}

curses有沒操作當前屏幕上的字符保存

每一個窗口都是一個win類型的
操作時指定它就可以了

得到字符不知道
但是也會有的

你可以買本ncurses的書看看系統的學習一下

curses有沒操作當前屏幕上的字符保存

用touchwin(*win)切換窗口啊!

//改變主窗口
touchwin(stdscr);
dcolor(0);
wrefresh(stdscr);
//改變窗口wTest
touchwin(wTest);
dcolor(0);
wrefresh(wTest);

curses有沒操作當前屏幕上的字符保存

touchwin 切換窗口
保存字符可以參照配置文件的做法

curses有沒操作當前屏幕上的字符保存

我用C++封裝過一個Screen類。

#ifndef SCREEN_H
#define SCREEN_H
#include <curses.h>;

#define NO_MENU_MESG        0         // NO_MENU_MESG 無菜單行  無提示行
#define MENU_MESG          1         // MENU_MESG 列菜單  提示行
#define MESG                 2         // MESG 提示行


class Screen
{
public:
        //全屏窗口(常用)
        Screen(int tital_row,                  //標題行數
               int f=0);                //窗口標誌:0,1,2

        //任意窗口(較常用)
        Screen(int h,                          //高度(行)
               int w,                          //寬度(列)
               int x,                          //起始行
               int y,                          //起始列
               int tital_row,  
               int f=0);

        //子窗口屏幕(特殊用途)
        Screen(WINDOW *subw,                  //子窗口
               int h,  
               int w,  
               int x,  
               int y,  
               int tital_row,  
               int f=0);

        WINDOW *Getwin(void);                 //取主窗口

        WINDOW *Getopewin(void);         //取操作窗口

        void Clearopewin(void);         //clear操作窗口

        void Settital(int row,                 //起始行
                      int col,          //起始列
                      char *c_tital,        //設置標題
                      int flag = 1);        //反白標誌 1 - 反白 0 - 無

        void Setmessage(char *c_meg, int meg_col = 0);        //設置提示串
        int Getmessagerow(void);

        int Getmenurow(void);                //取列菜單所在行

        WINDOW *Getmenuparent(void);        //取菜單父窗口
        void Createmenuparent(int num);

        virtual ~Screen();
public:
        int operate_start_x;                 //操作窗口起始行
        int operate_start_y;                 //操作窗口起始列
        int operate_width;                 //寬度(列)
        int operate_height;                 //高度(行)

        int current;                        //主菜單項指針

private:
        void Create(void);                 //產生窗口
        void Create(WINDOW *subw);        //產生子窗口
        void Wbox(int flag);                 //畫方框
        void Show(void);                //顯示窗口
        void Getforcus(void);                //顯示窗口
private:
        int i_x;                         //起始行
        int i_y;                         //起始列
        int i_width;                         //寬度
        int i_height;                         //高度
        int i_tital;                        //標題行數
        int i_meg;                        //提示行
        int i_menu;                        //菜單行
        int i_flag;                         //box()標誌:
                                        // 0 - NO_MENU_MESG
                                        // 1 - MENU_MESG
                                        // 2 - MESG
        WINDOW *win;                         //主窗口
        WINDOW *operatewin;                 //操作窗口
        WINDOW *menuparent[15];        //菜單窗口父窗口

};

#endif

curses有沒操作當前屏幕上的字符保存

無論是窗口還是輸入域,你都可以把它抽像為一個對象,有其自己的屬性,可通過以下的函數來獲取或設置
       #include <form.h>;
       int set_field_fore(FIELD *field, chtype attr);
       chtype field_fore(const FIELD *field);
       int set_field_back(FIELD *field, chtype attr);
       chtype field_back(const FIELD *field);
       int set_field_pad(FIELD *field, int pad);
       chtype field_pad(const FIELD *field);

curses有沒操作當前屏幕上的字符保存

thank you

curses有沒操作當前屏幕上的字符保存

dcolor(0)是什麼函數呀,我查不到???



Copyright © 1999-2000 LSLNET.COM. All rights reserved. 藍森林網站 版權所有。 E-mail : webmaster@lslnet.com