From 90b630f05f0edca663f4b9e170cc1222873a3b06 Mon Sep 17 00:00:00 2001 From: "Kirill Lipatov (Leency)" Date: Sun, 1 Oct 2017 11:57:00 +0000 Subject: [PATCH] full refactoring of CMM/lib/clipboard.h, ability to copy link URL in WebView, small improvements in clipview and app_plus git-svn-id: svn://kolibrios.org@7037 a494cfbc-eb01-0410-851d-a64ba20cac60 --- programs/cmm/TWB/links.h | 2 +- programs/cmm/app_plus/app_plus.c | 32 ++++++++----- programs/cmm/app_plus/scr.png | Bin 1659 -> 881 bytes programs/cmm/browser/WebView.c | 35 +++++++------- programs/cmm/clipview/clipview.c | 62 +++++++++++++++--------- programs/cmm/lib/clipboard.h | 75 +++++++++++++++++------------- programs/cmm/pipet/compile_en.bat | 4 +- programs/cmm/pipet/pipet.c | 27 +++-------- 8 files changed, 130 insertions(+), 107 deletions(-) diff --git a/programs/cmm/TWB/links.h b/programs/cmm/TWB/links.h index b44b43563d..8ac01f958b 100644 --- a/programs/cmm/TWB/links.h +++ b/programs/cmm/TWB/links.h @@ -84,7 +84,7 @@ bool LinksArray::HoverAndProceed(dword mx, my) return false; } if (mouse.pkm) && (mouse.up) { - // EventShowLinkMenu(mouse.x, mouse.y); + EventShowLinkMenu(mouse.x, mouse.y); return false; } if (active==i) return false; diff --git a/programs/cmm/app_plus/app_plus.c b/programs/cmm/app_plus/app_plus.c index e6d6512ab9..40ff4fc0ea 100644 --- a/programs/cmm/app_plus/app_plus.c +++ b/programs/cmm/app_plus/app_plus.c @@ -22,9 +22,11 @@ dword scr = FROM "scr.raw_8bit"; dword scr_pal[] = {0xFFFFFF,0xBBDDFF,0x4166B5,0xE0E4E6,0xAFBEDD,0xC4D4E8,0x52ACDD,0x000000, 0xE9DAB2,0xC99811,0xFDF9D4,0xF8B93C,0xFDEEBE,0xFBEBA6,0xDFAF4F,0xF3D57C}; +#define BTN_MANUAL_SEARCH 10 + #define APP_PLUS_INI_PATH "/kolibrios/settings/app_plus.ini" -#define APP_PLUS_INI_NOT_EXISTS "'APP+\n/kolibrios/settings/app_plus.ini is not exists.\nProgram terminated.' -tE" +#define APP_PLUS_INI_NOT_EXISTS "'APP+\n/kolibrios/settings/app_plus.ini does not exists.\nProgram terminated.' -tE" #define WINDOW_TITLE_TEXT "Error" #define CONTENT_HEADER_TEXT "/KOLIBRIOS/ IS NOT MOUNTED" @@ -49,9 +51,8 @@ void CheckKosMounted() } } -void RunAutosearch() +void WaitAutosearch() { - if (!CheckProcessExists("SEARCHAP")) io.run("/sys/SEARCHAP",0); while (CheckProcessExists("SEARCHAP")) pause(2); } @@ -60,25 +61,24 @@ void main() word id; CheckKosMounted(); - RunAutosearch(); + WaitAutosearch(); CheckKosMounted(); o_dialog.type = 2; load_dll(Proc_lib, #OpenDialog_init,0); OpenDialog_init stdcall (#o_dialog); + active_button_id = BTN_MANUAL_SEARCH; loop() switch(WaitEvent()) { case evButton: id=GetButtonID(); if (id==1) ExitProcess(); - if (id==10) - { - OpenDialog_start stdcall (#o_dialog); - if (o_dialog.status) SetAdditionalSystemDirectory("kolibrios", #openfile_path+1); - pause(3); - CheckKosMounted(); - } + if (id==BTN_MANUAL_SEARCH) EventManualSearch(); + break; + case evKey: + GetKeys(); + if (key_scancode == SCAN_CODE_ENTER) EventManualSearch(); break; case evReDraw: @@ -102,7 +102,15 @@ void draw_window() PutPaletteImage(#scr,144,171,Form.cwidth-180,y.n,8,#scr_pal); DrawRectangle(Form.cwidth-180-1,y.n-1, 144+1,171+1, system.color.work_graph); - DrawCaptButton(x,Form.cheight-66,300,30,10,system.color.work_button,system.color.work_button_text,MANUALLY_BUTTON_TEXT); + DrawStandartCaptButton(x, Form.cheight-66, BTN_MANUAL_SEARCH, MANUALLY_BUTTON_TEXT); +} + +void EventManualSearch() +{ + OpenDialog_start stdcall (#o_dialog); + if (o_dialog.status) SetAdditionalSystemDirectory("kolibrios", #openfile_path+1); + pause(3); + CheckKosMounted(); } diff --git a/programs/cmm/app_plus/scr.png b/programs/cmm/app_plus/scr.png index 71c1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5Vs zSTP4_lkTH6l$%N2WaYL*nRPAKryHMBPNEzk2;&n#PMPw-;`$9$#&%|p8l%SlsjYk= zp9hy%=#wwTcjpe@wO@Q$d|T^GUYxCDPQt0;-SpF417Cqg2baZf$6iQ9Ir+#QXZ23ZNoTPO_J-n$(HNdtUZGRo1>zQ8AHPJ z7JCQaC8>e_h-ecAyeYe7g3GA$Bplq}Z(EceHeCg^#skNKZTyB9 zq~PFM#q#Z@Cl400e#%z#aS0zOKlQ@~ zTrPN{tem1u!kR8WSY(%Z1Ln#DdtF(-~^ z<@-S??{7cR1`L1BwDdKrv%te^9g4Pxu-Kcb18L>_9jQ5-K6P$40k-5Q>n(P;Z=4M> z2Om7V0HPB$=aE80@Dd5|llZ?jKh)@WT({faqYUqMVr}o8lh^!NAv;&a4ko=mhKGsT zqHt*8O2!pGq9L{ZHEAFLPBkbBDhJVPn%|?r+#`vqEeJ}QOD&y5tQBmvz(@a-B4K&LdcvNu|y&KpMY4m|r*rF=22=pYwDq9=CdpFzJ<#N>7z9xh)lN@R~>S9-P`- zVr8MWu6kji5_e=ocV}5nTPq9qffI0b{!0~0 utN`9z3n`F9ugDDQN4)%x`vLisDnHBUoY6hz6b5`MAP-khmq)l03I75v(C-fb diff --git a/programs/cmm/browser/WebView.c b/programs/cmm/browser/WebView.c index 6452936b87..67cefa8e3f 100644 --- a/programs/cmm/browser/WebView.c +++ b/programs/cmm/browser/WebView.c @@ -15,6 +15,7 @@ #include "..\lib\collection.h" #include "..\lib\menu.h" #include "..\lib\random.h" +#include "..\lib\clipboard.h" //*.obj libraries #include "..\lib\obj\box_lib.h" @@ -30,7 +31,7 @@ char homepage[] = FROM "html\\homepage.htm""\0"; #ifdef LANG_RUS -char version[]="Текстовый браузер 1.71"; +char version[]="Текстовый браузер 1.72"; ?define IMAGES_CACHE_CLEARED "Кэш картинок очищен" ?define T_LAST_SLIDE "Это последний слайд" char loading[] = "Загрузка страницы...
"; @@ -40,10 +41,11 @@ char rmb_menu[] = "Посмотреть исходник Редактировать исходник История -Очистить кэш картинок Менеджер загрузок"; +char link_menu[] = +"Копировать ссылку"; #else -char version[]="Text-based Browser 1.71"; +char version[]="Text-based Browser 1.72"; ?define IMAGES_CACHE_CLEARED "Images cache cleared" ?define T_LAST_SLIDE "This slide is the last" char loading[] = "Loading...
"; @@ -53,13 +55,11 @@ char rmb_menu[] = "View source Edit source History -Free image cache Download Manager"; +char link_menu[] = +"Copy link"; #endif -char link_menu[] = -"Copy link -Download link"; #define URL_SERVICE_HISTORY "WebView://history" #define URL_SERVICE_HOME "WebView://home" @@ -96,10 +96,9 @@ enum { VIEW_SOURCE=1100, EDIT_SOURCE, VIEW_HISTORY, - FREE_IMG_CACHE, + //FREE_IMG_CACHE, DOWNLOAD_MANAGER, - COPY_LINK=1200, - DOWNLOAD_LINK + COPY_LINK=1200 }; #include "..\TWB\TWB.c" @@ -130,7 +129,6 @@ void main() loop() switch(WaitEvent()) { case evMouse: - if (!CheckActiveProcess(Form.ID)) break; edit_box_mouse stdcall (#address_box); mouse.get(); if (WB1.list.MouseOver(mouse.x, mouse.y)) @@ -361,11 +359,11 @@ void ProcessEvent(dword id__) } else RunProgram("/rd/1/tinypad", #URL); return; - case FREE_IMG_CACHE: - ImgCache.Free(); - notify(IMAGES_CACHE_CLEARED); - WB1.DrawPage(); - return; + // case FREE_IMG_CACHE: + // ImgCache.Free(); + // notify(IMAGES_CACHE_CLEARED); + // WB1.DrawPage(); + // return; case VIEW_HISTORY: strcpy(#URL, URL_SERVICE_HISTORY); OpenPage(); @@ -376,10 +374,13 @@ void ProcessEvent(dword id__) CreateThread(#Downloader,#downloader_stak+4092); } return; + case COPY_LINK: + Clipboard__CopyText(PageLinks.GetURL(PageLinks.active)); + notify("'URL copied to clipboard'O"); + return; } } - void StopLoading() { if (http_transfer) diff --git a/programs/cmm/clipview/clipview.c b/programs/cmm/clipview/clipview.c index dae851986a..3cc3a9933c 100644 --- a/programs/cmm/clipview/clipview.c +++ b/programs/cmm/clipview/clipview.c @@ -41,9 +41,6 @@ enum { proc_info Form; -Clipboard clipboard; - - //===================================================// // // // CODE // @@ -53,7 +50,7 @@ Clipboard clipboard; void main() { int id; - SetEventMask(0x27); + SetEventMask(EVM_REDRAW + EVM_KEY + EVM_BUTTON + EVM_MOUSE + EVM_MOUSE_FILTER); load_dll(boxlib, #box_lib_init,0); loop() { @@ -61,12 +58,11 @@ void main() switch(EAX & 0xFF) { case evMouse: - if (!CheckActiveProcess(Form.ID)) break; SelectList_ProcessMouse(); break; case evButton: - id=GetButtonID(); + id = GetButtonID(); if (id==1) ExitProcess(); if (id==BT_DELETE_LAST_SLOT) EventDeleteLastSlot(); if (id==BT_DELETE_ALL_SLOTS) EventDeleteAllSlots(); @@ -98,7 +94,7 @@ void main() break; default: - if (clipboard.GetSlotCount() > select_list.count) ClipViewSelectListDraw(); + if (Clipboard__GetSlotCount() > select_list.count) ClipViewSelectListDraw(); break; } } @@ -119,6 +115,16 @@ void DrawWindowContent() SelectList_DrawBorder(); } +dword slot_data; +struct clipboard_data +{ + dword size; + dword type; + dword encoding; + dword content; + dword content_offset; +} cdata; + void SelectList_DrawLine(dword i) { int yyy, length, slot_data_type_number; @@ -126,21 +132,28 @@ void SelectList_DrawLine(dword i) dword size_kb; dword text_color = 0; - clipboard.GetSlotData(select_list.first + i); + slot_data = Clipboard__GetSlotData(select_list.first + i); + cdata.size = ESDWORD[slot_data]; + cdata.type = ESDWORD[slot_data+4]; + if (cdata.type==SLOT_DATA_TYPE_TEXT) || (cdata.type==SLOT_DATA_TYPE_TEXT_BLOCK) + cdata.content_offset = 12; + else + cdata.content_offset = 8; + cdata.content = slot_data + cdata.content_offset; + yyy = i*select_list.item_h+select_list.y; WriteText(select_list.x+12, yyy+select_list.text_y, select_list.font_type, text_color, itoa(select_list.first + i)); - //WriteText(select_list.x+44, yyy+select_list.text_y, select_list.font_type, text_color, itoa(clipboard.slot_data.size)); - size_kb = ConvertSizeToKb(clipboard.slot_data.size); + size_kb = ConvertSizeToKb(cdata.size); WriteText(select_list.x+44, yyy+select_list.text_y, select_list.font_type, text_color, size_kb); - slot_data_type_number = clipboard.slot_data.type; + slot_data_type_number = cdata.type; WriteText(select_list.x+140, yyy+select_list.text_y, select_list.font_type, text_color, data_type[slot_data_type_number]); WriteText(select_list.x+select_list.w - 88, yyy+select_list.text_y, select_list.font_type, 0x006597, T_VIEW_OPTIONS); DefineButton(select_list.x+select_list.w - 95, yyy, 50, select_list.item_h, 100+i+BT_HIDE, NULL); DefineButton(select_list.x+select_list.w - 95 + 51, yyy, 40, select_list.item_h, 300+i+BT_HIDE, NULL); length = select_list.w-236 - 95 / select_list.font_w - 2; - if (clipboard.slot_data.size-8 < length) length = clipboard.slot_data.size-8; - memmov(#line_text, clipboard.slot_data.content, length); + if (cdata.size - cdata.content_offset < length) length = cdata.size - cdata.content_offset; + memmov(#line_text, cdata.content, length); replace_char(#line_text, 0, 31, length); // 31 is a dot WriteText(select_list.x+236, yyy+select_list.text_y, select_list.font_type, text_color, #line_text); } @@ -155,9 +168,8 @@ replace_char(dword in_str, char from_char, to_char, int length) { ESBYTE[in_str+length]=0; } -int SaveSlotContents(int slot_id) { - clipboard.GetSlotData(slot_id); - EAX = WriteFile(clipboard.slot_data.size, clipboard.slot_data.content, DEFAULT_SAVE_PATH); +int SaveSlotContents(dword size, off) { + EAX = WriteFile(size, off, DEFAULT_SAVE_PATH); if (!EAX) { return true; @@ -169,7 +181,7 @@ int SaveSlotContents(int slot_id) { } void ClipViewSelectListDraw() { - select_list.count = clipboard.GetSlotCount(); + select_list.count = Clipboard__GetSlotCount(); SelectList_Draw(); } @@ -188,27 +200,33 @@ void EventDeleteLastSlot() int i; for (i=0; i