Subversion Repositories Kolibri OS

Rev

Rev 6601 | Rev 6615 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 6601 Rev 6612
1
#ifndef KOLIBRI_EDITOR_H
1
#ifndef KOLIBRI_EDITOR_H
2
#define KOLIBRI_EDITOR_H
2
#define KOLIBRI_EDITOR_H
3
 
3
 
4
// (êîëè÷åñòâî ñèìâîëîâ â íîâîì äîêóìåíòå + 2)
4
// (êîëè÷åñòâî ñèìâîëîâ â íîâîì äîêóìåíòå + 2)
5
#define TE_MAXCHARS 100002
5
#define TE_MAXCHARS 100002
6
// ìàêñèìàëüíûé ðàçìåð ôàéëà ñèíòàêñèñà
6
// ìàêñèìàëüíûé ðàçìåð ôàéëà ñèíòàêñèñà
7
#define TE_MAX_SYNTAX_FILESIZE 410000
7
#define TE_MAX_SYNTAX_FILESIZE 410000
8
// buffer for copy|paste
8
// buffer for copy|paste
9
#define TE_BUF_SIZE  4096
9
#define TE_BUF_SIZE  4096
10
typedef void (*editor_callback)(void);
10
typedef void (*editor_callback)(void);
11
 
11
 
12
struct __attribute__ ((__packed__)) editor_symbol {
12
struct __attribute__ ((__packed__)) editor_symbol {
13
	uint8_t     c;      //  +0 ñèìâîë
13
	uint8_t     c;      //  +0 ñèìâîë
14
	uint8_t     col;    //  +1 öâåò
14
	uint8_t     col;    //  +1 öâåò
15
	struct editor_symbol   *prev;   //  +2
15
	struct editor_symbol   *prev;   //  +2
16
	struct editor_symbol   *next;   //  +6 óêàçàòåëè
16
	struct editor_symbol   *next;   //  +6 óêàçàòåëè
17
	uint32_t    tc;     //  +10 âðåì. ñîçäàíèÿ
17
	uint32_t    tc;     //  +10 âðåì. ñîçäàíèÿ
18
	uint32_t    td;     // +14 âðåì. óäàëåíèÿ
18
	uint32_t    td;     // +14 âðåì. óäàëåíèÿ
19
};
19
};
20
 
20
 
