Subversion Repositories Kolibri OS

Rev

Rev 6612 | Rev 7577 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 6612 Rev 6615
Line 10... Line 10...
10
typedef void (*editor_callback)(void);
10
typedef void (*editor_callback)(void);
Line 11... Line 11...
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
	uint32_t    prev;   //  +2 èíäåêñ ïðåäûäóùåãî
16
	struct editor_symbol   *next;   //  +6 óêàçàòåëè
16
	uint32_t    next;   //  +6 óêàçàòåëè (èíäåêñ ñëåäóþùåãî)
17
	uint32_t    tc;     //  +10 âðåì. ñîçäàíèÿ
17
	uint32_t    tc;     //  +10 âðåì. ñîçäàíèÿ
18
	uint32_t    td;     // +14 âðåì. óäàëåíèÿ
18
	uint32_t    td;     // +14 âðåì. óäàëåíèÿ
Line 19... Line 19...
19
};
19
};
Line 37... Line 37...
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;  // óêàçàòåëü çà ïîñëåäíèì ñóùåñòâóþùèì ñèìâîëîì (êîíåö ôàéëà)
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 êîëëè÷åñòâî êëþ÷åâûõ ñëîâ
Line 159... Line 159...
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
Line 161... Line 161...
161
 
161
 
162
 
-
 
163
 
-
 
164
extern void (*ted_but_sumb_upper_asm)(editor *) __attribute__((__stdcall__));
-
 
165
static inline void editor_selected_toupper(editor *ed)
-
 
166
{
-
 
167
    __asm__ __volatile__ (
-
 
168
             "push %%edi \n\t"
-
 
169
             "push %%esi \n\t":::);
-
 
170
 
-
 
171
    (*ted_but_sumb_upper_asm)(ed);
-
 
172
 
-
 
173
    __asm__ __volatile__ (
-
 
174
             "pop %%esi \n\t"
-
 
175
             "pop %%edi \n\t":::);
-
 
176
}
-
 
177
 
-
 
178
extern void (*ted_but_sumb_lover_asm)(editor *) __attribute__((__stdcall__));
-
 
179
static inline void editor_selected_tolower(editor *ed)
-
 
180
{
-
 
Line 181... Line 162...
181
    __asm__ __volatile__ (
162
 
Line 182... Line -...
182
             "push %%edi \n\t"
-
 
183
             "push %%esi \n\t":::);
-
 
184
 
163
 
185
    (*ted_but_sumb_lover_asm)(ed);
-
 
Line 186... Line -...
186
 
-
 
187
    __asm__ __volatile__ (
-
 
188
             "pop %%esi \n\t"
-
 
189
             "pop %%edi \n\t":::);
-
 
190
}
-
 
191
 
-
 
192
 
-
 
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)
-
 
195
{
-
 
196
    __asm__ __volatile__ (
-
 
197
             "push %%edi \n\t"
-
 
198
             "push %%esi \n\t":::);
-
 
199
 
-
 
200
    (*ted_but_convert_by_table_asm)(ed, table);
-
 
201
 
-
 
202
    __asm__ __volatile__ (
-
 
203
             "pop %%esi \n\t"
164
extern void (*ted_but_sumb_upper)(editor *) __attribute__((__stdcall__));
204
             "pop %%edi \n\t":::);
-
 
205
}
-
 
206
 
-
 
207
extern int (*ted_can_save_asm)(editor *) __attribute__((__stdcall__));
-
 
208
static inline int editor_can_save(editor *ed)
-
 
209
/// return 1 if need to be saved (has changes), 0 otherwise
165
 
Line 210... Line -...
210
{
-
 
211
    int ret;
-
 
212
    __asm__ __volatile__ (
-
 
213
             "push %%edi \n\t":::);
-
 
214
 
-
 
215
    (*ted_can_save_asm)(ed);
-
 
216
 
-
 
217
    __asm__ __volatile__ (
166
extern void (*ted_but_sumb_lover)(editor *) __attribute__((__stdcall__));
218
             "pop %%edi \n\t":"=a"(ret)::);
-
 
219
    return ret;
-
 
220
}
167
 
Line 221... Line -...
221
 
-
 
222
extern void (*ted_clear_asm)(editor *, int) __attribute__((__stdcall__));
-
 
223
static inline void editor_clear(editor *ed, int all)
-
 
224
/// all==1 - clear all memory
-
 
