From 4f8e6dce11e13c955be450adfb38c766e60d9275 Mon Sep 17 00:00:00 2001 From: "Kirill Lipatov (Leency)" Date: Mon, 18 May 2020 10:03:45 +0000 Subject: [PATCH] cmm: fix strstri webview: fix <> in non-html files quark: search updates git-svn-id: svn://kolibrios.org@7945 a494cfbc-eb01-0410-851d-a64ba20cac60 --- programs/cmm/TWB/TWB.c | 14 ++++++++---- programs/cmm/browser/WebView.c | 20 +++++----------- programs/cmm/browser/texts.h | 6 ++--- programs/cmm/lib/strings.h | 17 +++++++++++--- programs/cmm/quark/data.h | 6 ++--- programs/cmm/quark/quark.c | 42 ++++++++++++++++++++++------------ programs/cmm/quark/search.h | 27 ++++++---------------- programs/cmm/txtread/search.h | 4 ++-- 8 files changed, 72 insertions(+), 64 deletions(-) diff --git a/programs/cmm/TWB/TWB.c b/programs/cmm/TWB/TWB.c index d08b6500cb..975b7c1aa4 100644 --- a/programs/cmm/TWB/TWB.c +++ b/programs/cmm/TWB/TWB.c @@ -38,6 +38,7 @@ struct TWebBrowser { dword link_bg; dword bufpointer; dword bufsize; + dword is_html; void Paint(); void SetPageDefaults(); @@ -173,9 +174,13 @@ void TWebBrowser::ParseHtml(dword _bufpointer, _bufsize){ custom_encoding = CH_CP866; } SetPageDefaults(); - if (strstri(bufpointer, "", #tag.name); - j = strstri(bufpos, #tag.params); - if (j!=-1) bufpos = j-1; + if (j = strstri(bufpos, #tag.params)) bufpos = j-1; break; } @@ -267,6 +272,7 @@ void TWebBrowser::ParseHtml(dword _bufpointer, _bufsize){ } break; default: + _default: AddCharToTheLine(ESBYTE[bufpos]); } } diff --git a/programs/cmm/browser/WebView.c b/programs/cmm/browser/WebView.c index 1a762236ab..0b35587aaa 100644 --- a/programs/cmm/browser/WebView.c +++ b/programs/cmm/browser/WebView.c @@ -461,22 +461,14 @@ void ProcessEvent(dword id__) return; case COPY_LINK_URL: strncpy(#new_clip_url, PageLinks.GetURL(PageLinks.active), URL_SIZE); - if ( strcmp(#new_clip_url, "./", 2) ) - { - Clipboard__CopyText( GetAbsoluteURL(#new_clip_url, history.current()) ); - } - else { - Clipboard__CopyText( PageLinks.GetURL(PageLinks.active) ); - } + GetAbsoluteURL(#new_clip_url, history.current()); + Clipboard__CopyText(#new_clip_url); notify("'URL copied to clipboard'O"); return; case DOWNLOAD_LINK_CONTENTS: if (!downloader_opened) { strcpy(#downloader_edit, PageLinks.GetURL(PageLinks.active)); - if ( strcmp(#downloader_edit, "./", 2) ) - { - GetAbsoluteURL(#downloader_edit, history.current()); - } + GetAbsoluteURL(#downloader_edit, history.current()); CreateThread(#Downloader,#downloader_stak+4092); } return; @@ -548,10 +540,10 @@ bool HandleUrlFiles(dword _path, _data) { dword url_from_file; if (!UrlExtIs(_path, "url")) return false; - url_from_file = strstri(_data, "URL="); - if (url_from_file == -1) return false; + if (! url_from_file = strstri(_data, "URL=")) return false; replace_char(url_from_file, '\n', '\0', strlen(url_from_file)); - OpenPage(url_from_file); + OpenPage(url_from_file); + return true; } bool GetLocalFileData(dword _path) diff --git a/programs/cmm/browser/texts.h b/programs/cmm/browser/texts.h index 277ab5a90f..7ece1ba663 100644 --- a/programs/cmm/browser/texts.h +++ b/programs/cmm/browser/texts.h @@ -1,4 +1,4 @@ -char version[]="WebView 2.5c"; +char version[]="WebView 2.5e"; #ifdef LANG_RUS char page_not_found[] = FROM "html\\page_not_found_ru.htm""\0"; @@ -9,7 +9,7 @@ char rmb_menu[] = "Посмотреть исходник|Ctrl+U Редактировать исходник"; char main_menu[] = -"Открыть файл|Ctrl+O +"Открыть файл...|Ctrl+O Новое окно|Ctrl+N - История|Ctrl+H @@ -39,7 +39,7 @@ char rmb_menu[] = "View source|Ctrl+U Edit source"; char main_menu[] = -"Open local file|Ctrl+O +"Open local file...|Ctrl+O New window|Ctrl+N - History|Ctrl+H diff --git a/programs/cmm/lib/strings.h b/programs/cmm/lib/strings.h index b29ab5264b..54886d8579 100644 --- a/programs/cmm/lib/strings.h +++ b/programs/cmm/lib/strings.h @@ -503,6 +503,18 @@ inline int strnum(dword haystack, needle) return count; } +inline int strinum(dword haystack, needle) +{ + int count = 0; + int needle_len = strlen(needle); + loop() { + if (! haystack = strstri(haystack, needle)) break; + haystack+=needle_len; + count++; + } + return count; +} + inline signed int strcmpi(dword cmp1, cmp2) { char si, ue; @@ -537,7 +549,7 @@ inline dword strstri(dword searchin, usestr_s) searchin++; if (DSBYTE[usestr_e]=='\0') return searchin; } - return -1; + return 0; } @@ -546,8 +558,7 @@ inline unsigned int strcpyb(dword search_in, copyin, startstr, endstr) dword startp, endp; dword copyin_start_off = copyin; if (startstr==0) startp = search_in; else startp = strstr(search_in, startstr) + strlen(startstr); - endp = strstri(startp, endstr); - if (endp==0) endp = startp+strlen(search_in); + if (! endp = strstri(startp, endstr)) endp = startp+strlen(search_in); //if (startp==endp) return 0; do { diff --git a/programs/cmm/quark/data.h b/programs/cmm/quark/data.h index 12d26758cd..2a1206ecc3 100644 --- a/programs/cmm/quark/data.h +++ b/programs/cmm/quark/data.h @@ -13,7 +13,7 @@ char intro[] = " char copied_chars[] = "Скопировано сиволов: %i"; -char about[] = "Quark Text v0.7 +char about[] = "Quark Text v0.72 Автор: Кирилл Липатов aka Leency Сайт: http://aspero.pro @@ -52,7 +52,7 @@ Try to open some text file."; char copied_chars[] = "Copied %i chars"; -char about[] = "Quark Text v0.7 +char about[] = "Quark Text v0.72 Author: Kiril Lipatov aka Leency Website: http://aspero.pro @@ -129,7 +129,7 @@ void LoadIniSettings() Form.left = ini.GetInt("WinX", 150); Form.top = ini.GetInt("WinY", 50); Form.width = ini.GetInt("WinW", 640); - Form.height = ini.GetInt("WinH", 560); + Form.height = ini.GetInt("WinH", 563); } void SaveIniSettings() diff --git a/programs/cmm/quark/quark.c b/programs/cmm/quark/quark.c index 796e922778..cc8dc29439 100644 --- a/programs/cmm/quark/quark.c +++ b/programs/cmm/quark/quark.c @@ -55,6 +55,8 @@ int real_encoding = CH_CP866; int curcol_scheme; int font_size; +bool enable_edit = false; + #include "data.h" #include "search.h" @@ -255,8 +257,9 @@ void HandleKeyEvent() if (list.ProcessKey(key_scancode)) { if (key_modifier & KEY_LSHIFT) || (key_modifier & KEY_RSHIFT) selection.set_end(); DrawPage(); + return; } - //EventInsertCharIntoText(); + if(enable_edit) EventInsertCharIntoText(); } void HandleMouseEvent() @@ -314,7 +317,7 @@ bool EventSearchNext() { int new_y = search.find_next(list.first); if (new_y) { - list.first = new_y / list.item_h; + list.first = new_y; list.CheckDoesValuesOkey(); DrawPage(); } @@ -576,6 +579,13 @@ void EventCopyFilePath() DrawStatusBar(#copy_status_text); } +void EventEnableEdit() +{ + enable_edit ^= 1; + if (enable_edit) notify("'Edit mode is enabled.\nNow you can only replace text, not insert, nor delete.'I"); + draw_window(); +} + //===================================================// // // // DRAWS AND OTHER FUNCS // @@ -638,19 +648,21 @@ void DrawToolbar() DrawBar(0, 0, Form.cwidth, TOOLBAR_H - 1, sc.work); DrawBar(0, TOOLBAR_H - 1, Form.cwidth, 1, sc.work_graph); - //AddTopBarButton(#EventNewFile, ECTRL+SCAN_CODE_KEY_N, 2, x.set(8), false); - AddTopBarButton(#EventOpenDialog, ECTRL+SCAN_CODE_KEY_O, 0, x.set(8), false); - //AddTopBarButton(#EventSave, ECTRL+SCAN_CODE_KEY_S, 5, x.inc(SMALL_GAP), false); - AddTopBarButton(#EventShowFileInfo, ECTRL+SCAN_CODE_KEY_I, 10, x.inc(SMALL_GAP), false); - AddTopBarButton(#EventMagnifyMinus, ECTRL+SCAN_CODE_MINUS, 33, x.inc(BIG_GAP), false); - AddTopBarButton(#EventMagnifyPlus, ECTRL+SCAN_CODE_PLUS, 32, x.inc(SMALL_GAP), false); - AddTopBarButton(#EventClickSearch, ECTRL+SCAN_CODE_KEY_F, 49, x.inc(BIG_GAP), serha); search_mx = EAX; + x.set(-SMALL_GAP+8); + if(enable_edit) AddTopBarButton(#EventNewFile, ECTRL+SCAN_CODE_KEY_N, 2, x.inc(SMALL_GAP), false); + AddTopBarButton(#EventOpenDialog, ECTRL+SCAN_CODE_KEY_O, 0, x.inc(SMALL_GAP), false); + if(enable_edit) && (param[0]) AddTopBarButton(#EventSave, ECTRL+SCAN_CODE_KEY_S, 5, x.inc(SMALL_GAP), false); + AddTopBarButton(#EventShowFileInfo, ECTRL+SCAN_CODE_KEY_I, 10, x.inc(SMALL_GAP), false); + AddTopBarButton(#EventMagnifyMinus, ECTRL+SCAN_CODE_MINUS, 33, x.inc(BIG_GAP), false); + AddTopBarButton(#EventMagnifyPlus, ECTRL+SCAN_CODE_PLUS, 32, x.inc(SMALL_GAP), false); + AddTopBarButton(#EventClickSearch, ECTRL+SCAN_CODE_KEY_F, 49, x.inc(BIG_GAP), serha); search_mx = EAX; x.set(Form.cwidth-4); - //AddTopBarButton(#EventShowInfo, NULL, -1, x.inc(-SMALL_GAP), false); burger_mx = EAX; - AddTopBarButton(#EventShowThemesList, NULL, 40, x.inc(-SMALL_GAP), thema); theme_mx = EAX; - AddTopBarButton(#EventShowReopenMenu, ECTRL+SCAN_CODE_KEY_E, 16, x.inc(-SMALL_GAP), reopa); reopenin_mx = EAX; - //AddTopBarButton(#EventOpenSysfuncs, NULL, 18, x.inc(-SMALL_GAP), false); - //AddTopBarButton(#EventOpenPipet, NULL, 39, x.inc(-SMALL_GAP), false); + AddTopBarButton(#EventEnableEdit, NULL, 38, x.inc(-SMALL_GAP), enable_edit); + //if(enable_edit) AddTopBarButton(#EventShowInfo, NULL, -1, x.inc(-SMALL_GAP), false); burger_mx = EAX; + AddTopBarButton(#EventShowThemesList, NULL, 40, x.inc(-BIG_GAP), thema); theme_mx = EAX; + AddTopBarButton(#EventShowReopenMenu, ECTRL+SCAN_CODE_KEY_E, 16, x.inc(-SMALL_GAP), reopa); reopenin_mx = EAX; + if(enable_edit) AddTopBarButton(#EventOpenSysfuncs, NULL, 18, x.inc(-SMALL_GAP), false); + if(enable_edit) AddTopBarButton(#EventOpenPipet, NULL, 39, x.inc(-SMALL_GAP), false); } void DrawStatusBar(dword _in_text) @@ -719,6 +731,6 @@ void SetSizes(char _size) list.item_w = list.font_w; list.horisontal_selelection = true; list.SetSizes(0, TOOLBAR_H, Form.cwidth-scroll.size_x-1, - Form.cheight - TOOLBAR_H - search.height() - STATUSBAR_H /*- TAB_H*/, + Form.cheight - TOOLBAR_H - calc(search.visible * SEARCH_H) - STATUSBAR_H /*- TAB_H*/, math.round(list.font_h * 1.4)); } \ No newline at end of file diff --git a/programs/cmm/quark/search.h b/programs/cmm/quark/search.h index d37674a1be..3ff0fce8d0 100644 --- a/programs/cmm/quark/search.h +++ b/programs/cmm/quark/search.h @@ -9,8 +9,6 @@ struct SEARCH void show(); void hide(); bool draw(); - void draw_found(); - int height(); bool edit_key(); bool edit_mouse(); void clear(); @@ -37,11 +35,6 @@ void SEARCH::hide() draw_window(); } -int SEARCH::height() -{ - return visible * SEARCH_H; -} - bool SEARCH::edit_key() { if (visible) && (search_box.flags & ed_focus) { @@ -61,16 +54,9 @@ bool SEARCH::edit_mouse() return false; } -void SEARCH::draw_found() -{ - char matches[30]; - sprintf(#matches, T_MATCHES, found_count); - WriteTextWithBg(search_box.left+search_box.width+14+110, - search_box.top+3, 0xD0, sc.work_text, #matches, sc.work); -} - bool SEARCH::draw(dword _btn_find, _btn_hide, _y) { + char matches[30]; if (!visible) return false; DrawBar(0, _y, Form.cwidth, 1, sc.work_graph); DrawBar(0, _y+1, Form.cwidth, SEARCH_H-1, sc.work); @@ -85,7 +71,9 @@ bool SEARCH::draw(dword _btn_find, _btn_hide, _y) DrawCaptButton(search_box.left+search_box.width+14, search_box.top-1, 90, TOOLBAR_ICON_HEIGHT+1, _btn_find, sc.work_light, sc.work_text, T_FIND_NEXT); - draw_found(); + sprintf(#matches, T_MATCHES, found_count); + WriteTextWithBg(search_box.left+search_box.width+14+110, + search_box.top+3, 0xD0, sc.work_text, #matches, sc.work); DefineHiddenButton(Form.cwidth-26, search_box.top-1, TOOLBAR_ICON_HEIGHT+1, TOOLBAR_ICON_HEIGHT+1, _btn_hide); @@ -106,12 +94,11 @@ int SEARCH::find_next(int _cur_pos) if (!search_text[0]) return false; strcpy(#found_text, #search_text); - //highlight(0xFF0000, _bg_color); - found_count = strnum(io.buffer_data, #found_text); - draw_found(); + found_count = strinum(io.buffer_data, #found_text); + draw_window(); for (i=_cur_pos+1; i