21
/// ñòðóêòóðà òåêñòîâîãî ðåäàêòîðà
21
/// ñòðóêòóðà òåêñòîâîãî ðåäàêòîðà
22
typedef struct __attribute__ ((__packed__)) {
22
typedef struct __attribute__ ((__packed__)) {
23
    uint32_t    x_pos;  //0
23
    uint32_t    x_pos;  //0
24
    uint32_t    y_pos;  //50
24
    uint32_t    y_pos;  //50
25
    uint32_t    width;  //440
25
    uint32_t    width;  //440
26
    uint32_t    hight;  //150
26
    uint32_t    hight;  //150
27
    uint32_t    w_pane;      //30 øèðèíà ïàíåëè â îêíå
27
    uint32_t    w_pane;      //30 øèðèíà ïàíåëè â îêíå, width of left pane with line numbers
28
    uint32_t    h_pane;      //25 âûñîòà ïàíåëè â îêíå
28
    uint32_t    h_pane;      //25 âûñîòà ïàíåëè â îêíå, hight of top pane with Rows, Cols Undo info
29
    uint32_t    width_sym;  //9 øèðèíà ñèìâîëà (çíàêîìåñòà) â îêíå
29
    uint32_t    width_sym;  //9 øèðèíà ñèìâîëà (çíàêîìåñòà) â îêíå
30
    uint32_t    hight_sym;  //16 âûñîòà ñèìâîëà (çíàêîìåñòà) â îêíå
30
    uint32_t    hight_sym;  //16 âûñîòà ñèìâîëà (çíàêîìåñòà) â îêíå
31
	uint8_t     drag_m;     // âûäåëåíèå îò ìûøè
31
	uint8_t     drag_m;     // âûäåëåíèå îò ìûøè
32
	uint8_t     drag_k;     // âûäåëåíèå îò êëàâèàòóðû
32
	uint8_t     drag_k;     // âûäåëåíèå îò êëàâèàòóðû
33
	uint32_t    sel_x0;     // ñòðóêòóðà âûäåëåíèÿ
33
	uint32_t    sel_x0;     // ñòðóêòóðà âûäåëåíèÿ
34
	uint32_t    sel_y0;
34
	uint32_t    sel_y0;
35
	uint32_t    sel_x1;
35
	uint32_t    sel_x1;
36
	uint32_t    sel_y1;
36
	uint32_t    sel_y1;
37
	uint32_t    seln_x0;    //äîïîëíèòåëüíàÿ ñòðóêòóðà âûäåëåíèÿ
37
	uint32_t    seln_x0;    //äîïîëíèòåëüíàÿ ñòðóêòóðà âûäåëåíèÿ
38
	uint32_t    seln_y0;
38
	uint32_t    seln_y0;
39
	uint32_t    seln_x1;
39
	uint32_t    seln_x1;
40
	uint32_t    seln_y1;
40
	uint32_t    seln_y1;
41
	struct editor_symbol   *tex;    // text memory pointer
41
	struct editor_symbol   *tex;    // text memory pointer
42
	struct editor_symbol   *tex_1;  // text first symbol pointer
42
	struct editor_symbol   *tex_1;  // text first symbol pointer
43
	struct editor_symbol   *tex_end;// text end memory pointer
43
	struct editor_symbol   *tex_end;// text end memory pointer
44
	uint32_t    cur_x;      //êîîðäèíàòà x êóðñîðà
44
	uint32_t    cur_x;      //êîîðäèíàòà x êóðñîðà
45
	uint32_t    cur_y;      //êîîðäèíàòà y êóðñîðà
45
	uint32_t    cur_y;      //êîîðäèíàòà y êóðñîðà
46
	uint32_t    max_chars;  // TE_MAXCHARS ;+86 ìàêñèìàëüíîå ÷èñëî ñèìâîëîâ â îäíîì äîêóìåíòå
46
	uint32_t    max_chars;  // TE_MAXCHARS ;+86 ìàêñèìàëüíîå ÷èñëî ñèìâîëîâ â îäíîì äîêóìåíòå
47
	uint32_t    count_colors_text; // 1 ;+90 êîëè÷åñòâî öâåòîâ òåêñòà
47
	uint32_t    count_colors_text; // 1 ;+90 êîëè÷åñòâî öâåòîâ òåêñòà
48
	uint32_t    count_key_words;   //+94 êîëëè÷åñòâî êëþ÷åâûõ ñëîâ
48
	uint32_t    count_key_words;   //+94 êîëëè÷åñòâî êëþ÷åâûõ ñëîâ
49
	color_t     color_cursor;   // 0x808080 ;+98 öâåò êóðñîðà
49
	color_t     color_cursor;   // 0x808080 ;+98 öâåò êóðñîðà
50
	color_t     color_wnd_capt; // 0x80 ;+102 öâåò ïîëåé âîêðóã îêíà
50
	color_t     color_wnd_capt; // 0x80 ;+102 öâåò ïîëåé âîêðóã îêíà
51
	color_t     color_wnd_work; // 0x0 ;+106 öâåò ôîíà îêíà
51
	color_t     color_wnd_work; // 0x0 ;+106 öâåò ôîíà îêíà
52
	color_t     color_wnd_bord; //0xd0d0d0 ;+110 öâåò òåêñòà íà ïîëÿõ
52
	color_t     color_wnd_bord; //0xd0d0d0 ;+110 öâåò òåêñòà íà ïîëÿõ
53
	color_t     color_select;   // 0x208080 ;+114 öâåò âûäåëåíèÿ
53
	color_t     color_select;   // 0x208080 ;+114 öâåò âûäåëåíèÿ
54
	color_t     color_cur_text; // 0xff0000 ;+118 öâåò ñèìâîëà ïîä êóðñîðîì
54
	color_t     color_cur_text; // 0xff0000 ;+118 öâåò ñèìâîëà ïîä êóðñîðîì
55
	color_t     color_wnd_text; // 0xffff00 ;+122 öâåò òåêñòà â îêíå
55
	color_t     color_wnd_text; // 0xffff00 ;+122 öâåò òåêñòà â îêíå
56
	char       *syntax_file;    // óêàçàòåëü íà íà÷àëî ôàéëà ñèíòàêñèñà
56
	char       *syntax_file;    // óêàçàòåëü íà íà÷àëî ôàéëà ñèíòàêñèñà
57
	uint32_t    syntax_file_size;   // TE_MAX_SYNTAX_FILESIZE ;+130 ìàêñèìàëüíûé ðàçìåð ôàéëà ñèíòàêñèñà
57
	uint32_t    syntax_file_size;   // TE_MAX_SYNTAX_FILESIZE ;+130 ìàêñèìàëüíûé ðàçìåð ôàéëà ñèíòàêñèñà
58
	void       *text_colors;    // óêàçàòåëü íà ìàññèâ öâåòîâ òåêñòà
58
	void       *text_colors;    // óêàçàòåëü íà ìàññèâ öâåòîâ òåêñòà
59
	char       *help_text_f1;   // óêàçàòåëü íà òåêñò ñïðàâêè (ïî íàæàòèè F1)
59
	char       *help_text_f1;   // óêàçàòåëü íà òåêñò ñïðàâêè (ïî íàæàòèè F1)
60
	int         help_id;	    // -1 ;+142 èäåíòèôèêàòîð äëÿ ñïðàâêè
60
	int         help_id;	    // -1 ;+142 èäåíòèôèêàòîð äëÿ ñïðàâêè
61
	void       *key_words_data; // óêàçàòåëü íà ñòðóêòóðû êëþ÷åâûõ ñëîâ TexColViv
61
	void       *key_words_data; // óêàçàòåëü íà ñòðóêòóðû êëþ÷åâûõ ñëîâ TexColViv
62
	uint32_t    tim_ch;     // êîëè÷åñòâî èçìåíåíèé â ôàéëå
62
	uint32_t    tim_ch;     // êîëè÷åñòâî èçìåíåíèé â ôàéëå
63
	uint32_t    tim_undo;   // êîëè÷åñòâî îòìåíåííûõ äåéñòâèé
63
	uint32_t    tim_undo;   // êîëè÷åñòâî îòìåíåííûõ äåéñòâèé
64
	uint32_t    tim_ls;     // âðåìÿ ïîñëåäíåãî ñîõðàíåíèÿ
64
	uint32_t    tim_ls;     // âðåìÿ ïîñëåäíåãî ñîõðàíåíèÿ
65
	uint32_t    tim_co;     // âðåìÿ ïîñëåäíåé öâåòîâîé ðàçìåòêè
65
	uint32_t    tim_co;     // âðåìÿ ïîñëåäíåé öâåòîâîé ðàçìåòêè
66
	void       *el_focus;   // óêàçàòåëü íà ïåðåìåííóþ ýëåìåíòà â ôîêóñå pointer to pointer**
66
	void       *el_focus;   // óêàçàòåëü íà ïåðåìåííóþ ýëåìåíòà â ôîêóñå pointer to pointer**
67
	uint8_t     err_save;   // îøèáêà ñîõðàíåíèÿ ôàéëà
67
	uint8_t     err_save;   // îøèáêà ñîõðàíåíèÿ ôàéëà
68
	uint8_t     panel_id;   // íîìåð îòêðûòîé ïàíåëè
68
	uint8_t     panel_id;   // íîìåð îòêðûòîé ïàíåëè
69
	uint8_t     key_new;    // ñèìâîë, êîòîðûé áóäåò äîáàâëÿòñÿ ñ êëàâèàòóðû
69
	uint8_t     key_new;    // ñèìâîë, êîòîðûé áóäåò äîáàâëÿòñÿ ñ êëàâèàòóðû
70
	uint8_t     symbol_new_line; // ascii 20 ñèìâîë çàâåðøåíèÿ ñòðîêè
70
	uint8_t     symbol_new_line; // ascii 20 ñèìâîë çàâåðøåíèÿ ñòðîêè
71
	scrollbar  *scr_w;      // âåðòèêàëüíûé ñêðîëëèíã != NULL
71
	scrollbar  *scr_w;      // âåðòèêàëüíûé ñêðîëëèíã != NULL
72
	scrollbar  *scr_h;      // ãîðèçîíòàëüíûé ñêðîëëèíã != NULL
72
	scrollbar  *scr_h;      // ãîðèçîíòàëüíûé ñêðîëëèíã != NULL
73
	char       *arr_key_pos;// óêàçàòåëü íà ìàññèâ ïîçèöèé êëþ÷åâûõ ñëîâ
73
	char       *arr_key_pos;// óêàçàòåëü íà ìàññèâ ïîçèöèé êëþ÷åâûõ ñëîâ
74
	char       *buffer;     // óêàçàòåëü íà áóôåð êîïèðîâàíèÿ/âñòàâêè != NULL, also size
74
	char       *buffer;     // óêàçàòåëü íà áóôåð êîïèðîâàíèÿ/âñòàâêè != NULL, also size
75
	char       *buffer_find;// óêàçàòåëü íà áóôåð äëÿ ïîèñêà (sized 302)
75
	char       *buffer_find;// óêàçàòåëü íà áóôåð äëÿ ïîèñêà (sized 302)
76
	uint8_t     cur_ins;    // 1 ðåæèì ðàáîòû êóðñîðà (îáû÷íûé èëè çàìåíà)
76
	uint8_t     cur_ins;    // 1 ðåæèì ðàáîòû êóðñîðà (îáû÷íûé èëè çàìåíà)
77
	uint8_t     mode_color; // 1 ðåæèì âûäåëåíèÿ ñëîâ öâåòîì (0-âûêë. 1-âêë.)
77
	uint8_t     mode_color; // 1 ðåæèì âûäåëåíèÿ ñëîâ öâåòîì (0-âûêë. 1-âêë.)
78
	uint8_t     mode_invis; // 0 ðåæèì ïîêàçà íåïå÷àòàåìûõ ñèìâîëîâ
78
	uint8_t     mode_invis; // 0 ðåæèì ïîêàçà íåïå÷àòàåìûõ ñèìâîëîâ
79
	uint8_t     gp_opt;     // 0 îïöèè âîçâðàùàåìûå ôóíêöèåé ted_get_pos_by_cursor
79
	uint8_t     gp_opt;     // 0 îïöèè âîçâðàùàåìûå ôóíêöèåé ted_get_pos_by_cursor
80
	editor_callback fun_on_key_ctrl_o;  // óêàçàòåëü íà ôóíêöèþ âûçûâàåìóþ ïðè íàæàòèè Ctrl+O (îòêðûòèå ôàéëà), can be NULL
80
	editor_callback fun_on_key_ctrl_o;  // óêàçàòåëü íà ôóíêöèþ âûçûâàåìóþ ïðè íàæàòèè Ctrl+O (îòêðûòèå ôàéëà), can be NULL
81
	editor_callback fun_on_key_ctrl_f;  // ... Ctrl+F (âûçîâà/ñêðûòèÿ ïàíåëè ïîèñêà)
81
	editor_callback fun_on_key_ctrl_f;  // ... Ctrl+F (âûçîâà/ñêðûòèÿ ïàíåëè ïîèñêà)
82
	editor_callback fun_on_key_ctrl_n;  // ... Ctrl+N (ñîçäàíèå íîâîãî äîêóìåíòà)
82
	editor_callback fun_on_key_ctrl_n;  // ... Ctrl+N (ñîçäàíèå íîâîãî äîêóìåíòà)
83
	editor_callback fun_on_key_ctrl_s;  // ... Ctrl+S
83
	editor_callback fun_on_key_ctrl_s;  // ... Ctrl+S
84
	uint32_t    buffer_size;// BUF_SIZE ðàçìåð áóôåðà êîïèðîâàíèÿ/âñòàâêè
84
	uint32_t    buffer_size;// BUF_SIZE ðàçìåð áóôåðà êîïèðîâàíèÿ/âñòàâêè
85
	editor_callback fun_find_err;       // óêàçàòåëü íà ôóíêöèþ âûçûâàåìóþ åñëè ïîèñê çàêîí÷èëñÿ íåóäà÷íî
85
	editor_callback fun_find_err;       // óêàçàòåëü íà ôóíêöèþ âûçûâàåìóþ åñëè ïîèñê çàêîí÷èëñÿ íåóäà÷íî
86
	editor_callback fun_init_synt_err;  // unused óêàçàòåëü íà ôóíêöèþ âûçûâàåìóþ ïðè îøèáî÷íîì îòêðûòèè ôàéëà ñèíòàêñèñà
86
	editor_callback fun_init_synt_err;  // unused óêàçàòåëü íà ôóíêöèþ âûçûâàåìóþ ïðè îøèáî÷íîì îòêðûòèè ôàéëà ñèíòàêñèñà
87
	editor_callback fun_draw_panel_buttons; // óêàçàòåëü íà ôóíêöèþ ðèñîâàíèÿ ïàíåëè ñ êíîïêàìè
87
	editor_callback fun_draw_panel_buttons; // óêàçàòåëü íà ôóíêöèþ ðèñîâàíèÿ ïàíåëè ñ êíîïêàìè
88
	editor_callback fun_draw_panel_find;    // óêàçàòåëü íà ôóíêöèþ ðèñîâàíèÿ ïàíåëè ïîèñêà
88
	editor_callback fun_draw_panel_find;    // óêàçàòåëü íà ôóíêöèþ ðèñîâàíèÿ ïàíåëè ïîèñêà
89
	editor_callback fun_draw_panel_syntax;  // óêàçàòåëü íà ôóíêöèþ ðèñîâàíèÿ ïàíåëè ñèíòàêñèñà
89
	editor_callback fun_draw_panel_syntax;  // óêàçàòåëü íà ôóíêöèþ ðèñîâàíèÿ ïàíåëè ñèíòàêñèñà
90
	editor_callback fun_save_err;   // óêàçàòåëü íà ôóíêöèþ âûçûâàåìóþ åñëè ñîõðàíåíèå ôàéëà çàêîí÷èëîñü íåóäà÷íî
90
	editor_callback fun_save_err;   // óêàçàòåëü íà ôóíêöèþ âûçûâàåìóþ åñëè ñîõðàíåíèå ôàéëà çàêîí÷èëîñü íåóäà÷íî
91
	uint32_t    increase_size;  //200 ÷èñëî ñèìâîëîâ íà êîòîðûå áóäåò óâå÷èâàòüñÿ ïàìÿòü ïðè íåõâàòêå
91
	uint32_t    increase_size;  //200 ÷èñëî ñèìâîëîâ íà êîòîðûå áóäåò óâå÷èâàòüñÿ ïàìÿòü ïðè íåõâàòêå
92
	void       *ptr_free_symb;  // èñïîëüçóåòñÿ âíóòðè ýëåìåíòà äëÿ óñêîðåíèÿ âñòàâêè òåêñòà
92
	void       *ptr_free_symb;  // èñïîëüçóåòñÿ âíóòðè ýëåìåíòà äëÿ óñêîðåíèÿ âñòàâêè òåêñòà
93
	uint32_t    font_size;       // ;+250 ìíîæèòåëü äëÿ ðàçìåðà øðèôòà // binary OR mask for ECX SysFn4
93
	uint32_t    font_size;       // ;+250 ìíîæèòåëü äëÿ ðàçìåðà øðèôòà // binary OR mask for ECX SysFn4
94
} editor;
94
} editor;
95
 
