ラベル コンソール入出力 の投稿を表示しています。 すべての投稿を表示
ラベル コンソール入出力 の投稿を表示しています。 すべての投稿を表示

2005年8月28日日曜日

pdcursesをpython(MSC on win32版)で使う

pdcursesにないものでpython cursesで利用されている関数



curses(XPG4.2)にある関数
color_content color

filter util
getwin util
putwin util
use_env util

noqiflush inopts
qiflush inopts
wtimeout inopts

putp terminfo
setupterm terminfo
tigetflag terminfo
tigetnum terminfo
tigetstr terminfo
tparm terminfo

mvwgetnstr getstr

ncurses独自実装の関数?
has_key /* ncurses getch*/

過去のcurses(SYSV)との互換
getattrs /* old SYSV */

エクスポートしてない定数
_ISPAD
ncurses:curses.hに公開 "#define _ISPAD 0x10"
pdcurses:cursespriv.hにあり非公開 ただし"#define _PAD 0x10"になっている。
使用例:
WINDOW *win;
if (win._flag==_ISPAD) return(OK);

ncursesでの実装


#define getattrs(win)  ((win)?(win)->_attrs:A_NORMAL)


実装のしかた


#define _ISPAD          0x10

#define mvwgetnstr(w,y,x,str,n) (wmove(w,y,x)==ERR?ERR:wgetnstr(w,str,n))


下書きのまま(2008/09)

2005年8月26日金曜日

*cursesの差異とドキュメント配布場所

ソースファイルと一緒に配られているしっかりした解説が、ネット上ではあまり参照できない。
ただし、一次配布元からは参照できるようだ。
また、Wikipediaにもリンク集がある。

ncurses:

オフィシャル
http://invisible-island.net/ncurses/
http://dickey.his.com/ncurses/ (同じサーバ)
http://www.gnu.org/software/ncurses/ (情報が古め)

NCURSES FAQ
http://invisible-island.net/ncurses/ncurses.faq.html

ソースに同梱されている重要な書類
Writing Programs with NCURSES (116.55 KB)
html/ncurses-intro.html
http://invisible-island.net/ncurses/ncurses-intro.html

A Hacker's Guide to Ncurses Internals (32.97 KB)
html/hackguide.html
http://invisible-island.net/ncurses/hackguide.html

ncurses (3x) ― man2html
html/man/ncurses.3x.html
http://invisible-island.net/ncurses/man/ncurses.3x.html

その他の解説
ncurses Programming HOWTO
http://www.tldp.org/HOWTO/NCURSES-Programming-HOWTO/

wikipediaにもリンク集がある。
http://en.wikipedia.org/wiki/Ncurses

pdcurses:

Windowsにも対応している。

オフィシャル
http://pdcurses.sourceforge.net/
実装
http://pdcurses.sourceforge.net/doc/PDCurses.txt

python cursesパッケージ:

MSC on win32版では動かない。


python curses over pdcurses on windows:

pdcursesだけでは動かない
http://gnuwin32.sourceforge.net/packages/pdcurses.htm
http://gnuwin32.sourceforge.net/packages/termcap.htm
あとの足りない関数を補う必要がある。

下書きのまま(2008/09)

2005年8月16日火曜日

コンソールとエスケープシーケンス

escape sequence エスケープシークエンスとも言う

MS-DOS ansi.sys
http://www.microsoft.com/technet/archive/msdos/comm1.mspx

Linux
http://www.linux.or.jp/JM/html/LDP_man-pages/man4/console_codes.4.html

Windowsのコンソール(cmd.exe)では効かない。
BCC conio, wincon
MSC wincon
MSYS, MinGW wincon
CYGWIN stty, ioctl, curses
を使う。

下書きのまま(2008/09)

unixやcygwinのコンソール操作

unix系
GNU coreutils stty

http://www.bookshelf.jp/texi/coreutils/coreutils-ja_19.html#SEC119
http://www.gnu.org/software/coreutils/manual/html_chapter/coreutils_19.html#SEC115
http://www.linux.or.jp/JM/html/GNU_sh-utils/man1/stty.1.html

下書きのまま(2008/09)

conio.hに見るCランタイム コンソール関数のサポート状況

MSC

C:\Program Files\Microsoft Visual C++ Toolkit 2003\include\conio.h
C:\Program Files\Microsoft Visual C++ Toolkit 2003\lib\libc.lib
C:\Program Files\Microsoft Visual C++ Toolkit 2003\bin\msvcr71.dll
http://www.microsoft.com/japan/msdn/library/ja/vclib/html/_crt_console_and_port_i.2f.o.asp

関数:
_cgets, _cgetws
_cprintf, _cwprintf
_cputs
_cscanf, _cwscanf
_getch, _getwch
_getche, _getwche
_kbhit
_putch, _putwch
_ungetch, _ungetwch

定数:
なし

