Subversion Repositories Kolibri OS

Compare Revisions

Regard whitespace Rev 6600 → Rev 6601

/contrib/C_Layer/INCLUDE/kolibri_editor.h
120,7 → 120,7
 
static struct editor_syntax_file default_syntax = {
10, //count_colors_text
0, // count_key_words dd (f1-text)/48
1, // count_key_words dd (f1-text)/48, minimum 1
0xf1fcd0, //color_cursor dd 0xf1fcd0
0x080808, //color_wnd_capt dd 0x080808
0x1C1C1C, //color_wnd_work dd 0x1C1C1C
165,14 → 165,14
static inline void editor_selected_toupper(editor *ed)
{
__asm__ __volatile__ (
"push edi \n\t"
"push esi \n\t":::);
"push %%edi \n\t"
"push %%esi \n\t":::);
 
(*ted_but_sumb_upper_asm)(ed);
 
__asm__ __volatile__ (
"pop esi \n\t"
"pop edi \n\t":::);
"pop %%esi \n\t"
"pop %%edi \n\t":::);
}
 
extern void (*ted_but_sumb_lover_asm)(editor *) __attribute__((__stdcall__));
179,14 → 179,14
static inline void editor_selected_tolower(editor *ed)
{
__asm__ __volatile__ (
"push edi \n\t"
"push esi \n\t":::);
"push %%edi \n\t"
"push %%esi \n\t":::);
 
(*ted_but_sumb_lover_asm)(ed);
 
__asm__ __volatile__ (
"pop esi \n\t"
"pop edi \n\t":::);
"pop %%esi \n\t"
"pop %%edi \n\t":::);
}
 
 
194,28 → 194,28
static inline void editor_convert_by_table(editor *ed, char* table)
{
__asm__ __volatile__ (
"push edi \n\t"
"push esi \n\t":::);
"push %%edi \n\t"
"push %%esi \n\t":::);
 
(*ted_but_convert_by_table_asm)(ed, table);
 
__asm__ __volatile__ (
"pop esi \n\t"
"pop edi \n\t":::);
"pop %%esi \n\t"
"pop %%edi \n\t":::);
}
 
extern int (*ted_can_save_asm)(editor *) __attribute__((__stdcall__));
static inline int editor_can_save(editor *ed)
/// return 1 if can be saved
/// return 1 if need to be saved (has changes), 0 otherwise
{
int ret;
__asm__ __volatile__ (
"push edi \n\t":::);
"push %%edi \n\t":::);
 
(*ted_can_save_asm)(ed);
 
__asm__ __volatile__ (
"pop edi \n\t":"=a"(ret)::);
"pop %%edi \n\t":"=a"(ret)::);
return ret;
}
 
224,12 → 224,12
/// all==1 - clear all memory
{
__asm__ __volatile__ (
"push edi \n\t":::);
"push %%edi \n\t":::);
 
(*ted_clear_asm)(ed, all);
 
__asm__ __volatile__ (
"pop edi \n\t":::);
"pop %%edi \n\t":::);
}
 
extern void (*ted_delete_asm)(editor *) __attribute__((__stdcall__));
237,12 → 237,12
/// frees all memory (destroy)
{
__asm__ __volatile__ (
"push edi \n\t":::);
"push %%edi \n\t":::);
 
(*ted_delete_asm)(ed);
 
__asm__ __volatile__ (
"pop edi \n\t":::);
"pop %%edi \n\t":::);
free(ed->scr_w);
free(ed->scr_h);
free(ed->buffer);
254,12 → 254,12
/// allocate memory
{
__asm__ __volatile__ (
"push edi \n\t":::);
"push %%edi \n\t":::);
 
(*ted_init_asm)(ed);
 
__asm__ __volatile__ (
"pop edi \n\t":::);
"pop %%edi \n\t":::);
}
 
extern int (*ted_is_select)(editor *) __attribute__((__stdcall__));
268,12 → 268,12
{
int ret;
__asm__ __volatile__ (
"push ebx \n\t":::);
"push %%ebx \n\t":::);
 
(*ted_is_select)(ed);
 
__asm__ __volatile__ (
"pop ebx \n\t":"=a"(ret)::);
"pop %%ebx \n\t":"=a"(ret)::);
return ret;
}
 
