jim

Simple, lightweight, modal, vim-inspired text editor
git clone git://git.janpasierb.com/jim.git
Log | Files | Refs | README | LICENSE

jim.h (1998B)


      1 #ifndef HEADER_JIM
      2 #define HEADER_JIM
      3 
      4 #define _DEFAULT_SOURCE
      5 #define _BSD_SOURCE
      6 #define _GNU_SOURCE
      7 
      8 #include<termios.h>
      9 
     10 #define JIM_VER "0.0.1"
     11 #define EOF_PLACEHOLDER "+"
     12 
     13 #define CTRL_KEY(k) ((k) & 0x1F)
     14 
     15 #define CURSOR_TOP "\x1b[H"
     16 
     17 enum editorKey {
     18     DEL             = '\x08',
     19     DEL_NOR         = 'x',
     20     ESCAPE          = '\x1b',
     21     BACKSPACE       = '\x7f',
     22     RETURN          = '\r',
     23 	REPLACE			= 'r',
     24     QUIT            = 'q',
     25     NEWLINE_BELOW   = 'o',
     26     NEWLINE_ABOVE   = 'O',
     27     LEFT            = 'h',
     28     DOWN            = 'j',
     29     UP              = 'k',
     30     RIGHT           = 'l',
     31     GOTO            = 'g',
     32     FILE_BOTTOM     = 'G',
     33     SCREEN_POS      = 'z',
     34     SAVE            = 's',
     35     S               = 'S',
     36     T               = 't',
     37     B               = 'b',
     38     F               = 'f',
     39     NEXT            = 'n',
     40     PREVIOUS        = 'p',
     41     INS             = 'i',
     42     INSERT_LINE     = 'I',
     43     APPEND          = 'a',
     44     APPEND_LINE     = 'A',
     45     DELETE_LINE     = 'd',
     46     LINE_START      = '0',
     47     LINE_END        = '$',
     48     COLON           = ':',
     49     PERIOD          = '.',
     50     FORCE           = '!',
     51     SEARCH          = '/',
     52     SINGLE_QUOTE    = '\'',
     53     DOUBLE_QUOTE    = '"',
     54     BACKSLASH       = '\\',
     55     LESS_THAN       = '<',
     56     MORE_THAN       = '>',
     57     CONTROL         = '@',
     58     NONPRINTABLE    = '?'
     59 };
     60 
     61 enum editorMode {
     62     NORMAL,
     63     INSERT,
     64     COMMAND
     65 };
     66 
     67 typedef struct erow {
     68     int idx;
     69     int size;
     70     int rsize;
     71     char* chars;
     72     char* render;
     73     unsigned char* hl;
     74     int hl_open_comment;
     75 } erow;
     76 
     77 struct editorConfig {
     78     int cx, cy;
     79     int rx;
     80     int rowoff;
     81     int coloff;
     82     int screenrows;
     83     int screencols;
     84     int numrows;
     85     int dirty;
     86     int isr;
     87     int isbold;
     88 	int isreplace;
     89     erow* row;
     90     char* filename;
     91     char statusmsg[80];
     92     char clusterkey;
     93     enum editorMode mode;
     94     struct termios orig_termios;
     95     struct editorSyntax* syntax;
     96 };
     97 
     98 extern struct editorConfig E;
     99 
    100 #endif