MinGW, cygwin-mingw

C:\MinGW\include\conio.h, C:\MinGW\lib\libmsvcrt.a
C:\cygwin\usr\include\mingw\conio.h, c:\cygwin\lib\mingw\libmsvcrt.a

関数:
_getch(), _getche(), _kbhit(), _putch(), _ungetch()
_cgets(), _cprintf(), _cputs(), _cscanf()

変数:
なし

BCC5.5

C:\Borland\bcc55\Include\conio.h
C:\Borland\bcc55\Lib\cw32.lib
C:\Borland\bcc55\Lib\cw32i.lib, C:\Borland\bcc55\Lib\import32.lib, C:\Borland\bcc55\Bin\cc3250.dll

関数:
getpass()
getch(), getche(), kbhit(), putch(), ungetch() / _getch()
cgets(), cprintf(), cputs(), cscanf()
gotoxy(), wherex(), wherey()
gettext(), movetext(), puttext()
highviedo(), normvideo(), lowvideo()
clreol(), clrscr()
delline(),insline()
textattr(), textcolor(), textbackground(), textmode()
_setcursortype()
__flush_win95_keyup_events()
window()
gettextinfo()

変数:
グローバル変数 directvideo, _wscroll
グローバル定数 _NOCURSER, _SOLIDCURSER, _NORMALCURSER, BLINK, PASS_MAX
構造体 text_info
列挙子 text_modes, COLORS

DJGPP

C:\DJGPP\include\conio.h
C:\DJGPP\lib\libc.a

関数:
getch(), getche(), kbhit(), putch(), ungetch() / _conio_kbhit()
cgets(), cprintf(), cputs(), cscanf()
gotoxy(), wherex(), wherey()
gettext(), movetext(), puttext()
blinkvideo(), highviedo(), normvideo(), lowvideo(), intensevideo()
clreol(), clrscr()
delline(), insline()
textattr(), textcolor(), textbackground(), textmode()
_setcursortype(), _set_screen_lines()
gppconio_init()
window()
gettextinfo()

変数:
グローバル変数 directvideo, _wscroll
グローバル定数 _NOCURSER, _SOLIDCURSER, _NORMALCURSER, BLINK
構造体 text_info
列挙子 text_modes, COLORS

Windowsのコンソール入出力

主にWindowsのコマンドプロンプトの操作に使われる
(MS Visual)Cランタイムライブラリに含まれるコンソール入出力関数
http://www.microsoft.com/japan/msdn/library/ja/vclib/html/_crt_console_and_port_i.2f.o.asp
#include <conio.h>
  • _getch()
  • _getche()
  • _kbhit()
  • _ungetch()
  • _putch()
  • など


アンダバーが付かないgetch()などのANSI Cに準拠しない古い関数名でも使える。


MinGWとcygwin-mingwのgccは、MS Cランタイム(msvcrt.dll)にリンクされるので、
MSVCと同じ関数が使える。
DJGPPv2、BCC5.5では、独自のCランタイムライブラリとヘッダファイルが用意されているので、MS Cと同じ関数の他に、DOS系で利用されていた関数が使える。
http://www.borland.co.jp/cppbuilder/freecompiler/faq/bccfaq3.html

cygwin版gccは、cygwin?.dllにリンクされるが、Cランタイムのコンソール操作関数は
含まれていないのでcygwinからリンクする場合、-mno-cygwinを付けないと利用出来ない。

MSVCのコンソール入出力には、色を変えたりカーソルを移動する操作は用意されていないので、必要な場合はWindowsAPIに用意されているコンソール入出力関数(wincon.h)で行なう。
http://www.microsoft.com/japan/msdn/library/ja/jpfileio/html/_win32_setconsolecursorposition.asp


コンソール関数
conio.h ― Cランタイムライブラリ ヘッダ
wincon.h ― WindowsAPI, プラットフォームライブラリ ヘッダ

シリアル(COM Port)操作関数
conio.h ― Cランタイムライブラリ ヘッダ
winbase.h ― WindowsAPI, プラットフォームライブラリ ヘッダ


(MS Visual)Cランタイムライブラリ
msvcrt.lib libc.lib ― スタティックライブラリ
msvcrtd.lib libcd.lib ― msvcrt.dll用インポートライブラリ
msvcrt{,20,40}.dll, msvcr{70,71}.dll ― ダイナミックライブラリ

(Windows)プラットフォーム(SDK)ライブラリ
kernel32.lib ― kernel32.dll用インポートライブラリ
kernel32.dll ― ランタイムDLLファイル

Borand Cランタイムライブラリ
cw32.lib ― スタティクライブラリ
cw32i.lib ― Importライブラリ
cc3250.dll ― ランタイムDLL

DJGPP Cランタイムライブラリ
libc.a ― スタティクライブラリ

MinGW Cランタイムライブラリ
libmsvcrt.a