303,12 → 303,12
int ret;
struct fs_dirinfo di;
__asm__ __volatile__ (
"push edi \n\t":::);
"push %%edi \n\t":::);
 
(*ted_open_file_asm)(ed, &di, fname);
 
__asm__ __volatile__ (
"pop edi \n\t":"=b"(*readbytes), "=a"(ret)::);
"pop %%edi \n\t":"=b"(*readbytes), "=a"(ret)::);
return ret;
}
 
327,12 → 327,12
static inline void editor_cut(editor *ed)
{
__asm__ __volatile__ (
"push edi \n\t":::);
"push %%edi \n\t":::);
 
(*ted_but_cut)(ed);
 
__asm__ __volatile__ (
"pop edi \n\t":::);
"pop %%edi \n\t":::);
}
 
extern void (*ted_but_undo)(editor *) __attribute__((__stdcall__));
339,12 → 339,12
static inline void editor_undo(editor *ed)
{
__asm__ __volatile__ (
"push edi \n\t":::);
"push %%edi \n\t":::);
 
(*ted_but_undo)(ed);
 
__asm__ __volatile__ (
"pop edi \n\t":::);
"pop %%edi \n\t":::);
}
 
extern void (*ted_but_redo)(editor *) __attribute__((__stdcall__));
351,12 → 351,12
static inline void editor_redo(editor *ed)
{
__asm__ __volatile__ (
"push edi \n\t":::);
"push %%edi \n\t":::);
 
(*ted_but_redo)(ed);
 
__asm__ __volatile__ (
"pop edi \n\t":::);
"pop %%edi \n\t":::);
}
 
extern void (*ted_but_reverse)(editor *) __attribute__((__stdcall__));
363,14 → 363,14
static inline void editor_reverse(editor *ed)
{
__asm__ __volatile__ (
"push edi \n\t"
"push ebx\n\t":::);
"push %%edi \n\t"
"push %%ebx\n\t":::);
 
(*ted_but_reverse)(ed);
 
__asm__ __volatile__ (
"pop ebx \n\t"
"pop edi \n\t":::);
"pop %%ebx \n\t"
"pop %%edi \n\t":::);
}
 
extern void (*ted_text_colored_asm)() __attribute__((__stdcall__));
428,7 → 428,7
editor_keyboard(ed, conv_table, ed_ctrl, get_key().val);
}
 
inline void gui_add_editor(kolibri_window *wnd, editor* e)
static inline void gui_add_editor(kolibri_window *wnd, editor* e)
{
kolibri_window_add_element(wnd, KOLIBRI_EDITOR, e);
}
472,8 → 472,8
*/
ed->symbol_new_line = 20; // ascii(20)
 
ed->scr_w = kolibri_new_scrollbar_def(0, 0, 100, 30, 0);
ed->scr_h = kolibri_new_scrollbar_def(0, 0, 100, 30, 0);
ed->scr_w = kolibri_new_scrollbar_def(X_Y(50, 16), X_Y(50, 300), 100, 30, 0);
ed->scr_h = kolibri_new_scrollbar_def(X_Y(0, 150), X_Y(50, 16), 100, 30, 0);
 
ed->buffer_size = TE_BUF_SIZE;
ed->buffer = malloc(TE_BUF_SIZE);
/contrib/C_Layer/INCLUDE/kolibri_gui_elements.h
26,6 → 26,7
KOLIBRI_PATHSHOW,
KOLIBRI_FILEBROWSE,
KOLIBRI_EDITOR,
KOLIBRI_TREELIST,
 
/* Add elements above this element in order to let KOLIBRI_NUM_GUI_ELEMENTS */
/* stay at correct value */
81,6 → 82,7
#include "kolibri_statictext.h"
#include "kolibri_filebrowse.h"
#include "kolibri_editor.h"
#include "kolibri_treelist.h"
 
 
/*---------------------Define various functions for initializing GUI-------*/
156,6 → 158,11
kolibri_gui_op_table[KOLIBRI_EDITOR].mouse_fn = (cb_elem_boxlib)ted_mouse;
kolibri_gui_op_table[KOLIBRI_EDITOR].key_fn = (cb_elem_boxlib)editor_key;
debug_board_printf("KOLIBRI_EDITOR (%x,%x,%x)\n", ted_draw, ted_mouse, editor_key);
 