95
 
96
struct __attribute__ ((__packed__)) editor_color_item
96
struct __attribute__ ((__packed__)) editor_color_item
97
{
97
{
98
    char        word[40];   // ñëîâî äëÿ ïîäñâåòêè
98
    char        word[40];   // ñëîâî äëÿ ïîäñâåòêè
99
    uint32_t    f1_offset;  // ñìåùåíèå â òàáëèöå F1 ïîäñêàçîê
99
    uint32_t    f1_offset;  // ñìåùåíèå â òàáëèöå F1 ïîäñêàçîê
100
	uint8_t     flags;      // ôëàãè èñïîëüçóåìûå ïðè âûäåëåíèè
100
	uint8_t     flags;      // ôëàãè èñïîëüçóåìûå ïðè âûäåëåíèè
101
	uint8_t     endc;       // ñèìâîë êîíöà âûäåëåíèÿ (èñïîëüçóåòñÿ ïðè flags&4)
101
	uint8_t     endc;       // ñèìâîë êîíöà âûäåëåíèÿ (èñïîëüçóåòñÿ ïðè flags&4)
102
	uint8_t     escc;       // ýêðàíèðóþùèé ñèìâîë (èñïîëüçóåòñÿ ïðè flags&4)  ascii(34) ïðèìåðû ýêðàíèðîâàíèÿ \r \n \t
102
	uint8_t     escc;       // ýêðàíèðóþùèé ñèìâîë (èñïîëüçóåòñÿ ïðè flags&4)  ascii(34) ïðèìåðû ýêðàíèðîâàíèÿ \r \n \t
103
    uint8_t     color;      // öâåò ïî òàáëèöå öâåòîâ
103
    uint8_t     color;      // öâåò ïî òàáëèöå öâåòîâ
104
};
104
};
105
 
