Subversion Repositories Kolibri OS

Rev

Blame | Last modification | View Log | RSS feed

  1. /* PDCurses */
  2.  
  3. #include <curspriv.h>
  4.  
  5. /*man-start**************************************************************
  6.  
  7. termattr
  8. --------
  9.  
  10. ### Synopsis
  11.  
  12.     int baudrate(void);
  13.     char erasechar(void);
  14.     bool has_ic(void);
  15.     bool has_il(void);
  16.     char killchar(void);
  17.     char *longname(void);
  18.     chtype termattrs(void);
  19.     attr_t term_attrs(void);
  20.     char *termname(void);
  21.  
  22.     int erasewchar(wchar_t *ch);
  23.     int killwchar(wchar_t *ch);
  24.  
  25.     char wordchar(void);
  26.  
  27. ### Description
  28.  
  29.    baudrate() is supposed to return the output speed of the terminal. In
  30.    PDCurses, it simply returns INT_MAX.
  31.  
  32.    has_ic and has_il() return TRUE. These functions have meaning in some
  33.    other implementations of curses.
  34.  
  35.    erasechar() and killchar() return ^H and ^U, respectively -- the
  36.    ERASE and KILL characters. In other curses implementations, these may
  37.    vary by terminal type. erasewchar() and killwchar() are the wide-
  38.    character versions; they take a pointer to a location in which to
  39.    store the character, and return OK or ERR.
  40.  
  41.    longname() returns a pointer to a static area containing a verbose
  42.    description of the current terminal. The maximum length of the string
  43.    is 128 characters. It is defined only after the call to initscr() or
  44.    newterm().
  45.  
  46.    termname() returns a pointer to a static area containing a short
  47.    description of the current terminal (14 characters).
  48.  
  49.    termattrs() returns a logical OR of all video attributes supported by
  50.    the terminal.
  51.  
  52.    wordchar() is a PDCurses extension of the concept behind the
  53.    functions erasechar() and killchar(), returning the "delete word"
  54.    character, ^W.
  55.  
  56. ### Portability
  57.                              X/Open  ncurses  NetBSD
  58.     baudrate                    Y       Y       Y
  59.     erasechar                   Y       Y       Y
  60.     has_ic                      Y       Y       Y
  61.     has_il                      Y       Y       Y
  62.     killchar                    Y       Y       Y
  63.     longname                    Y       Y       Y
  64.     termattrs                   Y       Y       Y
  65.     termname                    Y       Y       Y
  66.     erasewchar                  Y       Y       Y
  67.     killwchar                   Y       Y       Y
  68.     term_attrs                  Y       Y       Y
  69.     wordchar                    -       -       -
  70.  
  71. **man-end****************************************************************/
  72.  
  73. #include <string.h>
  74. #include <limits.h>
  75.  
  76. int baudrate(void)
  77. {
  78.     PDC_LOG(("baudrate() - called\n"));
  79.  
  80.     return INT_MAX;
  81. }
  82.  
  83. char erasechar(void)
  84. {
  85.     PDC_LOG(("erasechar() - called\n"));
  86.  
  87.     return _ECHAR;      /* character delete char (^H) */
  88. }
  89.  
  90. bool has_ic(void)
  91. {
  92.     PDC_LOG(("has_ic() - called\n"));
  93.  
  94.     return TRUE;
  95. }
  96.  
  97. bool has_il(void)
  98. {
  99.     PDC_LOG(("has_il() - called\n"));
  100.  
  101.     return TRUE;
  102. }
  103.  
  104. char killchar(void)
  105. {
  106.     PDC_LOG(("killchar() - called\n"));
  107.  
  108.     return _DLCHAR;     /* line delete char (^U) */
  109. }
  110.  
  111. char *longname(void)
  112. {
  113.     PDC_LOG(("longname() - called\n"));
  114.  
  115.     return ttytype + 9; /* skip "pdcurses|" */
  116. }
  117.  
  118. chtype termattrs(void)
  119. {
  120.     PDC_LOG(("termattrs() - called\n"));
  121.  
  122.     return SP ? SP->termattrs : (chtype)0;
  123. }
  124.  
  125. attr_t term_attrs(void)
  126. {
  127.     PDC_LOG(("term_attrs() - called\n"));
  128.  
  129.     return SP ? SP->termattrs : (attr_t)0;
  130. }
  131.  
  132. char *termname(void)
  133. {
  134.     static char _termname[14] = "pdcurses";
  135.  
  136.     PDC_LOG(("termname() - called\n"));
  137.  
  138.     return _termname;
  139. }
  140.  
  141. char wordchar(void)
  142. {
  143.     PDC_LOG(("wordchar() - called\n"));
  144.  
  145.     return _DWCHAR;         /* word delete char */
  146. }
  147.  
  148. #ifdef PDC_WIDE
  149. int erasewchar(wchar_t *ch)
  150. {
  151.     PDC_LOG(("erasewchar() - called\n"));
  152.  
  153.     if (!ch)
  154.         return ERR;
  155.  
  156.     *ch = (wchar_t)_ECHAR;
  157.  
  158.     return OK;
  159. }
  160.  
  161. int killwchar(wchar_t *ch)
  162. {
  163.     PDC_LOG(("killwchar() - called\n"));
  164.  
  165.     if (!ch)
  166.         return ERR;
  167.  
  168.     *ch = (wchar_t)_DLCHAR;
  169.  
  170.     return OK;
  171. }
  172. #endif
  173.