kolibri_gui_op_table[KOLIBRI_TREELIST].redraw_fn = (cb_elem_boxlib)tl_draw;
kolibri_gui_op_table[KOLIBRI_TREELIST].mouse_fn = (cb_elem_boxlib)tl_mouse;
kolibri_gui_op_table[KOLIBRI_TREELIST].key_fn = (cb_elem_boxlib)treelist_key;
debug_board_printf("KOLIBRI_TREELIST (%x,%x,%x)\n", tl_draw, tl_mouse, treelist_key);
}
 
/* Create a new main GUI window for KolibriOS */
/contrib/C_Layer/INCLUDE/kolibri_msgbox.h
29,16 → 29,19
 
msgbox* box = calloc(sizeof(msgbox), 1);
box->retval = (uint8_t)def_but;
char *pc = box->texts,
*but_text = va_arg(vl, char*);
char *pc = box->texts;
strcpy(pc, title);
pc += strlen(title) + 1;
strcpy(pc, text);
pc += strlen(text) + 1;
 
char *but_text = va_arg(vl, char*);
while (but_text)
{
strcpy(pc, but_text);
pc += strlen(but_text) + 1;
// assert(pc - box->texts < sizeof box->texts);
but_text = va_arg(vl, char*);
}
 
va_end(vl);
/contrib/C_Layer/INCLUDE/kolibri_treelist.h
1,65 → 1,8
#ifndef KOLIBRI_TREELIST_H
#define KOLIBRI_TREELIST_H
 
/*
el_focus dd tedit0
mouse_dd dd 0
tree1 tree_list 264,count_of_dir_list_files+2, tl_key_no_edit+tl_draw_par_line+tl_list_box_mode,\
16,16, 0x8080ff,0x0000ff,0xffffff, 0,70,TED_PANEL_WIDTH-17,120, 0,0,0, el_focus,\
ws_dir_lbox,0
 
tree3 tree_list MAX_COLOR_WORD_LEN,3,tl_key_no_edit,\
16,16, 0x8080ff,0x0000ff,0xffffff, 5,30,300,160, 16, 0,0, el_focus, w_scr_t3,0
 
tree_file_struct:
dd 1
dd 0,0,count_of_dir_list_files
dd dir_mem
db 0
dd file_name ;sys_path
*/
/*
;struct TreeList
; type dw ? ;+ 0 òèï ýëåìåíòà, èëè èíäåêñ èêîíêè äëÿ óçëà
; lev db ? ;+ 2 óðîâåíü ýëåìåíòà
; clo db ? ;+ 3 ôëàã çàêðûòèÿ, èëè îòêðûòèÿ (èìååò ñìûñë äëÿ ðîäèòåëüñêîãî óçëà)
; perv dd ? ;+ 4 èíäåêñ ïðåäûäóùåãî ýëåìåíòà
; next dd ? ;+ 8 èíäåêñ ïîñëåäóþùåãî ýëåìåíòà
; tc dd ? ;+12 âðåì. ñîçäàíèÿ
; td dd ? ;+16 âðåì. óäàëåíèÿ
;ends
 
struc tree_list info_size,info_max_count,style, img_cx,img_cy,\
col_bkg,col_zag,col_txt, box_l,box_t,box_w,box_h, capt_cy,info_capt_offs,\
info_capt_len,el_focus, p_scroll,on_press {
.box_left dd box_l
.box_top dd box_t
.box_width dd box_w
.box_height dd box_h
.data_info dd 0
.info_size dw info_size
.info_max_count dd info_max_count
.style dd style
.data_nodes dd 0
.data_img dd 0
.img_cx dw img_cx
.img_cy dw img_cy
.data_img_sys dd 0
.ch_tim dd 0
.tim_undo dd 0
.cur_pos dd 0
.col_bkg dd col_bkg
.col_zag dd col_zag
.col_txt dd col_txt
.capt_cy dw capt_cy
.info_capt_offs dw info_capt_offs
.info_capt_len dw info_capt_len
.el_focus dd el_focus
.p_scroll dd p_scroll
.on_press dd on_press
}
*/
// êîíñòàíòû ñòèëÿ
/// êîíñòàíòû ñòèëÿ
enum tl_style {
TL_KEY_NO_EDIT = 1, // ýëåìåíò íåëüçÿ ðåäàêòèðîâàòü íà êëàâèàòóðå (èçìåíÿòü óðîâíè, óäàëÿòü)
TL_DRAW_PAR_LINE = 2, // ðèñîâàòü ëèíèè ê ðîäèòåëüñêîìó óçëó
66,7 → 9,25
TL_LISTBOX_MODE = 4 //ñòèëü íå îòîáðàæàåò óðîâíè (êàê â ListBox âñå îäíîãî óðîâíÿ)
};
 
