WebView 1.0 Beta 4: fixes, view page source

git-svn-id: svn://kolibrios.org@4718 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
Kirill Lipatov (Leency) 2014-03-30 11:57:13 +00:00
parent 6fafe38cf6
commit cb9906f10d
9 changed files with 209 additions and 93 deletions

View File

@ -17,6 +17,8 @@ struct TWebBrowser {
void DrawPage();
void DrawScroller();
void NewLine();
void Perenos();
byte end_parsing;
} WB1;
byte b_text, i_text, u_text, s_text, pre_text, blq_text, li_text, li_tab,
@ -54,13 +56,12 @@ char anchor[256];
#include "..\TWB\table.h"
//=======================================================================
void TWebBrowser::DrawPage()
{
int start_x, start_y, line_length, magrin_left=5;
int start_x, start_y, line_length, stolbec_len, magrin_left=5;
if (!header)
{
@ -75,8 +76,9 @@ void TWebBrowser::DrawPage()
if (stroka >= 0) && (stroka - 2 < list.visible) && (line) && (!anchor)
{
start_x = stolbec * 6 + list.x + magrin_left;
start_y = stroka * 10 + list.y + magrin_left;
line_length = strlen(#line) * 6;
start_y = stroka * list.line_h + list.y + magrin_left;
stolbec_len = strlen(#line);
line_length = stolbec_len * 6;
WriteBufText(start_x, 0, 0x88, text_colors[text_color_index], #line, buf_data);
IF (b_text) WriteBufText(start_x+1, 0, 0x88, text_colors[text_color_index], #line, buf_data);
@ -84,11 +86,11 @@ void TWebBrowser::DrawPage()
IF (s_text) DrawBuf.DrawBar(start_x, 4, line_length, 1, text_colors[text_color_index]);
IF (u_text) DrawBuf.DrawBar(start_x, 8, line_length, 1, text_colors[text_color_index]);
IF (link) {
UnsafeDefineButton(start_x-2, start_y, line_length + 3, 9, PageLinks.count + 400 + BT_HIDE, 0xB5BFC9);
UnsafeDefineButton(start_x-2, start_y-1, line_length + 3, 10, PageLinks.count + 400 + BT_HIDE, 0xB5BFC9);
DrawBuf.DrawBar(start_x, 8, line_length, 1, text_colors[text_color_index]);
PageLinks.AddText(#line, line_length, list.line_h, UNDERLINE);
}
stolbec += strlen(#line);
stolbec += stolbec_len;
}
}
//=======================================================================
@ -121,7 +123,7 @@ void TWebBrowser::Prepare(dword bufpos, in_filesize){
void TWebBrowser::Parse(){
word bukva[2];
int j, perenos_num;
int j;
byte ignor_param;
char temp[768];
dword bufpos = bufpointer;
@ -129,6 +131,7 @@ void TWebBrowser::Parse(){
b_text = i_text = u_text = s_text = blq_text = t_html = t_body =
li_text = link = ignor_text = text_color_index = text_colors[0] = li_tab =
condition_text_val = condition_text_active = 0; //îáíóëÿåì òåãè
end_parsing = false;
condition_max = 255;
text_align = ALIGN_LEFT;
link_color_inactive = 0x0000FF;
@ -148,8 +151,9 @@ void TWebBrowser::Parse(){
if (!strcmp(#URL + strlen(#URL) - 4, ".mht")) ignor_text = 1;
}
for ( ; bufpointer+bufsize > bufpos; bufpos++;)
for ( ; (bufpointer+bufsize > bufpos) && (ESBYTE[bufpos]!=0); bufpos++;)
{
if (end_parsing) break;
bukva = ESBYTE[bufpos];
if (ignor_text) && (bukva!='<') continue;
if (condition_text_active) && (condition_text_val != condition_href) && (bukva!='<') continue;
@ -160,7 +164,7 @@ void TWebBrowser::Parse(){
{
chrcat(#line, ' ');
bukva = temp = NULL;
goto NEXT_MARK;
Perenos();
}
case '\9':
if (pre_text) //èíà÷å èä¸ì íà 0x0d
@ -239,17 +243,7 @@ void TWebBrowser::Parse(){
if (tag[strlen(#tag)-1]=='/') tag[strlen(#tag)-1]=NULL; //for br/
if (tagparam) && (strlen(#tagparam) < 4000) GetNextParam();
if (stolbec + strlen(#line) > list.column_max) //============the same as NEXT_MARK
{
perenos_num = strrchr(#line, ' ');
if (!perenos_num) && (strlen(#line)>list.column_max) perenos_num=list.column_max;
strcpy(#temp, #line + perenos_num); //ïåðåíîñ ïî ñëîâàì
line[perenos_num] = 0x00;
if (stroka-1 > list.visible) && (list.first <>0) break 1; //óõîäèì...
DrawPage();
strcpy(#line, #temp);
NewLine(); //çàêðàøèâàåì ñëåäóùóþ ñòðîêó
}
if (stolbec + strlen(#line) > list.column_max) Perenos();
DrawPage();
line = NULL;
if (tag) SetTextStyle(list.x + 5, stroka * list.line_h + list.y + 5); //îáðàáîòêà òåãîâ
@ -264,22 +258,9 @@ void TWebBrowser::Parse(){
if (!stolbec) && (!line) break; //ñòðîêà íå ìîæåò íà÷èíàòüñÿ ñ ïðîáåëà
}
if (strlen(#line)<sizeof(line)) chrcat(#line, bukva);
if (stolbec + strlen(#line) > list.column_max)
{
NEXT_MARK:
perenos_num = strrchr(#line, ' ');
if (!perenos_num) && (strlen(#line)>list.column_max) perenos_num=list.column_max;
strcpy(#temp, #line + perenos_num);
line[perenos_num] = 0x00;
if (stroka-1 > list.visible) && (list.first <>0) break 1;
DrawPage();
strcpy(#line, #temp);
NewLine();
}
if (stolbec + strlen(#line) > list.column_max) Perenos();
}
}
DrawPage();
NewLine();
DrawBar(list.x, stroka * list.line_h + list.y + 5, list.w, -stroka * list.line_h + list.h - 5, bg_color);
@ -294,6 +275,19 @@ void TWebBrowser::Parse(){
DrawScroller();
}
void TWebBrowser::Perenos()
{
int perenos_num;
char new_line_text[4096];
perenos_num = strrchr(#line, ' ');
if (!perenos_num) && (strlen(#line)>list.column_max) perenos_num=list.column_max;
strcpy(#new_line_text, #line + perenos_num);
line[perenos_num] = 0x00;
if (stroka-1 > list.visible) && (list.first <>0) end_parsing=true;
DrawPage();
strcpy(#line, #new_line_text);
NewLine();
}
char oldtag[100];
@ -384,7 +378,7 @@ void TWebBrowser::SetTextStyle(int left1, top1) {
link = 1;
text_colors[text_color_index] = link_color_inactive;
PageLinks.AddLink(#options, stolbec*6+left1, top1);
PageLinks.AddLink(#options, stolbec*6+left1, top1-2);
}
if (anchor) && (!strcmp(#parametr, "name="))
{
@ -547,7 +541,7 @@ void TWebBrowser::SetTextStyle(int left1, top1) {
if (opened)
{
NewLine();
if (stroka > -1) && (stroka - 2 < list.visible) DrawBuf.DrawBar(li_tab * 5 * 6 + left1 - 5, list.line_h/2-3, 2, 2, 0x555555);
if (stroka > -1) && (stroka - 2 < list.visible) DrawBuf.DrawBar(li_tab * 5 * 6 + left1 - 5, list.line_h/2-2, 2, 2, 0x555555);
}
return;
}

View File

@ -1,5 +1,6 @@
struct path_string {
char Item[4096];
char Item[sizeof(URL)];
int was_first;
};
#define MAX_HISTORY_NUM 40
@ -10,6 +11,7 @@ struct UrlsHistory {
int current;
dword CurrentUrl();
dword GetUrl();
dword GetFirstLine();
void AddUrl();
byte GoBack();
byte GoForward();
@ -23,6 +25,10 @@ dword UrlsHistory::GetUrl(int id) {
return #history_list[id].Item;
}
dword UrlsHistory::GetFirstLine(int id) {
return history_list[id].was_first;
}
void UrlsHistory::AddUrl() {
int i;
if (links_count>0) && (!strcmp(#URL,#history_list[current].Item)) return;
@ -32,11 +38,12 @@ void UrlsHistory::AddUrl() {
current/=2;
for (i=0; i<current; i++;)
{
strlcpy(#history_list[i].Item, #history_list[MAX_HISTORY_NUM-i].Item, sizeof(history_list[0].Item));
strlcpy(#history_list[i].Item, #history_list[MAX_HISTORY_NUM-i].Item, sizeof(URL));
}
}
current++;
strlcpy(#history_list[current].Item, #URL, sizeof(history_list[0].Item));
// history_list[i].was_first = WB1.list.first;
strlcpy(#history_list[current].Item, #URL, sizeof(URL));
links_count=current;
}
@ -45,6 +52,7 @@ byte UrlsHistory::GoBack() {
if (current<=1) return 0;
current--;
strlcpy(#URL, #history_list[current].Item, sizeof(URL));
// stroka = history_list[current].was_first;
return 1;
}

View File

@ -44,19 +44,9 @@ void ImageCache::Images(int left1, top1, width1)
if (!strcmp(#parametr,"src=")) //íàäî îáúåäèíèòü ñ GetNewUrl()
{
if (http_transfer<>0) strcpy(#img_path, #history_list[BrowserHistory.current-1].Item); else
strcpy(#img_path, BrowserHistory.CurrentUrl());
if (strcmpn(#img_path, "http:", 5)!=0) || (strcmpn(#options, "http:", 5)!=0)
{
//get path: absolute or relative
if (options[0]=='/')
strcpy(#img_path, #options);
else
{
img_path[strrchr(#img_path, '/')] = '\0';
strcat(#img_path, #options);
}
cur_pic = GetImageNumber(#img_path);
}
strcpy(#img_path, #options);
PageLinks.GetAbsoluteURL(#img_path);
cur_pic = GetImageNumber(#img_path);
}
if (!strcmp(#parametr,"alt="))
{
@ -78,7 +68,8 @@ void ImageCache::Images(int left1, top1, width1)
if (imgw > width1) imgw = width1;
if (stroka==0) DrawBar(WB1.list.x, WB1.list.y, WB1.list.w-15, 5, bg_color); //çàêðàøèâàåì ïåðâóþ ñòðîêó
stroka += imgh/10;
stroka += imgh / WB1.list.line_h;
if (imgh % WB1.list.line_h) stroka++;
if (top1+imgh<WB1.list.y) || (top1>WB1.list.y+WB1.list.h-10) return; //åñëè ÂѨ èçîáðàæåíèå óøëî ÂÅÐÕ èëè ÂÍÈÇ
if (top1<WB1.list.y) //åñëè ÷àñòü èçîáðàæåíèÿ ñâåðõó
{
@ -95,11 +86,12 @@ void ImageCache::Images(int left1, top1, width1)
img_draw stdcall (pics[cur_pic].image, left1-5, top1, imgw, imgh,0,img_lines_first);
DrawBar(left1+imgw - 5, top1, WB1.list.w-imgw, imgh, bg_color);
DrawBar(WB1.list.x, top1+imgh, WB1.list.w, -imgh % WB1.list.line_h + WB1.list.line_h, bg_color);
IF (link)
{
UnsafeDefineButton(left1 - 5, top1, imgw, imgh-1, PageLinks.count + 400 + BT_HIDE, 0xB5BFC9);
PageLinks.AddText(0, imgw, imgh-1, NOLINE);
// WB1.DrawPage();
//WB1.DrawPage();
}
}

View File

@ -76,13 +76,13 @@ void LinksArray::Hover(dword mx, my, link_col_in, link_col_a, bg_col)
{
if (active==i) return;
CursorPointer.Set();
if (links[active].underline) DrawBar(links[active].x,links[active].y+8,links[active].w,1, link_col_in);
if (links[i].underline) DrawBar(links[i].x,links[i].y+8,links[i].w,1, bg_col);
if (links[active].underline) DrawBar(links[active].x,links[active].y+10,links[active].w,1, link_col_in);
if (links[i].underline) DrawBar(links[i].x,links[i].y+10,links[i].w,1, bg_col);
active = i;
DrawBar(progress_bar.left+progress_bar.width+10, progress_bar.top+2, Form.cwidth-progress_bar.left-progress_bar.width-10, 9, col_bg);
status_text.start_x = progress_bar.left+progress_bar.width+10;
status_text.start_y = progress_bar.top+2;
status_text.area_size_x = Form.cwidth-progress_bar.left-progress_bar.width-10;
status_text.start_y = Form.cheight-STATUSBAR_H+3;
status_text.area_size_x = Form.cwidth - status_text.start_x -3;
DrawBar(status_text.start_x, status_text.start_y, status_text.area_size_x, 9, col_bg);
status_text.text_pointer = links[active].link;
PathShow_prepare stdcall(#status_text);
PathShow_draw stdcall(#status_text);
@ -92,8 +92,8 @@ void LinksArray::Hover(dword mx, my, link_col_in, link_col_a, bg_col)
if (active!=-1)
{
CursorPointer.Restore();
if (links[active].underline) DrawBar(links[active].x,links[active].y+8,links[active].w,1, link_col_in);
DrawBar(progress_bar.left+progress_bar.width+10, progress_bar.top+2, Form.cwidth-progress_bar.left-progress_bar.width-10, 9, col_bg);
if (links[active].underline) DrawBar(links[active].x,links[active].y+10,links[active].w,1, link_col_in);
DrawBar(status_text.start_x, status_text.start_y, status_text.area_size_x, 9, col_bg);
active = -1;
}
}

View File

@ -29,14 +29,14 @@
char homepage[] = FROM "html\homepage.htm";
#ifdef LANG_RUS
char version[]=" ’¥ªáâ®¢ë© ¡à ã§¥à 1.0 Beta 3";
char version[]=" ’¥ªáâ®¢ë© ¡à ã§¥à 1.0 Beta 4";
?define IMAGES_CACHE_CLEARED "Šíè ª à⨭®ª ®ç¨é¥­"
?define T_LAST_SLIDE "<EFBFBD>â® ¯®á«¥¤­¨© á« ©¤"
char loading[] = "‡ £à㧪  áâà ­¨æë...<br>";
char page_not_found[] = FROM "html\page_not_found_ru.htm";
char accept_language[]= "Accept-Language: ru\n";
#else
char version[]=" Text-based Browser 1.0 Beta 3";
char version[]=" Text-based Browser 1.0 Beta 4";
?define IMAGES_CACHE_CLEARED "Images cache cleared"
?define T_LAST_SLIDE "This slide is the last"
char loading[] = "Loading...<br>";
@ -62,16 +62,18 @@ dword http_buffer;
dword TAB_H = false; //19;
dword TAB_W = 150;
dword TOOLBAR_H = 31; //50;
dword STATUSBAR_H =16;
dword col_bg = 0xE4DFE1;
dword panel_color = 0xF1F1F1;
dword border_color = 0x9F9F9F;
dword STATUSBAR_H =15;
dword col_bg;
dword panel_color;
dword border_color;
pb progress_bar = {0, 10, 83, 150, 12, 0, 0, 100, 0xeeeEEE, 8072B7EBh, 0x9F9F9F};
byte souce_mode = false;
#include "..\TWB\TWB.c"
#include "menu_rmb.h"
#include "history.h"
#include "show_src.h"
char editURL[sizeof(URL)];
int mouse_twb;
@ -79,19 +81,32 @@ edit_box address_box = {250,55,34,0xffffff,0x94AECE,0xffffff,0xffffff,0,sizeof(U
#define URL_SERVICE_HISTORY "WebView://history"
#define URL_SERVICE_HOME "WebView://home"
#define URL_SERVICE_SOURCE "WebView://source:"
enum { BACK=300, FORWARD, REFRESH, HOME, NEWTAB, GOTOURL, SEARCHWEB, INPUT_CH, INPUT_BT, BTN_UP, BTN_DOWN };
struct skin {
struct struct_skin {
dword image, w, h;
int Load();
} skin;
int LoadSkin()
int struct_skin::Load()
{
dword image_data;
skin.image = load_image(abspath("wv_skin.png"));
if (!skin.image) notify("WebView skin file 'wv_skin.png' not found, program will terminate");
skin.w = DSWORD[skin.image+4];
skin.h = DSWORD[skin.image+8];
image_data = DSDWORD[skin.image+24];
col_bg = DSDWORD[DSDWORD[skin.image+24]];
panel_color = DSDWORD[skin.w*4*4 + image_data];
border_color = DSDWORD[skin.w*4*7 + image_data];
progress_bar.progress_color = DSDWORD[skin.w*4*10 + image_data];
$and col_bg, 0x00ffffff
$and panel_color, 0x00ffffff
$and border_color, 0x00ffffff
$and progress_bar.progress_color, 0x00ffffff
}
void DrawProgress()
@ -104,6 +119,7 @@ void DrawProgress()
DrawBar(address_box.left-1, address_box.top+14, btn, 2, progress_bar.progress_color);
}
void main()
{
unsigned long key, btn;
@ -116,7 +132,7 @@ void main()
if (load_dll2(libio, #libio_init,1)!=0) notify("Error: library doesn't exists - libio");
if (load_dll2(libimg, #libimg_init,1)!=0) notify("Error: library doesn't exists - libimg");
if (load_dll2(libHTTP, #http_lib_init,1)!=0) notify("Error: library doesn't exists - http");
LoadSkin();
skin.Load();
Form.width=WIN_W;
Form.height=WIN_H;
@ -185,7 +201,7 @@ void main()
key = GetKey();
if (address_box.flags & 0b10) SWITCH(key)
{ CASE 52: CASE 53: CASE 54: goto _EDIT_MARK; }
{ CASE 52: CASE 53: CASE 54: CASE 180: CASE 181: goto _EDIT_MARK; }
Scan(key);
@ -268,7 +284,7 @@ void SetElementSizes()
{
address_box.top = TOOLBAR_H-TAB_H/2-7+TAB_H;
address_box.width = Form.cwidth - address_box.left - 25 - 22;
WB1.list.SetSizes(0, TOOLBAR_H, Form.width - 10 - scroll_wv.size_x, Form.cheight - TOOLBAR_H - STATUSBAR_H, 0, 10);
WB1.list.SetSizes(0, TOOLBAR_H, Form.width - 10 - scroll_wv.size_x, Form.cheight - TOOLBAR_H - STATUSBAR_H, 0, 11);
WB1.list.column_max = WB1.list.w - scroll_wv.size_x / 6;
WB1.list.visible = WB1.list.h - 5 / WB1.list.line_h;
WB1.DrawBuf.Init(WB1.list.x, WB1.list.y, WB1.list.w, WB1.list.line_h);
@ -372,11 +388,14 @@ void Scan(int id)
if (!BrowserHistory.GoForward()) return;
OpenPage();
return;
case 052: //F3
case 052: //F3
ShowSource();
break;
case 053: //F4
if (strncmp(#URL,"http:",5)==0)
{
WriteFile(bufsize, bufpointer, "/tmp0/1/webview.tmp");
if (EAX==0) RunProgram("/rd/1/tinypad", "/tmp0/1/webview.tmp");
WriteFile(bufsize, bufpointer, "/tmp0/1/WebView_tmp.htm");
if (EAX==0) RunProgram("/rd/1/tinypad", "/tmp0/1/WebView_tmp.htm");
}
else
{
@ -404,6 +423,7 @@ void Scan(int id)
strcpy(#editURL, "http://kolibrios.org/");
case GOTOURL:
case 0x0D: //enter
if (!editURL[0]) return;
if ((strncmp(#editURL,"http:",5)!=0) && (editURL[0]!='/') && ((strncmp(#editURL,"WebView:",8)!=0))
{
strcpy(#URL,"http://");
@ -559,6 +579,7 @@ void SetPageDefaults()
void OpenPage()
{
StopLoading();
souce_mode = false;
strcpy(#editURL, #URL);
BrowserHistory.AddUrl();
if (strncmp(#URL,"WebView:",8)==0)
@ -594,21 +615,27 @@ void OpenPage()
bufsize = EBX;
if (bufsize)
{
bufpointer = mem_Free(bufpointer);
mem_Free(bufpointer);
bufpointer = mem_Alloc(bufsize);
SetPageDefaults();
ReadFile(0, bufsize, bufpointer, #URL);
//ShowSource();
}
ShowPage();
}
}
DrawEditBox()
{
address_box.size = address_box.pos = address_box.shift = address_box.shift_old = strlen(#editURL);
address_box.offset = 0;
edit_box_draw stdcall(#address_box);
}
void ShowPage()
{
address_box.size = address_box.pos = strlen(#editURL);
address_box.offset=0;
edit_box_draw stdcall(#address_box);
DrawEditBox();
if (!bufsize)
{
PageLinks.Clear();

View File

@ -2,6 +2,7 @@ ShowHistory()
{
int i;
static int history_pointer;
int t;
free(history_pointer);
history_pointer = malloc(64000);
@ -9,7 +10,9 @@ ShowHistory()
strcat(history_pointer, "<h2>Visited pages</h2><blockquote><br>");
for (i=1; i<BrowserHistory.links_count; i++)
{
strcat(history_pointer, "<a href='");
// t = BrowserHistory.GetFirstLine(i);
// strcat(history_pointer, itoa(t));
strcat(history_pointer, " <a href='");
strcat(history_pointer, BrowserHistory.GetUrl(i));
strcat(history_pointer, "'>");
strcat(history_pointer, BrowserHistory.GetUrl(i));

View File

@ -1,18 +1,20 @@
//Leency - 2012-2013
char *ITEMS_LIST[]={
"WIN Ctrl+E",05,
"DOS Ctrl+D",04,
"KOI Ctrl+K",11,
"UTF Ctrl+U",21,
"WIN Ctrl+E",05,
"DOS Ctrl+D",04,
"KOI Ctrl+K",11,
"UTF Ctrl+U",21,
#ifdef LANG_RUS
"ˆá室­¨ª áâà ­¨æë F3",52,
"Žç¨áâ¨âì ªíè ª à⨭®ª" ,02,
"ˆáâ®à¨ï" ,03,
"<EFBFBD>®á¬®âà¥âì ¨á室­¨ª F3",52,
"<EFBFBD>¥¤ ªâ¨à®¢ âì ¨á室­¨ª F4",53,
"Žç¨áâ¨âì ªíè ª à⨭®ª" ,02,
"ˆáâ®à¨ï" ,03,
#else
"View source F3",52,
"Free image cache" ,09,
"History" ,03,
"View source F3",52,
"Edit source F4",53,
"Free image cache" ,09,
"History" ,03,
#endif
0};
@ -26,7 +28,7 @@ void menu_rmb()
menu.first = menu.current = 0;
while (ITEMS_LIST[menu.count*2]) menu.count++;
menu.SetSizes(2,2,165,menu.count*19,0,19);
menu.SetSizes(2,2,177,menu.count*19,0,19);
SetEventMask(100111b);
loop() switch(WaitEvent())

View File

@ -0,0 +1,69 @@
//you are butifull, you are butifull
dword ShowSource()
{
dword new_buf, new_buf_start, i;
byte ww, param, comment;
if (souce_mode) return;
souce_mode = true;
new_buf_start = new_buf = malloc(bufsize*5);
strcat(new_buf, "<pre>");
for (i=bufpointer; i<bufpointer+bufsize; i++)
{
ww = ESBYTE[i];
new_buf++;
switch (ww)
{
case '<':
if (ESBYTE[i+1]=='!') && (ESBYTE[i+2]=='-') && (ESBYTE[i+3]=='-')
{
strcat(new_buf, "<font color=#ccc>&lt;");
new_buf+=20;
}
else
{
strcat(new_buf, "<font color=#00f>&lt;");
new_buf+=20;
}
break;
case '>':
if (!param) //fix non-closed quote
{
param = 1;
strcat(new_buf, "&quot;</font>");
new_buf+=12;
}
if (ESBYTE[i-1]=='-') && (ESBYTE[i-2]=='-')
{
strcat(new_buf, "&gt;</font>");
new_buf+=10;
}
else
{
strcat(new_buf, "&gt;</font>");
new_buf+=10;
}
break;
case '\"':
case '\'':
if (param)
{
param = 0;
strcat(new_buf, "<font color=#f0f>&quot;");
new_buf+=22;
}
else
{
param = 1;
strcat(new_buf, "&quot;</font>");
new_buf+=12;
}
break;
default:
chrcat(new_buf, ww);
}
}
bufsize = new_buf;
free(bufpointer);
bufpointer = new_buf_start;
}

View File

@ -1,12 +1,32 @@
#define MEMSIZE 0x3E80
#include "..\lib\kolibri.h"
#include "..\lib\strings.h"
#include "..\lib\mem.h"
#include "..\lib\file_system.h"
void str_replace(dword buf_in, what_replace, to_what_replace) {
dword start_pos=0;
dword buf_from;
buf_from = malloc(strlen(buf_in));
loop() {
strcpy(buf_from, buf_in);
start_pos = strstr(buf_from, what_replace);
if (start_pos == 0) break;
strlcpy(buf_in, buf_from, start_pos-buf_from);
strcat(buf_in, to_what_replace);
start_pos += strlen(what_replace);
strcat(buf_in, start_pos);
}
free(buf_from);
}
void main()
{
int id, key;
strcpy(#param, " <html>lorem</html>");
str_replace(#param, "<", "&lt");
str_replace(#param, ">", "&gt");
loop()
{
@ -38,6 +58,7 @@ void draw_window()
DefineAndDrawWindow(215,100,250,200,0x34,0xFFFFFF,"Window header");
GetProcessInfo(#Form, SelfInfo);
WriteText(50,80,0x80,0,"Press Enter");
WriteText(10,110,0x80,0,#param);
}