lchat

A line oriented chat front end for ii.
git clone git://git.suckless.org/lchat
Log | Files | Refs | README

slackline.h (849B)


      1 #ifndef SLACKLINE_H
      2 #define SLACKLINE_H
      3 
      4 enum esc_seq {ESC_NONE, ESC, ESC_BRACKET, ESC_BRACKET_NUM};
      5 enum mode {SL_DEFAULT, SL_EMACS, SL_VI};
      6 
      7 struct slackline {
      8 	/* buffer */
      9 	char *buf;
     10 	char *ptr;	/* ptr of cursor */
     11 	char *last;	/* ptr of last byte of string */
     12 	size_t bufsize;
     13 
     14 	/* byte positions */
     15 	size_t bcur;	/* first byte of the rune of the cursor */
     16 	size_t blen;	/* amount of bytes of current string */
     17 
     18 	/* rune positions */
     19 	size_t rcur;	/* cursor */
     20 	size_t rlen;	/* amount of runes */
     21 
     22 	enum esc_seq esc;
     23 	char nummod;
     24 
     25 	/* UTF-8 handling */
     26 	char ubuf[6];	/* UTF-8 buffer */
     27 	size_t ubuf_len;
     28 
     29 	enum mode mode;
     30 };
     31 
     32 struct slackline *sl_init(void);
     33 void sl_free(struct slackline *sl);
     34 void sl_reset(struct slackline *sl);
     35 int sl_keystroke(struct slackline *sl, int key);
     36 void sl_mode(struct slackline *sl, enum mode mode);
     37 
     38 #endif