Main Page | Class Hierarchy | Class List | File List | Class Members | File Members

htio.h

Go to the documentation of this file.
00001 /*
00002  *      HT Editor
00003  *      io.h
00004  *
00005  *      Copyright (C) 1999-2002 Stefan Weyergraf (stefan@weyergraf.de)
00006  *
00007  *      This program is free software; you can redistribute it and/or modify
00008  *      it under the terms of the GNU General Public License version 2 as
00009  *      published by the Free Software Foundation.
00010  *
00011  *      This program is distributed in the hope that it will be useful,
00012  *      but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  *      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014  *      GNU General Public License for more details.
00015  *
00016  *      You should have received a copy of the GNU General Public License
00017  *      along with this program; if not, write to the Free Software
00018  *      Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
00019  */
00020 
00021 #ifndef __IO_H__
00022 #define __IO_H__
00023 
00024 #include "global.h"
00025 
00026 // include sys/types.h _before_ dirent.h because Darwin needs this (!)
00027 #include <sys/types.h>
00028 #include <dirent.h>
00029 #include <time.h>
00030 
00031 /*
00032  *      COMMON SYS
00033  */
00034  
00035 #ifdef PATH_MAX
00036 #define HT_NAME_MAX PATH_MAX            /* DJGPP at least */
00037 #else
00038 #ifdef MAXNAMLEN
00039 #define HT_NAME_MAX MAXNAMLEN           /* some BSD... */
00040 #else
00041 #ifdef NAME_MAX
00042 #define HT_NAME_MAX NAME_MAX            /* POSIX and friends... */
00043 #else
00044 #define HT_NAME_MAX 260                 /* unknown... */
00045 #endif
00046 #endif
00047 #endif
00048 
00049 #define HT_S_IFREG              0x1000
00050 #define HT_S_IFBLK              0x2000
00051 #define HT_S_IFCHR              0x3000
00052 #define HT_S_IFDIR              0x4000
00053 #define HT_S_IFFIFO             0x5000
00054 #define HT_S_IFLNK              0x6000
00055 #define HT_S_IFSOCK             0x7000
00056 
00057 #define HT_S_IFMT                       0xf000
00058 
00059 #define HT_S_ISREG(m)           (((m) & HT_S_IFMT) == HT_S_IFREG)
00060 #define HT_S_ISBLK(m)           (((m) & HT_S_IFMT) == HT_S_IFBLK)
00061 #define HT_S_ISCHR(m)           (((m) & HT_S_IFMT) == HT_S_IFCHR)
00062 #define HT_S_ISDIR(m)           (((m) & HT_S_IFMT) == HT_S_IFDIR)
00063 #define HT_S_ISFIFO(m)          (((m) & HT_S_IFMT) == HT_S_IFFIFO)
00064 #define HT_S_ISLNK(m)           (((m) & HT_S_IFMT) == HT_S_IFLNK)
00065 #define HT_S_ISSOCK(m)          (((m) & HT_S_IFMT) == HT_S_IFSOCK)
00066 
00067 #define HT_S_IRUSR            0x0100
00068 #define HT_S_IRGRP            0x0020
00069 #define HT_S_IROTH            0x0004
00070 #define HT_S_IWUSR            0x0080
00071 #define HT_S_IWGRP            0x0010
00072 #define HT_S_IWOTH            0x0002
00073 #define HT_S_IXUSR            0x0040
00074 #define HT_S_IXGRP            0x0008
00075 #define HT_S_IXOTH                      0x0001
00076 #define HT_S_IRWXU            (HT_S_IRUSR || HT_S_IWUSR || HT_S_IXUSR)
00077 #define HT_S_IRWXG            (HT_S_IRGRP || HT_S_IWGRP || HT_S_IXGRP)
00078 #define HT_S_IRWXO            (HT_S_IROTH || HT_S_IWOTH || HT_S_IXOTH)
00079 
00080 #define pstat_ctime                     0x00000001
00081 #define pstat_mtime                     0x00000002
00082 #define pstat_atime                     0x00000004
00083 #define pstat_uid                       0x00000008
00084 #define pstat_gid                       0x00000010
00085 #define pstat_mode_usr          0x00000020
00086 #define pstat_mode_grp          0x00000040
00087 #define pstat_mode_oth          0x00000080
00088 #define pstat_mode_r          0x00000100
00089 #define pstat_mode_w          0x00000200
00090 #define pstat_mode_x            0x00000400
00091 #define pstat_mode_type         0x00000800
00092 #define pstat_size                      0x00001000
00093 #define pstat_inode                     0x00002000
00094 #define pstat_cluster           0x00004000
00095 #define pstat_fsid                      0x00008000
00096 #define pstat_desc                      0x00010000
00097 
00098 #define pstat_mode_all          (pstat_mode_usr|pstat_mode_grp|pstat_mode_oth|pstat_mode_r|pstat_mode_w|pstat_mode_x|pstat_mode_type)
00099 
00100 /* sys_ipc_exec(...) options param flags */
00101 #define HT_IPC_NONBLOCKING      1
00102 
00103 /* system capabilities */
00104 #define SYSCAP_NONBLOCKING_IPC  1
00105 
00106 struct pstat_t {
00107         dword   caps;
00108         time_t  ctime;
00109         time_t  mtime;
00110         time_t  atime;
00111         int             uid;
00112         int             gid;
00113         mode_t  mode;   // S_ISUID, S_ISGID, S_I[RWX](USR|GRP|OTH)
00114         dword   size;
00115         dword   size_high;
00116         union {
00117                 dword   inode;
00118                 dword   cluster;
00119                 dword   fsid;
00120         };
00121         char desc[32];
00122 };
00123 
00124 struct pfind_t {
00125         const char *name;
00126         pstat_t stat;
00127         void *findstate;
00128 };
00129 
00130 typedef bool (*is_path_delim)(char c);
00131 
00132 int sys_ht_mode(int mode);
00133 
00134 int sys_basename(char *result, const char *filename);
00135 int sys_dirname(char *result, const char *filename);
00136 int sys_relname(char *result, const char *filename, const char *cwd);
00137 int sys_common_canonicalize(char *result, const char *in_name, const char *cwd, is_path_delim delim);
00138 char *sys_filename_suffix(const char *fn);
00139 int sys_tmpfile();
00140 
00141 /*
00142  *      COMMON CURSES
00143  */
00144 
00145 /* virtual colors */
00146 
00147 typedef int vc;
00148 
00149 #define VC_BLACK                        0
00150 #define VC_BLUE                 1
00151 #define VC_GREEN                        2
00152 #define VC_CYAN                 3
00153 #define VC_RED                          4
00154 #define VC_MAGENTA                      5
00155 #define VC_YELLOW                       6
00156 #define VC_WHITE                        7
00157 #define VC_TRANSPARENT          8
00158 
00159 #define VC_LIGHT(vc) ((vc) | 0x80)
00160 
00161 #define VC_GET_LIGHT(vc) ((vc) & 0x80)
00162 #define VC_GET_BASECOLOR(vc) ((vc) & 0x7f)
00163 
00164 /* virtual color pairs (fg/bg) */
00165 
00166 typedef int vcp;
00167 
00168 #define VCP(vc_fg, vc_bg) (vcp)((vc_bg) | ((vc_fg)<<8))
00169 #define VCP_BACKGROUND(v) ((v) & 0xff)
00170 #define VCP_FOREGROUND(v) ((v>>8) & 0xff)
00171 
00172 vcp vcp_mix(vcp base, vcp layer);
00173 
00174 /*
00175  *      STRUCT drawbufch
00176  */
00177 
00178 struct drawbufch {
00179         int ch;
00180         int c;
00181 };
00182 
00183 /*
00184  *      CLASS genericdrawbuf
00185  */
00186 
00187 class genericdrawbuf {
00188 public:
00189         bounds size;
00190 
00191         genericdrawbuf();
00192         virtual ~genericdrawbuf();
00193 /* new */
00194         virtual void b_fill(int x, int y, int w, int h, int c, int ch);
00195                    int b_printf(int x, int y, int c, char *format, ...);
00196         virtual int b_print(int x, int y, int c, char *text);
00197         virtual int b_printw(int x, int y, int c, int *text);
00198         virtual void b_printchar(int x, int y, int c, int ch);
00199         virtual int b_lprint(int x, int y, int c, int l, char *text);
00200         virtual int b_lprintw(int x, int y, int c, int l, int *text);
00201         virtual void b_resize(int rw, int rh);
00202         virtual void b_rmove(int rx, int ry);
00203         virtual void b_setbounds(bounds *b);
00204 /* graphical extension */
00205         virtual void b_line(int px1, int py1, int px2, int py2, int c);
00206         virtual void b_putpixel(int px, int py, int c);
00207         virtual void text_to_pixel_coord(int tx, int ty, int *px, int *py);
00208         virtual void pixel_to_text_coord(int px, int py, int *tx, int *ty);
00209 };
00210 
00211 /*
00212  *      CLASS drawbuf
00213  */
00214 
00215 class drawbuf: public genericdrawbuf {
00216 public:
00217         drawbufch *buf;
00218 
00219         drawbuf(bounds *b);
00220         ~drawbuf();
00221         
00222 /* overwritten */
00223         virtual void b_fill(int x, int y, int w, int h, int c, int ch);
00224         virtual void b_printchar(int x, int y, int c, int ch);
00225         virtual int b_lprint(int x, int y, int c, int l, char *text);
00226         virtual int b_lprintw(int x, int y, int c, int l, int *text);
00227         virtual void b_setbounds(bounds *b);
00228 };
00229 
00230 /*
00231  *      COMMON KEYB
00232  */
00233  
00234 enum ht_key {
00235 K_FIRST = 0,
00236 
00237 /* ASCII > 0 */
00238 
00239 K_Backspace             = 1,
00240 K_BackTab                       = 2,
00241 
00242 K_Tab                   = '\t',
00243 K_Return                        = '\n',
00244 K_Escape                        = '\e',
00245 
00246 K_Space                 = ' ',
00247 K_ExclamationPoint      = '!',
00248 K_DoubleQuote           = '"',
00249 K_Hash                  = '#',
00250 K_Dollar                        = '$',
00251 K_Percent                       = '%',
00252 K_Ampersand             = '&',
00253 K_Quote                 = '\'',
00254 K_LParen                        = '(',
00255 K_RParen                        = ')',
00256 K_Star                  = '*',
00257 K_Plus                  = '+',
00258 K_Comma                 = ',',
00259 K_Dash                  = '-',
00260 K_Period                        = '.',
00261 K_Slash                 = '/',
00262 K_Colon                 = ':',
00263 K_SemiColon             = ';',
00264 K_LAngle                        = '<',
00265 K_Equals                        = '=',
00266 K_RAngle                        = '>',
00267 K_QuestionMark          = '?',
00268 K_At                            = '@',
00269 
00270 K_LBracket              = '[',
00271 K_BackSlash             = '\'',
00272 K_RBracket              = ']',
00273 K_Caret                 = '^',
00274 K_UnderScore            = '_',
00275 K_BackQuote             = '`',
00276 K_LBrace                        = '{',
00277 K_Pipe                  = '|',
00278 K_RBrace                        = '}',
00279 K_Tilde                 = '~',
00280 
00281 K_BackTick              = 'ï',
00282 
00283 K_0                             = '0',
00284 K_1                             = '1',
00285 K_2                             = '2',
00286 K_3                             = '3',
00287 K_4                             = '4',
00288 K_5                             = '5',
00289 K_6                             = '6',
00290 K_7                             = '7',
00291 K_8                             = '8',
00292 K_9                             = '9',
00293 
00294 K_A                             = 'a',
00295 K_B                             = 'b',
00296 K_C                             = 'c',
00297 K_D                             = 'd',
00298 K_E                             = 'e',
00299 K_F                             = 'f',
00300 K_G                             = 'g',
00301 K_H                             = 'h',
00302 K_I                             = 'i',
00303 K_J                             = 'j',
00304 K_K                             = 'k',
00305 K_L                             = 'l',
00306 K_M                             = 'm',
00307 K_N                             = 'n',
00308 K_O                             = 'o',
00309 K_P                             = 'p',
00310 K_Q                             = 'q',
00311 K_R                             = 'r',
00312 K_S                             = 's',
00313 K_T                             = 't',
00314 K_U                             = 'u',
00315 K_V                             = 'v',
00316 K_W                             = 'w',
00317 K_X                             = 'x',
00318 K_Y                             = 'y',
00319 K_Z                             = 'z',
00320 
00321 K_Shift_A                       = 'A',
00322 K_Shift_B                       = 'B',
00323 K_Shift_C                       = 'C',
00324 K_Shift_D                       = 'D',
00325 K_Shift_E                       = 'E',
00326 K_Shift_F                       = 'F',
00327 K_Shift_G                       = 'G',
00328 K_Shift_H                       = 'H',
00329 K_Shift_I                       = 'I',
00330 K_Shift_J                       = 'J',
00331 K_Shift_K                       = 'K',
00332 K_Shift_L                       = 'L',
00333 K_Shift_M                       = 'M',
00334 K_Shift_N                       = 'N',
00335 K_Shift_O                       = 'O',
00336 K_Shift_P                       = 'P',
00337 K_Shift_Q                       = 'Q',
00338 K_Shift_R                       = 'R',
00339 K_Shift_S                       = 'S',
00340 K_Shift_T                       = 'T',
00341 K_Shift_U                       = 'U',
00342 K_Shift_V                       = 'V',
00343 K_Shift_W                       = 'W',
00344 K_Shift_X                       = 'X',
00345 K_Shift_Y                       = 'Y',
00346 K_Shift_Z                       = 'Z',
00347 
00348 K_LASTASCII             = 0xff,
00349 
00350 /* Special keys start here */
00351 
00352 K_Alt_Escape,
00353 K_Alt_Backspace,
00354 K_Alt_Tab,
00355 K_Alt_Enter,
00356 
00357 K_Left,
00358 K_Right,
00359 K_Up,
00360 K_Down,
00361 K_PageUp,
00362 K_PageDown,
00363 K_Home,
00364 K_End,
00365 K_Insert,
00366 K_Delete,
00367 
00368 K_Control_Left,
00369 K_Control_Right,
00370 K_Control_Up,
00371 K_Control_Down,
00372 K_Control_PageUp,
00373 K_Control_PageDown,
00374 K_Control_Home,
00375 K_Control_End,
00376 K_Control_Insert,
00377 K_Control_Delete,
00378 
00379 K_Control_Shift_Left,
00380 K_Control_Shift_Right,
00381 
00382 K_Shift_Left,
00383 K_Shift_Right,
00384 K_Shift_Up,
00385 K_Shift_Down,
00386 K_Shift_PageUp,
00387 K_Shift_PageDown,
00388 K_Shift_Home,
00389 K_Shift_End,
00390 K_Shift_Insert,
00391 K_Shift_Delete,
00392 
00393 K_Control_A,
00394 K_Control_B,
00395 K_Control_C,
00396 K_Control_D,
00397 K_Control_E,
00398 K_Control_F,
00399 K_Control_G,
00400 K_Control_H,
00401 K_Control_I,
00402 K_Control_J,
00403 K_Control_K,
00404 K_Control_L,
00405 K_Control_M,
00406 K_Control_N,
00407 K_Control_O,
00408 K_Control_P,
00409 K_Control_Q,
00410 K_Control_R,
00411 K_Control_S,
00412 K_Control_T,
00413 K_Control_U,
00414 K_Control_V,
00415 K_Control_W,
00416 K_Control_X,
00417 K_Control_Y,
00418 K_Control_Z,
00419 
00420 K_Alt_A,
00421 K_Alt_B,
00422 K_Alt_C,
00423 K_Alt_D,
00424 K_Alt_E,
00425 K_Alt_F,
00426 K_Alt_G,
00427 K_Alt_H,
00428 K_Alt_I,
00429 K_Alt_J,
00430 K_Alt_K,
00431 K_Alt_L,
00432 K_Alt_M,
00433 K_Alt_N,
00434 K_Alt_O,
00435 K_Alt_P,
00436 K_Alt_Q,
00437 K_Alt_R,
00438 K_Alt_S,
00439 K_Alt_T,
00440 K_Alt_U,
00441 K_Alt_V,
00442 K_Alt_W,
00443 K_Alt_X,
00444 K_Alt_Y,
00445 K_Alt_Z,
00446 
00447 K_Alt_1,
00448 K_Alt_2,
00449 K_Alt_3,
00450 K_Alt_4,
00451 K_Alt_5,
00452 K_Alt_6,
00453 K_Alt_7,
00454 K_Alt_8,
00455 K_Alt_9,
00456 K_Alt_0,
00457 
00458 K_F1,
00459 K_F2,
00460 K_F3,
00461 K_F4,
00462 K_F5,
00463 K_F6,
00464 K_F7,
00465 K_F8,
00466 K_F9,
00467 K_F10,
00468 K_F11,
00469 K_F12,
00470 
00471 K_Shift_F1,
00472 K_Shift_F2,
00473 K_Shift_F3,
00474 K_Shift_F4,
00475 K_Shift_F5,
00476 K_Shift_F6,
00477 K_Shift_F7,
00478 K_Shift_F8,
00479 K_Shift_F9,
00480 K_Shift_F10,
00481 K_Shift_F11,
00482 K_Shift_F12,
00483 
00484 K_Control_F1,
00485 K_Control_F2,
00486 K_Control_F3,
00487 K_Control_F4,
00488 K_Control_F5,
00489 K_Control_F6,
00490 K_Control_F7,
00491 K_Control_F8,
00492 K_Control_F9,
00493 K_Control_F10,
00494 K_Control_F11,
00495 K_Control_F12,
00496 
00497 K_Alt_F1,
00498 K_Alt_F2,
00499 K_Alt_F3,
00500 K_Alt_F4,
00501 K_Alt_F5,
00502 K_Alt_F6,
00503 K_Alt_F7,
00504 K_Alt_F8,
00505 K_Alt_F9,
00506 K_Alt_F10,
00507 K_Alt_F11,
00508 K_Alt_F12,
00509 
00510 K_LAST,
00511 K_INVALID = -1
00512 };
00513 
00514 #define K_COUNT                 ((int)K_LAST)
00515 
00516 ht_key ht_metakey(ht_key key);          /* generate ht_key for M+key from key */
00517 ht_key ht_unmetakey(ht_key metakey);    /* generate ht_key for key from M+key */
00518 
00519 void ht_set_key(ht_key key, int rawkey);
00520 
00521 ht_key ht_rawkey2key(int rawkey);
00522 
00523 #endif /* __IO_H__ */
00524 

Generated on Fri May 7 21:15:34 2004 by doxygen 1.3.5