add utf8_char_t struct
This commit is contained in:
+46
-5
@@ -7,6 +7,12 @@
|
||||
|
||||
#include "lisp.h"
|
||||
|
||||
|
||||
typedef struct{
|
||||
unsigned char c[4];
|
||||
char len;
|
||||
} utf_8_char_t;
|
||||
|
||||
/**
|
||||
* \struct erow
|
||||
* \brief Store one editor row
|
||||
@@ -16,8 +22,8 @@
|
||||
typedef struct erow {
|
||||
int size; /**< Size of the line */
|
||||
int rsize; /**< Size of the render line */
|
||||
char *chars; /**< Characters of the line */
|
||||
char *render; /**< The actual line we will print */
|
||||
utf_8_char_t *chars; /**< Characters of the line */
|
||||
utf_8_char_t *render; /**< The actual line we will print */
|
||||
} erow;
|
||||
|
||||
enum editorStatus_e {
|
||||
@@ -31,10 +37,45 @@ struct const_t {
|
||||
int QUIT_TIMES;
|
||||
};
|
||||
|
||||
// Key types
|
||||
typedef enum {
|
||||
KEY_CHAR, // Regular character or UTF-8
|
||||
KEY_CTRL, // Ctrl+letter
|
||||
KEY_ALT, // Alt+letter
|
||||
KEY_ARROW, // Arrow keys
|
||||
KEY_FUNCTION, // Function keys
|
||||
KEY_SPECIAL, // Tab, Enter, ESC, Backspace, etc.
|
||||
KEY_NAVIGATION, // Home, End, PgUp, PgDn, Insert, Delete
|
||||
KEY_UNKNOWN
|
||||
} KeyType;
|
||||
|
||||
// Modifiers
|
||||
typedef enum {
|
||||
MOD_NONE = 0,
|
||||
MOD_SHIFT = 1,
|
||||
MOD_ALT = 2,
|
||||
MOD_CTRL = 4
|
||||
} KeyModifier;
|
||||
|
||||
// Key information structure
|
||||
typedef struct {
|
||||
KeyType type;
|
||||
int modifiers; // Bitmask of KeyModifier
|
||||
union {
|
||||
unsigned int codepoint; // For KEY_CHAR
|
||||
char ctrl_char; // For KEY_CTRL (A-Z)
|
||||
char alt_char; // For KEY_ALT
|
||||
char arrow; // For KEY_ARROW (U/D/L/R)
|
||||
int function_num; // For KEY_FUNCTION (1-12)
|
||||
char special; // For KEY_SPECIAL and KEY_NAVIGATION
|
||||
} data;
|
||||
utf_8_char_t c; // Raw bytes
|
||||
} KeyInfo;
|
||||
|
||||
|
||||
struct keyBind_t {
|
||||
char *key_sequence;
|
||||
KeyInfo *key_sequence;
|
||||
Lisp command;
|
||||
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -77,7 +118,7 @@ struct editorConfig {
|
||||
* */
|
||||
|
||||
struct abuf {
|
||||
char *b; /**< Text that will be printed */
|
||||
unsigned char *b; /**< Text that will be printed */
|
||||
int len; /**< Length of the text */
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user