Subversion Repositories Kolibri OS

Compare Revisions

Regard whitespace Rev 6611 → Rev 6612

/contrib/C_Layer/INCLUDE/kolibri_button.h
21,7 → 21,8
return new_button;
}
 
void draw_button(kolibri_button *some_button)
__attribute__((__stdcall__))
static inline void draw_button(kolibri_button *some_button)
{
define_button(some_button -> x65536sizex, some_button -> y65536sizey, some_button -> identifier, some_button -> color);
}
/contrib/C_Layer/INCLUDE/kolibri_debug.h
9,7 → 9,7
/* Write a printf() like function (variable argument list) for
writing to debug board */
 
inline void debug_board_write_byte(const char ch){
static inline void debug_board_write_byte(const char ch){
__asm__ __volatile__(
"int $0x40"
:
22,7 → 22,7
debug_board_write_byte(*str++);
}
 
void debug_board_printf(const char *format,...)
static inline void debug_board_printf(const char *format,...)
{
va_list ap;
char log_board[300];
33,4 → 33,13
debug_board_write_str(log_board);
}
 
__attribute__ ((noinline)) void trap(int n)
{
// nothing todo, just see n in debugger. use "bp trap" command
__asm__ __volatile__(
"nop"
:
:"a"(n));
}
 
#endif /* KOLIBRI_DEBUG_H */
/contrib/C_Layer/INCLUDE/kolibri_editbox.h
5,8 → 5,8
 
/* flags meaning
ed_figure_only= 1000000000000000b ;îäíè ñèìâîëû
ed_always_focus= 100000000000000b
ed_focus= 10b ;ôîêóñ ââîäà ïðèëîæåíèÿ
ed_always_focus= 100000000000000b // âñåãäà ñ êóðñîðîì (ôîêóñîì)
ed_focus= 10b ;ôîêóñ ââîäà ïðèëîæåíèÿ, ìûøèòñÿ ñàìîñòîÿòåëüíî
ed_pass= 1b ;ïîëå ñ ïàðîëåì
ed_shift_on= 1000b ;åñëè íå óñòàíîâëåí -çíà÷èò âïåðâûå íàæàò shift,åñëè áûë óñòàíîâëåí, çíà÷èò ìû óæå ÷òî - òî äåëàëè óäåðæèâàÿ shift
ed_shift_on_off=1111111111110111b
44,7 → 44,7
unsigned int text_color;
unsigned int max;
char *text;
struct edit_box_t** mouse_variable; // must be pointer edit_box** to save focused editbox
void *mouse_variable; // must be pointer edit_box** to save focused editbox
unsigned int flags;
 
unsigned int size; // used symbols in buffer without trailing zero
72,7 → 72,7
max_chars = Limit of number of characters user can enter into edit box.
*/
 
edit_box* kolibri_new_edit_box(unsigned int tlx, unsigned int tly, unsigned int max_chars, edit_box **editbox_interlock)
edit_box* kolibri_new_edit_box(unsigned int tlx, unsigned int tly, unsigned int max_chars, void *editbox_interlock)
{
unsigned int PIXELS_PER_CHAR = 7;
edit_box *new_textbox = (edit_box *)calloc(1, sizeof(edit_box));
99,12 → 99,24
 
extern void (*edit_box_draw)(edit_box *) __attribute__((__stdcall__));
 
extern void (*edit_box_key)(edit_box *) __attribute__((__stdcall__));
/* editbox_key is a wrapper written in assembly to handle key press events for editboxes */
/* because inline assembly in GCC is a PITA and interferes with the EAX (AH) register */
/* which edit_box_key requires */
extern void editbox_key(edit_box *) __attribute__((__stdcall__));
__attribute__((__stdcall__)) void editbox_key(edit_box *e, oskey_t ch)
/// åñëè flags íå ñîäåðæèò ed_focus, èãíîðèðóåò ââîä
/// åñëè flags ñîäåðæèò ed_mouse_on èëè ed_disabled, èãíîðèðóåò ââîä
/// íà ââîäå îæèäàåò ch - êîä êëàâèøè, òîëüêî â ðåæèìå ASCII
{
__asm__ __volatile__ (
"push %2\n\t"
"call *%1 \n\t"::"a"(ch.val), "m"(edit_box_key), "m"(e):);
}
 
extern void (*edit_box_mouse)(edit_box *) __attribute__((__stdcall__));
/// ïðè ùåë÷êå íå ëåâîé êíîïêîé, îáíóëÿåò *mouse_variable! è ñáðàñûâàåò ôëàã ed_mouse_on
 
 
extern void (*edit_box_set_text)(edit_box *, char *) __attribute__((__stdcall__));
extern volatile unsigned press_key;
#endif /* KOLIBRI_EDITBOX_H */
/contrib/C_Layer/INCLUDE/kolibri_editor.h
24,8 → 24,8
uint32_t y_pos; //50
uint32_t width; //440
uint32_t hight; //150
uint32_t w_pane; //30 øèðèíà ïàíåëè â îêíå
uint32_t h_pane; //25 âûñîòà ïàíåëè â îêíå
uint32_t w_pane; //30 øèðèíà ïàíåëè â îêíå, width of left pane with line numbers
uint32_t h_pane; //25 âûñîòà ïàíåëè â îêíå, hight of top pane with Rows, Cols Undo info
uint32_t width_sym; //9 øèðèíà ñèìâîëà (çíàêîìåñòà) â îêíå
uint32_t hight_sym; //16 âûñîòà ñèìâîëà (çíàêîìåñòà) â îêíå
uint8_t drag_m; // âûäåëåíèå îò ìûøè
285,15 → 285,21
};
 
extern void (*ted_key_asm)(editor *, char* table, int control) __attribute__((__stdcall__));
static inline void editor_keyboard(editor *ed, char* table, enum control_keys control, int ch)
static inline __attribute__((__stdcall__)) void editor_keyboard(editor *ed, char* table, enum control_keys control, int ch)
/// control is KM_SHIFT, KM_ALT, KM_CTRL, KM_NUMLOCK,
/// ch = GET_KEY
/// table = SF_SYSTEM_GET,SSF_KEYBOARD_LAYOUT
{
__asm__ __volatile__ (
"push %4\n\t"
"push %3\n\t"
"push %2\n\t"
"call *%1 \n\t"::"a"(ch), "m"(ted_key_asm), "m"(ed), "m"(table), "m"(control):);
/*
__asm__ __volatile__ (
"nop \n\t"::"a"(ch):);
 
(*ted_key_asm)(ed, table, control);
*/
}
 
extern void (*ted_open_file_asm)(editor *, struct fs_dirinfo*, char *fname) __attribute__((__stdcall__));
410,10 → 416,12
return lang;
};
 
 
static void editor_key(editor* ed)
__attribute__((__stdcall__))
static void editor_key(editor* ed, oskey_t key)
// callback for gui
{
//if(ed->el_focus != ed) return; // need to check not to lose keyb buffer
 
uint32_t control = get_control_keys();
enum control_keys ed_ctrl = 0;
int ly_opt = 1;
425,7 → 433,7
char conv_table[128];
get_keyboard_layout(ly_opt, conv_table);
 
editor_keyboard(ed, conv_table, ed_ctrl, get_key().val);
editor_keyboard(ed, conv_table, ed_ctrl, key.val);
}
 
static inline void gui_add_editor(kolibri_window *wnd, editor* e)
433,7 → 441,7
kolibri_window_add_element(wnd, KOLIBRI_EDITOR, e);
}
 
