Author SHA1 Message Date
Leency 74ddc9517d fix clicking on url ".." 2026-06-30 09:36:40 +03:00
Leency 3ec46799ec dl:
- fix case when filename=file.ext without quotes;
- add invisible option "-i"
2026-06-20 18:46:21 +03:00
Leency 46dee41f8c WebView 4:
- multi-thread images load;
- store img_cache in /tmp0/1/Cache;
- reload img_cache after browser restart
2026-06-20 18:44:03 +03:00
18 changed files with 299 additions and 190 deletions

No files matched your search

+4 -1
View File
@@ -160,8 +160,11 @@ bool TWebBrowser::RenderImage(dword cur_img)
if (img_y + img_h >= canvas.bufh) canvas.IncreaseBufSize();
if (secondrun)
if (secondrun)
{
if (bg_colors.get_last() - bg_colors.get(0)) {
canvas.DrawBar(draw_x, draw_y, img_w, list.item_h, bg_colors.get_last());
}
if (ESDWORD[cur_img+20] != IMAGE_BPP32) {
img_convert stdcall(cur_img, 0, IMAGE_BPP32, 0, 0);
$push eax
+16 -5
View File
@@ -304,6 +304,9 @@ void TWebBrowser::tag_img()
{
char img_path[4096]=0;
dword base64img;
dword img_data=0, img_size=0;
if (!secondrun) return;
if (!tag.get_value_of("data-large-image"))
if (!tag.get_value_of("data-src"))
@@ -334,16 +337,22 @@ void TWebBrowser::tag_img()
if (EAX) goto IMGOK; else goto NOIMG;
}
if (cache.has(#img_path)) {
img_decode stdcall (cache.current_buf, cache.current_size, 0);
if (EAX) goto IMGOK; else goto NOIMG;
if (cache2.is_contain(#img_path))
{
read_file(cache2.path.get(cache2.cur), #img_data, #img_size);
if (img_size) {
img_decode stdcall (img_data, img_size, 0);
if (EAX) goto IMGOK;
} else {
//cache2.url.set_null(cache2.cur);
}
} else {
if (img_url.get_pos_by_name(#img_path)==-1) img_url.add(#img_path);
goto NOIMG;
}
goto NOIMG;
IMGOK:
if (RenderImage(EAX)) return;
if (RenderImage(EAX)) goto IMG_END;
NOIMG:
if (tag.get_value_of("title")) || (tag.get_value_of("alt")) {
@@ -361,6 +370,8 @@ NOIMG:
RenderTextbuf();
style.image = false;
text_colors.pop();
IMG_END:
free(img_data);
}
struct TABLE {
+79 -55
View File
@@ -78,7 +78,6 @@ char search_engine[256];
#include "settings.h"
#include "tabs.h"
dword cur_img_url;
dword shared_url;
dword http_get_type=PAGE;
dword render_start_time;
@@ -91,6 +90,10 @@ char editURL[URL_SIZE+1];
edit_box omnibox_edit = {250, 0, 0, 0xffffff,
0x94AECE, 0xffffff, 0xffffff,0x10000000,URL_SIZE-2,#editURL,0,,19,19};
int img_downloaders[256];
int img_downloaders_count = 0;
bool img_loading = false;
//===================================================//
// //
// CODE //
@@ -140,8 +143,9 @@ void main()
LoadLibraries();
LoadIniConfig();
HandleParam();
cache2.load();
omnibox_edit.left = PADDING+TSZE*2+PADDING+6;
omnibox_edit.left = PADDING+TSZE*3+PADDING+8;
omnibox_edit.top = PADDING+3;
WB1.list.SetFont(8, 14, 10011000b);
@@ -202,9 +206,8 @@ void main()
break;
case evReDraw:
DefineAndDrawWindow(GetScreenWidth()-WIN_W/2-random(80),GetScreenHeight()-WIN_H/2-random(80),
//DefineAndDrawWindow(0,0,
WIN_W,WIN_H,0x73,0,0,0);
DefineAndDrawWindow(GetScreenWidth()-WIN_W/2-random(80),
skin_h-WIN_H/2-random(80),WIN_W,WIN_H,0x73,0,0,0);
GetProcessInfo(#Form, SelfInfo);
ProcessMenuClick();
sc.get();
@@ -217,12 +220,13 @@ void main()
case evNetwork:
if (http.transfer <= 0) break;
http.receive();
if (http.receive_result != 0) break;
if (debug_mode) {
EAX = http.transfer;
debugln(#EAX.http_msg.http_header);
}
if (http.status_code >= 300) && (http.status_code < 400)
{
// Handle redirects
@@ -232,7 +236,6 @@ void main()
} else {
StopLoading();
redirect_count = 0;
if (http_get_type==IMG) goto _IMG_RES;
notify("'Too many redirects.' -E");
}
} else {
@@ -256,18 +259,6 @@ void main()
free(http.content_pointer);
DrawOmnibox();
}
else if (http_get_type==IMG) {
_IMG_RES:
if (http.status_code >= 200) && (http.status_code < 300) {
cache.add(cur_img_url, http.content_pointer, http.content_received, IMG, NULL);
} else {
cache.add(cur_img_url, 0, 0, IMG, NULL);
}
http.hfree();
free(http.content_pointer);
GetImg(false);
}
debugln("end evNetwork");
}
break;
default:
@@ -276,6 +267,7 @@ void main()
ESDWORD[shared_url] = '\0';
ActivateWindow(GetProcessSlot(Form.ID));
}
if (img_loading) CheckImgDownloads();
}
}
@@ -290,7 +282,7 @@ void ProcessButtonClick(dword id__)
{
switch (id__)
{
case 1: ExitProcess();
case 1: cache2.save(); ExitProcess();
case TAB_CLOSE_ID...TAB_CLOSE_ID+TABS_MAX: EventTabClose(id__ - TAB_CLOSE_ID); return;
case TAB_ID...TAB_ID+TABS_MAX: EventAllTabsClick(id__ - TAB_ID); return;
case ENCODINGS...ENCODINGS+6: EventManuallyChangeEncoding(id__-ENCODINGS); return;
@@ -363,7 +355,7 @@ void ProcessKeyEvent()
void SetElementSizes()
{
omnibox_edit.width = Form.cwidth - BUTTON_W - SEARCH_GO_GAP - BUTTON_W - omnibox_edit.left - 52 - 23;
omnibox_edit.width = Form.cwidth - omnibox_edit.left - 51;
if (Form.cwidth - scroll_wv.size_x != WB1.list.w) {
//temporary fix for crash
//related to 'cur_img_url' var read
@@ -391,14 +383,15 @@ void draw_window()
DrawBar(0,TOOLBAR_H-2, Form.cwidth,1, MixColors(sc.dark, sc.work, 180));
DrawBar(0,TOOLBAR_H-1, Form.cwidth,1, sc.line);
DrawBar(0, PADDING, omnibox_edit.left-2, TSZE+1, sc.work);
DrawBar(omnibox_edit.left+omnibox_edit.width+24, PADDING, Form.cwidth-omnibox_edit.left-omnibox_edit.width-24, TSZE+1, sc.work);
DrawBar(omnibox_edit.left+omnibox_edit.width+2, PADDING, Form.cwidth-omnibox_edit.left-omnibox_edit.width-2, TSZE+1, sc.work);
DrawTopPanelButton(BACK_BUTTON, PADDING-1, PADDING, 30, false);
DrawTopPanelButton(FORWARD_BUTTON, PADDING+TSZE+PADDING-2, PADDING, 31, false);
DrawTopPanelButton(SANDWICH_BUTTON, Form.cwidth-PADDING-TSZE + 2 , PADDING, -1, burger_active); //burger menu
DrawTopPanelButton(SEARCH_BUTTON, Form.cwidth - PADDING - TSZE - 3 - BUTTON_W, PADDING, 49, false); // Search web button
DrawTopPanelButton(GO_BUTTON, Form.cwidth - PADDING - TSZE - 3 - BUTTON_W - SEARCH_GO_GAP - BUTTON_W, PADDING, 12, false); // go to address button
DrawTopPanelButton(SANDWICH_BUTTON, Form.cwidth-PADDING-TSZE-4, PADDING, -1, burger_active); //burger menu
//DrawTopPanelButton(SEARCH_BUTTON, Form.cwidth - PADDING - TSZE - 3 - BUTTON_W, PADDING, 49, false); // Search web button
//DrawTopPanelButton(GO_BUTTON, Form.cwidth - PADDING - TSZE - 3 - BUTTON_W - SEARCH_GO_GAP - BUTTON_W, PADDING, 12, false); // go to address button
DrawBar(0,Form.cheight - STATUSBAR_H, Form.cwidth,1, sc.line);
@@ -492,8 +485,10 @@ void EventCopyLinkToClipboard()
void StopLoading()
{
if (http.stop()) pause(10);
http.stop();
//if (http.stop()) pause(10);
prbar.value = 0;
img_loading = false;
}
//rewrite into
@@ -573,6 +568,8 @@ void OpenPage(dword _open_URL)
anchors.take_anchor_from(#new_url);
}
debug("\nWebView GET => "); debugln(#new_url);
/*
There could be several possible types of addresses:
- cached page (only http/https)
@@ -773,9 +770,9 @@ void LoadInternalPage(dword _bufdata, _in_bufsize){
WB1.DrawPage();
}
http.hfree();
if (WB1.img_url.count) {
GetImg(true);
DrawOmnibox();
if (WB1.img_url.count) {
GetImg();
DrawOmnibox();
} else {
PageLoaded();
}
@@ -925,18 +922,18 @@ void DrawStatusBar(dword _msg)
void DrawOmnibox()
{
int imgxoff;
DrawOvalBorder(omnibox_edit.left-2, omnibox_edit.top-3, omnibox_edit.width+24, 24, sc.line,
DrawOvalBorder(omnibox_edit.left-2, omnibox_edit.top-3, omnibox_edit.width+2, 24, sc.line,
sc.line, sc.line, sc.dark);
DrawBar(omnibox_edit.left-1, omnibox_edit.top-2, omnibox_edit.width+24, 1, 0xD8DCD8);
DrawBar(omnibox_edit.left-1, omnibox_edit.top-1, omnibox_edit.width+24, 1, omnibox_edit.bg_color);
DrawBar(omnibox_edit.left-1, omnibox_edit.top-2, omnibox_edit.width+2, 1, 0xD8DCD8);
DrawBar(omnibox_edit.left-1, omnibox_edit.top-1, omnibox_edit.width+2, 1, omnibox_edit.bg_color);
DrawBar(omnibox_edit.left-1, omnibox_edit.top, 1, 22, omnibox_edit.bg_color);
if (http.transfer) || (img_loading) { imgxoff = 67; } else imgxoff = 66;
DrawTopPanelButton(REFRESH_BUTTON, PADDING+TSZE*2+PADDING+2, PADDING, imgxoff, false);
if (omnibox_edit.flags & ed_focus) omnibox_edit.flags = ed_focus; else omnibox_edit.flags = 0;
EditBox_UpdateText(#omnibox_edit, omnibox_edit.flags);
edit_box_draw stdcall(#omnibox_edit);
if (http.transfer) imgxoff = 23*23*3; else imgxoff = 0;
PutImage(omnibox_edit.left+omnibox_edit.width, omnibox_edit.top-1, 23, 23, imgxoff + #editbox_icons);
DefineHiddenButton(omnibox_edit.left+omnibox_edit.width, omnibox_edit.top-2, 22, 23, REFRESH_BUTTON);
DrawProgress();
}
@@ -1001,37 +998,64 @@ void HandleRedirect()
free(redirect_url);
}
dword GetImg(bool _new)
void GetImg()
{
int i;
if (!show_images) return;
http_get_type = IMG;
char cur_downloader_path[4096];
char local_path[64];
dword cur_img_url;
for (i = 0; i < WB1.img_url.count; i++)
{
if (!show_images) || (!WB1.img_url.count) return;
img_downloaders_count = math.min(WB1.img_url.count, 256);
CreateDir("/tmp0/1/Cache");
for (i = 0; i < img_downloaders_count; i++) {
cur_img_url = WB1.img_url.get(i);
if (cache.has(cur_img_url)==false) {
prbar.max = WB1.img_url.count;
prbar.value = i;
if (GetUrl(cur_img_url)) {
DrawStatusBar(cur_img_url);
DrawProgress();
return;
}
if (cache2.is_contain(cur_img_url)) continue;
sprintf(#local_path, "/tmp0/1/Cache/wv_%i_%i.png", Form.ID, cache2.url.count + 1);
sprintf(#cur_downloader_path, "-i %s|%s", cur_img_url, #local_path);
cache2.add(cur_img_url, #local_path);
img_downloaders[i] = RunProgram("/sys/network/dl", #cur_downloader_path);
}
img_loading = true;
prbar.max = img_downloaders_count;
prbar.value = 0;
}
void CheckImgDownloads()
{
int i;
int done_count = 0;
for (i = 0; i < img_downloaders_count; i++) {
if (!img_downloaders[i]) || (!GetProcessSlot(img_downloaders[i])) {
img_downloaders[i] = 0;
done_count++;
}
}
if (_new) return;
DrawOmnibox();
DrawStatusBar(T_RENDERING);
WB1.Reparse();
WB1.DrawPage();
PageLoaded();
if (done_count < img_downloaders_count) {
prbar.max = img_downloaders_count;
prbar.value = done_count;
DrawProgress();
sprintf(#param, "Downloading images: %i/%i...", prbar.value, prbar.max);
DrawStatusBar(#param);
} else {
DrawStatusBar(T_RENDERING);
WB1.Reparse();
WB1.DrawPage();
PageLoaded();
img_loading = false;
DrawOmnibox();
}
}
void PageLoaded()
{
DrawStatusBar(sprintf(#param, T_DONE_IN_SEC, GetStartTime()-render_start_time/100,
GetStartTime()-render_start_time*10));
GetStartTime()-render_start_time*10));
}
stop:
+64
View File
@@ -61,4 +61,68 @@ void _cache::clear()
current_size = NULL;
current_type = NULL;
current_charset = NULL;
}
struct _cache2
{
collection url;
collection path;
dword cur;
void add();
bool is_contain();
void clear();
void save();
void load();
} cache2;
void _cache2::add(dword _url, _path)
{
if (!is_contain(_url)) {
url.add(_url);
path.add(_path);
}
}
bool _cache2::is_contain(dword _url)
{
cur = url.get_pos_by_name(_url);
if (cur == -1) return false;
return true;
}
void _cache2::clear()
{
url.drop();
path.drop();
}
void _cache2::save()
{
dword buf, buf_size, i;
buf_size = url.data_size + path.data_size + url.count + url.count + 7;
buf = malloc(buf_size);
strcpy(buf, "[img]\n");
for ( i = 0 ; i < path.count ; i++ ) {
if (!url.get(i)) continue;
strcat(buf, url.get(i));
strcat(buf, "=");
strcat(buf, path.get(i));
strcat(buf, "\n");
}
strcat(buf, "\0");
CreateFile(math.min(buf_size, strlen(buf)), buf, "/tmp0/1/Cache/_list_db.ini");
free(buf);
}
void _cache2::load()
{
ini_enum_keys stdcall ("/tmp0/1/Cache/_list_db.ini", "img", #_cache2_load_sections);
}
byte _cache2_load_sections(dword key_value, key_name, sec_name, f_name)
{
cache2.add(key_name, key_value);
}
+1 -3
View File
@@ -108,11 +108,9 @@ enum {
TAB_CLOSE_ID = 900
};
char editbox_icons[] = FROM "res/editbox_icons.raw";
#define WIN_W 850
#define WIN_H 920
#define DEFAULT_URL URL_SERVICE_HOMEPAGE
char version[]="WebView 3.98";
char version[]="WebView 4";
+1
View File
@@ -26,6 +26,7 @@
<a href=//menuetos.net>menuetos.net</a>
<a href=//osnews.com>osnews.com</a>
<kosicon n=6><a href=https://cobradile.neocities.org>145 images</a>
<h3><kosicon n=54>Cyrillic only</h3>
<a href=//dgmag.in>dgmag.in</a> <a href=//old-dos.ru>old-dos.ru</a> <a href=//lionovsky.us>lionovsky.us</a> <a href=//mirrors.pdp-11.ru>mirrors.pdp-11.ru</a>
+34 -7
View File
@@ -13,6 +13,7 @@
#include "const.h"
bool open_file = false;
bool invisible = false;
dword speed;
@@ -58,7 +59,7 @@ void main()
sc.get();
InitDownload();
if (param) {
if (param[0]) {
path_pointer = #param;
//save path specified? Example: https://example.com/file|/sys/media/ac97snd
if (save_path_separator_pos = strchr(#param, '|')) {
@@ -66,11 +67,19 @@ void main()
strcpy(#filepath, save_path_separator_pos+1);
ESBYTE[save_path_separator_pos] = '\0';
}
if (streqrp(#param, "-e ")) {
// invisible window
if (!strncmp(#param, "-i ", 3)) {
autoclose.checked = true;
invisible = true;
path_pointer += 3;
}
// autoclose
if (!strncmp(#param, "-e ", 3)) {
autoclose.checked = true;
path_pointer += 3;
}
if (streqrp(#param, "-eo ")) {
// autoclose and open file
if (!strncmp(#param, "-eo ", 4)) {
autoclose.checked = true;
open_file = true;
path_pointer += 4;
@@ -151,6 +160,8 @@ void DrawDlButton(int x, id, t)
void DefineWindow()
{
if (invisible) return;
sc.get();
pb.frame_color = ed.border_color = ed.focus_border_color = sc.line;
DefineAndDrawWindow(110 + random(300), 100 + random(300), WIN_W+9,
@@ -161,6 +172,9 @@ void DefineWindow()
void DrawWindow()
{
#define BUT_Y 58;
if (invisible) return;
if (!http.transfer) && (!filepath) {
DrawBar(GAPX, 102, WIN_W - GAPX - GAPX+1, 24+1, sc.work);
DeleteButton(BTN_DIR);
@@ -220,6 +234,7 @@ void StartDownloading()
DrawWindow();
} else {
pb.progress_color = PB_COL_ERROR;
if (invisible) ExitProcess();
notify(T_ERROR_STARTING_DOWNLOAD);
StopDownloading();
EditBox_UpdateText(#ed, ed_focus + ed_always_focus);
@@ -305,7 +320,9 @@ void MonitorProgress()
void CompleteDownload()
{
SaveFile(0);
if (autoclose.checked) ExitProcess();
if (autoclose.checked) {
ExitProcess();
}
pb.value = pb.max;
pb.progress_color = PB_COL_COMPLETE;
StopDownloading();
@@ -318,6 +335,8 @@ void SaveFile(int attempt)
int i;
char notify_message[4296];
char file_name[URL_SIZE+96];
bool quote = false;
dword filename_pos;
//if save_path is not set then we have to combine it
if (!save_path_set) {
@@ -336,11 +355,19 @@ void SaveFile(int attempt)
//Content-Disposition: attachment; filename="RealFootball_2018_Nokia_5800_EN_IGP_EU_TS_101.zip"
if (http.header_field("content-disposition", #file_name, sizeof(file_name))) {
if (EDX = strstr(#file_name,"filename=\"")) {
strcat(#filepath, EDX+10);
filename_pos = strstr(#file_name,"filename=");
if (filename_pos) {
if (ESBYTE[filename_pos] == '\"') {
quote = true;
filename_pos++;
}
strcat(#filepath, filename_pos+9);
ESBYTE[strchr(#filepath,'\"')] = '\0';
ESBYTE[strchr(#filepath,' ')] = '\0';
ESBYTE[strchr(#filepath,';')] = '\0';
}
} else {
}
if (!filename_pos) {
// Clean all slashes at the end
strcpy(#file_name, #uEdit);
while (file_name[strlen(#file_name)-1] == '/') {
+6 -7
View File
@@ -223,14 +223,13 @@ void _http::receive()
switch(ESBYTE[new_URL]) {
case '.':
new_URL++;
if (ESBYTE[new_URL] == '/') {
new_URL++;
}
else if (ESBYTE[new_URL] == '.') && (ESBYTE[new_URL+1] == '/') {
_GO_UP:
if (ESBYTE[new_URL+1] == '/') {
new_URL+=2;
newurl[strrchr(#newurl, '/')-1] = '\0';
}
else if (ESBYTE[new_URL+1] == '.') && (ESBYTE[new_URL+2] == '/') {
_GO_UP:
new_URL+=3;
newurl[strrchr(#newurl, '/')-1] = '\0';
}
goto _DEFAULT;
case '?':
+14 -18
View File
@@ -905,24 +905,20 @@ inline signed csshexdec(dword text)
:dword miniprintf(dword dst, format, insert_line)
{
dword in_pos = strchr(format, '%');
if (!in_pos) {
_NO_STR:
strcpy(dst, format);
return dst;
}
EBX = ESBYTE[EAX+1];
if (EBX == 's') {
if (!insert_line) goto _NO_STR;
strncpy(dst, format, in_pos - format);
strcat(dst, insert_line);
strcat(dst, in_pos+2);
}
if (EBX == 'd') || (EBX == 'i') {
strncpy(dst, format, in_pos - format);
strcat(dst, itoa(insert_line));
strcat(dst, in_pos+2);
if (!in_pos) || (!insert_line) {
strcpy(dst, format);
} else {
EBX = ESBYTE[EAX+1];
if (EBX == 's') {
strncpy(dst, format, in_pos - format);
strcat(dst, insert_line);
strcat(dst, in_pos+2);
}
if (EBX == 'd') || (EBX == 'i') {
strncpy(dst, format, in_pos - format);
strcat(dst, itoa(insert_line));
strcat(dst, in_pos+2);
}
}
return dst;
}
+1 -1
View File
@@ -2,4 +2,4 @@
@del tmpdisk
@rename tmpdisk.com tmpdisk
@del warning.txt
if not exist tmpdisk ( @pause )
@pause
+1 -1
View File
@@ -2,4 +2,4 @@
@del tmpdisk
@rename tmpdisk.com tmpdisk
@del warning.txt
if not exist tmpdisk ( @pause )
@pause
Binary file not shown.

After

Width:  |  Height:  |  Size: 236 B

+1
View File
@@ -0,0 +1 @@
ЬЬЬЬЬЬЬЬЬЬЬЬЬЬД ╝<┘I╝<┘I╝<┘I╝<┘I╝<┘I┘I┘IЬД ┤<╝<┘I╝<ЬЬЬЬ┘I╝<┘I┘IЬД ╝<┤<╝<╝<Ь№№№№№№Ь╝<┘I╝<┘IЬД ┤<╝<┘I┤<Ь№№№№№№Ь╝<╝<┘I╝<ЬД ┤<ЬЬЬЬ№№№№№№ЬЬЬЬ┘IЬД ┤<Ь№№№№№№№№№№№№№№№№№№№№№№№№Ь╝<ЬД ╝<Ь№№№№№№№№№№№№№№№№№№№№№№№№Ь┘IЬД ┤<ЬЬЬЬ№№№№№№ЬЬЬЬ┘IЬД ┤<┤<╝<┤<Ь№№№№№№Ь┘I╝<╝<┘IЬД ┤<╝<┤<╝<Ь№№№№№№Ь┘I╝<┘I╝<ЬД ╝<┤<╝<┤<ЬЬЬЬ╝<┤<╝<┘IЬД д4┤<д4┤<┤<╝<┤<┤<┤<╝<┤<╝<ЬД Д Д Д Д Д Д Д Д Д Д Д Д Д ,Ф,Ф,Ф,Ф,Ф,Ф,Ф,Ф,Ф,Ф,Ф,Ф,Ф,Ф,ФD ▄SЇD ▄SЇSЇSЇSЇSЇSЇSЇSЇSЇ,Ф,Ф< ┌D ▄SЇD ▄D ▄SЇD ▄SЇD ▄SЇSЇSЇ,Ф,ФD ▄< ┌D ▄D ▄D ▄D ▄SЇD ▄SЇD ▄SЇSЇ,Ф,Ф< ┌D ▄SЇ< ┌D ▄D ▄D ▄SЇD ▄SЇD ▄SЇ,Ф,Ф< ┌4 ┤4 ┤4 ┤4 ┤4 ┤4 ┤4 ┤4 ┤4 ┤4 ┤SЇ,Ф,Ф< ┌4 ┤№№№№№№№№№№№№№№№№№№№№№№№№4 ┤D ▄,Ф,ФD ▄4 ┤№№№№№№№№№№№№№№№№№№№№№№№№4 ┤SЇ,Ф,Ф< ┌4 ┤4 ┤4 ┤4 ┤4 ┤4 ┤4 ┤4 ┤4 ┤4 ┤SЇ,Ф,Ф< ┌D ▄D ▄D ▄< ┌D ▄D ▄< ┌SЇD ▄D ▄SЇ,Ф,Ф9 ┴D ▄D ▄D ▄D ▄D ▄D ▄D ▄SЇD ▄SЇD ▄,Ф,ФD ▄9 ┴D ▄9 ┴D ▄9 ┴D ▄9 ┴D ▄< ┌D ▄SЇ,Ф,Ф9 ┴< ┌9 ┴< ┌9 ┴D ▄9 ┴< ┌9 ┴D ▄< ┌D ▄,Ф,Ф,Ф,Ф,Ф,Ф,Ф,Ф,Ф,Ф,Ф,Ф,Ф,Ф,Ф
Binary file not shown.

After

Width:  |  Height:  |  Size: 114 B

+1
View File
@@ -0,0 +1 @@
lddTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTlddTTTффф№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№№фффTTTTTT┤ммффффффффффффффффффффффффффффффффф┤ммTTTTTT┤ммффффффффффффффффффффффффффффффффф┤ммTTTTTT┤ммффффффффффффффффффффффффффффффффф┤ммTTTTTT┤мм┤мм┤мм┤мм┤мм┤мм┤мм┤мм┤мм┤мм┤мм┤мм┤ммTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTT№№№TTT№№№TTT№№№TTT№№№TTT№№№TTT№№№TTT№№№TTT№№№№№№TTT№№№TTT№№№TTT№№№TTT№№№TTT№№№TTT№№№TTT№№№
+6 -7
View File
@@ -16,7 +16,7 @@
0};
#else
?define DELETE_DISK_TEXT "Trying to delete /tmp%i"
?define NEW_DISK_TEXT "Trying to add RAM disk /tmp%i, the size of %i MB"
?define NEW_DISK_TEXT "Trying to add virtual disk /tmp%i, the size of %i MB"
char *rezult_text[]={
"TmpDisk operation completed successfully",
"unknown IOCTL code, wrong input/output size...",
@@ -31,7 +31,7 @@
char Console_Work()
{
unsigned int disk_size, driver_rezult;
char t_size[256];
char size_t[256];
strlwr(#param);
@@ -45,8 +45,8 @@ char Console_Work()
ioctl.inp_size = sizeof(del_disk);
ioctl.output = 0;
ioctl.out_size = 0;
miniprintf(#t_size, DELETE_DISK_TEXT, add_disk.DiskId);
debugln(#t_size);
sprintf(#size_t, DELETE_DISK_TEXT, add_disk.DiskId);
debugln(#size_t);
break;
case 'a': //Add disk
disk_size= strchr(#param, 's');
@@ -62,9 +62,8 @@ char Console_Work()
ioctl.inp_size = sizeof(add_disk);
ioctl.output = 0;
ioctl.out_size = 0;
miniprintf(#t_size, NEW_DISK_TEXT, add_disk.DiskId);
miniprintf(#param, #t_size, add_disk.DiskSize/2048);
debugln(#param);
sprintf(#size_t, NEW_DISK_TEXT, add_disk.DiskId, add_disk.DiskSize/2048);
debugln(#size_t);
break;
default:
debugln("\ntmpdisk: unknown command line parameters!");
+69 -84
View File
@@ -5,47 +5,33 @@
#include "..\lib\gui.h"
#include "..\lib\obj\box_lib.h"
//===================================================//
// //
// TRANSLATIONS //
// //
//===================================================//
#ifdef LANG_RUS
?define T_WIN_TITLE "TmpDisk 0.80: Управление дисками в ОЗУ"
?define T_ADD_DISK " Добавить диск [Ins]"
?define T_DELETE_DISK " Удалить диск [Del]"
?define INTRO_TEXT_1 "Ни одного диска пока не добавлено."
?define INTRO_TEXT_2 "Пожалуйста, добавьте tmp0, он необходим."
?define NEW_DISK_SIZE "Размер нового диска"
?define NEW_DISK_SIZE_W 19*8
?define INTRO_TEXT_1 "Здесь будет отображаться список"
?define INTRO_TEXT_2 "виртуальных дисков в системе."
?define INTRO_TEXT_3 "Попробуйте добавить один..."
?define SIZE_TEXT "Размер нового диска в МБ:"
?define NOTIFY_TEXT_NO_DISK "'Для начала добавьте хотя бы один диск' -W"
?define NOTIFY_SYSTEM_DISK0 "'Диск с номером 0 является системным и удалять его не рекомендуется.
В случае, если вы точно знаете, что делаете, удалить его можно с зажатой клавишей SHIFT.' -W"
?define NOTIFY_TEXT_DISK_LIMIT "'Достигнут предел количества виртуальных дисков' -W"
?define FREE_RAM_TEXT "MB (Доступно %i MБ)"
?define FREE_RAM_TEXT "Размер свободной оперативной памяти: %i MБ"
#else
?define T_WIN_TITLE "TmpDisk 0.80: RAM Disk Manager"
?define T_ADD_DISK " Add disk [Ins]"
?define T_DELETE_DISK " Delete disk [Del]"
?define INTRO_TEXT_1 "No disks added yet."
?define INTRO_TEXT_2 "Please add tmp0 as it is crucial."
?define NEW_DISK_SIZE "New Disk size"
?define NEW_DISK_SIZE_W 13*8
?define INTRO_TEXT_1 " There will be list of mounted"
?define INTRO_TEXT_2 " virtual disks."
?define INTRO_TEXT_3 " Try to add one..."
?define SIZE_TEXT "New Disk size in MB:"
?define NOTIFY_TEXT_NO_DISK "'You need to have at least one disk' -W"
?define NOTIFY_SYSTEM_DISK0 "'Disc number 0 is a system disk. It is not recommended to delete it.
In case when you know what you are doing you can delete it with the SHIFT key pressed.' -W"
?define NOTIFY_TEXT_DISK_LIMIT "'Reached the limit of the number of virtual disks' -W"
?define FREE_RAM_TEXT "MB (Free RAM: %i MB)"
?define FREE_RAM_TEXT "Free RAM size: %i MB"
#endif
//===================================================//
// //
// DATA //
// //
//===================================================//
struct path_string { unsigned char Item[10]; };
path_string disk_list[10];
@@ -53,31 +39,26 @@ dword devbuf;
char disk_num;
char selected;
#define WIN_W 400
#define WIN_H 240
proc_info Form;
unsigned char icons_btn[] = FROM "img/btn.raw";
unsigned char disk_icon[] = FROM "img/disk.raw";
#define TOPPANELH 68
?define FREE_RAM_TEXT_X NEW_DISK_SIZE_W + 61
#define BOTPANELH 26
char new_disk_size[5];
edit_box edit_disk_size= {40,NEW_DISK_SIZE_W+13,6,0xffffff,0x94AECE,0xFFFfff,0xffffff,0x10000000,
sizeof(new_disk_size)-1,#new_disk_size,0, ed_focus+ed_figure_only};
char tmp_path[8] = "/tmp#/1";
//===================================================//
// //
// CODE //
// //
//===================================================//
char new_disk_size[7];
edit_box edit_disk_size= {50,0,7,0xffffff,0x94AECE,0xFFFfff,0xffffff,0x10000000,
sizeof(new_disk_size)-2,#new_disk_size,0, ed_focus+ed_figure_only};
void Main_Window()
{
word id;
proc_info Form;
int x;
#define NO_DLL_INIT
load_dll(boxlib, #box_lib_init,0);
GetNewSizeDisk();
edit_disk_size.left = strlen(SIZE_TEXT)*8 + 13;
@SetEventMask(EVM_REDRAW + EVM_KEY + EVM_BUTTON + EVM_MOUSE + EVM_MOUSE_FILTER);
loop()
{
@@ -162,49 +143,44 @@ void Main_Window()
break;
case evReDraw:
sc.get();
DefineAndDrawWindow(screen.w-WIN_W/2,screen.h-WIN_H/2,
WIN_W+9, WIN_H+skin_h+4,0x74,sc.work,T_WIN_TITLE,0);
DefineAndDrawWindow(170,150,405,290,0x74,sc.work,"Virtual Disk Manager 0.69",0);
GetProcessInfo(#Form, SelfInfo);
if (Form.status_window&ROLLED_UP) break;
DrawWindowContent();
DrawBar(0,0, Form.cwidth,TOPPANELH, sc.work);
DrawBar(0,TOPPANELH, Form.cwidth,1, sc.line);
WriteText(6, 9, 0x90, sc.work_text, SIZE_TEXT);
DrawRectangle(edit_disk_size.left-1, edit_disk_size.top-1, edit_disk_size.width+2, 23,sc.line);
edit_box_draw stdcall (#edit_disk_size);
x = 6 + DrawStandartCaptButton(6, 36, 10, T_ADD_DISK);
DrawStandartCaptButton(x, 36, 11, T_DELETE_DISK);
PutImage(6+6, 42, 14,14, #icons_btn);
PutImage(x+6, 42, 14,14, 14*14*3+#icons_btn);
GetDisks();
DrawTmpDisks();
}
}
}
void DrawWindowContent()
{
int x;
char free_ram_text[60];
DrawBar(0,0, WIN_W,TOPPANELH, sc.work);
DrawBar(0,TOPPANELH, WIN_W,1, sc.line);
WriteText(6, 9, 0x90, sc.work_text, NEW_DISK_SIZE);
DrawRectangle(edit_disk_size.left-1, edit_disk_size.top-1, edit_disk_size.width+2, 23,sc.line);
edit_box_draw stdcall (#edit_disk_size);
#define BTN_W WIN_W - 12 / 2 - 3
DrawCaptButton(6, 36, BTN_W, 24, 10, 0x45975E, 0xFFFfff, T_ADD_DISK);
DrawCaptButton(6+BTN_W+6, 36, BTN_W, 24, 11, 0xC75C54, 0xFFFfff, T_DELETE_DISK);
miniprintf(#free_ram_text, FREE_RAM_TEXT, GetFreeRAM()/1024);
WriteText(FREE_RAM_TEXT_X, 9, 0x90, sc.work_text, #free_ram_text);
GetDisks();
DrawTmpDisks();
}
void GetNewSizeDisk()
{
int fr;
fr = GetFreeRAM() / 5 * 2;
fr = itoa(fr / 2048);
edit_box_set_text stdcall (#edit_disk_size, fr);
strcpy(#new_disk_size, fr);
EditBox_UpdateText(#edit_disk_size, edit_disk_size.flags);
edit_box_draw stdcall (#edit_disk_size);
}
void OpenTmpDisk()
{
if (disk_num) {
tmp_path[4] = disk_list[selected].Item[3];
RunProgram("/sys/File managers/Eolite", #tmp_path);
}
unsigned char eol_param[10];
if (!disk_num) return;
strcpy(#eol_param, "/tmp#/1");
eol_param[4] = disk_list[selected].Item[3];
RunProgram("/sys/File managers/Eolite", #eol_param);
}
@@ -233,6 +209,16 @@ void GetDisks()
}
dword GetDiskSize(dword disk_n)
{
BDVK bdvk;
char tmp_path[8];
strcpy(#tmp_path, "/tmp#/1");
tmp_path[4] = disk_n + '0';
GetFileInfo(#tmp_path, #bdvk);
return bdvk.sizelo;
}
unsigned int disk_pos_x[]={13,13,13,102,102,102,191,191,191,279,279,279};
unsigned int disk_pos_y[]={79,127,175, 79,127,175, 79,127,175, 79,127,175};
@@ -241,13 +227,19 @@ void DrawTmpDisks()
#define SELECTION_ACTIVE 0x0080FF;
#define SELECTION_INACTIVE 0x757489;
dword selection_color;
char free_ram_text[60];
byte i;
DrawBar(0,TOPPANELH+1, WIN_W,WIN_H-TOPPANELH-1, sc.light);
DrawBar(0,TOPPANELH+1, Form.cwidth,Form.cheight-TOPPANELH-BOTPANELH-2, 0xFFFFFF);
DrawBar(0,Form.cheight-BOTPANELH-1, Form.cwidth,1, sc.line);
DrawBar(0,Form.cheight-BOTPANELH, Form.cwidth,BOTPANELH, sc.work);
sprintf(#free_ram_text, FREE_RAM_TEXT, GetFreeRAM()/1024);
WriteText(10, Form.cheight-20, 0x90, sc.work_text, #free_ram_text);
if (disk_num==0)
{
WriteText(20, TOPPANELH+22, 0x90, sc.work_text, INTRO_TEXT_1);
WriteText(20, TOPPANELH+40, 0x90, 0xFF000d, INTRO_TEXT_2);
WriteText(17,TOPPANELH+15, 0x90, 0x777777, INTRO_TEXT_1);
WriteText(17,TOPPANELH+15+15, 0x90, 0x777777, INTRO_TEXT_2);
WriteText(17,TOPPANELH+15+42, 0x90, 0x777777, INTRO_TEXT_3);
return;
};
if (selected>=disk_num) selected=disk_num-1; //restore selected
@@ -256,29 +248,21 @@ void DrawTmpDisks()
DeleteButton(20+i);
if (i>=disk_num) continue;
DefineButton(disk_pos_x[i], disk_pos_y[i], 80, 40, 20+i, 0xFFFfff);
WriteText(disk_pos_x[i]+34,disk_pos_y[i]+6, 0x90, 0x222222, #disk_list[i].Item);
WriteText(disk_pos_x[i]+36,disk_pos_y[i]+24, 0x80, 0x555555,
GetDiskSizeInMb(disk_list[i].Item[3]));
draw_icon_16(disk_pos_x[i]+10,disk_pos_y[i]+10, 51);
WriteText(disk_pos_x[i]+29,disk_pos_y[i]+6, 0x90, 0x222222, #disk_list[i].Item);
WriteText(disk_pos_x[i]+30,disk_pos_y[i]+24, 0x80, 0x555555,
ConvertSize(GetDiskSize(disk_list[i].Item[3] - '0')));
PutImage(disk_pos_x[i]+9,disk_pos_y[i]+10, 15,9, #disk_icon);
if (selected==i) {
if ( edit_disk_size.flags & ed_focus)
selection_color = SELECTION_INACTIVE;
else
selection_color = SELECTION_ACTIVE;
DrawWideRectangle(disk_pos_x[i], disk_pos_y[i], 80, 40, 2, selection_color);
PutPixel(disk_pos_x[i], disk_pos_y[i], sc.light);
PutPixel(disk_pos_x[i], disk_pos_y[i], 0xFFFfff);
}
}
}
:dword GetDiskSizeInMb(dword disk_n)
{
BDVK bdvk;
tmp_path[4] = disk_n;
GetFileInfo(#tmp_path, #bdvk);
miniprintf(#param, "%i MB", bdvk.sizelo / 1048576);
return #param;
}
void AddDisk()
{
@@ -306,8 +290,9 @@ void AddDisk()
err = Console_Work();
if ((err!=0) && (err<7)) notify(rezult_text[err]);
pause(5);
GetDisks();
DrawTmpDisks();
GetNewSizeDisk();
DrawWindowContent();
}
@@ -329,8 +314,8 @@ void DelDisk()
err = byte Console_Work();
if ((err!=0) && (err<7)) notify(rezult_text[err]);
pause(15);
GetNewSizeDisk();
DrawWindowContent();
GetDisks();
DrawTmpDisks();
}
+1 -1
View File
@@ -1,4 +1,4 @@
#define MEMSIZE 1024*30
#define MEMSIZE 0xA0000
#include "..\lib\kolibri.h"
#include "..\lib\mem.h"
#include "..\lib\strings.h"