|
藍森林 http://www.lslnet.com 2006年6月6日 10:18
如何保存部分屏幕數據?
請問在 curses 程序中,如何將屏幕上一部分顯示數據保存?
執行類似以下的功能: savewin(WINDOW *w, int y1, int x1, int y2, int x2).
謝謝!!! |
如何保存部分屏幕數據?
舊貼中有人問過
解決方法應該是使用壓棧方法 |
如何保存部分屏幕數據?
如果只想保存一部分那麼可能不行
一最小應該是以窗口保存 |
如何保存部分屏幕數據?
無雙老大,你好,我在 ncurses 代碼中,發現其程序中有一個 ctype *text 數據,然後通過對每個窗口的 text 數據訪問,可以保存(恢復)窗口的部分數據,但是在基本的 curses 數據定義中,沒有 text 數據結構,其中在 _st_win結構中僅有一個 ctype **_y的數據,就是不知該數據應如何使用,如何來設計窗口保存函數?
謝謝大家的參予,我相信眾人拾柴火焰高!! |
如何保存部分屏幕數據?
ncurses沒有用過
你但是它自己帶有例子的
你可以看看
另外那個代碼是哪裡的
如果是ncurses的例子代碼
那可以使用grep查找一下 |
如何保存部分屏幕數據?
無雙老大,是這樣的,我在 ncurses 函數中找到了屏幕保存和恢復函數,但是該函數中需要訪問 WINDOW 窗口結構數據,而該數據與 sco505 中的定義不一致,就是沒法找到這兩者之間的對應關係,故而無法保存所需要的屏幕數據。
請老大幫忙查看一下下面的代碼,然後找到其與 sco505 中的對應關係然後告訴我寫該程序的要點, 謝謝 !!!!
[code]
/****************************************************************************
* Copyright (c) 1998 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
* "Software"), to deal in the Software without restriction, including *
* without limitation the rights to use, copy, modify, merge, publish, *
* distribute, distribute with modifications, sublicense, and/or sell *
* copies of the Software, and to permit persons to whom the Software is *
* furnished to do so, subject to the following conditions: *
* *
* The above copyright notice and this permission notice shall be included *
* in all copies or substantial portions of the Software. *
* *
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
* IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
* THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
* *
* Except as contained in this notice, the name(s) of the above copyright *
* holders shall not be used in advertising or otherwise to promote the *
* sale, use or other dealings in this Software without prior written *
* authorization. *
****************************************************************************/
/****************************************************************************
* Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com>; 1992,1995 *
* and: Eric S. Raymond <esr@snark.thyrsus.com>; *
****************************************************************************/
#include <curses.priv.h>;
#include <sys/stat.h>;
#include <time.h>;
#include <term.h>; /* exit_ca_mode, non_rev_rmcup */
MODULE_ID("$Id: lib_screen.c,v 1.15 1999/07/24 20:05:29 tom Exp $")
static time_t dumptime;
WINDOW *getwin(FILE *filep)
{
WINDOW tmp, *nwin;
int n;
T((T_CALLED("getwin(%p)"), filep));
(void) fread(&tmp, sizeof(WINDOW), 1, filep);
if (ferror(filep))
returnWin(0);
if ((nwin = newwin(tmp._maxy+1, tmp._maxx+1, 0, 0)) == 0)
returnWin(0);
/*
* We deliberately do not restore the _parx, _pary, or _parent
* fields, because the window hierarchy within which they
* made sense is probably gone.
*/
nwin->;_curx = tmp._curx;
nwin->;_cury = tmp._cury;
nwin->;_maxy = tmp._maxy;
nwin->;_maxx = tmp._maxx;
nwin->;_begy = tmp._begy;
nwin->;_begx = tmp._begx;
nwin->;_yoffset = tmp._yoffset;
nwin->;_flags = tmp._flags & ~(_SUBWIN|_ISPAD);
nwin->;_attrs = tmp._attrs;
nwin->;_bkgd = tmp._bkgd;
nwin->;_clear = tmp._clear;
nwin->;_scroll = tmp._scroll;
nwin->;_leaveok = tmp._leaveok;
nwin->;_use_keypad = tmp._use_keypad;
nwin->;_delay = tmp._delay;
nwin->;_immed = tmp._immed;
nwin->;_sync = tmp._sync;
nwin->;_regtop = tmp._regtop;
nwin->;_regbottom = tmp._regbottom;
for (n = 0; n < nwin->;_maxy + 1; n++)
{
(void) fread(nwin->;_line[n].text,
sizeof(chtype), (size_t)(nwin->;_maxx + 1), filep);
if (ferror(filep))
{
delwin(nwin);
returnWin(0);
}
}
touchwin(nwin);
returnWin(nwin);
}
int putwin(WINDOW *win, FILE *filep)
{
int code = ERR;
int n;
T((T_CALLED("putwin(%p,%p)"), win, filep));
if (win) {
(void) fwrite(win, sizeof(WINDOW), 1, filep);
if (ferror(filep))
returnCode(code);
for (n = 0; n < win->;_maxy + 1; n++)
{
(void) fwrite(win->;_line[n].text,
sizeof(chtype), (size_t)(win->;_maxx + 1), filep);
if (ferror(filep))
returnCode(code);
}
code = OK;
}
returnCode(code);
}
int scr_restore(const char *file)
{
FILE *fp = 0;
T((T_CALLED("scr_restore(%s)"), _nc_visbuf(file)));
if (_nc_access(file, R_OK) < 0
|| (fp = fopen(file, "rb")) == 0)
returnCode(ERR);
else
{
delwin(newscr);
newscr = getwin(fp);
(void) fclose(fp);
returnCode(OK);
}
}
int scr_dump(const char *file)
{
FILE *fp = 0;
T((T_CALLED("scr_dump(%s)"), _nc_visbuf(file)));
if (_nc_access(file, W_OK) < 0
|| (fp = fopen(file, "wb")) == 0)
returnCode(ERR);
else
{
(void) putwin(newscr, fp);
(void) fclose(fp);
dumptime = time((time_t *)0);
returnCode(OK);
}
}
int scr_init(const char *file)
{
FILE *fp = 0;
struct stat stb;
T((T_CALLED("scr_init(%s)"), _nc_visbuf(file)));
if (exit_ca_mode && non_rev_rmcup)
returnCode(ERR);
if (_nc_access(file, R_OK) < 0
|| (fp = fopen(file, "rb")) == 0)
returnCode(ERR);
else if (fstat(STDOUT_FILENO, &stb) || stb.st_mtime >; dumptime)
returnCode(ERR);
else
{
delwin(curscr);
curscr = getwin(fp);
(void) fclose(fp);
returnCode(OK);
}
}
int scr_set(const char *file)
{
T((T_CALLED("scr_set(%s)"), _nc_visbuf(file)));
if (scr_init(file) == ERR)
returnCode(ERR);
else
{
delwin(newscr);
newscr = dupwin(curscr);
returnCode(OK);
}
}
[/code] |
如何保存部分屏幕數據?
) fread(nwin->;_line[n].text,
sizeof(chtype), (size_t)(nwin->;_maxx + 1), filep);
主要就是這裡
保存時把窗口的每行信息保存
nwin->;_line[n].text應該是窗口每一行的信息吧我想
因為ncurses是文本模式的 每行都是由字符組成
所以你也可以照做 |
如何保存部分屏幕數據?
是的,我也看到 ncurses 中窗口數據就是在 _line 中保存的,但是在 sco505 中我卻找不到 _line 類似的數據結構,只是見到了一個 ctype **_y 的數據定義,但是但我編程對該數據保存,卻沒有實現窗口數據保存效果,不知我對窗口數據的分析存在哪些錯誤?
謝謝老大的關心!! |
如何保存部分屏幕數據?
#include <curses.priv.h>;
定義應該在這裡
另外所有平台上的curses結構都是一樣的(我想 它不會為每個平台創建一個結構 因為沒有必要)
你可以在這頭文件中找找看
或是使用gdb時跟跟看(看能不能跟進去) |
如何保存部分屏幕數據?
而該數據與 sco505 中的定義不一致,就是沒法找到這兩者之間的對應關係,故而無法保存所需要的屏幕數據。
請到sco系統提供的cursor相關庫中查找
到/usr/include下面grep一下。
這個數據類型的定義可能存在兼容性的問題。 |
| |