From: matz@... (Yukihiro Matsumoto) Date: 1997-03-31T17:50:10+09:00 Subject: [ruby-list:2548] Re: curses library まつもと ゆきひろです. In message "[ruby-list:2547] Re: curses library" on 97/03/31, MAEDA Shugo writes: |On Mon, 31 Mar 97 14:42:36 JST, |matz@caelum.co.jp (Yukihiro Matsumoto) wrote: | || いっそのこと,Init_curses()の中でinitscr()してしまったらどう || です? cursesモジュールをrequireしておいて,initscrしないでお || く必然性はあまりないような…. | |それも考えたのですが、requireしただけでinitscr()してしまうと |printなどと併用できないのでまずいかなと。 そうかあ,cursesってそういうものなのね.考えてみれば当然だよ なあ.こういう場合には定数は提供しない方が良いのではないでしょ うか? |あと、close_screenせずにexitすると端末がとんでもないことになる |のですが、この辺は使用者まかせでよいんでしょうか? たぶん.ちなみにpythonのcursesは以下のようなAPIのようです. rubyにマップすると トップレベルのもの - Cursesモジュールのモジュール関数 Window - Curses::Windowクラス Pad - Curses::Padクラス(Padってなに?) という感じになるんではないでしょうか? md5の時にpython用に書 かれたモジュールをrubyに持って来ましたが,一般的にはruby用に 書き直すのはかなり簡単です. -- This is a curses implementation. I have tried to be as complete as possible. If there are functions you need that are not included, please let me know and/or send me some diffs. There are 3 basic types exported by this module: 1) Screen - This is not currently used 2) Window - This is the basic type. This is equivalent to "WINDOW *". 3) Pad - This is similar to Window, but works with Pads as defined in curses. Most of the routines can be looked up using the curses man page. Here is a list of the currently supported methods and attributes in the curses module: Return Value Func/Attr Description -------------------------------------------------------------------------- StringObject version A string representing the current version of this module. WindowObject initscr() This initializes the screen for use None endwin() Closes down the screen and returns things as they were before calling initscr() True/FalseObject isendwin() Has endwin() been called? None doupdate() Updates screen WindowObject newwin(nlines,ncols,begin_y,begin_x) newwin(begin_y,begin_x) newwin() creates and returns a new window. None beep() Beep the screen if possible None flash() Flash the screen if possible None ungetch(int) Push the int back so next getch() will return it. Note: argument is an INT, not a CHAR None flushinp() Flush all input buffers None cbreak() Enter cbreak mode None nocbreak() Leave cbreak mode None echo() Enter echo mode None noecho() Leave echo mode None nl() Enter nl mode None nonl() Leave nl mode None raw() Enter raw mode None noraw() Leave raw mode None intrflush(int) Set or reset interruptable flush mode, int=1 if set, 0 if notset. None meta(int) Allow 8 bit or 7 bit chars. int=1 is 8 bit, int=0 is 7 bit StringObject keyname(int) return the text representation of a KEY_ value. (see below) Here is a list of the currently supported methods and attributes in the WindowObject: Return Value Func/Attr Description -------------------------------------------------------------------------- None refresh() Do refresh None nooutrefresh() Mark for refresh but wait None mvwin(new_y,new_x) Move Window None move(new_y,new_x) Move Cursor WindowObject subwin(nlines,ncols,begin_y,begin_x) subwin(begin_y,begin_x) None addch(y,x,ch,attr) addch(y,x,ch) addch(ch,attr) addch(ch) None insch(y,x,ch,attr) insch(y,x,ch) insch(ch,attr) insch(ch) None delch(y,x) delch() None echochar(ch,attr) echochar(ch) None addstr(y,x,str,attr) addstr(y,x,str) addstr(str,attr) addstr(str) None attron(attr) None attroff(attr) None attrset(sttr) None standend() None standout() None border(ls,rs,ts,bs,tl,tr,bl,br) (accepts 0-8 INT args) None box(vertch,horch) vertch and horch are INTS box() None hline(y,x,ch,n) hline(ch,n) None vline(y,x,ch,n) vline(ch,n) None erase() None deleteln() None insertln() (y,x) getyx() (y,x) getbegyx() (y,x) getmaxyx() None clear() None clrtobot() None clrtoeol() None scroll() None touchwin() None touchline(start,count) IntObject getch(y,x) getch() StringObject getstr(y,x) getstr() IntObject inch(y,x) inch() None clearok(int) int=0 or int=1 None idlok(int) int=0 or int=1 None leaveok(int) int=0 or int=1 None scrollok(int) int=0 or int=1 None setscrreg(top,bottom) None keypad(int) int=0 or int=1 None nodelay(int) int=0 or int=1 None notimeout(int) int=0 or int=1