static inline editor* kolibri_new_editor(uint32_t x_w, uint32_t y_h, uint32_t font, uint32_t max_chars, editor **editor_interlock)
static inline editor* kolibri_new_editor(uint32_t x_w, uint32_t y_h, uint32_t font, uint32_t max_chars, void *editor_interlock)
/// font - 0b10SSS 8x16 size multiply (SSS+1), 0xSSS - 6x9 multiply (SSS+1)
 
{
443,7 → 451,8
ed->y_pos = y_h >> 16;
ed->hight = y_h & 0xFFFF;
 
// no panel, w_pane, h_pane == 0
ed->w_pane = 30;
ed->h_pane = 20;
// font
if (font == 0) font = 0x10; // default 16 = 8x16
int font_multipl = (font & 7) + 1;
472,8 → 481,8
*/
ed->symbol_new_line = 20; // ascii(20)
 
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->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
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
 
ed->buffer_size = TE_BUF_SIZE;
ed->buffer = malloc(TE_BUF_SIZE);
483,6 → 492,8
ed->mode_color = 1; // can select text
ed->mode_invis = 1; // show nonprinted symbols
 
ed->el_focus = editor_interlock;
 
// ??? saveregs ax,cx,di
editor_init(ed); // memory allocation, cleaning
ed->syntax_file = (char*)&default_syntax;
/contrib/C_Layer/INCLUDE/kolibri_filebrowse.h
226,4 → 226,52
extern void (*filebrowse_key)(filebrowser *) __attribute__((__stdcall__));
extern void (*filebrowse_mouse)(filebrowser *) __attribute__((__stdcall__));
 
__attribute__((__stdcall__)) static inline void filebrowser_key(filebrowser *fb, oskey_t keypress)
/// wrapper for key, translate keypress (ASCII mode) to action for browser
{
// if (!fb->select_flag) return; // same reaction as other controls
 
int extended_key = 0, act = 0;
 
if(keypress.state) return;
if (keypress.code == 0xE0){ extended_key = 1; return; }
 
act = 0;
switch(keypress.ctrl_key) // ascii scancode
{
case 80: // arrow down
act = 1; break;
case 72: // arrow up
act = 2; break;
case 81: // PageDown
act = 3; break;
case 73: // PageUp
act = 4; break;
case 71: // Home
act = 5; break;
case 79: // End
act = 6; break;
case 28: // Enter
act = 7; break;
case 82: // Insert
act = 8; break;
case 78: // NumPad+ select all
act = 9; break;
case 74: // NumPad- deselct
act = 10; break;
case 55: // NumPad* invert selection
act = 11; break;
default:
act = 12; // search by letter
}
fb->key_action = act;
fb->key_action_num = keypress.ctrl_key;
 
// debug_board_printf("key pressed [%X] %d, action %d, ext_flag = %d\n", keypress.val, brows.key_action_num, act, extended_key);
 
if (extended_key) extended_key = 0;
(*filebrowse_key)(fb);
}
 
 
#endif /* KOLIBRI_FILEBROWSE_H */
/contrib/C_Layer/INCLUDE/kolibri_gui.h
66,7 → 66,7
}
}
 