105
 
106
struct editor_syntax_file
106
struct editor_syntax_file
107
{
107
{
108
    uint32_t    count_colors_text;  // êîë-âî öâåòîâ òåêñòà dd (text-color_wnd_text)/4
108
    uint32_t    count_colors_text;  // êîë-âî öâåòîâ òåêñòà dd (text-color_wnd_text)/4
109
    uint32_t    count_key_words;    // êîë-âî êëþ÷åâûõ ñëîâ dd (f1-text)/48
109
    uint32_t    count_key_words;    // êîë-âî êëþ÷åâûõ ñëîâ dd (f1-text)/48
110
    color_t     color_cursor;       // dd 0xf1fcd0
110
    color_t     color_cursor;       // dd 0xf1fcd0
111
    color_t     color_wnd_capt;     // dd 0x080808
111
    color_t     color_wnd_capt;     // dd 0x080808
112
    color_t     color_wnd_work;     // dd 0x1C1C1C
112
    color_t     color_wnd_work;     // dd 0x1C1C1C
113
    color_t     color_wnd_bord;     // dd 0xc0c0c0
113
    color_t     color_wnd_bord;     // dd 0xc0c0c0
114
    color_t     color_select;       // dd 0x3E3D32
114
    color_t     color_select;       // dd 0x3E3D32
115
    color_t     color_cur_text;     // dd 0x808080
115
    color_t     color_cur_text;     // dd 0x808080
116
    color_t     color_wnd_text[];   // òàáëèöà öâåòîâ ðàçìåðîì count_colors_text
116
    color_t     color_wnd_text[];   // òàáëèöà öâåòîâ ðàçìåðîì count_colors_text
117
    // editor_color_item[];         // òàáëèöà êëþ÷åâûõ ïîäñâå÷åííûõ ñëîâ ðàçìåðîì count_key_words
117
    // editor_color_item[];         // òàáëèöà êëþ÷åâûõ ïîäñâå÷åííûõ ñëîâ ðàçìåðîì count_key_words
118
};
118
};
119
 
119
 
120
 
120
 
121
static struct editor_syntax_file default_syntax = {
121
static struct editor_syntax_file default_syntax = {
122
    10,     //count_colors_text
122
    10,     //count_colors_text
123
    1,      // count_key_words dd (f1-text)/48, minimum 1
123
    1,      // count_key_words dd (f1-text)/48, minimum 1
124
    0xf1fcd0, //color_cursor dd 0xf1fcd0
124
    0xf1fcd0, //color_cursor dd 0xf1fcd0
125
    0x080808, //color_wnd_capt dd 0x080808
125
    0x080808, //color_wnd_capt dd 0x080808
126
    0x1C1C1C, //color_wnd_work dd 0x1C1C1C
126
    0x1C1C1C, //color_wnd_work dd 0x1C1C1C
127
    0xc0c0c0, //color_wnd_bord dd 0xc0c0c0
127
    0xc0c0c0, //color_wnd_bord dd 0xc0c0c0
128
    0x3E3D32, //color_select dd 0x3E3D32
128
    0x3E3D32, //color_select dd 0x3E3D32
129
    0x808080, //color_cur_text dd 0x808080
129
    0x808080, //color_cur_text dd 0x808080
130
	{0xD0D0D0, 0xffff00, 0x00ff00, 0x00ffff, 0x808080, 0xff40ff, 0x4080ff, 0xff0000, 0x8080ff, 0x00ccff}
130
	{0xD0D0D0, 0xffff00, 0x00ff00, 0x00ffff, 0x808080, 0xff40ff, 0x4080ff, 0xff0000, 0x8080ff, 0x00ccff}
131
};
131
};
132
// next structure must follow syntax definition, at least has 1 element !!!
132
// next structure must follow syntax definition, at least has 1 element !!!
133
static struct editor_color_item  word1 = {
133
static struct editor_color_item  word1 = {
134
    "siemargl", 1, 0, 0, 1  // test word colored as 1st in table
134
    "siemargl", 1, 0, 0, 1  // test word colored as 1st in table
135
};
135
};
136
// next structure preferably follow syntax definition, at least has 1 element !!!
136
// next structure preferably follow syntax definition, at least has 1 element !!!
137
static char f1_table[] = {
137
static char f1_table[] = {
138
    "\0"
138
    "\0"
139
    "First\0"
139
    "First\0"
140
    "Last\0"
140
    "Last\0"
141
};
141
};
142
 
142
 
143
 
143
 
144
extern void (*ted_draw)(editor *) __attribute__((__stdcall__));
144
extern void (*ted_draw)(editor *) __attribute__((__stdcall__));
145
extern void (*ted_init_scroll_bars)(editor *, int opt) __attribute__((__stdcall__));
145
extern void (*ted_init_scroll_bars)(editor *, int opt) __attribute__((__stdcall__));
146
/// opt bits = 1 - ìåíÿòü öâåò ñêðîëëèíãîâ, 2 - èçìåíèëèñü ðàçìåðû îêíà, 4 - èçìåíèëèñü ðàçìåðû äîêóìåíòà
146
/// opt bits = 1 - ìåíÿòü öâåò ñêðîëëèíãîâ, 2 - èçìåíèëèñü ðàçìåðû îêíà, 4 - èçìåíèëèñü ðàçìåðû äîêóìåíòà
147
extern void (*ted_init_syntax_file)(editor *) __attribute__((__stdcall__));
147
extern void (*ted_init_syntax_file)(editor *) __attribute__((__stdcall__));
148
extern void (*ted_mouse)(editor *) __attribute__((__stdcall__));
148
extern void (*ted_mouse)(editor *) __attribute__((__stdcall__));
149
extern void (*ted_text_add)(editor *, char *text, int textlen, int opt) __attribute__((__stdcall__));
149
extern void (*ted_text_add)(editor *, char *text, int textlen, int opt) __attribute__((__stdcall__));
150
/// add text to cursor pos
150
/// add text to cursor pos
151
/// opt == ted_opt_ed_change_time, ted_opt_ed_move_cursor
151
/// opt == ted_opt_ed_change_time, ted_opt_ed_move_cursor
152
///ted_opt_ed_move_cursor equ 1 ;äâèãàòü êóðñîð ïîñëå äîáàâëåíèÿ òåêñòà
152
///ted_opt_ed_move_cursor equ 1 ;äâèãàòü êóðñîð ïîñëå äîáàâëåíèÿ òåêñòà
153
///ted_opt_ed_change_time equ 2 ;äîáàâëÿòü èçìåíåíèÿ ïðè ðåäàêòèðîâàíèè òåêñòà
153
///ted_opt_ed_change_time equ 2 ;äîáàâëÿòü èçìåíåíèÿ ïðè ðåäàêòèðîâàíèè òåêñòà
154
extern void (*ted_but_select_word)(editor *) __attribute__((__stdcall__));
154
extern void (*ted_but_select_word)(editor *) __attribute__((__stdcall__));
155
/// select word under cursor
155
/// select word under cursor
156
extern void (*ted_but_copy)(editor *) __attribute__((__stdcall__));
156
extern void (*ted_but_copy)(editor *) __attribute__((__stdcall__));
157
extern void (*ted_but_paste)(editor *) __attribute__((__stdcall__));
157
extern void (*ted_but_paste)(editor *) __attribute__((__stdcall__));
158
 