/// êîíñòàíòû äëÿ ôóíêöèé
enum tl_err {
TL_ERR_LOAD_CAPTION = 1, //â ïàìÿòè íåò çàãîëîâêà 'tree'
TL_ERR_SAVE_MEMOTY_SIZE = 2, //íå õâàòàåò ïàìÿòè äëÿ ñîõðàíåíèÿ ýëåìåíòà
TL_ERR_LOAD_INFO_SIZE = 4, //íå ñîâïàäàåò ðàçìåð èíôîðìàöèîííîé ñòðóêòóðû ïðè îòêðûòèè
};
 
typedef struct __attribute__ ((__packed__)) {
uint16_t type; //òèï ýëåìåíòà, èëè èíäåêñ èêîíêè äëÿ óçëà
uint8_t lev; //óðîâåíü ýëåìåíòà
uint8_t clo; //ôëàã çàêðûòèÿ, èëè îòêðûòèÿ (èìååò ñìûñë äëÿ ðîäèòåëüñêîãî óçëà)
uint32_t prev; //èíäåêñ ïðåäûäóùåãî ýëåìåíòà
uint32_t next; //èíäåêñ ïîñëåäóþùåãî ýëåìåíòà
uint32_t tcreat; //âðåì. ñîçäàíèÿ
uint32_t tdel; //âðåì. óäàëåíèÿ
} treelist_node;
 
 
typedef struct __attribute__ ((__packed__)) {
uint32_t left;
uint32_t top;
uint32_t width;
75,7 → 36,7
uint16_t info_size; // ðàçìåð äàííûõ âûäåëÿåìûõ äëÿ êàæäîãî óçëà (ïîëüçîâàòåëüñüêèå äàííûå + òåêñò äëÿ ïîäïèñè)
uint32_t info_max_count; // ìàêñèìàëüíîå êîëè÷åñòâî óçëîâ, êîòîðûå ìîæíî äîáàâèòü â ýëåìåíò
uint32_t style; // ñòèëè ýëåìåíòà
void *data_nodes; // óêàçàòåëü íà ñòðóêòóðû óçëîâ
treelist_node *data_nodes; // óêàçàòåëü íà ñòðóêòóðû óçëîâ
void *data_img; // óêàçàòåëü íà èçîáðàæåíèÿ ñ èêîíêàìè óçëîâ
uint16_t img_cx; // øèðèíà èêîíîê
uint16_t img_cy; // âûñîòà èêîíîê
84,23 → 45,428
uint32_t tim_undo; // êîëè÷åñòâî îòìåíåííûõ äåéñòâèé
uint32_t cur_pos; // ïîçèöèÿ êóðñîðà
color_t col_bkg; // öâåò ôîíà
color_t tl_col_zag; // öâåò çàãîëîâêà
color_t tl_col_txt; // öâåò òåêñòà
color_t col_zag; // öâåò çàãîëîâêà
color_t col_txt; // öâåò òåêñòà
uint16_t capt_cy; // âûñîòà ïîäïèñè
uint16_t info_capt_offs;//ñäâèã äëÿ íà÷àëà òåêñòà (ïîäïèñè óçëà)
uint16_t info_capt_len;//äëèíà òåêñòà ïîäïèñè óçëà (åñëè = 0 òî äî êîíöà ñòðóêòóðû)
void *el_focus; // óêàçàòåëü íà ñòðóêòóðó ýëåìåíòà â ôîêóñå
void *p_scroll; // óêàçàòåëü íà ñòðóêòóðó ñêðîëëèíãà
scrollbar *p_scroll; // óêàçàòåëü íà ñòðóêòóðó ñêðîëëèíãà
void *on_press; // +84 óêàçàòåëü íà ôóíêöèþ, êîòîðàÿ âûçûâàåòñÿ ïðè íàæàòèè Enter
} treelist;
 
