- fix new association adding [Critical]
- use system color for file path
TextRead:
- new feature: color schemes
- reopen option "Other" opens file in @open (thanks punk_joker for idea)

git-svn-id: svn://kolibrios.org@7466 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
Kirill Lipatov (Leency) 2018-10-14 22:02:13 +00:00
parent 8261da26a4
commit 14e47edee3
4 changed files with 128 additions and 38 deletions

View File

@ -1,9 +1,10 @@
_ini ini = { "/sys/settings/txtread.ini", "Config" };
_ini ini = { "/sys/settings/app.ini", "Txtread" };
void LoadIniSettings()
{
kfont.size.pt = ini.GetInt("FontSize", 14);
encoding = ini.GetInt("Encoding", CH_CP866);
curcol_scheme = ini.GetInt("ColorScheme", 1);
Form.left = ini.GetInt("WinX", 150);
Form.top = ini.GetInt("WinY", 50);
Form.width = ini.GetInt("WinW", 640);
@ -14,6 +15,7 @@ void SaveIniSettings()
{
ini.SetInt("FontSize", kfont.size.pt);
ini.SetInt("Encoding", encoding);
ini.SetInt("ColorScheme", curcol_scheme);
ini.SetInt("WinX", Form.left);
ini.SetInt("WinY", Form.top);
ini.SetInt("WinW", Form.width);

Binary file not shown.

Before

Width:  |  Height:  |  Size: 961 B

After

Width:  |  Height:  |  Size: 1.0 KiB

View File

@ -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 @@ Ctrl+E - reopen current file in another app
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,8 +77,11 @@ proc_info Form;
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,
@ -54,17 +90,30 @@ enum {
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 @@ void InitDlls()
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 @@ void main()
}
}
//===================================================//
// //
// EVENTS //
// //
//===================================================//
void HandleButtonEvent()
{
@ -134,7 +188,10 @@ void HandleButtonEvent()
EventShowEncodingList();
break;
case RUN_EDIT:
EventShowEdit();
EventShowReopenMenu();
break;
case COLOR_SCHEME:
EventShowColorSchemesList();
break;
case SHOW_INFO:
EventShowInfo();
@ -171,7 +228,7 @@ void HandleKeyEvent()
EventMagnifyMinus();
break;
case SCAN_CODE_KEY_E:
EventShowEdit();
EventShowReopenMenu();
break;
case SCAN_CODE_TAB:
EventChangeEncoding();
@ -199,7 +256,6 @@ void HandleMouseEvent()
}
}
/* ----------------------------------------------------- */
void EventOpenFile()
@ -237,20 +293,33 @@ void EventMagnifyMinus()
PreparePage();
}
void EventShowEdit()
{
menu.selected = 0;
menu.show(Form.left+5 + reopenin_menu_left, Form.top+29+skin_height, 130,
"Tinypad\nTextEdit\nWebView\nFB2Read\nHexView", 20);
}
void EventShowEncodingList()
{
menu.selected = encoding + 1;
menu.show(Form.left+5 + charsets_menu_left, Form.top+29+skin_height, 130,
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_mx, Form.top+29+skin_height, 130,
"Tinypad\nTextEdit\nWebView\nFB2Read\nHexView\nOther", 20);
}
void EventShowColorSchemesList()
{
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 EventOpenFileInAnotherProgram(dword _app)
void EventMenuClick()
{
byte open_param[4096];
switch(menu.cur_y)
{
//Encoding
@ -295,12 +365,24 @@ void EventMenuClick()
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)
{
@ -323,7 +405,8 @@ void OpenFile(dword f_path)
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 @@ void draw_window()
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)
@ -356,7 +439,8 @@ void draw_window()
DrawPage();
} else {
PreparePage();
}
}
DrawRectangle(scroll.start_x, scroll.start_y, scroll.size_x, scroll.size_y-1, scroll.bckg_col);
}

View File

@ -1,11 +1,11 @@
DEBUG equ 0
DEBUG = 0
LIST_WIDTH equ 256
WIN_WIDTH equ (LIST_WIDTH + 16 + 12)
LIST_SIZE equ 12
LINE_SIZE equ 40
LIST_HEIGHT equ (LIST_SIZE * LINE_SIZE / 2)
WIN_HEIGHT equ (LIST_HEIGHT + 80)
LIST_WIDTH = 256
WIN_WIDTH = (LIST_WIDTH + 16 + 12)
LIST_SIZE = 12
LINE_SIZE = 40
LIST_HEIGHT = (LIST_SIZE * LINE_SIZE / 2)
WIN_HEIGHT = (LIST_HEIGHT + 80)
use32
org 0
@ -299,6 +299,7 @@ end if
mov ebx, [skin.work_text]
mov [ps_addres.txt], eax
mov [ps_addres], ebx
m2m [ps_addres.color], [skin.work_text]
invoke pathshow.init, ps_addres
;; get checkbox
@ -582,7 +583,10 @@ end if
stdcall string.concatenate, [param_a], buffer
@@:
invoke libini.set_str, assoc_ini, assoc_ini.sec, [param_e], buffer, 33
stdcall string.length, buffer
mov edi, eax
invoke libini.set_str, assoc_ini, assoc_ini.sec, [param_e], buffer, edi
jmp exit
;----------------------