1,5 → 1,11 |
#define MEMSIZE 4096*25 |
|
//===================================================// |
// // |
// LIB // |
// // |
//===================================================// |
|
#include "../lib/io.h" |
#include "../lib/gui.h" |
#include "../lib/list_box.h" |
13,6 → 19,12 |
|
#include "../lib/patterns/simple_open_dialog.h" |
|
//===================================================// |
// // |
// DATA // |
// // |
//===================================================// |
|
#define TOOLBAR_H 34 |
#define TOOLBAR_ICON_WIDTH 26 |
#define TOOLBAR_ICON_HEIGHT 24 |
20,7 → 32,7 |
#define DEFAULT_EDITOR "/sys/tinypad" |
|
#define INTRO_TEXT "This is a plain Text Reader.\nTry to open some text file." |
#define VERSION "Text Reader v1.22" |
#define VERSION "Text Reader v1.3" |
#define ABOUT "Idea: Leency, punk_joker |
Code: Leency, Veliant, KolibriOS Team |
|
34,6 → 46,27 |
|
Press any key..." |
|
dword color_schemes[] = { |
0xFFFfff, 0, |
0xF0F0F0, 0, |
0xE9E5DA, 0, |
0xF0F0C7, 0, |
0xFCF0DA, 0x574531, |
0xFDF6E3, 0x303A41, |
0x282C34, 0xABB2BF, |
0x282923, 0xD8D8D2 |
}; |
|
char color_scheme_names[] = |
"White & Black |
Grey & Black RtfRead |
Khaki & Black QNX |
Lemon & Black Fb2Read |
Antique & Black Pocket |
Linen & Black Horst |
DarkGrey & Grey Godot |
DarkGrey & Grey Monokai"; |
|
char default_dir[] = "/rd/1"; |
od_filter filter2 = { 8, "TXT\0\0" }; |
|
44,9 → 77,12 |
char title[4196]; |
|
bool help_opened = false; |
int charsets_menu_left = 0; |
int reopenin_menu_left = 0; |
int charsets_mx; |
int reopenin_mx; |
int colscheme_mx; |
|
int curcol_scheme; |
|
enum { |
OPEN_FILE, |
MAGNIFY_MINUS, |
54,17 → 90,30 |
CHANGE_ENCODING, |
RUN_EDIT, |
SHOW_INFO, |
SHOW_FILE_PROPERTIES |
SHOW_FILE_PROPERTIES, |
COLOR_SCHEME |
}; |
|
int encoding; |
|
dword bg_color = 0xF0F0F0; |
dword text_color = 0; |
dword bg_color; |
dword text_color; |
|
//===================================================// |
// // |
// INTERNAL INCLUDES // |
// // |
//===================================================// |
|
#include "ini.h" |
#include "prepare_page.h" |
|
//===================================================// |
// // |
// CODE // |
// // |
//===================================================// |
|
void InitDlls() |
{ |
load_dll(boxlib, #box_lib_init, 0); |
75,12 → 124,12 |
load_dll(Proc_lib, #OpenDialog_init,0); |
} |
|
|
void main() |
{ |
InitDlls(); |
OpenDialog_init stdcall (#o_dialog); |
LoadIniSettings(); |
EventSetColorScheme(curcol_scheme); |
kfont.init(DEFAULT_FONT); |
Libimg_LoadImage(#skin, abspath("toolbar.png")); |
OpenFile(#param); |
106,6 → 155,11 |
} |
} |
|
//===================================================// |
// // |
// EVENTS // |
// // |
//===================================================// |
|
void HandleButtonEvent() |
{ |
134,8 → 188,11 |
EventShowEncodingList(); |
break; |
case RUN_EDIT: |
EventShowEdit(); |
EventShowReopenMenu(); |
break; |
case COLOR_SCHEME: |
EventShowColorSchemesList(); |
break; |
case SHOW_INFO: |
EventShowInfo(); |
break; |
171,7 → 228,7 |
EventMagnifyMinus(); |
break; |
case SCAN_CODE_KEY_E: |
EventShowEdit(); |
EventShowReopenMenu(); |
break; |
case SCAN_CODE_TAB: |
EventChangeEncoding(); |
199,7 → 256,6 |
} |
} |
|
|
/* ----------------------------------------------------- */ |
|
void EventOpenFile() |
237,20 → 293,33 |
PreparePage(); |
} |
|
void EventShowEdit() |
void EventShowEncodingList() |
{ |
menu.selected = encoding + 1; |
menu.show(Form.left+5 + charsets_mx, Form.top+29+skin_height, 130, |
"UTF-8\nKOI8-RU\nCP1251\nCP1252\nISO8859-5\nCP866", 10); |
} |
|
void EventShowReopenMenu() |
{ |
menu.selected = 0; |
menu.show(Form.left+5 + reopenin_menu_left, Form.top+29+skin_height, 130, |
"Tinypad\nTextEdit\nWebView\nFB2Read\nHexView", 20); |
menu.show(Form.left+5 + reopenin_mx, Form.top+29+skin_height, 130, |
"Tinypad\nTextEdit\nWebView\nFB2Read\nHexView\nOther", 20); |
} |
|
void EventShowEncodingList() |
void EventShowColorSchemesList() |
{ |
menu.selected = encoding + 1; |
menu.show(Form.left+5 + charsets_menu_left, Form.top+29+skin_height, 130, |
"UTF-8\nKOI8-RU\nCP1251\nCP1252\nISO8859-5\nCP866", 10); |
menu.selected = curcol_scheme + 1; |
menu.show(Form.left+5 + colscheme_mx, Form.top+29+skin_height, 175, #color_scheme_names, 30); |
} |
|
void EventSetColorScheme(dword _setn) |
{ |
curcol_scheme = _setn; |
bg_color = color_schemes[curcol_scheme*2]; |
text_color = color_schemes[curcol_scheme*2+1]; |
} |
|
void EventShowInfo() { |
help_opened = true; |
DrawBar(list.x, list.y, list.w, list.h, 0xFFFfff); |
273,6 → 342,7 |
|
void EventMenuClick() |
{ |
byte open_param[4096]; |
switch(menu.cur_y) |
{ |
//Encoding |
295,13 → 365,25 |
case 24: |
EventOpenFileInAnotherProgram("/sys/develop/heed"); |
break; |
case 25: |
sprintf(#open_param,"~%s",#param); |
RunProgram("/sys/@open", #open_param); |
break; |
//ColorSchemes |
case 30...38: |
EventSetColorScheme(menu.cur_y-30); |
PreparePage(); |
break; |
} |
menu.cur_y = 0; |
} |
|
/* ------------------------------------------- */ |
//===================================================// |
// // |
// DRAWS AND OTHER FUNCS // |
// // |
//===================================================// |
|
|
void OpenFile(dword f_path) |
{ |
int tmp; |
323,7 → 405,8 |
|
void draw_window() |
{ |
#define PADDING 6 |
#define BUTTONS_GAP 6 |
#define BLOCKS_GAP 15 |
#define TOOLBAR_BUTTON_WIDTH 26 |
incn x; |
DefineAndDrawWindow(Form.left,Form.top,Form.width,Form.height,0x73,0,#title,0); |
338,16 → 421,16 |
|
x.n = 0; |
DrawToolbarButton(OPEN_FILE, x.inc(8)); |
DrawToolbarButton(SHOW_FILE_PROPERTIES, x.inc(TOOLBAR_BUTTON_WIDTH + PADDING)); |
DrawToolbarButton(MAGNIFY_MINUS, x.inc(TOOLBAR_BUTTON_WIDTH + PADDING + PADDING)); |
DrawToolbarButton(SHOW_FILE_PROPERTIES, x.inc(TOOLBAR_BUTTON_WIDTH + BUTTONS_GAP)); |
|
DrawToolbarButton(MAGNIFY_MINUS, x.inc(TOOLBAR_BUTTON_WIDTH + BLOCKS_GAP)); |
DrawToolbarButton(MAGNIFY_PLUS, x.inc(TOOLBAR_BUTTON_WIDTH - 1)); |
DrawToolbarButton(CHANGE_ENCODING, x.inc(TOOLBAR_BUTTON_WIDTH + PADDING + PADDING)); |
charsets_menu_left = x.n; |
DrawToolbarButton(RUN_EDIT, x.inc(TOOLBAR_BUTTON_WIDTH + PADDING + PADDING)); |
reopenin_menu_left = x.n; |
DrawToolbarButton(COLOR_SCHEME, x.inc(TOOLBAR_BUTTON_WIDTH + BUTTONS_GAP)); colscheme_mx = x.n; |
|
DrawToolbarButton(CHANGE_ENCODING, x.inc(TOOLBAR_BUTTON_WIDTH + BLOCKS_GAP)); charsets_mx = x.n; |
DrawToolbarButton(RUN_EDIT, x.inc(TOOLBAR_BUTTON_WIDTH + BLOCKS_GAP)); reopenin_mx = x.n; |
DrawToolbarButton(SHOW_INFO, Form.cwidth - 34); |
|
|
if ((Form.cwidth-scroll.size_x-1 == list.w) && |
(Form.cheight-TOOLBAR_H == list.h) && |
(list.count) |
357,6 → 440,7 |
} else { |
PreparePage(); |
} |
|
DrawRectangle(scroll.start_x, scroll.start_y, scroll.size_x, scroll.size_y-1, scroll.bckg_col); |
} |
|