/*
;êîíñòàíòû äëÿ ôóíêöèé
tl_err_save_memory_size equ 10b ;íå õâàòàåò ïàìÿòè äëÿ ñîõðàíåíèÿ ýëåìåíòà
tl_err_load_caption equ 1b ;â ïàìÿòè íåò çàãîëîâêà 'tree'
tl_err_load_info_size equ 100b ;íå ñîâïàäàåò ðàçìåð èíôîðìàöèîííîé ñòðóêòóðû ïðè îòêðûòèè
tl_load_mode_add equ 0x20000 ;îïöèÿ ñ÷èòûâàíèÿ â ðåæèìå äîáàâëåíèÿ èíôîðìàöèè
tl_save_load_heder_size equ 26 ;ðàçìåð çàãîëîâêà äëÿ çàïèñè/÷òåíèÿ ýëåìåíòîâ
*/
static inline treelist* kolibri_new_treelist( uint32_t x_w, uint32_t y_h, uint16_t capt_cy, uint32_t icon_size_xy, uint16_t info_size, uint32_t info_max_count,
uint16_t info_capt_len, uint16_t info_capt_offs, enum tl_style style, void *el_focus, color_t back, color_t title, color_t txt)
{
treelist *tl = (treelist *)calloc(1, sizeof(treelist));
tl->left= x_w >> 16;
tl->width = x_w & 0xFFFF;
tl->top = y_h >> 16;
tl->height = y_h & 0xFFFF;
tl->info_size = info_size;
tl->info_max_count = info_max_count;
tl->style = style;
tl->img_cx = icon_size_xy >> 16;
tl->img_cy = icon_size_xy & 0xFFFF;
tl->col_bkg = back;
tl->col_zag = title;
tl->col_txt = txt;
tl->info_capt_len = info_capt_len;
tl->info_capt_offs = info_capt_offs;
tl->el_focus = el_focus;
tl->p_scroll = kolibri_new_scrollbar_def(X_Y(0, 16), X_Y(70, 30), 100, 30, 0);
return tl;
}
 
static inline void gui_add_treelist(kolibri_window *wnd, treelist* tl)
{
kolibri_window_add_element(wnd, KOLIBRI_TREELIST, tl);
}
 
 
///ðåàêöèÿ íà ìûøü
extern void (*tl_mouse)(treelist *) __attribute__((__stdcall__));
 
///âûâîä ñïèñêà íà ýêðàí
extern void (*tl_draw)(treelist *) __attribute__((__stdcall__));
 
///ïåðåìåùàåì óçåë ââåðõ
extern void (*tl_node_move_up)(treelist *) __attribute__((__stdcall__));
 
///ïåðåìåùàåì óçåë âíèç
extern void (*tl_node_move_down)(treelist *) __attribute__((__stdcall__));
 
extern void (*tl_data_init_asm)(treelist *) __attribute__((__stdcall__));
///âûäåëåíèå ïàìÿòè äëÿ ñòðóêòóð ñïèñêà è îñíîâíîé èíôîðìàöèè (êîíñòðóêòîð)
static inline void treelist_data_init(treelist *tl)
{
__asm__ __volatile__ (
"push %%edi \n\t":::);
 
(*tl_data_init_asm)(tl);
 
__asm__ __volatile__ (
"pop %%edi \n\t":::);
}
 
extern void (*tl_data_clear_asm)(treelist *) __attribute__((__stdcall__));
///î÷èñòêà ïàìÿòè ýëåìåíòà (äåñòðóêòîð)
static inline void treelist_data_clear(treelist *tl)
{
__asm__ __volatile__ (
"push %%edi \n\t":::);
 
(*tl_data_clear_asm)(tl);
 
__asm__ __volatile__ (
"pop %%edi \n\t":::);
}
 