158
 
159
extern void (*ted_but_find_next)(editor *) __attribute__((__stdcall__));
159
extern void (*ted_but_find_next)(editor *) __attribute__((__stdcall__));
160
///move cursor to , calls ted_fun_find_err() if exist
160
///move cursor to , calls ted_fun_find_err() if exist
161
 
161
 
162
 
162
 
163
 
163
 
164
extern void (*ted_but_sumb_upper_asm)(editor *) __attribute__((__stdcall__));
164
extern void (*ted_but_sumb_upper_asm)(editor *) __attribute__((__stdcall__));
165
static inline void editor_selected_toupper(editor *ed)
165
static inline void editor_selected_toupper(editor *ed)
166
{
166
{
167
    __asm__ __volatile__ (
167
    __asm__ __volatile__ (
168
             "push %%edi \n\t"
168
             "push %%edi \n\t"
169
             "push %%esi \n\t":::);
169
             "push %%esi \n\t":::);
170
 
170
 
171
    (*ted_but_sumb_upper_asm)(ed);
171
    (*ted_but_sumb_upper_asm)(ed);
172
 
172
 
173
    __asm__ __volatile__ (
173
    __asm__ __volatile__ (
174
             "pop %%esi \n\t"
174
             "pop %%esi \n\t"
175
             "pop %%edi \n\t":::);
175
             "pop %%edi \n\t":::);
176
}
176
}
177
 
177
 
178
extern void (*ted_but_sumb_lover_asm)(editor *) __attribute__((__stdcall__));
178
extern void (*ted_but_sumb_lover_asm)(editor *) __attribute__((__stdcall__));
179
static inline void editor_selected_tolower(editor *ed)
179
static inline void editor_selected_tolower(editor *ed)
180
{
180
{
181
    __asm__ __volatile__ (
181
    __asm__ __volatile__ (
182
             "push %%edi \n\t"
182
             "push %%edi \n\t"
183
             "push %%esi \n\t":::);
183
             "push %%esi \n\t":::);
184
 
184
 
185
    (*ted_but_sumb_lover_asm)(ed);
185
    (*ted_but_sumb_lover_asm)(ed);
186
 
186
 
187
    __asm__ __volatile__ (
187
    __asm__ __volatile__ (
188
             "pop %%esi \n\t"
188
             "pop %%esi \n\t"
189
             "pop %%edi \n\t":::);
189
             "pop %%edi \n\t":::);
190
}
190
}
191
 
191
 
192
 
192
 
193
extern void (*ted_but_convert_by_table_asm)(editor *, char* table) __attribute__((__stdcall__));
193
extern void (*ted_but_convert_by_table_asm)(editor *, char* table) __attribute__((__stdcall__));
194
static inline void editor_convert_by_table(editor *ed, char* table)
194
static inline void editor_convert_by_table(editor *ed, char* table)
195
{
195
{
196
    __asm__ __volatile__ (
196
    __asm__ __volatile__ (
197
             "push %%edi \n\t"
197
             "push %%edi \n\t"
198
             "push %%esi \n\t":::);
198
             "push %%esi \n\t":::);
199
 
199
 
200
    (*ted_but_convert_by_table_asm)(ed, table);
200
    (*ted_but_convert_by_table_asm)(ed, table);
201
 
201
 
202
    __asm__ __volatile__ (
202
    __asm__ __volatile__ (
203
             "pop %%esi \n\t"
203
             "pop %%esi \n\t"
204
             "pop %%edi \n\t":::);
204
             "pop %%edi \n\t":::);
205
}
205
}
206
 
206
 
207
extern int (*ted_can_save_asm)(editor *) __attribute__((__stdcall__));
207
extern int (*ted_can_save_asm)(editor *) __attribute__((__stdcall__));
208
static inline int editor_can_save(editor *ed)
208
static inline int editor_can_save(editor *ed)
209
/// return 1 if need to be saved (has changes), 0 otherwise
209
/// return 1 if need to be saved (has changes), 0 otherwise
210
{
210
{
211
    int ret;
211
    int ret;
212
    __asm__ __volatile__ (
212
    __asm__ __volatile__ (
213
             "push %%edi \n\t":::);
213
             "push %%edi \n\t":::);
214
 
214
 
215
    (*ted_can_save_asm)(ed);
215
    (*ted_can_save_asm)(ed);
216
 
216
 
217
    __asm__ __volatile__ (
217
    __asm__ __volatile__ (
218
             "pop %%edi \n\t":"=a"(ret)::);
218
             "pop %%edi \n\t":"=a"(ret)::);
219
    return ret;
219
    return ret;
220
}
220
}
221
 
221
 
222
extern void (*ted_clear_asm)(editor *, int) __attribute__((__stdcall__));
222
extern void (*ted_clear_asm)(editor *, int) __attribute__((__stdcall__));
223
static inline void editor_clear(editor *ed, int all)
223
static inline void editor_clear(editor *ed, int all)
224
/// all==1 - clear all memory
224
/// all==1 - clear all memory
225
{
225
{
226
    __asm__ __volatile__ (
226
    __asm__ __volatile__ (
227
             "push %%edi \n\t":::);
227
             "push %%edi \n\t":::);
228
 
228
 
229
    (*ted_clear_asm)(ed, all);
229
    (*ted_clear_asm)(ed, all);
230
 
230
 
231
    __asm__ __volatile__ (
231
    __asm__ __volatile__ (
232
             "pop %%edi \n\t":::);
232
             "pop %%edi \n\t":::);
233
}
233
}
234
 
234
 