225
{
-
 
226
    __asm__ __volatile__ (
-
 
227
             "push %%edi \n\t":::);
168
extern void (*ted_but_convert_by_table)(editor *, char* table) __attribute__((__stdcall__));
228
 
169
 
229
    (*ted_clear_asm)(ed, all);
170
/// return 1 if need to be saved (has changes), 0 otherwise
230
 
171
extern int (*ted_can_save)(editor *) __attribute__((__stdcall__));
231
    __asm__ __volatile__ (
-
 
232
             "pop %%edi \n\t":::);
-
 
233
}
-
 
234
 
172
 
235
extern void (*ted_delete_asm)(editor *) __attribute__((__stdcall__));
-
 
236
static inline void editor_delete(editor *ed)
-
 
237
/// frees all memory (destroy)
-
 
238
{
173
/// all==1 - clear all memory
239
    __asm__ __volatile__ (
174
extern void (*ted_clear)(editor *, int all) __attribute__((__stdcall__));
240
             "push %%edi \n\t":::);
175
 
241
 
176
extern void (*ted_delete)(editor *) __attribute__((__stdcall__));
242
    (*ted_delete_asm)(ed);
177
static inline void editor_delete(editor *ed)
Line 243... Line -...
243
 
-
 
244
    __asm__ __volatile__ (
-
 
245
             "pop %%edi \n\t":::);
178
/// frees all memory (destroy)
246
    free(ed->scr_w);
-
 
247
    free(ed->scr_h);
-
 
248
    free(ed->buffer);
-
 
249
    free(ed->buffer_find);
-
 
250
}
179
{
251
 
-
 
252
extern void (*ted_init_asm)(editor *) __attribute__((__stdcall__));
-
 
253
static inline void editor_init(editor *ed)
-
 
254
/// allocate memory
-
 
Line 255... Line -...
255
{
-
 
256
    __asm__ __volatile__ (
-
 
257
             "push %%edi \n\t":::);
180
    (*ted_delete)(ed);
258
 
-
 
259
    (*ted_init_asm)(ed);
-
 
260
 
-
 
261
    __asm__ __volatile__ (
-
 
262
             "pop %%edi \n\t":::);
-
 
263
}
181
    free(ed->scr_w);
264
 
-
 
265
extern int (*ted_is_select)(editor *) __attribute__((__stdcall__));
-
 
266
static inline int editor_is_select(editor *ed)
-
 
267
/// return 1 if have selection
-
 
268
{
-
 
Line 269... Line 182...
269
    int ret;
182
    free(ed->scr_h);
270
    __asm__ __volatile__ (
183
    free(ed->buffer);
271
             "push %%ebx \n\t":::);
184
    free(ed->buffer_find);
272
 
185
}
Line 328... Line 241...
328
 
241
 
329
    return ed->err_save;
242
    return ed->err_save;
Line 330... Line 243...
330
}
243
}
331
 
-
 
332
extern void (*ted_but_cut)(editor *) __attribute__((__stdcall__));
-
 
333
static inline void editor_cut(editor *ed)
-
 
334
{
-
 
335
    __asm__ __volatile__ (
-
 
336
             "push %%edi \n\t":::);
-
 
337
 
-
 
338
    (*ted_but_cut)(ed);
-
 
339
 
-
 
340
    __asm__ __volatile__ (
-
 
Line 341... Line 244...
341
             "pop %%edi \n\t":::);
244
 
342
}
-
 
343
 
-
 
344
extern void (*ted_but_undo)(editor *) __attribute__((__stdcall__));
-
 
345
static inline void editor_undo(editor *ed)
-
 
346
{
-
 
347
    __asm__ __volatile__ (
-
 
348
             "push %%edi \n\t":::);
-
 
349
 
-
 
350
    (*ted_but_undo)(ed);
-
 
351
 
-
 
Line 352... Line 245...
352
    __asm__ __volatile__ (
245
extern void (*ted_but_cut)(editor *) __attribute__((__stdcall__));
353
             "pop %%edi \n\t":::);
-
 
354
}
-
 
355
 
-
 
356
extern void (*ted_but_redo)(editor *) __attribute__((__stdcall__));
-
 
357
static inline void editor_redo(editor *ed)
-
 
358
{
-
 
359
    __asm__ __volatile__ (
-
 
360
             "push %%edi \n\t":::);
-
 
361
 
-
 
362
    (*ted_but_redo)(ed);
-
 
Line 363... Line 246...
363
 
246
 
364
    __asm__ __volatile__ (
-
 
365
             "pop %%edi \n\t":::);
-
 
366
}
-
 
367
 
-
 
368
extern void (*ted_but_reverse)(editor *) __attribute__((__stdcall__));
-
 
369
static inline void editor_reverse(editor *ed)
-
 