extern void (*tl_info_clear_asm)(treelist *) __attribute__((__stdcall__));
///î÷èñòêà ñïèñêà (èíôîðìàöèè)
static inline void treelist_info_clear(treelist *tl)
{
__asm__ __volatile__ (
"push %%edi \n\t":::);
 
(*tl_info_clear_asm)(tl);
 
__asm__ __volatile__ (
"pop %%edi \n\t":::);
}
 
extern void (*tl_key_asm)(treelist *) __attribute__((__stdcall__));
///ðåàêöèÿ íà êëàâèàòóðó
static inline void treelist_key(treelist *tl)
{
__asm__ __volatile__ (
"push %%ebx \n\t"
"push %%edi \n\t":::);
 
(*tl_key_asm)(tl);
 
__asm__ __volatile__ (
"pop %%edi \n\t"
"pop %%ebx \n\t":::);
}
 
extern void (*tl_info_undo_asm)(treelist *) __attribute__((__stdcall__));
///îòìåíà äåéñòâèÿ
static inline void treelist_undo(treelist *tl)
{
__asm__ __volatile__ (
"push %%edi \n\t":::);
 
(*tl_info_undo_asm)(tl);
 
__asm__ __volatile__ (
"pop %%edi \n\t":::);
}
 
extern void (*tl_info_redo_asm)(treelist *) __attribute__((__stdcall__));
///ïîâòîð äåéñòâèÿ
static inline void treelist_redo(treelist *tl)
{
__asm__ __volatile__ (
"push %%edi \n\t":::);
 
(*tl_info_redo_asm)(tl);
 
__asm__ __volatile__ (
"pop %%edi \n\t":::);
}
 
extern void (*tl_node_add_asm)(treelist *, uint32_t n_opt, void *n_info) __attribute__((__stdcall__));
///äîáàâèòü óçåë
///input:
/// tlist - óêàçàòåëü íà ñòðóêòóðó ëèñòà
/// n_opt - îïöèè äîáàâëåíèÿ
/// n_info - óêàçàòåëü íà äîáàâëÿåìûå äàííûå
static inline void treelist_node_add(treelist *tl, void *n_info, uint16_t type, uint8_t clos, uint8_t lev)
{
__asm__ __volatile__ (
"push %%ebx \n\t"
"push %%edi \n\t":::);
 
uint32_t n_opt = (type << 16) | (clos << 8) | lev;
(*tl_node_add_asm)(tl, n_opt, n_info);
 
__asm__ __volatile__ (
"pop %%edi \n\t"
"pop %%ebx \n\t":::);
}
 
extern void (*tl_node_set_data_asm)(treelist *, void *n_info) __attribute__((__stdcall__));
///çàïèñàòü â òåêóùèé óçåë
///input:
/// tlist - óêàçàòåëü íà ñòðóêòóðó ëèñòà
/// n_info - óêàçàòåëü íà äàííûå
static inline void treelist_node_setdata(treelist *tl, void *n_info)
{
__asm__ __volatile__ (
"push %%esi \n\t"
"push %%edi \n\t":::);
 
(*tl_node_set_data_asm)(tl, n_info);
 
__asm__ __volatile__ (
"pop %%edi \n\t"
"pop %%esi \n\t":::);
}
 
extern void* (*tl_node_get_data_asm)(treelist *) __attribute__((__stdcall__));
///âçÿòü óêàçàòåëü íà äàííûå óçëà ïîä êóðñîðîì
static inline void* treelist_getdata(treelist *tl)
{
__asm__ __volatile__ (
"push %%edi \n\t":::);
 
void *res =
(*tl_node_get_data_asm)(tl);
 
__asm__ __volatile__ (
"pop %%edi \n\t":::);
return res;
}
 
extern void (*tl_node_delete_asm)(treelist *) __attribute__((__stdcall__));
///óäàëèòü óçåë ïîä êóðñîðîì
static inline void treelist_node_delete(treelist *tl)
{
__asm__ __volatile__ (
"push %%edi \n\t":::);
 
(*tl_node_delete_asm)(tl);
 
__asm__ __volatile__ (
"pop %%edi \n\t":::);
}
 
