mirror of
https://github.com/KolibriOS/kolibrios.git
synced 2024-11-25 02:09:36 +03:00
cmm: fix strstri
webview: fix <> in non-html files quark: search updates git-svn-id: svn://kolibrios.org@7945 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
parent
e43264a49a
commit
4f8e6dce11
@ -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, "<body")==-1) {
|
||||
is_html = true;
|
||||
if (!strstri(bufpointer, "<body")) {
|
||||
t_body = true;
|
||||
if (strstri(bufpointer, "<html")==-1) style.pre = true; //show linebreaks for a plaint text
|
||||
if (!strstri(bufpointer, "<html")) {
|
||||
style.pre = true; //show linebreaks for a plaint text
|
||||
is_html = false;
|
||||
}
|
||||
}
|
||||
for (bufpos=bufpointer ; (bufpos < bufpointer+bufsize) && (ESBYTE[bufpos]!=0) ; bufpos++;)
|
||||
{
|
||||
@ -213,6 +218,7 @@ void TWebBrowser::ParseHtml(dword _bufpointer, _bufsize){
|
||||
}
|
||||
break;
|
||||
case '<':
|
||||
if (!is_html) goto _default;
|
||||
bufpos++;
|
||||
if (!strncmp(bufpos,"!--",3))
|
||||
{
|
||||
@ -252,8 +258,7 @@ void TWebBrowser::ParseHtml(dword _bufpointer, _bufsize){
|
||||
// ignore text inside the next tags
|
||||
if (tag.is("script")) || (tag.is("style")) || (tag.is("binary")) || (tag.is("select")) {
|
||||
sprintf(#tag.params, "</%s>", #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]);
|
||||
}
|
||||
}
|
||||
|
@ -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());
|
||||
}
|
||||
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);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool GetLocalFileData(dword _path)
|
||||
|
@ -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[] =
|
||||
"<EFBFBD>®á¬®âà¥âì ¨á室¨ª|Ctrl+U
|
||||
<EFBFBD>¥¤ ªâ¨à®¢ âì ¨á室¨ª";
|
||||
char main_menu[] =
|
||||
"Žâªàëâì ä ©«|Ctrl+O
|
||||
"Žâªàëâì ä ©«...|Ctrl+O
|
||||
<EFBFBD>®¢®¥ ®ª®|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
|
||||
|
@ -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
|
||||
{
|
||||
|
@ -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()
|
||||
|
@ -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);
|
||||
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(#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;
|
||||
//AddTopBarButton(#EventOpenSysfuncs, NULL, 18, x.inc(-SMALL_GAP), false);
|
||||
//AddTopBarButton(#EventOpenPipet, NULL, 39, x.inc(-SMALL_GAP), false);
|
||||
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));
|
||||
}
|
@ -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<list.count; i++) {
|
||||
if (strstri(lines.get(i),#search_text)!=-1) return atoi(lines.get(i));
|
||||
if (strstri(lines.get(i),#search_text)) return i;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
@ -124,7 +124,7 @@ int SEARCH::find_next(int _cur_pos, _bg_color)
|
||||
draw_found();
|
||||
|
||||
for (i=_cur_pos+1; i<pos.count; i++) {
|
||||
if (strstri(lines.get(i),#search_text)!=-1) return atoi(pos.get(i));
|
||||
if (strstri(lines.get(i),#search_text)) return atoi(pos.get(i));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@ -135,7 +135,7 @@ int SEARCH::highlight(dword _color, _bg_color)
|
||||
dword col;
|
||||
found_count = 0;
|
||||
for (i=0; i<pos.count; i++) {
|
||||
if (strstri(lines.get(i),#search_text)==-1) {
|
||||
if (!strstri(lines.get(i),#search_text)) {
|
||||
col=_bg_color;
|
||||
} else {
|
||||
col=_color;
|
||||
|
Loading…
Reference in New Issue
Block a user