370
{
-
 
371
    __asm__ __volatile__ (
-
 
372
             "push %%edi \n\t"
-
 
373
             "push %%ebx\n\t":::);
-
 
374
 
-
 
375
    (*ted_but_reverse)(ed);
-
 
Line 376... Line 247...
376
 
247
extern void (*ted_but_undo)(editor *) __attribute__((__stdcall__));
377
    __asm__ __volatile__ (
248
 
378
             "pop %%ebx \n\t"
249
extern void (*ted_but_redo)(editor *) __attribute__((__stdcall__));
379
             "pop %%edi \n\t":::);
250
 
380
}
251
extern void (*ted_but_reverse)(editor *) __attribute__((__stdcall__));
Line 381... Line -...
381
 
-
 
382
extern void (*ted_text_colored_asm)() __attribute__((__stdcall__));
252
 
Line 383... Line 253...
383
static inline void editor_text_colored(editor *ed)
253
extern void (*ted_text_colored_asm)() __attribute__((__stdcall__));
384
{
254
static inline void editor_text_colored(editor *ed)
385
    __asm__ __volatile__ (
255
{
Line 492... Line 362...
492
    ed->mode_color = 1; // can select text
362
    ed->mode_color = 1; // can select text
493
    ed->mode_invis = 1; // show nonprinted symbols
363
    ed->mode_invis = 1; // show nonprinted symbols
Line 494... Line 364...
494
 
364
 
Line 495... Line -...
495
    ed->el_focus = editor_interlock;
-
 
496
 
365
    ed->el_focus = editor_interlock;
497
    // ??? saveregs ax,cx,di
366
 
498
    editor_init(ed);  // memory allocation, cleaning
367
    (*ted_init)(ed);  // memory allocation, cleaning
499
    ed->syntax_file = (char*)&default_syntax;
368
    ed->syntax_file = (char*)&default_syntax;
500
    (*ted_init_syntax_file)(ed); // load colors and syntax highlight
369
    (*ted_init_syntax_file)(ed); // load colors and syntax highlight
Line 501... Line 370...
501
    ed->help_text_f1 = f1_table; // override if not aligned immediately after syntax words
370
    ed->help_text_f1 = f1_table; // override if not aligned immediately after syntax words
502
    ed->key_words_data = &word1;
371
    ed->key_words_data = &word1;
Line -... Line 372...
-
 
372
 
-
 
373
    return ed;
-
 
374
}
-
 
375
 
-
 
376
/// return 1 if symbol is not visible (deleted or undo-ed)
-
 
377
static inline int editor_symbol_not_vis(editor* ed, struct editor_symbol* sym)
-
 
378
{
-
 
379
    return (sym->td && sym->td + ed->tim_undo <= ed->tim_ch) || (sym->tc > ed->tim_ch - ed->tim_undo);
-
 
380
}
-
 
381
 
-
 
382
/// returns next good symbol by index
-
 
383
static inline
-
 
384
uint32_t editor_iterat_next(editor* ed, uint32_t idx)
-
 
385
{
-
 
386
    uint32_t  i;
-
 
387
    if (ed->tim_undo)
-
 
388
    {
-
 
389
        for (i = ed->tex[idx].next; i != 0 && (ed->tex[i].c == '\n' || editor_symbol_not_vis(ed, ed->tex + i)); i = ed->tex[i].next);
-
 
390
    } else
-
 
391
    {
-
 
392
        for (i = ed->tex[idx].next; i != 0 && (ed->tex[i].c == '\n' || ed->tex[i].td); i = ed->tex[i].next);
-
 
393
    }
-
 
394
    return i;
-
 
395
}
-
 
396
 
-
 
397
// returns malloc'ed mem
-
 
398
static inline
-
 
399
char*  editor_get_text(editor* ed)
-
 
400
{
-
 
401
    char    *buf = malloc(ed->max_chars), *pc = buf;
-
 
402
    if (!pc) return NULL;
-
 
403
 
-
 
404
    int  i;
-
 
405
//    *pc++ = ed->tex[0].c;
-
 
406
    for (i = ed->tex[0].next; i; i = editor_iterat_next(ed, i)) *pc++ = ed->tex[i].c;
Line -... Line 407...
-
 
407
    *pc++ = '\0';
-
 
408
 
-
 
409
    return buf;
-
 
410
}
-
 
411
 
-
 
412
/*
-
 
413
char*  editor_get_text20(editor* ed)
-
 
414
{
-
 
415
    char    *buf = malloc(ed->max_chars), *pc = buf;
-
 
416
    if (!pc) return NULL;
-
 
417
 
-
 
418
    int  i = ed->tex[0].next, c = 0;
-
 
419
    for (; i > 0 && c < 30; c++, i = ed->tex[i].next) *pc++ = ed->tex[i].c;
503
 
420
    *pc++ = '\0';