void kolibri_handle_event_key(kolibri_window* some_window)
void kolibri_handle_event_key(kolibri_window* some_window, oskey_t key)
{
/* Enumerate and trigger key handling functions of window elements here */
if(some_window->elements)
75,9 → 75,9
 
do
{
/* Only execute if the function pointer isn't NULL */
/* Only execute if the function pointer isn't NULL, or -1 (fail to find in export table) */
if((int)kolibri_gui_op_table[current_element -> type].key_fn > 0)
kolibri_gui_op_table[current_element -> type].key_fn(current_element -> element);
kolibri_gui_op_table[current_element -> type].key_fn(current_element -> element, key);
 
current_element = current_element -> next;
} while(current_element != some_window->elements); /* Have we covered all elements? */
/contrib/C_Layer/INCLUDE/kolibri_gui_elements.h
44,12 → 44,13
}kolibri_window_element;
 
typedef void (*cb_elem_boxlib)(void *) __attribute__((__stdcall__));
typedef void (*cbkey_elem_boxlib)(void *, oskey_t) __attribute__((__stdcall__));
 
/* Generic structure for supporting functions on various elements of Kolibri's GUI */
typedef struct {
cb_elem_boxlib redraw_fn;
cb_elem_boxlib mouse_fn;
cb_elem_boxlib key_fn;
cbkey_elem_boxlib key_fn;
}kolibri_element_operations;
 
/* Structure for a GUI Window on Kolibri. It also contains all the elements drawn in window */
95,7 → 96,7
/* Setting up functions for edit box GUI elements*/
kolibri_gui_op_table[KOLIBRI_EDIT_BOX].redraw_fn = (cb_elem_boxlib)edit_box_draw;
kolibri_gui_op_table[KOLIBRI_EDIT_BOX].mouse_fn = (cb_elem_boxlib)edit_box_mouse;
kolibri_gui_op_table[KOLIBRI_EDIT_BOX].key_fn = (cb_elem_boxlib)editbox_key;
kolibri_gui_op_table[KOLIBRI_EDIT_BOX].key_fn = (cbkey_elem_boxlib)editbox_key;
 
/* Setting up functions for check box GUI elements*/
kolibri_gui_op_table[KOLIBRI_CHECK_BOX].redraw_fn = (cb_elem_boxlib)check_box_draw2;
152,17 → 153,16
 