extern void (*tl_cur_beg_asm)(treelist *) __attribute__((__stdcall__));
///ïîñòàâèòü êóðñîð íà ïåðâûé óçåë
static inline void treelist_cursor_begin(treelist *tl)
{
__asm__ __volatile__ (
"push %%edi \n\t":::);
 
(*tl_cur_beg_asm)(tl);
 
__asm__ __volatile__ (
"pop %%edi \n\t":::);
}
 
extern void (*tl_cur_next_asm)(treelist *) __attribute__((__stdcall__));
///ïåðåíåñòè êóðñîð íà 1 ïîçèöèþ íèæå
static inline void treelist_cursor_next(treelist *tl)
{
__asm__ __volatile__ (
"push %%ebx \n\t"
"push %%esi \n\t"
"push %%edi \n\t":::);
 
(*tl_cur_next_asm)(tl);
 
__asm__ __volatile__ (
"pop %%edi \n\t"
"pop %%esi \n\t"
"pop %%ebx \n\t":::);
}
 
extern void (*tl_cur_perv_asm)(treelist *) __attribute__((__stdcall__));
///ïåðåíåñòè êóðñîð íà 1 ïîçèöèþ âûøå
static inline void treelist_cursor_prev(treelist *tl)
{
__asm__ __volatile__ (
"push %%ebx \n\t"
"push %%esi \n\t"
"push %%edi \n\t":::);
 
(*tl_cur_perv_asm)(tl);
 
__asm__ __volatile__ (
"pop %%edi \n\t"
"pop %%esi \n\t"
"pop %%ebx \n\t":::);
}
 
extern void (*tl_node_close_open_asm)(treelist *) __attribute__((__stdcall__));
///îòêðûòü/çàêðûòü óçåë (ðàáîòàåò ñ óçëàìè êîòîðûå èìåþò äî÷åðíèå óçëû)
static inline void treelist_close_open(treelist *tl)
{
__asm__ __volatile__ (
"push %%edi \n\t":::);
 
(*tl_node_close_open_asm)(tl);
 
__asm__ __volatile__ (
"pop %%edi \n\t":::);
}
 
extern void (*tl_node_lev_inc_asm)(treelist *) __attribute__((__stdcall__));
///óâåëè÷èòü óðîâåíü
static inline void treelist_level_inc(treelist *tl)
{
__asm__ __volatile__ (
"push %%edi \n\t":::);
 
(*tl_node_lev_inc_asm)(tl);
 
__asm__ __volatile__ (
"pop %%edi \n\t":::);
}
 
extern void (*tl_node_lev_dec_asm)(treelist *) __attribute__((__stdcall__));
///óìåíüøèòü óðîâåíü
static inline void treelist_level_dec(treelist *tl)
{
__asm__ __volatile__ (
"push %%edi \n\t":::);
 
(*tl_node_lev_dec_asm)(tl);
 
__asm__ __volatile__ (
"pop %%edi \n\t":::);
}
 
extern treelist_node* (*tl_node_poi_get_info_asm)(treelist *, int node_ind) __attribute__((__stdcall__));
///âçÿòü óêàçàòåëü íà ñòðóêòóðó óçëà â óêàçàííîé ïîçèöèè
///input:
/// tlist - pointer to 'TreeList' struct
/// node_ind - node index
///output - pointer to node info or NULL
static inline treelist_node* treelist_getnode(treelist *tl, int node_ind)
{
__asm__ __volatile__ (
"push %%ebx \n\t"
"push %%edi \n\t":::);
 
treelist_node *ret =
(*tl_node_poi_get_info_asm)(tl, node_ind);
 
__asm__ __volatile__ (
"pop %%edi \n\t"
"pop %%ebx \n\t":::);
return ret;
}
 
extern treelist_node* (*tl_node_poi_get_next_info_asm)(treelist *, treelist_node*) __attribute__((__stdcall__));
///âçÿòü óêàçàòåëü íà ñëåäóùóþ ñòðóêòóðó óçëà
///input:
/// tlist - pointer to 'TreeList' struct
/// node_p - node param struct
///output - pointer to next node struct or NULL
static inline treelist_node* treelist_getnode_next(treelist *tl, treelist_node* node)
{
__asm__ __volatile__ (
"push %%ebx \n\t"
"push %%edi \n\t":::);
 
treelist_node *ret =
(*tl_node_poi_get_next_info_asm)(tl, node);
 
__asm__ __volatile__ (
"pop %%edi \n\t"
"pop %%ebx \n\t":::);
return ret;
}
 
