editor, treelist, msgbox initial
git-svn-id: svn://kolibrios.org@6589 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
parent
8f3ca726d6
commit
59d92b4ec3
@ -104,7 +104,7 @@ import lib_boxlib, \
|
||||
ted_is_select, 'ted_is_select' , \
|
||||
ted_key, 'ted_key' , \
|
||||
ted_mouse, 'ted_mouse' , \
|
||||
ted_open_file, 'ted_open_file' , \
|
||||
ted_open_file, 'ted_open_file_asm' , \
|
||||
ted_save_file, 'ted_save_file' , \
|
||||
ted_text_add, 'ted_text_add' , \
|
||||
ted_but_select_word, 'ted_but_select_word' , \
|
||||
@ -156,3 +156,30 @@ public path_show_draw as '_path_show_draw'
|
||||
public fb_draw_panel as '_filebrowse_draw'
|
||||
public fb_mouse as '_filebrowse_mouse'
|
||||
public fb_key as '_filebrowse_key'
|
||||
|
||||
public ted_but_sumb_upper as '_ted_but_sumb_upper_asm'
|
||||
public ted_but_sumb_lover as '_ted_but_sumb_lover_asm'
|
||||
public ted_but_convert_by_table as '_ted_but_convert_by_table_asm'
|
||||
public ted_can_save as '_ted_can_save_asm'
|
||||
public ted_clear as '_ted_clear_asm'
|
||||
public ted_delete as '_ted_delete_asm'
|
||||
public ted_draw as '_ted_draw'
|
||||
public ted_init as '_ted_init_asm'
|
||||
public ted_init_scroll_bars as '_ted_init_scroll_bars'
|
||||
public ted_init_syntax_file as '_ted_init_syntax_file'
|
||||
public ted_is_select as '_ted_is_select_asm'
|
||||
public ted_key as '_ted_key_asm'
|
||||
public ted_mouse as '_ted_mouse'
|
||||
public ted_open_file as '_ted_open_file_asm'
|
||||
public ted_save_file as '_ted_save_file_asm'
|
||||
public ted_text_add as '_ted_text_add'
|
||||
public ted_but_select_word as '_ted_but_select_word'
|
||||
public ted_but_cut as '_ted_but_cut_asm'
|
||||
public ted_but_copy as '_ted_but_copy'
|
||||
public ted_but_paste as '_ted_but_paste'
|
||||
public ted_but_undo as '_ted_but_undo_asm'
|
||||
public ted_but_redo as '_ted_but_redo_asm'
|
||||
public ted_but_reverse as '_ted_but_reverse_asm'
|
||||
public ted_but_find_next as '_ted_but_find_next'
|
||||
public ted_text_colored as 'ted_text_colored_asm'
|
||||
|
||||
|
34
contrib/C_Layer/ASM/loadmsgbox.asm
Normal file
34
contrib/C_Layer/ASM/loadmsgbox.asm
Normal file
@ -0,0 +1,34 @@
|
||||
|
||||
format coff
|
||||
use32 ; Tell compiler to use 32 bit instructions
|
||||
|
||||
section '.init' code ; Keep this line before includes or GCC messes up call addresses
|
||||
|
||||
include '../../../programs/proc32.inc'
|
||||
include '../../../programs/macros.inc'
|
||||
purge section,mov,add,sub
|
||||
|
||||
include '../../../programs/dll.inc'
|
||||
|
||||
public init_msgbox as '_kolibri_msgbox_init'
|
||||
;;; Returns 0 on success. -1 on failure.
|
||||
|
||||
proc init_msgbox
|
||||
pusha
|
||||
mcall 68,11
|
||||
stdcall dll.Load, @IMPORT
|
||||
popa
|
||||
ret
|
||||
endp
|
||||
|
||||
@IMPORT:
|
||||
library lib_boxlib, 'msgbox.obj'
|
||||
|
||||
import lib_boxlib, \
|
||||
mb_create, 'mb_create' , \
|
||||
mb_reinit, 'mb_reinit' , \
|
||||
mb_setfunctions, 'mb_setfunctions'
|
||||
|
||||
public mb_create as '_msgbox_create'
|
||||
public mb_reinit as '_msgbox_reinit'
|
||||
public mb_setfunctions as '_msgbox_setfunctions'
|
@ -38,7 +38,7 @@ int main()
|
||||
edit_box *textbox = kolibri_new_edit_box(20, 30, 40, &editbox_interlock);
|
||||
edit_box *textbox2 = kolibri_new_edit_box(20, 50, 30, &editbox_interlock);
|
||||
kolibri_button *button = kolibri_new_button(310, 30, 24, 14, 0x21, kolibri_color_table.color_work_button);
|
||||
frame *fr = kolibri_new_frame(X_Y(12, 350), X_Y(5, 70), 0x00FCFCFC, 0x00DCDCDC, "Frame Title", 0, kolibri_color_table.color_work_text, kolibri_color_table.color_work_area);
|
||||
frame *fr = kolibri_new_frame(X_Y(12, 350), X_Y(5, 70), 0x00FCFCFC, 0x00DCDCDC, "Frame Title", 0, kolibri_color_table.color_work_text, kolibri_color_table.color_work_area, 0);
|
||||
|
||||
kolibri_window_add_element(main_window, KOLIBRI_EDIT_BOX, textbox);
|
||||
kolibri_window_add_element(main_window, KOLIBRI_EDIT_BOX, textbox2);
|
||||
|
@ -41,7 +41,6 @@ int main(int argc, char **argv)
|
||||
kolibri_proclib_init(); // opensave && color dialogs
|
||||
kolibri_libimg_init(); // png handling
|
||||
|
||||
|
||||
int gui_event = KOLIBRI_EVENT_REDRAW;
|
||||
uint32_t pressed_button = 0;
|
||||
// uint32_t mouse_button;
|
||||
@ -110,21 +109,12 @@ int main(int argc, char **argv)
|
||||
brows.folder_data = read_folderdata("/rd/1");
|
||||
brows.select_panel_counter = 1; // if want to show selection
|
||||
|
||||
kolibri_handle_event_redraw(main_window);
|
||||
brows.all_redraw = 1;
|
||||
(*filebrowse_draw)(&brows);
|
||||
|
||||
|
||||
//??? set_os_keyb_mode(1); // needed for keyboard use in menu
|
||||
|
||||
int extended_key = 0, act = 0;
|
||||
do /* Start of main activity loop */
|
||||
{
|
||||
switch(gui_event)
|
||||
{
|
||||
case KOLIBRI_EVENT_REDRAW:
|
||||
//???? start red
|
||||
//brows.marked_file = 1;
|
||||
control_minimal_window_size(430, 500);
|
||||
brows.all_redraw = 1;
|
||||
kolibri_handle_event_redraw(main_window);
|
||||
|
132
contrib/C_Layer/EXAMPLE/libguic_kolibri/editor_tree_msgbox.c
Normal file
132
contrib/C_Layer/EXAMPLE/libguic_kolibri/editor_tree_msgbox.c
Normal file
@ -0,0 +1,132 @@
|
||||
|
||||
/*
|
||||
KolibriGUI demobox
|
||||
-Editor (multiline edit)
|
||||
-TreeView
|
||||
-MsgBox Dialog
|
||||
|
||||
Free for all
|
||||
|
||||
Initially written by Siemargl, 2016
|
||||
|
||||
|
||||
ToDo
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <assert.h>
|
||||
#include "kos32sys.h"
|
||||
#include "kolibri_gui.h"
|
||||
#include "kolibri_libimg.h"
|
||||
#include "kolibri_msgbox.h"
|
||||
|
||||
char temp_path[4096];
|
||||
|
||||
char* load_file_inmem(char* fname, int32_t* read_sz); // see below
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
/* Load all libraries, initialize global tables like system color table and
|
||||
operations table. kolibri_gui_init() will EXIT with mcall -1 if it fails
|
||||
to do it's job. This is all you need to call and all libraries and GUI
|
||||
elements can be used after a successful call to this function
|
||||
*/
|
||||
kolibri_gui_init();
|
||||
kolibri_proclib_init(); // opensave && color dialogs
|
||||
kolibri_libimg_init(); // png handling
|
||||
|
||||
int gui_event = KOLIBRI_EVENT_REDRAW;
|
||||
uint32_t pressed_button = 0;
|
||||
// uint32_t mouse_button;
|
||||
// pos_t mouse_pos;
|
||||
oskey_t keypress;
|
||||
|
||||
// load image for buttons
|
||||
const int icon_rgb_size = 16*16*3; // every icons 16x16 24bpp
|
||||
char *image_data_rgb,
|
||||
*image_data,
|
||||
*filedata;
|
||||
// make full path + argv
|
||||
strcpy(temp_path, argv[0]);
|
||||
char *pc = strrchr(temp_path, '/'); // this fails if has params with '/' within. use argv[0] instead
|
||||
if (pc) pc[1] = 0;
|
||||
strcat(temp_path, "reload_16x16_8b.png");
|
||||
// debug_board_write_str(temp_path);
|
||||
|
||||
int32_t read_bytes;
|
||||
filedata = load_file_inmem(temp_path, &read_bytes);
|
||||
image_data_rgb = malloc(icon_rgb_size * 3); // we know size
|
||||
// îïðåäåëÿåì âèä èçîáðàæåíèÿ è ïåðåâîäèì åãî âî âðåìåííûé áóôåð image_data
|
||||
image_data = (*img_decode)(filedata, read_bytes, 0);
|
||||
// ïðåîáðàçóåì èçîáðàæåíèå ê ôîðìàòó rgb
|
||||
(*img_to_rgb2)(image_data, image_data_rgb);
|
||||
// óäàëÿåì âðåìåííûé áóôåð image_data
|
||||
(*img_destroy)(image_data);
|
||||
free(filedata);
|
||||
|
||||
// creating GUI using library functions
|
||||
kolibri_window *main_window = kolibri_new_window(50, 40, 470, 500, "Editor, TreeView and MsgBox demo");
|
||||
|
||||
editor *ed;
|
||||
editor *ed_lock;
|
||||
|
||||
gui_add_editor(main_window, ed = kolibri_new_editor(X_Y(10, 440), X_Y(20, 150), 0x1001, 2048, &ed_lock));
|
||||
ed_lock = ed;
|
||||
|
||||
|
||||
filedata = load_file_inmem("/rd/1/File managers/z_icons.png", &read_bytes);
|
||||
image_data_rgb = malloc(icon_rgb_size * 20); // we know size
|
||||
// îïðåäåëÿåì âèä èçîáðàæåíèÿ è ïåðåâîäèì åãî âî âðåìåííûé áóôåð image_data
|
||||
image_data = (*img_decode)(filedata, read_bytes, 0);
|
||||
// ïðåîáðàçóåì èçîáðàæåíèå ê ôîðìàòó rgb
|
||||
(*img_to_rgb2)(image_data, image_data_rgb);
|
||||
// óäàëÿåì âðåìåííûé áóôåð image_data
|
||||
(*img_destroy)(image_data);
|
||||
free(filedata);
|
||||
|
||||
filedata = load_file_inmem("/rd/1/File managers/icons.ini", &read_bytes);
|
||||
|
||||
|
||||
int extended_key = 0, act = 0;
|
||||
msgbox* box = kolibri_new_msgbox("Exit", "Are\rYOU\rSure?", 3, "YES", "Absolute", "Not Yet", NULL); // default NOT
|
||||
|
||||
do /* Start of main activity loop */
|
||||
{
|
||||
switch(gui_event)
|
||||
{
|
||||
case KOLIBRI_EVENT_REDRAW:
|
||||
if (box->retval == 1 || box->retval == 2) return 0; // msgbox closes
|
||||
|
||||
kolibri_handle_event_redraw(main_window);
|
||||
break;
|
||||
case KOLIBRI_EVENT_NONE:
|
||||
break;
|
||||
case KOLIBRI_EVENT_KEY:
|
||||
if (ed_lock == ed)
|
||||
editor_key(ed);
|
||||
else
|
||||
kolibri_handle_event_key(main_window);
|
||||
break;
|
||||
case KOLIBRI_EVENT_BUTTON:
|
||||
pressed_button = get_os_button();
|
||||
switch (pressed_button)
|
||||
{
|
||||
case BTN_QUIT:
|
||||
if (box->retval == 3 || box->retval == 0) // not started or cancelled, analyze when redraw after closing msgbox
|
||||
kolibri_start_msgbox(box, NULL);
|
||||
return 0;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case KOLIBRI_EVENT_MOUSE:
|
||||
kolibri_handle_event_mouse(main_window);
|
||||
break;
|
||||
}
|
||||
|
||||
gui_event = get_os_event();
|
||||
} while(1) ; /* End of main activity loop */
|
||||
|
||||
return 0;
|
||||
}
|
@ -7,7 +7,7 @@
|
||||
|
||||
extern int kolibri_buf2d_init(void);
|
||||
|
||||
typedef struct {
|
||||
typedef struct __attribute__ ((__packed__)) {
|
||||
unsigned int *buf_pointer;
|
||||
uint16_t left;
|
||||
uint16_t top;
|
||||
|
@ -4,7 +4,7 @@
|
||||
char cd_com_area_name[] = "FFFFFFFF_color_dialog";
|
||||
char cd_start_path[] = "/rd/1/colrdial";
|
||||
|
||||
typedef struct {
|
||||
typedef struct __attribute__ ((__packed__)) {
|
||||
unsigned int type;
|
||||
unsigned int procinfo;
|
||||
unsigned int com_area_name;
|
||||
|
497
contrib/C_Layer/INCLUDE/kolibri_editor.h
Normal file
497
contrib/C_Layer/INCLUDE/kolibri_editor.h
Normal file
@ -0,0 +1,497 @@
|
||||
#ifndef KOLIBRI_EDITOR_H
|
||||
#define KOLIBRI_EDITOR_H
|
||||
|
||||
// (êîëè÷åñòâî ñèìâîëîâ â íîâîì äîêóìåíòå + 2)
|
||||
#define TE_MAXCHARS 100002
|
||||
// ìàêñèìàëüíûé ðàçìåð ôàéëà ñèíòàêñèñà
|
||||
#define TE_MAX_SYNTAX_FILESIZE 410000
|
||||
// buffer for copy|paste
|
||||
#define TE_BUF_SIZE 4096
|
||||
typedef void (*editor_callback)(void);
|
||||
|
||||
struct __attribute__ ((__packed__)) editor_symbol {
|
||||
uint8_t c; // +0 ñèìâîë
|
||||
uint8_t col; // +1 öâåò
|
||||
struct editor_symbol *prev; // +2
|
||||
struct editor_symbol *next; // +6 óêàçàòåëè
|
||||
uint32_t tc; // +10 âðåì. ñîçäàíèÿ
|
||||
uint32_t td; // +14 âðåì. óäàëåíèÿ
|
||||
};
|
||||
|
||||
/// ñòðóêòóðà òåêñòîâîãî ðåäàêòîðà
|
||||
typedef struct __attribute__ ((__packed__)) {
|
||||
uint32_t x_pos; //0
|
||||
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 width_sym; //9 øèðèíà ñèìâîëà (çíàêîìåñòà) â îêíå
|
||||
uint32_t hight_sym; //16 âûñîòà ñèìâîëà (çíàêîìåñòà) â îêíå
|
||||
uint8_t drag_m; // âûäåëåíèå îò ìûøè
|
||||
uint8_t drag_k; // âûäåëåíèå îò êëàâèàòóðû
|
||||
uint32_t sel_x0; // ñòðóêòóðà âûäåëåíèÿ
|
||||
uint32_t sel_y0;
|
||||
uint32_t sel_x1;
|
||||
uint32_t sel_y1;
|
||||
uint32_t seln_x0; //äîïîëíèòåëüíàÿ ñòðóêòóðà âûäåëåíèÿ
|
||||
uint32_t seln_y0;
|
||||
uint32_t seln_x1;
|
||||
uint32_t seln_y1;
|
||||
struct editor_symbol *tex; // text memory pointer
|
||||
struct editor_symbol *tex_1; // text first symbol pointer
|
||||
struct editor_symbol *tex_end;// text end memory pointer
|
||||
uint32_t cur_x; //êîîðäèíàòà x êóðñîðà
|
||||
uint32_t cur_y; //êîîðäèíàòà y êóðñîðà
|
||||
uint32_t max_chars; // TE_MAXCHARS ;+86 ìàêñèìàëüíîå ÷èñëî ñèìâîëîâ â îäíîì äîêóìåíòå
|
||||
uint32_t count_colors_text; // 1 ;+90 êîëè÷åñòâî öâåòîâ òåêñòà
|
||||
uint32_t count_key_words; //+94 êîëëè÷åñòâî êëþ÷åâûõ ñëîâ
|
||||
color_t color_cursor; // 0x808080 ;+98 öâåò êóðñîðà
|
||||
color_t color_wnd_capt; // 0x80 ;+102 öâåò ïîëåé âîêðóã îêíà
|
||||
color_t color_wnd_work; // 0x0 ;+106 öâåò ôîíà îêíà
|
||||
color_t color_wnd_bord; //0xd0d0d0 ;+110 öâåò òåêñòà íà ïîëÿõ
|
||||
color_t color_select; // 0x208080 ;+114 öâåò âûäåëåíèÿ
|
||||
color_t color_cur_text; // 0xff0000 ;+118 öâåò ñèìâîëà ïîä êóðñîðîì
|
||||
color_t color_wnd_text; // 0xffff00 ;+122 öâåò òåêñòà â îêíå
|
||||
char *syntax_file; // óêàçàòåëü íà íà÷àëî ôàéëà ñèíòàêñèñà
|
||||
uint32_t syntax_file_size; // TE_MAX_SYNTAX_FILESIZE ;+130 ìàêñèìàëüíûé ðàçìåð ôàéëà ñèíòàêñèñà
|
||||
void *text_colors; // óêàçàòåëü íà ìàññèâ öâåòîâ òåêñòà
|
||||
char *help_text_f1; // óêàçàòåëü íà òåêñò ñïðàâêè (ïî íàæàòèè F1)
|
||||
int help_id; // -1 ;+142 èäåíòèôèêàòîð äëÿ ñïðàâêè
|
||||
void *key_words_data; // óêàçàòåëü íà ñòðóêòóðû êëþ÷åâûõ ñëîâ TexColViv
|
||||
uint32_t tim_ch; // êîëè÷åñòâî èçìåíåíèé â ôàéëå
|
||||
uint32_t tim_undo; // êîëè÷åñòâî îòìåíåííûõ äåéñòâèé
|
||||
uint32_t tim_ls; // âðåìÿ ïîñëåäíåãî ñîõðàíåíèÿ
|
||||
uint32_t tim_co; // âðåìÿ ïîñëåäíåé öâåòîâîé ðàçìåòêè
|
||||
void *el_focus; // óêàçàòåëü íà ïåðåìåííóþ ýëåìåíòà â ôîêóñå pointer to pointer**
|
||||
uint8_t err_save; // îøèáêà ñîõðàíåíèÿ ôàéëà
|
||||
uint8_t panel_id; // íîìåð îòêðûòîé ïàíåëè
|
||||
uint8_t key_new; // ñèìâîë, êîòîðûé áóäåò äîáàâëÿòñÿ ñ êëàâèàòóðû
|
||||
uint8_t symbol_new_line; // ascii 20 ñèìâîë çàâåðøåíèÿ ñòðîêè
|
||||
scrollbar *scr_w; // âåðòèêàëüíûé ñêðîëëèíã != NULL
|
||||
scrollbar *scr_h; // ãîðèçîíòàëüíûé ñêðîëëèíã != NULL
|
||||
char *arr_key_pos;// óêàçàòåëü íà ìàññèâ ïîçèöèé êëþ÷åâûõ ñëîâ
|
||||
char *buffer; // óêàçàòåëü íà áóôåð êîïèðîâàíèÿ/âñòàâêè != NULL, also size
|
||||
char *buffer_find;// óêàçàòåëü íà áóôåð äëÿ ïîèñêà (sized 302)
|
||||
uint8_t cur_ins; // 1 ðåæèì ðàáîòû êóðñîðà (îáû÷íûé èëè çàìåíà)
|
||||
uint8_t mode_color; // 1 ðåæèì âûäåëåíèÿ ñëîâ öâåòîì (0-âûêë. 1-âêë.)
|
||||
uint8_t mode_invis; // 0 ðåæèì ïîêàçà íåïå÷àòàåìûõ ñèìâîëîâ
|
||||
uint8_t gp_opt; // 0 îïöèè âîçâðàùàåìûå ôóíêöèåé ted_get_pos_by_cursor
|
||||
editor_callback fun_on_key_ctrl_o; // óêàçàòåëü íà ôóíêöèþ âûçûâàåìóþ ïðè íàæàòèè Ctrl+O (îòêðûòèå ôàéëà), can be NULL
|
||||
editor_callback fun_on_key_ctrl_f; // ... Ctrl+F (âûçîâà/ñêðûòèÿ ïàíåëè ïîèñêà)
|
||||
editor_callback fun_on_key_ctrl_n; // ... Ctrl+N (ñîçäàíèå íîâîãî äîêóìåíòà)
|
||||
editor_callback fun_on_key_ctrl_s; // ... Ctrl+S
|
||||
uint32_t buffer_size;// BUF_SIZE ðàçìåð áóôåðà êîïèðîâàíèÿ/âñòàâêè
|
||||
editor_callback fun_find_err; // óêàçàòåëü íà ôóíêöèþ âûçûâàåìóþ åñëè ïîèñê çàêîí÷èëñÿ íåóäà÷íî
|
||||
editor_callback fun_init_synt_err; // unused óêàçàòåëü íà ôóíêöèþ âûçûâàåìóþ ïðè îøèáî÷íîì îòêðûòèè ôàéëà ñèíòàêñèñà
|
||||
editor_callback fun_draw_panel_buttons; // óêàçàòåëü íà ôóíêöèþ ðèñîâàíèÿ ïàíåëè ñ êíîïêàìè
|
||||
editor_callback fun_draw_panel_find; // óêàçàòåëü íà ôóíêöèþ ðèñîâàíèÿ ïàíåëè ïîèñêà
|
||||
editor_callback fun_draw_panel_syntax; // óêàçàòåëü íà ôóíêöèþ ðèñîâàíèÿ ïàíåëè ñèíòàêñèñà
|
||||
editor_callback fun_save_err; // óêàçàòåëü íà ôóíêöèþ âûçûâàåìóþ åñëè ñîõðàíåíèå ôàéëà çàêîí÷èëîñü íåóäà÷íî
|
||||
uint32_t increase_size; //200 ÷èñëî ñèìâîëîâ íà êîòîðûå áóäåò óâå÷èâàòüñÿ ïàìÿòü ïðè íåõâàòêå
|
||||
void *ptr_free_symb; // èñïîëüçóåòñÿ âíóòðè ýëåìåíòà äëÿ óñêîðåíèÿ âñòàâêè òåêñòà
|
||||
uint32_t font_size; // ;+250 ìíîæèòåëü äëÿ ðàçìåðà øðèôòà // binary OR mask for ECX SysFn4
|
||||
} editor;
|
||||
|
||||
struct __attribute__ ((__packed__)) editor_color_item
|
||||
{
|
||||
char word[40]; // ñëîâî äëÿ ïîäñâåòêè
|
||||
uint32_t f1_offset; // ñìåùåíèå â òàáëèöå F1 ïîäñêàçîê
|
||||
uint8_t flags; // ôëàãè èñïîëüçóåìûå ïðè âûäåëåíèè
|
||||
uint8_t endc; // ñèìâîë êîíöà âûäåëåíèÿ (èñïîëüçóåòñÿ ïðè flags&4)
|
||||
uint8_t escc; // ýêðàíèðóþùèé ñèìâîë (èñïîëüçóåòñÿ ïðè flags&4) ascii(34) ïðèìåðû ýêðàíèðîâàíèÿ \r \n \t
|
||||
uint8_t color; // öâåò ïî òàáëèöå öâåòîâ
|
||||
};
|
||||
|
||||
struct editor_syntax_file
|
||||
{
|
||||
uint32_t count_colors_text; // êîë-âî öâåòîâ òåêñòà dd (text-color_wnd_text)/4
|
||||
uint32_t count_key_words; // êîë-âî êëþ÷åâûõ ñëîâ dd (f1-text)/48
|
||||
color_t color_cursor; // dd 0xf1fcd0
|
||||
color_t color_wnd_capt; // dd 0x080808
|
||||
color_t color_wnd_work; // dd 0x1C1C1C
|
||||
color_t color_wnd_bord; // dd 0xc0c0c0
|
||||
color_t color_select; // dd 0x3E3D32
|
||||
color_t color_cur_text; // dd 0x808080
|
||||
color_t color_wnd_text[]; // òàáëèöà öâåòîâ ðàçìåðîì count_colors_text
|
||||
// editor_color_item[]; // òàáëèöà êëþ÷åâûõ ïîäñâå÷åííûõ ñëîâ ðàçìåðîì count_key_words
|
||||
};
|
||||
|
||||
|
||||
static struct editor_syntax_file default_syntax = {
|
||||
10, //count_colors_text
|
||||
0, // count_key_words dd (f1-text)/48
|
||||
0xf1fcd0, //color_cursor dd 0xf1fcd0
|
||||
0x080808, //color_wnd_capt dd 0x080808
|
||||
0x1C1C1C, //color_wnd_work dd 0x1C1C1C
|
||||
0xc0c0c0, //color_wnd_bord dd 0xc0c0c0
|
||||
0x3E3D32, //color_select dd 0x3E3D32
|
||||
0x808080, //color_cur_text dd 0x808080
|
||||
{0xD0D0D0, 0xffff00, 0x00ff00, 0x00ffff, 0x808080, 0xff40ff, 0x4080ff, 0xff0000, 0x8080ff, 0x00ccff}
|
||||
};
|
||||
// next structure must follow syntax definition, at least has 1 element !!!
|
||||
static struct editor_color_item word1 = {
|
||||
"siemargl", 1, 0, 0, 1 // test word colored as 1st in table
|
||||
};
|
||||
// next structure preferably follow syntax definition, at least has 1 element !!!
|
||||
static char f1_table[] = {
|
||||
"\0"
|
||||
"First\0"
|
||||
"Last\0"
|
||||
};
|
||||
|
||||
|
||||
extern void (*ted_draw)(editor *) __attribute__((__stdcall__));
|
||||
extern void (*ted_init_scroll_bars)(editor *, int opt) __attribute__((__stdcall__));
|
||||
/// opt bits = 1 - ìåíÿòü öâåò ñêðîëëèíãîâ, 2 - èçìåíèëèñü ðàçìåðû îêíà, 4 - èçìåíèëèñü ðàçìåðû äîêóìåíòà
|
||||
extern void (*ted_init_syntax_file)(editor *) __attribute__((__stdcall__));
|
||||
extern void (*ted_mouse)(editor *) __attribute__((__stdcall__));
|
||||
extern void (*ted_text_add)(editor *, char *text, int textlen, int opt) __attribute__((__stdcall__));
|
||||
/// add text to cursor pos
|
||||
/// opt == ted_opt_ed_change_time, ted_opt_ed_move_cursor
|
||||
///ted_opt_ed_move_cursor equ 1 ;äâèãàòü êóðñîð ïîñëå äîáàâëåíèÿ òåêñòà
|
||||
///ted_opt_ed_change_time equ 2 ;äîáàâëÿòü èçìåíåíèÿ ïðè ðåäàêòèðîâàíèè òåêñòà
|
||||
extern void (*ted_but_select_word)(editor *) __attribute__((__stdcall__));
|
||||
/// select word under cursor
|
||||
extern void (*ted_but_copy)(editor *) __attribute__((__stdcall__));
|
||||
extern void (*ted_but_paste)(editor *) __attribute__((__stdcall__));
|
||||
|
||||
extern void (*ted_but_find_next)(editor *) __attribute__((__stdcall__));
|
||||
///move cursor to <ed_buffer_find>, calls ted_fun_find_err() if exist
|
||||
|
||||
|
||||
|
||||
extern void (*ted_but_sumb_upper_asm)(editor *) __attribute__((__stdcall__));
|
||||
static inline void editor_selected_toupper(editor *ed)
|
||||
{
|
||||
__asm__ __volatile__ (
|
||||
"push edi \n\t"
|
||||
"push esi \n\t":::);
|
||||
|
||||
(*ted_but_sumb_upper_asm)(ed);
|
||||
|
||||
__asm__ __volatile__ (
|
||||
"pop esi \n\t"
|
||||
"pop edi \n\t":::);
|
||||
}
|
||||
|
||||
extern void (*ted_but_sumb_lover_asm)(editor *) __attribute__((__stdcall__));
|
||||
static inline void editor_selected_tolower(editor *ed)
|
||||
{
|
||||
__asm__ __volatile__ (
|
||||
"push edi \n\t"
|
||||
"push esi \n\t":::);
|
||||
|
||||
(*ted_but_sumb_lover_asm)(ed);
|
||||
|
||||
__asm__ __volatile__ (
|
||||
"pop esi \n\t"
|
||||
"pop edi \n\t":::);
|
||||
}
|
||||
|
||||
|
||||
extern void (*ted_but_convert_by_table_asm)(editor *, char* table) __attribute__((__stdcall__));
|
||||
static inline void editor_convert_by_table(editor *ed, char* table)
|
||||
{
|
||||
__asm__ __volatile__ (
|
||||
"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":::);
|
||||
}
|
||||
|
||||
extern int (*ted_can_save_asm)(editor *) __attribute__((__stdcall__));
|
||||
static inline int editor_can_save(editor *ed)
|
||||
/// return 1 if can be saved
|
||||
{
|
||||
int ret;
|
||||
__asm__ __volatile__ (
|
||||
"push edi \n\t":::);
|
||||
|
||||
(*ted_can_save_asm)(ed);
|
||||
|
||||
__asm__ __volatile__ (
|
||||
"pop edi \n\t":"=a"(ret)::);
|
||||
return ret;
|
||||
}
|
||||
|
||||
extern void (*ted_clear_asm)(editor *, int) __attribute__((__stdcall__));
|
||||
static inline void editor_clear(editor *ed, int all)
|
||||
/// all==1 - clear all memory
|
||||
{
|
||||
__asm__ __volatile__ (
|
||||
"push edi \n\t":::);
|
||||
|
||||
(*ted_clear_asm)(ed, all);
|
||||
|
||||
__asm__ __volatile__ (
|
||||
"pop edi \n\t":::);
|
||||
}
|
||||
|
||||
extern void (*ted_delete_asm)(editor *) __attribute__((__stdcall__));
|
||||
static inline void editor_delete(editor *ed)
|
||||
/// frees all memory (destroy)
|
||||
{
|
||||
__asm__ __volatile__ (
|
||||
"push edi \n\t":::);
|
||||
|
||||
(*ted_delete_asm)(ed);
|
||||
|
||||
__asm__ __volatile__ (
|
||||
"pop edi \n\t":::);
|
||||
free(ed->scr_w);
|
||||
free(ed->scr_h);
|
||||
free(ed->buffer);
|
||||
free(ed->buffer_find);
|
||||
}
|
||||
|
||||
extern void (*ted_init_asm)(editor *) __attribute__((__stdcall__));
|
||||
static inline void editor_init(editor *ed)
|
||||
/// allocate memory
|
||||
{
|
||||
__asm__ __volatile__ (
|
||||
"push edi \n\t":::);
|
||||
|
||||
(*ted_init_asm)(ed);
|
||||
|
||||
__asm__ __volatile__ (
|
||||
"pop edi \n\t":::);
|
||||
}
|
||||
|
||||
extern int (*ted_is_select)(editor *) __attribute__((__stdcall__));
|
||||
static inline int editor_is_select(editor *ed)
|
||||
/// return 1 if have selection
|
||||
{
|
||||
int ret;
|
||||
__asm__ __volatile__ (
|
||||
"push ebx \n\t":::);
|
||||
|
||||
(*ted_is_select)(ed);
|
||||
|
||||
__asm__ __volatile__ (
|
||||
"pop ebx \n\t":"=a"(ret)::);
|
||||
return ret;
|
||||
}
|
||||
|
||||
enum control_keys {
|
||||
KM_SHIFT = 0x00010000,
|
||||
KM_CTRL = 0x00020000,
|
||||
KM_ALT = 0x00040000,
|
||||
KM_NUMLOCK = 0x00080000
|
||||
};
|
||||
|
||||
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)
|
||||
/// control is KM_SHIFT, KM_ALT, KM_CTRL, KM_NUMLOCK,
|
||||
/// ch = GET_KEY
|
||||
/// table = SF_SYSTEM_GET,SSF_KEYBOARD_LAYOUT
|
||||
{
|
||||
__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__));
|
||||
static inline int editor_openfile(editor *ed, char *fname, int *readbytes)
|
||||
/// returns errcode as SysFn70
|
||||
{
|
||||
int ret;
|
||||
struct fs_dirinfo di;
|
||||
__asm__ __volatile__ (
|
||||
"push edi \n\t":::);
|
||||
|
||||
(*ted_open_file_asm)(ed, &di, fname);
|
||||
|
||||
__asm__ __volatile__ (
|
||||
"pop edi \n\t":"=b"(*readbytes), "=a"(ret)::);
|
||||
return ret;
|
||||
}
|
||||
|
||||
extern void (*ted_save_file_asm)(editor *, struct fs_dirinfo*, char *fname) __attribute__((__stdcall__));
|
||||
static inline int editor_savefile(editor *ed, char *fname)
|
||||
/// returns errcode, calls fun_save_err() if exists
|
||||
{
|
||||
struct fs_dirinfo di;
|
||||
|
||||
(*ted_save_file_asm)(ed, &di, fname);
|
||||
|
||||
return ed->err_save;
|
||||
}
|
||||
|
||||
extern void (*ted_but_cut)(editor *) __attribute__((__stdcall__));
|
||||
static inline void editor_cut(editor *ed)
|
||||
{
|
||||
__asm__ __volatile__ (
|
||||
"push edi \n\t":::);
|
||||
|
||||
(*ted_but_cut)(ed);
|
||||
|
||||
__asm__ __volatile__ (
|
||||
"pop edi \n\t":::);
|
||||
}
|
||||
|
||||
extern void (*ted_but_undo)(editor *) __attribute__((__stdcall__));
|
||||
static inline void editor_undo(editor *ed)
|
||||
{
|
||||
__asm__ __volatile__ (
|
||||
"push edi \n\t":::);
|
||||
|
||||
(*ted_but_undo)(ed);
|
||||
|
||||
__asm__ __volatile__ (
|
||||
"pop edi \n\t":::);
|
||||
}
|
||||
|
||||
extern void (*ted_but_redo)(editor *) __attribute__((__stdcall__));
|
||||
static inline void editor_redo(editor *ed)
|
||||
{
|
||||
__asm__ __volatile__ (
|
||||
"push edi \n\t":::);
|
||||
|
||||
(*ted_but_redo)(ed);
|
||||
|
||||
__asm__ __volatile__ (
|
||||
"pop edi \n\t":::);
|
||||
}
|
||||
|
||||
extern void (*ted_but_reverse)(editor *) __attribute__((__stdcall__));
|
||||
static inline void editor_reverse(editor *ed)
|
||||
{
|
||||
__asm__ __volatile__ (
|
||||
"push edi \n\t"
|
||||
"push ebx\n\t":::);
|
||||
|
||||
(*ted_but_reverse)(ed);
|
||||
|
||||
__asm__ __volatile__ (
|
||||
"pop ebx \n\t"
|
||||
"pop edi \n\t":::);
|
||||
}
|
||||
|
||||
extern void (*ted_text_colored_asm)() __attribute__((__stdcall__));
|
||||
static inline void editor_text_colored(editor *ed)
|
||||
{
|
||||
__asm__ __volatile__ (
|
||||
"nop \n\t"::"D"(ed):);
|
||||
|
||||
(*ted_text_colored_asm)();
|
||||
}
|
||||
|
||||
static inline
|
||||
uint32_t get_control_keys(void)
|
||||
{
|
||||
uint32_t ctrl;
|
||||
|
||||
__asm__ __volatile__(
|
||||
"int $0x40 \n\t"
|
||||
:"=a"(ctrl)
|
||||
:"a"(66),"b"(3));
|
||||
|
||||
return ctrl;
|
||||
};
|
||||
|
||||
static inline
|
||||
int get_keyboard_layout(int opt, char* buf)
|
||||
/// 128 byte buffer
|
||||
/// opt: 1 - normal, 2 - shifted, 3 - alted, or 9 - return language
|
||||
{
|
||||
uint32_t lang;
|
||||
|
||||
__asm__ __volatile__(
|
||||
"int $0x40 \n\t"
|
||||
:"=a"(lang)
|
||||
:"a"(26),"b"(2), "c"(opt), "d"(buf));
|
||||
|
||||
return lang;
|
||||
};
|
||||
|
||||
|
||||
static void editor_key(editor* ed)
|
||||
// callback for gui
|
||||
{
|
||||
uint32_t control = get_control_keys();
|
||||
enum control_keys ed_ctrl = 0;
|
||||
int ly_opt = 1;
|
||||
if (control & 3) { ed_ctrl |= KM_SHIFT; ly_opt = 2; }
|
||||
if (control & 0xC) ed_ctrl |= KM_CTRL;
|
||||
if (control & 0x30){ ed_ctrl |= KM_ALT; ly_opt = 3; }
|
||||
if (control & 0x80) ed_ctrl |= KM_NUMLOCK;
|
||||
|
||||
char conv_table[128];
|
||||
get_keyboard_layout(ly_opt, conv_table);
|
||||
|
||||
editor_keyboard(ed, conv_table, ed_ctrl, get_key().val);
|
||||
}
|
||||
|
||||
inline void gui_add_editor(kolibri_window *wnd, editor* e)
|
||||
{
|
||||
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)
|
||||
/// font - 0b10SSS 8x16 size multiply (SSS+1), 0xSSS - 6x9 multiply (SSS+1)
|
||||
|
||||
{
|
||||
editor *ed = (editor *)calloc(1, sizeof(editor));
|
||||
ed->x_pos = x_w >> 16;
|
||||
ed->width = x_w & 0xFFFF;
|
||||
ed->y_pos = y_h >> 16;
|
||||
ed->hight = y_h & 0xFFFF;
|
||||
|
||||
// no panel, w_pane, h_pane == 0
|
||||
// font
|
||||
if (font == 0) font = 0x10; // default 16 = 8x16
|
||||
int font_multipl = (font & 7) + 1;
|
||||
ed->font_size = font << 24;
|
||||
if (font & 0x10) // 8x16
|
||||
{
|
||||
ed->width_sym = 8 * font_multipl;
|
||||
ed->hight_sym = 16 * font_multipl;
|
||||
} else // 6x9
|
||||
{
|
||||
ed->width_sym = 6 * font_multipl;
|
||||
ed->hight_sym = 9 * font_multipl;
|
||||
}
|
||||
// memory sizing for text & syntax
|
||||
ed->max_chars = max_chars;
|
||||
ed->increase_size = max_chars / 2;
|
||||
ed->syntax_file_size = sizeof (default_syntax);
|
||||
|
||||
/* // loaded auto from syntax
|
||||
ed->color_cursor = 0x808080;
|
||||
ed->color_wnd_capt = 0x80;
|
||||
ed->color_wnd_bord = 0xd0d0d0;
|
||||
ed->color_select = 0x208080;
|
||||
ed->color_cur_text = 0xff0000;
|
||||
ed->color_wnd_text = 0xffff00;
|
||||
*/
|
||||
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->buffer_size = TE_BUF_SIZE;
|
||||
ed->buffer = malloc(TE_BUF_SIZE);
|
||||
ed->buffer_find = malloc(TE_BUF_SIZE / 8); //where to store text to search
|
||||
|
||||
ed->cur_ins = 1; // insert mode default
|
||||
ed->mode_color = 1; // can select text
|
||||
ed->mode_invis = 1; // show nonprinted symbols
|
||||
|
||||
// ??? saveregs ax,cx,di
|
||||
editor_init(ed); // memory allocation, cleaning
|
||||
ed->syntax_file = (char*)&default_syntax;
|
||||
(*ted_init_syntax_file)(ed); // load colors and syntax highlight
|
||||
ed->help_text_f1 = f1_table; // override if not aligned immediately after syntax words
|
||||
ed->key_words_data = &word1;
|
||||
|
||||
return ed;
|
||||
}
|
||||
|
||||
|
||||
#endif // KOLIBRI_EDITOR_H
|
@ -112,7 +112,7 @@ typedef struct __attribute__ ((__packed__)) {
|
||||
uint32_t select_flag; // widget have focus, set auto on mouseclick, but need to reset before mouse()
|
||||
color_t background_color; // self explained, 0xffffff
|
||||
color_t select_color; // self explained, 0xbbddff
|
||||
color_t select_text_color; // self explained - have a bug - newer used
|
||||
color_t select_text_color; // self explained - have a bug - never really used
|
||||
color_t text_color; // self explained
|
||||
color_t reduct_text_color; // 0xff0000 - spec color for cutted filenames
|
||||
color_t marked_text_color; // not used
|
||||
@ -216,12 +216,7 @@ inline filebrowser* kolibri_filebrowser_def(filebrowser* fb, uint32_t x_w, uint3
|
||||
0x000000, 0xbbddff, kolibri_color_table.color_work_text, kolibri_color_table.color_work_area, 0xff0000);
|
||||
}
|
||||
*/
|
||||
/*
|
||||
inline frame* kolibri_new_frame_def(uint32_t x_w, uint32_t y_h, char *text)
|
||||
{
|
||||
return kolibri_new_frame(x_w, y_h, 0x00FCFCFC, 0x00DCDCDC, text, TOP, kolibri_color_table.color_work_text, kolibri_color_table.color_work_area);
|
||||
}
|
||||
*/
|
||||
|
||||
inline void gui_add_filebrowser(kolibri_window *wnd, filebrowser* f)
|
||||
{
|
||||
kolibri_window_add_element(wnd, KOLIBRI_FILEBROWSE, f);
|
||||
|
@ -1,9 +1,25 @@
|
||||
#ifndef KOLIBRI_FRAME_H
|
||||
#define KOLIBRI_FRAME_H
|
||||
|
||||
enum {
|
||||
TOP,
|
||||
BOTTON
|
||||
enum fr_text_position_t {
|
||||
FR_TOP,
|
||||
FR_BOTTON
|
||||
};
|
||||
|
||||
/*
|
||||
; FR_FLAGS = [x][yyy][z]
|
||||
; z - Caption
|
||||
; yyy - BorderStyle
|
||||
; x - BackStyle
|
||||
*/
|
||||
enum fr_flags_t {
|
||||
FR_CAPTION = 1, // if text != null set auto
|
||||
FR_DOUBLE = 0, // default
|
||||
FR_RAISED = 2,
|
||||
FR_SUNKEN = 4,
|
||||
FR_ETCHED = 6,
|
||||
FR_RINGED = 8,
|
||||
FR_FILLED = 0x10
|
||||
};
|
||||
|
||||
typedef struct {
|
||||
@ -12,7 +28,7 @@ typedef struct {
|
||||
uint32_t y_h;
|
||||
color_t ext_col;
|
||||
color_t int_col;
|
||||
uint32_t draw_text_flag;
|
||||
uint32_t flags;
|
||||
char *text_pointer;
|
||||
uint32_t text_position;
|
||||
uint32_t font_number;
|
||||
@ -21,14 +37,16 @@ typedef struct {
|
||||
color_t font_bg_color;
|
||||
}frame;
|
||||
|
||||
inline frame* kolibri_frame(frame* f, uint32_t x_w, uint32_t y_h, color_t ext_col, color_t int_col, char *text, uint32_t text_position, color_t font_color, color_t font_bgcolor)
|
||||
inline frame* kolibri_frame(frame* f, uint32_t x_w, uint32_t y_h, color_t ext_col, color_t int_col, char *text, enum fr_text_position_t text_position,
|
||||
color_t font_color, color_t font_bgcolor, enum fr_flags_t flags)
|
||||
{
|
||||
f->type = 0;
|
||||
f->x_w = x_w;
|
||||
f->y_h = y_h;
|
||||
f->ext_col = ext_col;
|
||||
f->int_col = int_col;
|
||||
f->draw_text_flag = text != NULL;
|
||||
f->flags = flags;
|
||||
if (text) f->flags |= FR_CAPTION;
|
||||
f->text_pointer = text;
|
||||
f->text_position = text_position;
|
||||
f->font_number = 0; // 0 == font 6x9, 1==8x16
|
||||
@ -36,23 +54,25 @@ inline frame* kolibri_frame(frame* f, uint32_t x_w, uint32_t y_h, color_t ext_co
|
||||
f->font_color = font_color | 0x80000000;
|
||||
f->font_bg_color = font_bgcolor;
|
||||
|
||||
|
||||
return f;
|
||||
}
|
||||
|
||||
inline frame* kolibri_new_frame(uint32_t x_w, uint32_t y_h, color_t ext_col, color_t int_col, char *text, uint32_t text_position, color_t font_color, color_t font_bgcolor)
|
||||
inline frame* kolibri_new_frame(uint32_t x_w, uint32_t y_h, color_t ext_col, color_t int_col, char *text, enum fr_text_position_t text_position,
|
||||
color_t font_color, color_t font_bgcolor, enum fr_flags_t flags)
|
||||
{
|
||||
frame *new_frame = (frame *)malloc(sizeof(frame));
|
||||
return kolibri_frame(new_frame, x_w, y_h, ext_col, int_col, text, text_position, font_color, font_bgcolor);
|
||||
return kolibri_frame(new_frame, x_w, y_h, ext_col, int_col, text, text_position, font_color, font_bgcolor, flags);
|
||||
}
|
||||
|
||||
inline frame* kolibri_frame_def(frame* f, uint32_t x_w, uint32_t y_h, char *text)
|
||||
{
|
||||
return kolibri_frame(f, x_w, y_h, 0x00FCFCFC, 0x00DCDCDC, text, TOP, kolibri_color_table.color_work_text, kolibri_color_table.color_work_area);
|
||||
return kolibri_frame(f, x_w, y_h, 0x00FCFCFC, 0x00DCDCDC, text, FR_TOP, kolibri_color_table.color_work_text, kolibri_color_table.color_work_area, 0);
|
||||
}
|
||||
|
||||
inline frame* kolibri_new_frame_def(uint32_t x_w, uint32_t y_h, char *text)
|
||||
{
|
||||
return kolibri_new_frame(x_w, y_h, 0x00FCFCFC, 0x00DCDCDC, text, TOP, kolibri_color_table.color_work_text, kolibri_color_table.color_work_area);
|
||||
return kolibri_new_frame(x_w, y_h, 0x00FCFCFC, 0x00DCDCDC, text, FR_TOP, kolibri_color_table.color_work_text, kolibri_color_table.color_work_area, 0);
|
||||
}
|
||||
|
||||
inline void gui_add_frame(kolibri_window *wnd, frame* f)
|
||||
|
@ -25,6 +25,7 @@ enum KOLIBRI_GUI_ELEMENT_TYPE {
|
||||
KOLIBRI_D_BUTTON,
|
||||
KOLIBRI_PATHSHOW,
|
||||
KOLIBRI_FILEBROWSE,
|
||||
KOLIBRI_EDITOR,
|
||||
|
||||
/* Add elements above this element in order to let KOLIBRI_NUM_GUI_ELEMENTS */
|
||||
/* stay at correct value */
|
||||
@ -79,7 +80,7 @@ void kolibri_window_add_element(kolibri_window *some_window, enum KOLIBRI_GUI_EL
|
||||
#include "kolibri_scrollbar.h"
|
||||
#include "kolibri_statictext.h"
|
||||
#include "kolibri_filebrowse.h"
|
||||
|
||||
#include "kolibri_editor.h"
|
||||
|
||||
|
||||
/*---------------------Define various functions for initializing GUI-------*/
|
||||
@ -150,7 +151,11 @@ kolibri_gui_op_table[KOLIBRI_PATHSHOW].key_fn = NULL;
|
||||
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;
|
||||
debug_board_printf("KOLIBRI_FILEBROWSE (%x,%x,%x)\n", filebrowse_draw, filebrowse_mouse, filebrowse_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);
|
||||
}
|
||||
|
||||
/* Create a new main GUI window for KolibriOS */
|
||||
|
@ -22,7 +22,7 @@ typedef struct {
|
||||
};
|
||||
} t_font;
|
||||
|
||||
typedef struct {
|
||||
typedef struct __attribute__ ((__packed__)) {
|
||||
uint16_t left, top, right, bottom;
|
||||
} t_rect;
|
||||
|
||||
|
60
contrib/C_Layer/INCLUDE/kolibri_msgbox.h
Normal file
60
contrib/C_Layer/INCLUDE/kolibri_msgbox.h
Normal file
@ -0,0 +1,60 @@
|
||||
#ifndef KOLIBRI_MSGBOX_H
|
||||
#define KOLIBRI_MSGBOX_H
|
||||
#include <stdarg.h>
|
||||
|
||||
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 msgbox_stack[1024];
|
||||
uint32_t top_stack;
|
||||
} msgbox;
|
||||
|
||||
|
||||
typedef void (*msgbox_callback)(void);
|
||||
|
||||
static int msgbox_inited;
|
||||
extern void kolibri_msgbox_init();
|
||||
extern void (*msgbox_create)(msgbox *, void *thread) __attribute__((__stdcall__)); // clears callbacks, ! if fix lib, we can return eax as of Fn51
|
||||
extern void (*msgbox_setfunctions)(msgbox_callback*) __attribute__((__stdcall__)); // must be called immediately after create, zero-ended array
|
||||
extern void (*msgbox_reinit)(msgbox *) __attribute__((__stdcall__)); // recalc sizes when structure changes, called auto when MsgBoxCreate
|
||||
|
||||
static inline msgbox* kolibri_new_msgbox(char* title, char* text, int def_but, ...)
|
||||
/// text can be multilined by code 13 = "\r"
|
||||
/// def_but - highlighted and used on Enter (if zero - default is [X]), user may use Tabs or Arrows
|
||||
/// last params are buttons text, max 8. last must set as NULL
|
||||
{
|
||||
va_list vl;
|
||||
va_start(vl, def_but);
|
||||
|
||||
msgbox* box = calloc(sizeof(msgbox), 1);
|
||||
box->retval = (uint8_t)def_but;
|
||||
char *pc = box->texts,
|
||||
*but_text = va_arg(vl, char*);
|
||||
strcpy(pc, title);
|
||||
pc += strlen(title) + 1;
|
||||
|
||||
while (but_text)
|
||||
{
|
||||
strcpy(pc, but_text);
|
||||
pc += strlen(but_text) + 1;
|
||||
// assert(pc - box->texts < sizeof box->texts);
|
||||
}
|
||||
|
||||
va_end(vl);
|
||||
|
||||
return box;
|
||||
}
|
||||
|
||||
void kolibri_start_msgbox(msgbox* box, msgbox_callback cb[])
|
||||
{
|
||||
if (!msgbox_inited)
|
||||
{
|
||||
kolibri_msgbox_init();
|
||||
msgbox_inited++;
|
||||
}
|
||||
(*msgbox_create)(box, &box->top_stack);
|
||||
if (cb) (*msgbox_setfunctions)(cb);
|
||||
}
|
||||
|
||||
#endif
|
@ -11,12 +11,12 @@ enum open_dialog_mode {
|
||||
SELECT
|
||||
};
|
||||
|
||||
typedef struct {
|
||||
typedef struct __attribute__ ((__packed__)) {
|
||||
unsigned int size;
|
||||
unsigned char end;
|
||||
}od_filter;
|
||||
|
||||
typedef struct {
|
||||
typedef struct __attribute__ ((__packed__)) {
|
||||
unsigned int mode;
|
||||
char* procinfo;
|
||||
char* com_area_name;
|
||||
|
@ -1,7 +1,7 @@
|
||||
#ifndef KOLIBRI_OPTIONBOX_H
|
||||
#define KOLIBRI_OPTIONBOX_H
|
||||
|
||||
typedef struct option_box_t{
|
||||
typedef struct __attribute__ ((__packed__)) option_box_t {
|
||||
struct option_box_t **selected;
|
||||
uint16_t posx;
|
||||
uint16_t posy;
|
||||
|
@ -1,7 +1,7 @@
|
||||
#ifndef KOLIBRI_PATHSHOW_H
|
||||
#define KOLIBRI_PATHSHOW_H
|
||||
|
||||
typedef struct {
|
||||
typedef struct __attribute__ ((__packed__)) {
|
||||
uint32_t type;
|
||||
uint32_t x_y;
|
||||
uint16_t font_size_x; // 6 - for font 0, 8 - for font 1
|
||||
|
@ -1,7 +1,7 @@
|
||||
#ifndef KOLIBRI_SCROLLBAR_H
|
||||
#define KOLIBRI_SCROLLBAR_H
|
||||
|
||||
typedef struct {
|
||||
typedef struct __attribute__ ((__packed__)) {
|
||||
// uint16_t xsize;
|
||||
// uint16_t xpos;
|
||||
// uint16_t ysize;
|
||||
@ -9,7 +9,7 @@ typedef struct {
|
||||
uint32_t x_w;
|
||||
uint32_t y_h;
|
||||
uint32_t btn_height;
|
||||
uint32_t type;
|
||||
uint32_t type; // type 1 - stylish frame, type 2 - ?, type 0 - ?
|
||||
uint32_t max_area;
|
||||
uint32_t cur_area;
|
||||
uint32_t position;
|
||||
|
106
contrib/C_Layer/INCLUDE/kolibri_treelist.h
Normal file
106
contrib/C_Layer/INCLUDE/kolibri_treelist.h
Normal file
@ -0,0 +1,106 @@
|
||||
#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, // рисовать линии к родительскому узлу
|
||||
TL_LISTBOX_MODE = 4 //стиль не отображает уровни (как в ListBox все одного уровня)
|
||||
};
|
||||
|
||||
typedef struct __attribute__ ((__packed__)) {
|
||||
uint32_t left;
|
||||
uint32_t top;
|
||||
uint32_t width;
|
||||
uint32_t height;
|
||||
void *data_info; // указатель на основные даные
|
||||
uint16_t info_size; // размер данных выделяемых для каждого узла (пользовательськие данные + текст для подписи)
|
||||
uint32_t info_max_count; // максимальное количество узлов, которые можно добавить в элемент
|
||||
uint32_t style; // стили элемента
|
||||
void *data_nodes; // указатель на структуры узлов
|
||||
void *data_img; // указатель на изображения с иконками узлов
|
||||
uint16_t img_cx; // ширина иконок
|
||||
uint16_t img_cy; // высота иконок
|
||||
void *data_img_sys;//указатель на системные изображения (стрелки, плюсики)
|
||||
uint32_t ch_tim; // количество изменений в файле
|
||||
uint32_t tim_undo; // количество отмененных действий
|
||||
uint32_t cur_pos; // позиция курсора
|
||||
color_t col_bkg; // цвет фона
|
||||
color_t tl_col_zag; // цвет заголовка
|
||||
color_t tl_col_txt; // цвет текста
|
||||
uint16_t capt_cy; // высота подписи
|
||||
uint16_t info_capt_offs;//сдвиг для начала текста (подписи узла)
|
||||
uint16_t info_capt_len;//длина текста подписи узла (если = 0 то до конца структуры)
|
||||
void *el_focus; // указатель на структуру элемента в фокусе
|
||||
void *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 ;размер заголовка для записи/чтения элементов
|
||||
*/
|
||||
|
||||
#endif //KOLIBRI_TREELIST_H
|
Loading…
Reference in New Issue
Block a user