PageRenderTime 45ms CodeModel.GetById 34ms app.highlight 8ms RepoModel.GetById 1ms app.codeStats 0ms

/packages/ncurses/examples/twindow.pp

https://github.com/slibre/freepascal
Puppet | 82 lines | 69 code | 13 blank | 0 comment | 0 complexity | 61a1bd6092a9ed411053051e98194295 MD5 | raw file
Possible License(s): LGPL-2.0, LGPL-2.1, LGPL-3.0
 1program test_window;
 2{$mode objfpc}
 3
 4uses
 5  ncurses, panel, sysutils;
 6
 7procedure printw(win: PWINDOW; y,x: Smallint; fmt: AnsiString; args: Array of const);
 8var
 9  tstr: AnsiString;
10begin
11  FmtStr(tstr, fmt, args);
12  mvwaddstr(win,y,x, PChar(tstr));
13end;
14
15procedure printinfo(win: PWINDOW);
16begin
17  with win^ do
18  begin
19    printw(win,1 ,1,'_cury=%-3d, _curx=%-3d : cursor position',[_cury,_curx]);
20    printw(win,2 ,1,'_maxy=%-3d, _maxx=%-3d : maximums of x and y, NOT window size',[_maxy,_maxx]);
21    printw(win,3 ,1,'_begy=%-3d, _begx=%-3d : screen coords of upper-left-hand corner',[_begy,_begx]);
22    printw(win,4 ,1,'_flags=%-3d           : window state flags',[_flags]);
23    printw(win,5 ,1,'_attrs=%-4d          : current attribute for non-space character',[_attrs]);
24    printw(win,6 ,1,'_bkgd=%-3d            : current background char/attribute pair',[_bkgd]);
25    printw(win,7 ,1,'_notimeout=%-1d         :  no time out on function-key entry?', [Byte(_notimeout)]);
26    printw(win,8 ,1,'_clear=%-1d             : consider all data in the window invalid?',[Byte(_clear)]);
27    printw(win,9 ,1,'_leaveok=%-1d           : OK to not reset cursor on exit?',[Byte(_leaveok)]);
28    printw(win,10,1,'_scroll=%-1d            : OK to scroll this window?',[Byte(_scroll)]);
29    printw(win,11,1,'_idlok=%-1d             : OK to use insert/delete line?',[Byte(_idlok)]);
30    printw(win,12,1,'_idcok=%-1d             : OK to use insert/delete char?',[Byte(_idcok)]);
31    printw(win,13,1,'_immed=%-1d             : window in immed mode? (not yet used)',[Byte(_immed)]);
32    printw(win,14,1,'_sync=%-1d              : window in sync mode?',[Byte(_sync)]);
33    printw(win,15,1,'_use_keypad=%-1d        : process function keys into KEY_ symbols?',[Byte(_use_keypad)]);
34    printw(win,16,1,'_delay=%-3d           : 0 = nodelay, <0 = blocking, >0 = delay',[_delay]);
35    printw(win,17,1,'_parx=%-3d            : x coordinate of this window in parent',[_parx]);
36    printw(win,18,1,'_pary=%-3d            : y coordinate of this window in parent',[_pary]);
37    printw(win,19,1,'_yoffset=%-3d         : real begy is _begy + _yoffset',[_yoffset]);
38    printw(win,20,1,'_bkgrnd.attr=%-4d    : current background char/attribute pair',[_bkgrnd.attr]);
39  end;
40end;
41
42var
43  win : pWINDOW;
44  cy, cx, by, bx, my, mx: Longint;
45begin
46
47  try
48    initscr();
49    start_color;
50    noecho;
51    init_pair(1,COLOR_WHITE,COLOR_BLUE);
52    init_pair(2,COLOR_RED,COLOR_BLUE);
53
54    win:= newwin( LINES - 2, COLS - 6, 1, 3);
55
56    wbkgd(win, COLOR_PAIR(1));
57    erase;
58    refresh;
59
60    box(win, ACS_VLINE, ACS_HLINE);
61
62    wmove(win,12,24);
63    printinfo(win);
64
65    wrefresh(win);
66    getch;
67
68    getyx(win,cy,cx);
69    getbegyx(win,by,bx);
70    getmaxyx(win,my,mx);
71    delwin(win);
72    clear();
73
74    printw(stdscr,1 ,1,'getyx(win,%d,%d)',[cy,cx]);
75    printw(stdscr,2 ,1,'getbegyx(win,%d,%d);',[by,bx]);
76    printw(stdscr,3 ,1,'getmaxyx(win,%d,%d);',[my,mx]);
77    getch;
78
79  finally
80    endwin();
81  end;
82end.