/[LeafOK_CVS]/lbbs/include/io.h
ViewVC logotype

Diff of /lbbs/include/io.h

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 1.21 by sysadm, Mon Jun 9 15:39:05 2025 UTC Revision 1.32 by sysadm, Sun Jan 4 03:45:54 2026 UTC
# Line 1  Line 1 
1  /***************************************************************************  /* SPDX-License-Identifier: GPL-3.0-or-later */
2                                                          io.h  -  description  /*
3                                                           -------------------   * io
4          Copyright            : (C) 2004-2025 by Leaflet   *   - basic terminal-based user input / output features
5          Email                : leaflet@leafok.com   *
6   ***************************************************************************/   * Copyright (C) 2004-2026  Leaflet <leaflet@leafok.com>
7     */
 /***************************************************************************  
  *                                                                         *  
  *   This program is free software; you can redistribute it and/or modify  *  
  *   it under the terms of the GNU General Public License as published by  *  
  *   the Free Software Foundation; either version 3 of the License, or     *  
  *   (at your option) any later version.                                   *  
  *                                                                         *  
  ***************************************************************************/  
8    
9  #ifndef _IO_H_  #ifndef _IO_H_
10  #define _IO_H_  #define _IO_H_
11    
12    #include <iconv.h>
13  #include <stdio.h>  #include <stdio.h>
14    
15  #define CR '\r'  enum io_key_t
16  #define LF '\n'  {
17  #define BACKSPACE '\b'      CR = '\r',
18  #define BELL '\b'      LF = '\n',
19  #define KEY_TAB 9      BACKSPACE = '\b',
20  #define KEY_ESC 27      BELL = '\7',
21  #define KEY_SPACE '\040'      KEY_TAB = '\t',
22        KEY_ESC = '\033',
23  #ifndef EXTEND_KEY      KEY_SPACE = '\040',
24  #define EXTEND_KEY  
25        // Expand key
26  #define KEY_NULL 0xffff      KEY_NULL = 0xffff,
27  #define KEY_TIMEOUT 0xfffe      KEY_TIMEOUT = 0xfffe,
28  #define KEY_CONTROL 0xff      KEY_CONTROL = 0xff,
29  #define KEY_UP 0x0101      KEY_UP = 0x0101,
30  #define KEY_DOWN 0x0102      KEY_DOWN = 0x0102,
31  #define KEY_RIGHT 0x0103      KEY_RIGHT = 0x0103,
32  #define KEY_LEFT 0x0104      KEY_LEFT = 0x0104,
33  #define KEY_CSI 0x011b // ESC ESC      KEY_CSI = 0x011b, // ESC ESC
34  #define KEY_HOME 0x0201      KEY_HOME = 0x0201,
35  #define KEY_INS 0x0202      KEY_INS = 0x0202,
36  #define KEY_DEL 0x0203      KEY_DEL = 0x0203,
37  #define KEY_END 0x0204      KEY_END = 0x0204,
38  #define KEY_PGUP 0x0205      KEY_PGUP = 0x0205,
39  #define KEY_PGDN 0x0206      KEY_PGDN = 0x0206,
40    
41  #define KEY_F1 0x0207      KEY_F1 = 0x0207,
42  #define KEY_F2 0x0208      KEY_F2 = 0x0208,
43  #define KEY_F3 0x0209      KEY_F3 = 0x0209,
44  #define KEY_F4 0x020a      KEY_F4 = 0x020a,
45  #define KEY_F5 0x020b      KEY_F5 = 0x020b,
46  #define KEY_F6 0x020c      KEY_F6 = 0x020c,
47  #define KEY_F7 0x020d      KEY_F7 = 0x020d,
48  #define KEY_F8 0x020e      KEY_F8 = 0x020e,
49  #define KEY_F9 0x020f      KEY_F9 = 0x020f,
50  #define KEY_F10 0x0210      KEY_F10 = 0x0210,
51  #define KEY_F11 0x0211      KEY_F11 = 0x0211,
52  #define KEY_F12 0x0212      KEY_F12 = 0x0212,
53    
54  #define KEY_SHIFT_F1 0x0213      KEY_SHIFT_F1 = 0x0213,
55  #define KEY_SHIFT_F2 0x0214      KEY_SHIFT_F2 = 0x0214,
56  #define KEY_SHIFT_F3 0x0215      KEY_SHIFT_F3 = 0x0215,
57  #define KEY_SHIFT_F4 0x0216      KEY_SHIFT_F4 = 0x0216,
58  #define KEY_SHIFT_F5 0x0217      KEY_SHIFT_F5 = 0x0217,
59  #define KEY_SHIFT_F6 0x0218      KEY_SHIFT_F6 = 0x0218,
60  #define KEY_SHIFT_F7 0x0219      KEY_SHIFT_F7 = 0x0219,
61  #define KEY_SHIFT_F8 0x021a      KEY_SHIFT_F8 = 0x021a,
62  #define KEY_SHIFT_F9 0x021b      KEY_SHIFT_F9 = 0x021b,
63  #define KEY_SHIFT_F10 0x021c      KEY_SHIFT_F10 = 0x021c,
64  #define KEY_SHIFT_F11 0x021d      KEY_SHIFT_F11 = 0x021d,
65  #define KEY_SHIFT_F12 0x021e      KEY_SHIFT_F12 = 0x021e,
66    
67  #define KEY_CTRL_F1 0x021f      KEY_CTRL_F1 = 0x021f,
68  #define KEY_CTRL_F2 0x0220      KEY_CTRL_F2 = 0x0220,
69  #define KEY_CTRL_F3 0x0221      KEY_CTRL_F3 = 0x0221,
70  #define KEY_CTRL_F4 0x0222      KEY_CTRL_F4 = 0x0222,
71  #define KEY_CTRL_F5 0x0223      KEY_CTRL_F5 = 0x0223,
72  #define KEY_CTRL_F6 0x0224      KEY_CTRL_F6 = 0x0224,
73  #define KEY_CTRL_F7 0x0225      KEY_CTRL_F7 = 0x0225,
74  #define KEY_CTRL_F8 0x0226      KEY_CTRL_F8 = 0x0226,
75  #define KEY_CTRL_F9 0x0227      KEY_CTRL_F9 = 0x0227,
76  #define KEY_CTRL_F10 0x0228      KEY_CTRL_F10 = 0x0228,
77  #define KEY_CTRL_F11 0x0229      KEY_CTRL_F11 = 0x0229,
78  #define KEY_CTRL_F12 0x022a      KEY_CTRL_F12 = 0x022a,
79    
80  #define KEY_CTRL_UP 0x0230      KEY_CTRL_UP = 0x0230,
81  #define KEY_CTRL_DOWN 0x0231      KEY_CTRL_DOWN = 0x0231,
82  #define KEY_CTRL_RIGHT 0x0232      KEY_CTRL_RIGHT = 0x0232,
83  #define KEY_CTRL_LEFT 0x0233      KEY_CTRL_LEFT = 0x0233,
84  #define KEY_CTRL_HOME 0x0234      KEY_CTRL_HOME = 0x0234,
85  #define KEY_CTRL_END 0x0235      KEY_CTRL_END = 0x0235,
86    };
 #endif // EXPAND_KEY  