extern void* (*_tl_node_poi_get_data_asm)(treelist *, treelist_node*) __attribute__((__stdcall__));
///;âçÿòü óêàçàòåëü íà äàííûå óçëà
///input:
/// tlist - pointer to 'TreeList' struct
/// node_p - node param struct
///output - pointer
static inline void* treelist_getnode_data(treelist *tl, treelist_node *node)
{
__asm__ __volatile__ (
"push %%edi \n\t":::);
 
void *ret =
(*_tl_node_poi_get_data_asm)(tl, node);
 
__asm__ __volatile__ (
"pop %%edi \n\t":::);
return ret;
}
 
extern int (*tl_save_mem_asm)(treelist *, int opt, void *h_mem, int mem_size) __attribute__((__stdcall__));
/// tlist - pointer to 'TreeList' struct
/// opt - options: 0 - first element, 1 - add next element
/// h_mem - pointer to memory
/// mem_size - memory size
///output - error code
static inline int treelist_save2mem(treelist *tl, int opt, void *h_mem, int mem_size)
{
__asm__ __volatile__ (
"push %%ebx \n\t"
"push %%esi \n\t"
"push %%edi \n\t":::);
 
int ret =
(*tl_save_mem_asm)(tl, opt, h_mem, mem_size);
 
__asm__ __volatile__ (
"pop %%edi \n\t"
"pop %%esi \n\t"
"pop %%ebx \n\t":::);
return ret;
}
 
extern int (*_tl_load_mem_asm)(treelist *, int opt, void *h_mem, int mem_size) __attribute__((__stdcall__));
/**input:
; tlist - pointer to 'TreeList' struct
; opt - options: element index + (2*(add mode)+(init mode)) shl 16, tl_load_mode_add equ 0x20000 ;îïöèÿ ñ÷èòûâàíèÿ â ðåæèìå äîáàâëåíèÿ èíôîðìàöèè
; h_mem - pointer to memory
; mem_size - memory size
; ðàçìåð ïàìÿòè, ïîêà íå èñïîëüçóåòñÿ (íàçíà÷àëñÿ äëÿ êîíòðîëÿ)
; äëÿ åãî èñïîëüçîâàíèÿ íóæíî äîðàáîòàòü ôóíêöèþ
;output:
; eax - error code
;memory header format:
; +0 - (4) 'tree'
; +4 - (2) info size
; +6 - (4) count nodes
; +10 - (4) tlist style
; +14 - (4) cursor pos
; +18 - (2) info capt offs
; +20 - (2) info capt len
; +22 - (4) scroll pos
;memory data format:
; +26 - (info size + 8) * count nodes */
static inline int treelist_load4mem(treelist *tl, int opt, void *h_mem, int mem_size)
{
__asm__ __volatile__ (
"push %%ebx \n\t"
"push %%esi \n\t"
"push %%edi \n\t":::);
 
int ret =
(*_tl_load_mem_asm)(tl, opt, h_mem, mem_size);
 
__asm__ __volatile__ (
"pop %%edi \n\t"
"pop %%esi \n\t"
"pop %%ebx \n\t":::);
return ret;
}
 
extern int (*tl_get_mem_size_asm)(treelist *, void *h_mem) __attribute__((__stdcall__));
/// ;áåðåò ðàçìåð ïàìÿòè çàíÿòîé ôóíêöèåé tl_save_mem ïðè ñîõðàíåíèè ýëåìåíòîâ
/// tlist - pointer to 'TreeList' struct
/// h_mem - pointer to saved memory
static inline int treelist_get_memsize(treelist *tl, void *h_mem)
{
__asm__ __volatile__ (
"push %%ebx \n\t"
"push %%edi \n\t":::);
 
int ret =
(*tl_get_mem_size_asm)(tl, h_mem);
 
__asm__ __volatile__ (
"pop %%edi \n\t"
"pop %%ebx \n\t":::);
return ret;
}
 
#endif //KOLIBRI_TREELIST_H