Code: Alles auswählen
In [1]: import curses
In [2]: curses.setupterm()
In [3]: curses.tigetstr('bold')
Out[3]: '\x1b[1m'
In [4]: BOLD = curses.tigetstr('bold')
In [5]: NORMAL = curses.tigetstr('sgr0') # setzt die Einstellungen zurück
In [6]: print 'Echt {0}fett{1}'.format(BOLD, NORMAL)
------> print('Echt {0}fett{1}'.format(BOLD, NORMAL))
Echt [b]fett[/b] # sieht man im Forum nicht
Was mich interessiert, ist also `strnames`:The tigetflag, tigetnum and tigetstr routines return the value of the capability corresponding to the terminfo capname passed to them, such as xenl.
The tigetflag routine returns the value -1 if capname is not a boolean capability, or 0 if it is canceled or absent from the terminal description.
The tigetnum routine returns the value -2 if capname is not a numeric capability, or -1 if it is canceled or absent from the terminal description.
The tigetstr routine returns the value (char *)-1 if capname is not a string capability, or 0 if it is canceled or absent from the terminal description.
The capname for each capability is given in the table column entitled capname code in the capabilities section of terminfo(5).
char *boolnames[], *boolcodes[], *boolfnames[]
char *numnames[], *numcodes[], *numfnames[]
char *strnames[], *strcodes[], *strfnames[]
These null-terminated arrays contain the capnames, the termcap codes, and the full C names, for each of the terminfo variables.
Code: Alles auswählen
In [7]: from ctypes import CDLL
In [8]: from ctypes.util import find_library
In [9]: libcurses = CDLL(find_library('curses'))
In [10]: libcurses.strnames
Out[10]: <_FuncPtr object at 0x9f3e50c>