diff --git a/programs/cmm/TWB/TWB.c b/programs/cmm/TWB/TWB.c index 25c093b5c1..a8701b95bf 100644 --- a/programs/cmm/TWB/TWB.c +++ b/programs/cmm/TWB/TWB.c @@ -1,6 +1,6 @@ #include "..\TWB\colors.h" #include "..\TWB\anchors.h" -#include "..\TWB\parce_tag.h" +#include "..\TWB\parse_tag.h" #include "..\TWB\special.h" #include "..\TWB\img_cache.h" #include "..\TWB\tag_list.h" @@ -12,6 +12,9 @@ dword link_color_active; #define BODY_MARGIN 6 #define BASIC_LINE_H 18 +DrawBufer DrawBuf; +char line[500]; + struct _style { bool b, u, s, h, @@ -27,7 +30,6 @@ struct _style { struct TWebBrowser { llist list; _style style; - DrawBufer DrawBuf; dword draw_y, stolbec; int zoom; dword o_bufpointer; @@ -36,7 +38,7 @@ struct TWebBrowser { dword bufpointer; dword bufsize; - void DrawStyle(); + void Paint(); void SetPageDefaults(); void AddCharToTheLine(); void ParseHtml(); @@ -46,14 +48,13 @@ struct TWebBrowser { void DrawScroller(); void ChangeEncoding(); void DrawPage(); - char line[500]; char header[150]; }; scroll_bar scroll_wv = { 15,NULL,NULL,NULL,0,2,NULL,0,0,0xeeeeee,0xBBBbbb,0xeeeeee}; //============================================================================================ -void TWebBrowser::DrawStyle() +void TWebBrowser::Paint() { dword start_x, line_length, stolbec_len; dword text_color__; @@ -96,7 +97,6 @@ void TWebBrowser::DrawStyle() text_color__ = text_colors[text_color_index]; if (link) && (text_colors[text_color_index]==text_colors[0]) text_color__ = link_color_default; - DrawBuf.WriteText(start_x, draw_y, list.font_type, text_color__, #line); if (style.b) DrawBuf.WriteText(start_x+1, draw_y, list.font_type, text_color__, #line); if (style.s) DrawBuf.DrawBar(start_x, list.item_h / 2 - zoom + draw_y, line_length, zoom, text_color__); @@ -151,7 +151,7 @@ void TWebBrowser::AddCharToTheLine(unsigned char _char) if (line[line_len-1]==' ') return; //no double spaces if (!stolbec) && (!line) return; //no paces at the beginning of the line } - if (line_len < sizeof(TWebBrowser.line)) chrcat(#line, _char); + if (line_len < sizeof(line)) chrcat(#line, _char); CheckForLineBreak(); } //============================================================================================ @@ -164,8 +164,12 @@ void TWebBrowser::ParseHtml(dword _bufpointer, _bufsize){ int tab_len; dword bufpos; bufsize = _bufsize; - bufpointer = malloc(bufsize); - memmov(bufpointer, _bufpointer, bufsize); + if (bufpointer != _bufpointer) { + bufpointer = malloc(bufsize); + memmov(bufpointer, _bufpointer, bufsize); + } else { + custom_encoding = CH_CP866; + } SetPageDefaults(); if (strstri(bufpointer, " 0) { + if (http.transfer) { StopLoading(); draw_window(); } else { @@ -393,6 +417,21 @@ void ProcessEvent(dword id__) if (debug_mode) notify("'Debug mode ON'-I"); else notify("'Debug mode OFF'-I"); return; + case NEW_TAB: + if (http.transfer) break; + EventOpenNewTab(URL_SERVICE_HOMEPAGE); + return; + case TAB_ID...TAB_ID+TABS_MAX: + if (http.transfer) break; + if (mouse.mkm) { + EventTabClose(id__ - TAB_ID); + } else { + EventTabClick(id__ - TAB_ID); + } + return; + case TAB_CLOSE_ID...TAB_CLOSE_ID+TABS_MAX: + EventTabClose(id__ - TAB_CLOSE_ID); + return; } } @@ -456,9 +495,13 @@ void OpenPage(dword _open_URL) StopLoading(); - strcpy(#editURL, _open_URL); - address_box.flags=0; - DrawOmnibox(); + if (open_new_tab) { + open_new_tab = false; + EventOpenNewTab(_open_URL); + return; + } + + SetOmniboxText(_open_URL); strncpy(#new_url, _open_URL, URL_SIZE); @@ -535,7 +578,7 @@ void EventClickLink(dword _click_URL) return; } - if (http.transfer > 0) { + if (http.transfer) { StopLoading(); history.back(); } @@ -607,6 +650,7 @@ void LoadInternalPage(dword _bufdata, _in_bufsize){ } WB1.ParseHtml(_bufdata, _in_bufsize); DrawStatusBar(NULL); + DrawActiveTab(); if (source_mode) { source_mode = false; ShowSource(WB1.bufpointer, _in_bufsize); @@ -689,9 +733,11 @@ void EventOpenDialog() void EventViewSource() { char source_view_param[URL_SIZE+1]; - strcpy(#source_view_param, "-source "); - strncat(#source_view_param, history.current(), URL_SIZE); - RunProgram(#program_path, #source_view_param); + //strcpy(#source_view_param, "-source "); + //strncat(#source_view_param, history.current(), URL_SIZE); + //RunProgram(#program_path, #source_view_param); + source_mode = true; + EventOpenNewTab(history.current()); } dword GetFileSize(dword _path) @@ -781,5 +827,12 @@ void DrawOmnibox() DrawProgress(); } +void SetOmniboxText(dword _text) +{ + strcpy(#editURL, _text); + address_box.flags=0; + DrawOmnibox(); +} + stop: \ No newline at end of file diff --git a/programs/cmm/browser/tabs.h b/programs/cmm/browser/tabs.h new file mode 100644 index 0000000000..ab73c5e0e4 --- /dev/null +++ b/programs/cmm/browser/tabs.h @@ -0,0 +1,209 @@ + +//===================================================// +// // +// MODULE // +// // +//===================================================// + +#define TABS_MAX 5 + +TWebBrowser data[TABS_MAX+1]; +_history tabstory[TABS_MAX+1]; + +struct TAB +{ + int count; + signed int active; + bool add(); + bool close(); + void save_state(); + void restore(); +} tab = {1,0}; + + +bool TAB::add() +{ + if (count==TABS_MAX) return false; + save_state(); + count++; + active = count-1; + history = tabstory[active]; + return true; +} + +bool TAB::close(int _tab_number) +{ + int i; + if (count==1) return false; + for (i=_tab_number; i<=TABS_MAX; i++) { + data[i] = data[i+1]; + tabstory[i] = tabstory[i+1]; + } + if (_tab_number0) active--; + if (active==count-1) && (active>0) active--; + count--; + return true; +} + +void TAB::save_state() +{ + tabstory[active] = history; + data[active] = WB1; +} + +void TAB::restore(int _id) +{ + tab.active = _id; + WB1 = data[_id]; + history = tabstory[_id]; +} + +//===================================================// +// // +// WebView Actions // +// // +//===================================================// + +#define DEFAULT_TABW 220 +int tab_w = DEFAULT_TABW; + +int GetTabWidth() +{ + if (tab.count * DEFAULT_TABW + TAB_H < Form.cwidth) return DEFAULT_TABW; else + return Form.cwidth - TAB_H - 2 / tab.count; +} + +void DrawTab(int _id) +{ + #define CLOSE_S 13 + dword bgcol, border_bottom_color; + char header_no_version[sizeof(TWebBrowser.header)]; + char name[DEFAULT_TABW/6]; + int xxx = _id * tab_w; + + if (_id==tab.active) { + tab.save_state(); + bgcol = system.color.work_light; + border_bottom_color = system.color.work_light; + } else { + bgcol=system.color.work; + border_bottom_color = system.color.work_graph; + } + if (data[_id].header) { + strncpy(#header_no_version, #data[_id].header, strlen(#data[_id].header)-sizeof(version)-2); + strncpy(#name, #header_no_version, tab_w-CLOSE_S/6-2); + } + DrawBar(xxx, TOOLBAR_H, 1, TAB_H, system.color.work_dark); + DrawBar(xxx+1, TOOLBAR_H, tab_w-1, TAB_H-1, bgcol); + DrawBar(xxx+1, TOOLBAR_H+TAB_H-1, tab_w-1, 1, border_bottom_color); + DefineHiddenButton(xxx, TOOLBAR_H-1, tab_w, TAB_H, TAB_ID+_id); + WriteTextCenter(xxx, TOOLBAR_H+6, tab_w-CLOSE_S, system.color.work_text, #name); + + DefineHiddenButton(xxx+tab_w-CLOSE_S-3, TOOLBAR_H+3, CLOSE_S-1, CLOSE_S-1, TAB_CLOSE_ID+_id); + DrawBar(xxx+tab_w-CLOSE_S-3, TOOLBAR_H+3, CLOSE_S, CLOSE_S, system.color.work_dark); + WriteText(xxx+tab_w-CLOSE_S+1, TOOLBAR_H+5, 0x80, system.color.work_light, "x"); +} + +void DrawActiveTab() +{ + if (tab_w == GetTabWidth()) DrawTab(tab.active); + else DrawTabsBar(); +} + +void DrawNewTabButton() +{ + dword btn_light = MixColors(system.color.work_button, 0xFFFfff, 220); + dword btn_dark = MixColors(system.color.work_button, 0, 180); + int xxx = tab.count * tab_w; + DrawBar(xxx, TOOLBAR_H, 1, TAB_H, system.color.work_graph); + DrawBar(xxx+1, TOOLBAR_H, TAB_H, TAB_H-1, system.color.work_button); + DrawRectangle3D(xxx+1, TOOLBAR_H, TAB_H, TAB_H-1, btn_light, btn_dark); + PutPixel(xxx+1+TAB_H, TOOLBAR_H, btn_dark); + DefineHiddenButton(xxx+1, TOOLBAR_H, TAB_H-1, TAB_H-1, NEW_TAB); + WriteText(xxx+7, TOOLBAR_H+2, 0x90, system.color.work_button_text, "+"); +} + +void DrawTabsBar() +{ + dword i; + tab_w = GetTabWidth(); + for (i=0; i=tab.count) _id = 0; + if (_id==-1) _id = tab.count-1; + tab.save_state(); + tab.restore(_id); + SetElementSizes(); + if (!BrowserWidthChanged()) { + DrawTabsBar(); + WB1.ParseHtml(WB1.bufpointer, WB1.bufsize); + WB1.DrawPage(); + } + SetOmniboxText(history.current()); +} + +void EventOpenNewTab(dword _url) +{ + tab.add(); + OpenPage(_url); + DrawTabsBar(); +} + +void EventActivateNextTab() +{ + EventTabClick(tab.active+1); +} + +void EventActivatePreviousTab() +{ + EventTabClick(tab.active-1); +} + + +:void DebugTabs() +{ + debugln("\n\n\nHISTORY=========================="); + history.add("history"); + history.debug(); + + debugln("\n\n\nTABSTORY[0]======================"); + tabstory[0].add("tabstory0"); + tabstory[0].debug(); + + debugln("\n\n\nTABSTORY[1]======================"); + tabstory[1].add("tabstory1"); + tabstory[1].debug(); + + debugln("\n\n\n\n"); + debugval("history.items.data_start", history.items.data_start); + debugval("tabstory[0].items.data_start", tabstory[0].items.data_start); + debugval("tabstory[1].items.data_start", tabstory[1].items.data_start); + debugln("\n\n\n\n"); +} diff --git a/programs/cmm/browser/texts.h b/programs/cmm/browser/texts.h index 9c1e1408ae..504bfb3ee8 100644 --- a/programs/cmm/browser/texts.h +++ b/programs/cmm/browser/texts.h @@ -1,4 +1,4 @@ -char version[]="WebView 2.26"; +char version[]="WebView 2.4"; #ifdef LANG_RUS char page_not_found[] = FROM "html\\page_not_found_ru.htm""\0"; diff --git a/programs/cmm/codeview/codeview.c b/programs/cmm/codeview/codeview.c index 592d0437f3..d2d6f867f1 100644 --- a/programs/cmm/codeview/codeview.c +++ b/programs/cmm/codeview/codeview.c @@ -158,8 +158,8 @@ void SetElementSizes() WB1.list.wheel_size = 7 * BASIC_LINE_H; WB1.list.column_max = WB1.list.w - scroll_wv.size_x / WB1.list.font_w; WB1.list.visible = WB1.list.h; - if (WB1.list.w!=WB1.DrawBuf.bufw) { - WB1.DrawBuf.Init(WB1.list.x, WB1.list.y, WB1.list.w, 32700); + if (WB1.list.w!=DrawBuf.bufw) { + DrawBuf.Init(WB1.list.x, WB1.list.y, WB1.list.w, 32700); OpenPage(#current_path); } } diff --git a/programs/cmm/easyshot/easyshot.c b/programs/cmm/easyshot/easyshot.c index 53a9016e79..eedcc50e75 100644 --- a/programs/cmm/easyshot/easyshot.c +++ b/programs/cmm/easyshot/easyshot.c @@ -20,7 +20,6 @@ ?define T_TAKE_SCREENSHOT " Сделать скриншот" ?define T_SETTINGS "Настройки" ?define T_EDITBOX_FRAME " Путь сохранения скриншота " - ?define T_MINIMIZE "Свернуть окно при снимке" ?define T_CONTINUOUS_SHOOTING "Continuous shooting" ?define T_DELAY "Задержка в секундах" ?define T_NO_DIR "'Папка не существует!' -E" @@ -29,7 +28,6 @@ ?define T_TAKE_SCREENSHOT " Take a screenshot" ?define T_SETTINGS "Settings" ?define T_EDITBOX_FRAME " Save path " - ?define T_MINIMIZE "Minimize window" ?define T_CONTINUOUS_SHOOTING "Continuous shooting" ?define T_DELAY "Delay in seconds" ?define T_NO_DIR "'Directory does not exists!' -E" @@ -59,7 +57,6 @@ edit_box edit_save = {250,25,100,0xffffff,0x94AECE,0xFFFfff,0xffffff, 0x10000000,sizeof(save_path)-2,#save_path,0, 0b}; more_less_box delay = { 1, 0, 64, T_DELAY }; -checkbox minimize = { T_MINIMIZE, true }; checkbox continuous_shooting = { T_CONTINUOUS_SHOOTING, true }; @@ -136,11 +133,10 @@ void DrawMainContent() } void EventTakeScreenshot() { - if (minimize.checked) MinimizeWindow(); + MinimizeWindow(); pause(delay.value*100); CopyScreen(screenshot, 0, 0, screen.width, screen.height); ActivateWindow(GetProcessSlot(Form.ID)); - if (!minimize.checked) DrawMainContent(); EventSaveImageFile(); } @@ -150,7 +146,11 @@ void EventSaveImageFile() char save_file_name[4096]; do { i++; - sprintf(#save_file_name, "%s/screen_%i.png", #save_path_stable, i); + //sprintf(, "%s/screen_%i.png", #save_path_stable, i); + strcpy(#save_file_name, #save_path_stable); + strcat(#save_file_name, "/screen_"); + strcat(#save_file_name, itoa(i)); + strcat(#save_file_name, ".png"); } while (file_exists(#save_file_name)); save_image(screenshot, screen.width, screen.height, #save_file_name); } @@ -171,7 +171,7 @@ void SettingsWindow() case evKey: GetKeys(); if (SCAN_CODE_ESC == key_scancode) ExitProcess(); - EAX= key_ascii << 8; + EAX = key_editbox; edit_box_key stdcall (#edit_save); break; @@ -197,7 +197,6 @@ void SettingsWindow() } delay.click(id); - minimize.click(id); break; case evReDraw: @@ -209,8 +208,7 @@ void DrawSettingsWindow() { DefineAndDrawWindow(Form.left+100, Form.top-40, 400, 230, 0x34, system.color.work, T_SETTINGS, 0); GetProcessInfo(#Settings, SelfInfo); - minimize.draw(15, 15); - delay.draw(15, 45); + delay.draw(15, 30); DrawFrame(15, 85, 360, 95, T_EDITBOX_FRAME); DrawEditBoxPos(32, 110, #edit_save); DrawStandartCaptButton(edit_save.left + edit_save.width + 15, edit_save.top-3, BTN_OD, "..."); diff --git a/programs/cmm/lib/collection.h b/programs/cmm/lib/collection.h index 43e10dd1ec..73f317c2fc 100644 --- a/programs/cmm/lib/collection.h +++ b/programs/cmm/lib/collection.h @@ -67,7 +67,10 @@ struct collection :void collection::drop() { if (data_start) free(data_start); - data_size = data_start = element_offset[count] = count = 0; + data_size = 0; + data_start = 0; + element_offset[count] = 0; + count = 0; } diff --git a/programs/cmm/lib/debug.h b/programs/cmm/lib/debug.h index c98b612f36..329737aa3e 100644 --- a/programs/cmm/lib/debug.h +++ b/programs/cmm/lib/debug.h @@ -51,4 +51,12 @@ inline fastcall void debugln( EDX) debugln(#tmpch); } +:void debug_n(dword _text, _size) +{ + dword res_text = malloc(_size); + strncpy(res_text, _text, _size-1); + debugln(res_text); + free(res_text); +} + #endif \ No newline at end of file diff --git a/programs/cmm/lib/keyboard.h b/programs/cmm/lib/keyboard.h index 421861ab9e..d2fa3a2b2c 100644 --- a/programs/cmm/lib/keyboard.h +++ b/programs/cmm/lib/keyboard.h @@ -128,12 +128,26 @@ GETKEYII: key_ascii = AH; $shr eax,16 key_scancode = AL; - //get alt/shift/ctrl key status + key_modifier = GetKeyModifier(); + EAX = key_editbox; +} + +// ECX is a mode: 1 - scancodes, 0 - ascii +inline fastcall SetKeyboardMode(ECX) +{ + $mov eax,66 + $mov ebx,1 + //$mov ecx,? + $int 0x40 +} + +//get alt/shift/ctrl key status +inline fastcall dword GetKeyModifier() +{ $mov eax,66 $mov ebx,3 $int 0x40 key_modifier = EAX; - EAX = key_editbox; } #endif \ No newline at end of file diff --git a/programs/cmm/lib/patterns/history.h b/programs/cmm/lib/patterns/history.h index 37beb177c0..7f18ffdd60 100644 --- a/programs/cmm/lib/patterns/history.h +++ b/programs/cmm/lib/patterns/history.h @@ -3,6 +3,7 @@ struct _history { collection items; int active; + void clear(); int add(); int back(); int forward(); @@ -35,4 +36,10 @@ int _history::forward() dword _history::current() { return items.get(active-1); -} \ No newline at end of file +} + +:void _history::clear() +{ + items.drop(); + active=0; +} diff --git a/programs/cmm/liza/mail_box.c b/programs/cmm/liza/mail_box.c index 5a6f9113ef..a16dab0f97 100644 --- a/programs/cmm/liza/mail_box.c +++ b/programs/cmm/liza/mail_box.c @@ -356,7 +356,7 @@ void InitTWB() { Form.cheight - mail_list.y - mail_list.h - LIST_INFO_H - 1 - status_bar_h, 12); WB1.list.column_max = WB1.list.w - 30 / 6; WB1.list.visible = WB1.list.h / WB1.list.item_h; - WB1.DrawBuf.Init(WB1.list.x, WB1.list.y, WB1.list.w, WB1.list.h); + DrawBuf.Init(WB1.list.x, WB1.list.y, WB1.list.w, WB1.list.h); WB1.list.first = WB1.list.count = 0; } diff --git a/programs/cmm/pipet/pipet.c b/programs/cmm/pipet/pipet.c index 3a1a38d875..2a581438b9 100644 --- a/programs/cmm/pipet/pipet.c +++ b/programs/cmm/pipet/pipet.c @@ -1,4 +1,4 @@ -#define MEMSIZE 1024*40 +#define MEMSIZE 1024*20 #include "../lib/gui.h" #include "../lib/clipboard.h" @@ -10,7 +10,6 @@ // // //===================================================// -proc_info Form; dword pick_active = true; dword picked_color = 0; char picked_color_string[11]; @@ -32,19 +31,16 @@ char picked_color_string[11]; void main() { int btn; - SetEventMask(EVM_REDRAW + EVM_KEY + EVM_BUTTON + EVM_MOUSE + EVM_MOUSE_FILTER); + proc_info Form; + SetEventMask(EVM_REDRAW + EVM_KEY + EVM_BUTTON + EVM_MOUSE); SetWindowLayerBehaviour(-1, ZPOS_ALWAYS_TOP); loop() switch(WaitEvent()) { case evMouse: - mouse.get(); - - if (mouse.x>0) && (mouse.x0) && (mouse.y0) && (mouse.x0) && (mouse.y list.visible * 10) DrawPage(); //draw result