29 #ifndef TEXT_H |
29 #ifndef TEXT_H |
30 #define TEXT_H |
30 #define TEXT_H |
31 |
31 |
32 #include "../ui/text.h" |
32 #include "../ui/text.h" |
33 #include "toolkit.h" |
33 #include "toolkit.h" |
34 #include <ucx/list.h> |
34 #include <cx/list.h> |
35 |
35 |
36 #ifdef __cplusplus |
36 #ifdef __cplusplus |
37 extern "C" { |
37 extern "C" { |
38 #endif |
38 #endif |
39 |
39 |
40 #define UI_TEXTBUF_INSERT 0 |
40 #define UI_TEXTBUF_INSERT 0 |
41 #define UI_TEXTBUF_DELETE 1 |
41 #define UI_TEXTBUF_DELETE 1 |
42 typedef struct UiTextBufOp { |
42 typedef struct UiTextBufOp UiTextBufOp; |
|
43 struct UiTextBufOp { |
|
44 UiTextBufOp *prev; |
|
45 UiTextBufOp *next; |
43 int type; // UI_TEXTBUF_INSERT, UI_TEXTBUF_DELETE |
46 int type; // UI_TEXTBUF_INSERT, UI_TEXTBUF_DELETE |
44 int start; |
47 int start; |
45 int end; |
48 int end; |
46 int len; |
49 int len; |
47 char *text; |
50 char *text; |
48 } UiTextBufOp; |
51 }; |
49 |
52 |
50 typedef struct UiUndoMgr { |
53 typedef struct UiUndoMgr { |
51 UcxList *begin; |
54 UiTextBufOp *begin; |
52 UcxList *cur; |
55 UiTextBufOp *end; |
53 int length; |
56 UiTextBufOp *cur; |
54 int event; |
57 int length; |
|
58 int event; |
55 } UiUndoMgr; |
59 } UiUndoMgr; |
56 |
60 |
57 typedef struct UiTextArea { |
61 typedef struct UiTextArea { |
58 UiContext *ctx; |
62 UiContext *ctx; |
59 int last_selection_state; |
63 int last_selection_state; |
67 int ui_textarea_position(UiText *text); |
71 int ui_textarea_position(UiText *text); |
68 void ui_textarea_selection(UiText *text, int *begin, int *end); |
72 void ui_textarea_selection(UiText *text, int *begin, int *end); |
69 int ui_textarea_length(UiText *text); |
73 int ui_textarea_length(UiText *text); |
70 |
74 |
71 UiUndoMgr* ui_create_undomgr(); |
75 UiUndoMgr* ui_create_undomgr(); |
|
76 void ui_destroy_undomgr(UiUndoMgr *mgr); |
72 void ui_text_selection_callback( |
77 void ui_text_selection_callback( |
73 Widget widget, |
78 Widget widget, |
74 UiTextArea *textarea, |
79 UiTextArea *textarea, |
75 XtPointer data); |
80 XtPointer data); |
76 void ui_text_modify_callback(Widget widget, UiVar *var, XtPointer data); |
81 void ui_text_modify_callback(Widget widget, UiVar *var, XtPointer data); |