235
extern void (*ted_delete_asm)(editor *) __attribute__((__stdcall__));
235
extern void (*ted_delete_asm)(editor *) __attribute__((__stdcall__));
236
static inline void editor_delete(editor *ed)
236
static inline void editor_delete(editor *ed)
237
/// frees all memory (destroy)
237
/// frees all memory (destroy)
238
{
238
{
239
    __asm__ __volatile__ (
239
    __asm__ __volatile__ (
240
             "push %%edi \n\t":::);
240
             "push %%edi \n\t":::);
241
 
241
 
242
    (*ted_delete_asm)(ed);
242
    (*ted_delete_asm)(ed);
243
 
243
 
244
    __asm__ __volatile__ (
244
    __asm__ __volatile__ (
245
             "pop %%edi \n\t":::);
245
             "pop %%edi \n\t":::);
246
    free(ed->scr_w);
246
    free(ed->scr_w);
247
    free(ed->scr_h);
247
    free(ed->scr_h);
248
    free(ed->buffer);
248
    free(ed->buffer);
249
    free(ed->buffer_find);
249
    free(ed->buffer_find);
250
}
250
}
251
 
251
 
252
extern void (*ted_init_asm)(editor *) __attribute__((__stdcall__));
252
extern void (*ted_init_asm)(editor *) __attribute__((__stdcall__));
253
static inline void editor_init(editor *ed)
253
static inline void editor_init(editor *ed)
254
/// allocate memory
254
/// allocate memory
255
{
255
{
256
    __asm__ __volatile__ (
256
    __asm__ __volatile__ (
257
             "push %%edi \n\t":::);
257
             "push %%edi \n\t":::);
258
 
258
 
259
    (*ted_init_asm)(ed);
259
    (*ted_init_asm)(ed);
260
 
260
 
261
    __asm__ __volatile__ (
261
    __asm__ __volatile__ (
262
             "pop %%edi \n\t":::);
262
             "pop %%edi \n\t":::);
263
}
263
}
264
 
264
 
265
extern int (*ted_is_select)(editor *) __attribute__((__stdcall__));
265
extern int (*ted_is_select)(editor *) __attribute__((__stdcall__));
266
static inline int editor_is_select(editor *ed)
266
static inline int editor_is_select(editor *ed)
267
/// return 1 if have selection
267
/// return 1 if have selection
268
{
268
{
269
    int ret;
269
    int ret;
270
    __asm__ __volatile__ (
270
    __asm__ __volatile__ (
271
             "push %%ebx \n\t":::);
271
             "push %%ebx \n\t":::);
272
 
272
 
273
    (*ted_is_select)(ed);
273
    (*ted_is_select)(ed);
274
 
274
 
275
    __asm__ __volatile__ (
275
    __asm__ __volatile__ (
276
             "pop %%ebx \n\t":"=a"(ret)::);
276
             "pop %%ebx \n\t":"=a"(ret)::);
277
    return ret;
277
    return ret;
278
}
278
}
279
 
279
 
280
enum control_keys {
280
enum control_keys {
281
    KM_SHIFT = 0x00010000,
281
    KM_SHIFT = 0x00010000,
282
    KM_CTRL = 0x00020000,
282
    KM_CTRL = 0x00020000,
283
    KM_ALT = 0x00040000,
283
    KM_ALT = 0x00040000,
284
    KM_NUMLOCK = 0x00080000
284
    KM_NUMLOCK = 0x00080000
285
};
285
};
286
 
286
 