kolibri_gui_op_table[KOLIBRI_FILEBROWSE].redraw_fn = (cb_elem_boxlib)filebrowse_draw;
kolibri_gui_op_table[KOLIBRI_FILEBROWSE].mouse_fn = (cb_elem_boxlib)filebrowse_mouse;
kolibri_gui_op_table[KOLIBRI_FILEBROWSE].key_fn = (cb_elem_boxlib)filebrowse_key;
kolibri_gui_op_table[KOLIBRI_FILEBROWSE].key_fn = (cbkey_elem_boxlib)filebrowser_key;
 
kolibri_gui_op_table[KOLIBRI_EDITOR].redraw_fn = (cb_elem_boxlib)ted_draw;
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_EDITOR].key_fn = (cbkey_elem_boxlib)editor_key;
 
kolibri_gui_op_table[KOLIBRI_TREELIST].redraw_fn = (cb_elem_boxlib)tl_draw;
kolibri_gui_op_table[KOLIBRI_TREELIST].redraw_fn = (cb_elem_boxlib)treelist_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);
kolibri_gui_op_table[KOLIBRI_TREELIST].key_fn = (cbkey_elem_boxlib)treelist_key;
debug_board_printf("KOLIBRI_TREELIST (%x,%x,%x)\n", treelist_draw, tl_mouse, treelist_key);
}
 
/* Create a new main GUI window for KolibriOS */
/contrib/C_Layer/INCLUDE/kolibri_msgbox.h
5,7 → 5,7
typedef struct __attribute__ ((__packed__)) {
uint8_t retval; // 0 - win closed, 1 to n - button num, also default button on start
uint8_t reserv;
char texts[2048]; // mus be enough ;-)
char texts[2048]; // must be enough ;-)
char msgbox_stack[1024];
uint32_t top_stack;
} msgbox;
49,7 → 49,7
return box;
}
 
void kolibri_start_msgbox(msgbox* box, msgbox_callback cb[])
static inline void kolibri_start_msgbox(msgbox* box, msgbox_callback cb[])
{
if (!msgbox_inited)
{
/contrib/C_Layer/INCLUDE/kolibri_scrollbar.h
29,7 → 29,7
uint32_t run_size;
uint32_t position2;
uint32_t work_size;
uint32_t all_redraw;
uint32_t all_redraw; // need to be set =1 before each redraw
uint32_t ar_offset;
} scrollbar;
 
/contrib/C_Layer/INCLUDE/kolibri_treelist.h
74,7 → 74,7
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);
tl->p_scroll = kolibri_new_scrollbar_def(X_Y(0, 16), X_Y(0, 0), 100, 30, 0);
return tl;
}
 
89,7 → 89,13
 
///âûâîä ñïèñêà íà ýêðàí
extern void (*tl_draw)(treelist *) __attribute__((__stdcall__));
__attribute__((__stdcall__)) static inline void treelist_draw(treelist *tl)
{
tl->p_scroll->all_redraw = 1;
(*tl_draw)(tl);
}
 
 
///ïåðåìåùàåì óçåë ââåðõ
extern void (*tl_node_move_up)(treelist *) __attribute__((__stdcall__));
 
120,6 → 126,7
 
__asm__ __volatile__ (
"pop %%edi \n\t":::);
free(tl->p_scroll);
}
 
extern void (*tl_info_clear_asm)(treelist *) __attribute__((__stdcall__));
137,17 → 144,13
 
extern void (*tl_key_asm)(treelist *) __attribute__((__stdcall__));
///ðåàêöèÿ íà êëàâèàòóðó
static inline void treelist_key(treelist *tl)
__attribute__((__stdcall__)) static inline void treelist_key(treelist *tl, oskey_t code)
{
__asm__ __volatile__ (
"push %%ebx \n\t"
"push %%edi \n\t":::);
"push %2\n\t"
"call *%1 \n\t"::"a"(code.val), "m"(tl_key_asm), "m"(tl):); // indirect call with asterisk *
 
(*tl_key_asm)(tl);
 
__asm__ __volatile__ (
"pop %%edi \n\t"
"pop %%ebx \n\t":::);
// (*tl_key_asm)(tl);
}
 
extern void (*tl_info_undo_asm)(treelist *) __attribute__((__stdcall__));