87    
88  #define Ctrl(C) ((C) - 'A' + 1)  #define Ctrl(C) ((C) - 'A' + 1)
89    
90  #define DOECHO (1)  enum io_echo_t
91  #define NOECHO (0)  {
92        NOECHO = 0,
93        DOECHO = 1,
94    };
95    
96    enum io_iconv_t
97    {
98        CHARSET_MAX_LEN = 20,
99    };
100    
101  extern int prints(const char *format, ...);  extern const char BBS_default_charset[CHARSET_MAX_LEN + 1];
102    extern char stdio_charset[CHARSET_MAX_LEN + 1];
103    
104  extern int outc(char c);  extern int io_init(void);
105    extern void io_cleanup(void);
106    
107    extern int prints(const char *format, ...);
108    extern int outc(char c);
109  extern int iflush(void);  extern int iflush(void);
110    
111  extern int igetch(int timeout);  extern int igetch(int timeout);
   
112  extern int igetch_t(int sec);  extern int igetch_t(int sec);
   
113  extern void igetch_reset(void);  extern void igetch_reset(void);
114    
115    extern int io_buf_conv(iconv_t cd, char *p_buf, int *p_buf_len, int *p_buf_offset, char *p_conv, size_t conv_size, int *p_conv_len);
116    extern int io_conv_init(const char *charset);
117    extern int io_conv_cleanup(void);
118    
119  #endif //_IO_H_  #endif //_IO_H_


Legend:
Removed lines/characters  
Changed lines/characters
  Added lines/characters

webmaster@leafok.com
ViewVC Help
Powered by ViewVC 1.3.0-beta1