287
extern void (*ted_key_asm)(editor *, char* table, int control) __attribute__((__stdcall__));
287
extern void (*ted_key_asm)(editor *, char* table, int control) __attribute__((__stdcall__));
288
static inline void editor_keyboard(editor *ed, char* table, enum control_keys control, int ch)
288
static inline __attribute__((__stdcall__)) void editor_keyboard(editor *ed, char* table, enum control_keys control, int ch)
289
/// control is KM_SHIFT, KM_ALT, KM_CTRL, KM_NUMLOCK,
289
/// control is KM_SHIFT, KM_ALT, KM_CTRL, KM_NUMLOCK,
290
/// ch = GET_KEY
290
/// ch = GET_KEY
291
/// table = SF_SYSTEM_GET,SSF_KEYBOARD_LAYOUT
291
/// table = SF_SYSTEM_GET,SSF_KEYBOARD_LAYOUT
292
{
292
{
293
    __asm__ __volatile__ (
293
    __asm__ __volatile__ (
-
 
294
             "push %4\n\t"
-
 
295
             "push %3\n\t"
-
 
296
             "push %2\n\t"
-
 
297
             "call *%1 \n\t"::"a"(ch), "m"(ted_key_asm), "m"(ed), "m"(table), "m"(control):);
-
 
298
/*
-
 
299
    __asm__ __volatile__ (
294
             "nop \n\t"::"a"(ch):);
300
             "nop \n\t"::"a"(ch):);
295
 
-
 
296
    (*ted_key_asm)(ed, table, control);
301
    (*ted_key_asm)(ed, table, control);
-
 
302
*/
297
}
303
}
298
 
304
 
299
extern void (*ted_open_file_asm)(editor *, struct fs_dirinfo*, char *fname) __attribute__((__stdcall__));
305
extern void (*ted_open_file_asm)(editor *, struct fs_dirinfo*, char *fname) __attribute__((__stdcall__));
300
static inline int editor_openfile(editor *ed, char *fname, int *readbytes)
306
static inline int editor_openfile(editor *ed, char *fname, int *readbytes)
301
/// returns errcode as SysFn70
307
/// returns errcode as SysFn70
302
{
308
{
303
    int     ret;
309
    int     ret;
304
    struct fs_dirinfo   di;
310
    struct fs_dirinfo   di;
305
    __asm__ __volatile__ (
311
    __asm__ __volatile__ (
306
             "push %%edi \n\t":::);
312
             "push %%edi \n\t":::);
307
 
313
 
308
    (*ted_open_file_asm)(ed, &di, fname);
314
    (*ted_open_file_asm)(ed, &di, fname);
309
 
315
 
310
    __asm__ __volatile__ (
316
    __asm__ __volatile__ (
311
             "pop %%edi \n\t":"=b"(*readbytes), "=a"(ret)::);
317
             "pop %%edi \n\t":"=b"(*readbytes), "=a"(ret)::);
312
    return ret;
318
    return ret;
313
}
319
}
314
 
320
 
315
extern void (*ted_save_file_asm)(editor *, struct fs_dirinfo*, char *fname) __attribute__((__stdcall__));
321
extern void (*ted_save_file_asm)(editor *, struct fs_dirinfo*, char *fname) __attribute__((__stdcall__));
316
static inline int editor_savefile(editor *ed, char *fname)
322
static inline int editor_savefile(editor *ed, char *fname)
317
/// returns errcode, calls fun_save_err() if exists
323
/// returns errcode, calls fun_save_err() if exists
318
{
324
{
319
    struct fs_dirinfo   di;
325
    struct fs_dirinfo   di;
320
 
326
 
321
    (*ted_save_file_asm)(ed, &di, fname);
327
    (*ted_save_file_asm)(ed, &di, fname);
322
 
328
 
323
    return ed->err_save;
329
    return ed->err_save;
324
}
330
}
325
 
331
 
326
extern void (*ted_but_cut)(editor *) __attribute__((__stdcall__));
332
extern void (*ted_but_cut)(editor *) __attribute__((__stdcall__));
327
static inline void editor_cut(editor *ed)
333
static inline void editor_cut(editor *ed)
328
{
334
{
329
    __asm__ __volatile__ (
335
    __asm__ __volatile__ (
330
             "push %%edi \n\t":::);
336
             "push %%edi \n\t":::);
331
 
337
 
332
    (*ted_but_cut)(ed);
338
    (*ted_but_cut)(ed);
333
 
339
 
334
    __asm__ __volatile__ (
340
    __asm__ __volatile__ (
335
             "pop %%edi \n\t":::);
341
             "pop %%edi \n\t":::);
336
}
342
}
337
 
343
 
338
extern void (*ted_but_undo)(editor *) __attribute__((__stdcall__));
344
extern void (*ted_but_undo)(editor *) __attribute__((__stdcall__));
339
static inline void editor_undo(editor *ed)
345
static inline void editor_undo(editor *ed)
340
{
346
{
341
    __asm__ __volatile__ (
347
    __asm__ __volatile__ (
342
             "push %%edi \n\t":::);
348
             "push %%edi \n\t":::);
343
 
349
 
344
    (*ted_but_undo)(ed);
350
    (*ted_but_undo)(ed);
345
 
351
 
346
    __asm__ __volatile__ (
352
    __asm__ __volatile__ (
347
             "pop %%edi \n\t":::);
353
             "pop %%edi \n\t":::);
348
}
354
}
349
 
355
 
350
extern void (*ted_but_redo)(editor *) __attribute__((__stdcall__));
356
extern void (*ted_but_redo)(editor *) __attribute__((__stdcall__));
351
static inline void editor_redo(editor *ed)
357
static inline void editor_redo(editor *ed)
352
{
358
{
353
    __asm__ __volatile__ (
359
    __asm__ __volatile__ (
354
             "push %%edi \n\t":::);
360
             "push %%edi \n\t":::);
355
 
361
 
356
    (*ted_but_redo)(ed);
362
    (*ted_but_redo)(ed);
357
 
363
 
358
    __asm__ __volatile__ (
364
    __asm__ __volatile__ (
359
             "pop %%edi \n\t":::);
365
             "pop %%edi \n\t":::);
360
}
366
}
361
 
367
 
362
extern void (*ted_but_reverse)(editor *) __attribute__((__stdcall__));
368
extern void (*ted_but_reverse)(editor *) __attribute__((__stdcall__));
363
static inline void editor_reverse(editor *ed)
369
static inline void editor_reverse(editor *ed)
364
{
370
{
365
    __asm__ __volatile__ (
371
    __asm__ __volatile__ (
366
             "push %%edi \n\t"
372
             "push %%edi \n\t"
367
             "push %%ebx\n\t":::);
373
             "push %%ebx\n\t":::);
368
 
374
 
369
    (*ted_but_reverse)(ed);
375
    (*ted_but_reverse)(ed);
370
 
376
 
371
    __asm__ __volatile__ (
377
    __asm__ __volatile__ (
372
             "pop %%ebx \n\t"
378
             "pop %%ebx \n\t"
373
             "pop %%edi \n\t":::);
379
             "pop %%edi \n\t":::);
374
}
380
}
375
 
381
 
376
extern void (*ted_text_colored_asm)() __attribute__((__stdcall__));
382
extern void (*ted_text_colored_asm)() __attribute__((__stdcall__));
377
static inline void editor_text_colored(editor *ed)
383
static inline void editor_text_colored(editor *ed)
378
{
384
{
379
    __asm__ __volatile__ (
385
    __asm__ __volatile__ (
380
             "nop \n\t"::"D"(ed):);
386
             "nop \n\t"::"D"(ed):);
381
 
387
 
382
    (*ted_text_colored_asm)();
388
    (*ted_text_colored_asm)();
383
}
389
}
384
 
390
 
385
static inline
391
static inline
386
uint32_t get_control_keys(void)
392
uint32_t get_control_keys(void)
387
{
393
{
388
    uint32_t ctrl;
394
    uint32_t ctrl;
389
 
395
 
390
    __asm__ __volatile__(
396
    __asm__ __volatile__(
391
    "int $0x40 \n\t"
397
    "int $0x40 \n\t"
392
    :"=a"(ctrl)
398
    :"=a"(ctrl)
393
    :"a"(66),"b"(3));
399
    :"a"(66),"b"(3));
394
 
400
 
395
    return ctrl;
401
    return ctrl;
396
};
402
};
397
 
403
 
398
static inline
404
static inline
399
int get_keyboard_layout(int opt, char* buf)
405
int get_keyboard_layout(int opt, char* buf)
400
/// 128 byte buffer
406
/// 128 byte buffer
401
/// opt: 1 - normal, 2 - shifted, 3 - alted, or 9 - return language
407
/// opt: 1 - normal, 2 - shifted, 3 - alted, or 9 - return language
402
{
408
{
403
    uint32_t lang;
409
    uint32_t lang;
404
 
410
 
405
    __asm__ __volatile__(
411
    __asm__ __volatile__(
406
    "int $0x40 \n\t"
412
    "int $0x40 \n\t"
407
    :"=a"(lang)
413
    :"=a"(lang)
408
    :"a"(26),"b"(2), "c"(opt), "d"(buf));
414
    :"a"(26),"b"(2), "c"(opt), "d"(buf));
409
 
415
 
410
    return lang;
416
    return lang;
411
};
417
};
412
 
-
 
-
 
418
 
413
 
419
__attribute__((__stdcall__))
414
static void editor_key(editor* ed)
420
static void editor_key(editor* ed, oskey_t key)
415
// callback for gui
421
// callback for gui
-
 
422
{
-
 
423
    //if(ed->el_focus != ed) return;  // need to check not to lose keyb buffer
416
{
424
 
417
    uint32_t control = get_control_keys();
425
    uint32_t control = get_control_keys();
418
    enum control_keys ed_ctrl = 0;
426
    enum control_keys ed_ctrl = 0;
419
    int ly_opt = 1;
427
    int ly_opt = 1;
420
    if (control & 3) { ed_ctrl |= KM_SHIFT; ly_opt = 2; }
428
    if (control & 3) { ed_ctrl |= KM_SHIFT; ly_opt = 2; }
421
    if (control & 0xC) ed_ctrl |= KM_CTRL;
429
    if (control & 0xC) ed_ctrl |= KM_CTRL;
422
    if (control & 0x30){ ed_ctrl |= KM_ALT; ly_opt = 3; }
430
    if (control & 0x30){ ed_ctrl |= KM_ALT; ly_opt = 3; }
423
    if (control & 0x80) ed_ctrl |= KM_NUMLOCK;
431
    if (control & 0x80) ed_ctrl |= KM_NUMLOCK;
424
 
432
 
425
    char conv_table[128];
433
    char conv_table[128];
426
    get_keyboard_layout(ly_opt, conv_table);
434
    get_keyboard_layout(ly_opt, conv_table);
427
 
435
 
428
    editor_keyboard(ed, conv_table, ed_ctrl, get_key().val);
436
    editor_keyboard(ed, conv_table, ed_ctrl, key.val);
429
}
437
}
430
 
438
 
431
static inline void gui_add_editor(kolibri_window *wnd, editor* e)
439
static inline void gui_add_editor(kolibri_window *wnd, editor* e)
432
{
440
{
433
    kolibri_window_add_element(wnd, KOLIBRI_EDITOR, e);
441
    kolibri_window_add_element(wnd, KOLIBRI_EDITOR, e);
434
}
442
}
435
 
443
 
436
static inline editor* kolibri_new_editor(uint32_t x_w, uint32_t y_h, uint32_t font, uint32_t max_chars, editor **editor_interlock)
444
static inline editor* kolibri_new_editor(uint32_t x_w, uint32_t y_h, uint32_t font, uint32_t max_chars, void *editor_interlock)
437
/// font - 0b10SSS 8x16 size multiply (SSS+1), 0xSSS - 6x9 multiply (SSS+1)
445
/// font - 0b10SSS 8x16 size multiply (SSS+1), 0xSSS - 6x9 multiply (SSS+1)
438
 
446
 
439
{
447
{
440
    editor *ed = (editor *)calloc(1, sizeof(editor));
448
    editor *ed = (editor *)calloc(1, sizeof(editor));
441
    ed->x_pos = x_w >> 16;
449
    ed->x_pos = x_w >> 16;
442
    ed->width = x_w & 0xFFFF;
450
    ed->width = x_w & 0xFFFF;
443
    ed->y_pos = y_h >> 16;
451
    ed->y_pos = y_h >> 16;
444
    ed->hight = y_h & 0xFFFF;
452
    ed->hight = y_h & 0xFFFF;
-
 
453
 
445
 
454
    ed->w_pane = 30;
446
    // no panel, w_pane, h_pane == 0
455
    ed->h_pane = 20;
447
    // font
456
    // font
448
    if (font == 0) font = 0x10;  // default 16 = 8x16
457
    if (font == 0) font = 0x10;  // default 16 = 8x16
449
    int font_multipl = (font & 7) + 1;
458
    int font_multipl = (font & 7) + 1;
450
    ed->font_size = font << 24;
459
    ed->font_size = font << 24;
451
    if (font & 0x10) // 8x16
460
    if (font & 0x10) // 8x16
452
    {
461
    {
453
        ed->width_sym = 8 * font_multipl;
462
        ed->width_sym = 8 * font_multipl;
454
        ed->hight_sym = 16 * font_multipl;
463
        ed->hight_sym = 16 * font_multipl;
455
    } else   // 6x9
464
    } else   // 6x9
456
    {
465
    {
457
        ed->width_sym = 6 * font_multipl;
466
        ed->width_sym = 6 * font_multipl;
458
        ed->hight_sym = 9 * font_multipl;
467
        ed->hight_sym = 9 * font_multipl;
459
    }
468
    }
460
    // memory sizing for text & syntax
469
    // memory sizing for text & syntax
461
    ed->max_chars = max_chars;
470
    ed->max_chars = max_chars;
462
    ed->increase_size = max_chars / 2;
471
    ed->increase_size = max_chars / 2;
463
    ed->syntax_file_size = sizeof (default_syntax);
472
    ed->syntax_file_size = sizeof (default_syntax);
464
 
473
 
465
/* // loaded auto from syntax
474
/* // loaded auto from syntax
466
    ed->color_cursor = 0x808080;
475
    ed->color_cursor = 0x808080;
467
    ed->color_wnd_capt = 0x80;
476
    ed->color_wnd_capt = 0x80;
468
    ed->color_wnd_bord = 0xd0d0d0;
477
    ed->color_wnd_bord = 0xd0d0d0;
469
    ed->color_select = 0x208080;
478
    ed->color_select = 0x208080;
470
    ed->color_cur_text = 0xff0000;
479
    ed->color_cur_text = 0xff0000;
471
    ed->color_wnd_text = 0xffff00;
480
    ed->color_wnd_text = 0xffff00;
472
*/
481
*/
473
    ed->symbol_new_line = 20;  // ascii(20)
482
    ed->symbol_new_line = 20;  // ascii(20)
474
 
483
 
475
    ed->scr_w = kolibri_new_scrollbar_def(X_Y(50, 16), X_Y(50, 300), 100, 30, 0);
484
    ed->scr_w = kolibri_new_scrollbar_def(X_Y(0, 16), X_Y(0, 0), 100, 30, 0);  // cur_area will be inited ltr, max & pos undef
476
    ed->scr_h = kolibri_new_scrollbar_def(X_Y(0, 150), X_Y(50, 16), 100, 30, 0);
485
    ed->scr_h = kolibri_new_scrollbar_def(X_Y(0, 0), X_Y(0, 16), 100, 30, 0);  // cur_area will be inited ltr, max & pos undef
477
 
486
 
478
    ed->buffer_size = TE_BUF_SIZE;
487
    ed->buffer_size = TE_BUF_SIZE;
479
    ed->buffer = malloc(TE_BUF_SIZE);
488
    ed->buffer = malloc(TE_BUF_SIZE);
480
    ed->buffer_find = malloc(TE_BUF_SIZE / 8);  //where to store text to search
489
    ed->buffer_find = malloc(TE_BUF_SIZE / 8);  //where to store text to search
481
 
490
 
482
    ed->cur_ins = 1; // insert mode default
491
    ed->cur_ins = 1; // insert mode default
483
    ed->mode_color = 1; // can select text
492
    ed->mode_color = 1; // can select text
484
    ed->mode_invis = 1; // show nonprinted symbols
493
    ed->mode_invis = 1; // show nonprinted symbols
-
 
494
 
-
 
495
    ed->el_focus = editor_interlock;
485
 
496
 
486
    // ??? saveregs ax,cx,di
497
    // ??? saveregs ax,cx,di
487
    editor_init(ed);  // memory allocation, cleaning
498
    editor_init(ed);  // memory allocation, cleaning
488
    ed->syntax_file = (char*)&default_syntax;
499
    ed->syntax_file = (char*)&default_syntax;
489
    (*ted_init_syntax_file)(ed); // load colors and syntax highlight
500
    (*ted_init_syntax_file)(ed); // load colors and syntax highlight
490
    ed->help_text_f1 = f1_table; // override if not aligned immediately after syntax words
501
    ed->help_text_f1 = f1_table; // override if not aligned immediately after syntax words
491
    ed->key_words_data = &word1;
502
    ed->key_words_data = &word1;
492
 
503
 
493
    return ed;
504
    return ed;
494
}
505
}
495
 
506
 
496
 
507
 
497
#endif // KOLIBRI_EDITOR_H
508
#endif // KOLIBRI_EDITOR_H