/programs/cmm/TWB/TWB.c |
---|
446,7 → 446,7 |
if (value = tag.get_value_of("alt=")) && (strlen(value)<sizeof(line)-3) && (value) sprintf(#line, "[%s]", value); |
if (!img_path) { line=0; return; } |
style.image = true; |
page_img.add_pos(#img_path, stolbec+1*list.font_w+3, draw_y); |
page_img.add(#img_path, stolbec+1*list.font_w+3, draw_y); |
text_colors.add(0x9A6F29); |
if (!line) { |
if (!strncmp(#img_path, "data:", 5)) img_path=0; |
607,6 → 607,6 |
void TWebBrowser::DrawPage() |
{ |
PutPaletteImage(list.first * DrawBuf.bufw * 4 + buf_data+8, DrawBuf.bufw, list.h, DrawBuf.bufx, DrawBuf.bufy, 32, 0); |
page_img.draw_all(list.x, list.y, list.first, list.h); |
page_img.draw(list.x, list.y, list.first, list.h); |
DrawScroller(); |
} |
/programs/cmm/TWB/img.h |
---|
3,27 → 3,19 |
{ |
collection url; |
collection_int xywh; |
collection_int data; |
int getid; |
dword add(); |
void clear(); |
dword add_pos(); |
bool set_size(); |
dword current_url(); |
bool next_url(); |
void draw_all(); |
bool draw(); |
void set_data(); |
void draw(); |
}; |
void _img::clear() |
{ |
url.drop(); |
xywh.drop(); |
getid = 0; |
} |
#ifndef NO_IMG |
dword _img::add_pos(dword _path, _x, _y) |
dword _img::add(dword _path, _x, _y) |
{ |
char full_path[URL_SIZE]; |
strncpy(#full_path, _path, URL_SIZE); |
32,26 → 24,18 |
url.add(#full_path); |
xywh.add(_x); |
xywh.add(_y); |
xywh.add(NULL); |
xywh.add(NULL); |
xywh.add(0); |
xywh.add(0); |
return full_path; |
} |
bool _img::set_size(dword _buf, _size) |
void _img::clear() |
{ |
char vvv[1000]; |
int w, h; |
img_decode stdcall (_buf, _size, 0); |
if (EAX) { |
EDI = EAX; |
w = ESDWORD[EDI+4]; |
h = ESDWORD[EDI+8]; |
xywh.set(getid*4+2, ESDWORD[EDI+4]); |
xywh.set(getid*4+3, ESDWORD[EDI+8]); |
sprintf(#vvv, "%s w:%i h:%i", current_url(), w, h); |
debugln(#vvv); |
url.drop(); |
xywh.drop(); |
data.drop(); |
getid = 0; |
} |
} |
dword _img::current_url() |
{ |
67,28 → 51,40 |
return 0; |
} |
void _img::draw_all(int _x, _y, _start, _height) |
void _img::set_data(dword _data, _data_len) |
{ |
int i, img_y; |
data.set(getid, _data); |
} |
void _img::draw(int _x, _y, _start, _height) |
{ |
int i, img_x, img_y; |
for (i=0; i<url.count; i++) |
{ |
img_x = xywh.get(i*4); |
img_y = xywh.get(i*4 + 1); |
if (img_y > _start) && (img_y < _start + _height) |
&& (cache.has(url.get(i))) draw(_x, _y, _start, i); |
{ |
if (cache.has(url.get(i))) |
DrawLibimgImage(img_x + _x, img_y-_start + _y, cache.current_buf, cache.current_size); |
} |
} |
} |
bool _img::draw(int _x, _y, _start, i) |
void DrawLibimgImage(dword _x, _y, _data, _data_len) |
{ |
libimg_image im; |
img_decode stdcall (cache.current_buf, cache.current_size, 0); |
if (EAX) { |
img_decode stdcall (_data, _data_len, 0); |
$or eax, eax |
$jz __ERROR__ |
im.image = EAX; |
im.draw(xywh.get(i*4) + _x, xywh.get(i*4+1) - _start + _y, im.w, im.h, 0, 0); |
im.set_vars(); |
im.draw(_x, _y, im.w, im.h, 0, 0); |
__ERROR__: |
} |
} |
/* |
140,3 → 136,12 |
*/ |
#else |
dword _img::add(dword _path, _x, _y) {}; |
void _img::clear() {}; |
dword _img::current_url() {}; |
bool _img::next_url() {}; |
void _img::set_data(dword _data, _data_len) {}; |
void _img::draw(int _x, _y, _start, _height) {}; |
#endif |
/programs/cmm/browser/WebView.c |
---|
31,7 → 31,7 |
char editbox_icons[] = FROM "res/editbox_icons.raw"; |
char version[]="WebView 2.7e"; |
char version[]="WebView 2.7c"; |
#include "texts.h" |
#include "cache.h" |
236,7 → 236,7 |
if (http.transfer <= 0) break; |
http.receive(); |
EventUpdateProgressBar(); |
if (http_get_type==PAGE) CheckContentType(); |
CheckContentType(); |
if (http.receive_result != 0) break; |
if (http.status_code >= 300) && (http.status_code < 400) |
{ |
259,7 → 259,7 |
} |
else if (http_get_type==IMG) { |
cache.add(WB1.page_img.current_url(), http.content_pointer, http.content_received, IMG); |
WB1.page_img.set_size(http.content_pointer, http.content_received); |
WB1.page_img.set_data(cache.data.get_last(), http.content_received); |
GetImg(); |
} |
} |
/programs/cmm/browser/res/highlight_c.h |
---|
File deleted |
\ No newline at end of file |
/programs/cmm/codeview/codeview.c |
---|
0,0 → 1,249 |
#define MEMSIZE 4096 * 200 |
#define NO_IMG true |
//libraries |
#include "..\lib\gui.h" |
#include "..\lib\draw_buf.h" |
#include "..\lib\list_box.h" |
#include "..\lib\cursor.h" |
#include "..\lib\collection.h" |
#include "..\lib\random.h" |
#include "..\lib\clipboard.h" |
// *.obj libraries |
#include "..\lib\obj\box_lib.h" |
#include "..\lib\obj\libio.h" |
#include "..\lib\obj\libimg.h" |
#include "..\lib\obj\iconv.h" |
#include "..\lib\obj\proc_lib.h" |
//useful patterns |
#include "..\lib\patterns\simple_open_dialog.h" |
#include "..\lib\patterns\toolbar_button.h" |
char homepage[] = FROM "html\\homepage.htm""\0"; |
char page_not_found[] = FROM "html\\page_not_found_en.htm""\0"; |
char version[]="C-- Code View"; |
char accept_language[]= "Accept-Language: en\n"; |
#define URL_SERVICE_HOME "CodeView:home" |
proc_info Form; |
dword TOOLBAR_H = 40; |
dword STATUSBAR_H = 0; |
bool debug_mode = false; |
bool open_in_a_new_window = false; |
enum { |
REFRESH_BUTTON, |
EDIT_SOURCE, |
OPEN_PAGE, |
}; |
#define URL_SIZE 4000; |
#include "..\TWB\TWB.c" |
TWebBrowser WB1; |
#include "highlight_c.h" |
char default_dir[] = "/rd/1"; |
od_filter filter2 = { 16, "C\0H\0C--\0H--\0CPP\0\0" }; |
char current_path[URL_SIZE+1]; |
char edit_path[URL_SIZE+1]; |
int mouse_twb; |
edit_box address_box = {250,60,30,0xffffff,0x94AECE,0xffffff,0xffffff,0x10000000,URL_SIZE-2,#edit_path,#mouse_twb,2,19,19}; |
#define SKIN_Y 24 |
void LoadLibraries() |
{ |
load_dll(boxlib, #box_lib_init,0); |
load_dll(libio, #libio_init,1); |
load_dll(libimg, #libimg_init,1); |
load_dll(iconv_lib, #iconv_open,0); |
load_dll(Proc_lib, #OpenDialog_init,0); |
OpenDialog_init stdcall (#o_dialog); |
} |
void main() |
{ |
int i, id; |
LoadLibraries(); |
if (param) strcpy(#current_path, #param); else strcpy(#current_path, URL_SERVICE_HOME); |
WB1.list.SetFont(8, 14, 10011000b); |
WB1.list.no_selection = true; |
SetEventMask(EVM_REDRAW + EVM_KEY + EVM_BUTTON + EVM_MOUSE + EVM_MOUSE_FILTER); |
loop() switch(WaitEvent()) |
{ |
case evMouse: |
edit_box_mouse stdcall (#address_box); |
mouse.get(); |
if (WB1.list.MouseScroll(mouse.vert)) WB1.DrawPage(); |
scrollbar_v_mouse (#scroll_wv); |
if (WB1.list.first != scroll_wv.position) |
{ |
WB1.list.first = scroll_wv.position; |
WB1.DrawPage(); |
break; |
} |
break; |
case evButton: |
id = GetButtonID(); |
if (1==id) ExitProcess(); |
if (OPEN_PAGE==id) EventOpenDialog(); |
break; |
case evKey: |
GetKeys(); |
if (SCAN_CODE_F5 == key_scancode) { |
OpenPage(#current_path); |
} |
if (SCAN_CODE_F3 == key_scancode) { |
RunProgram("/rd/1/tinypad", #current_path); |
} |
if (key_modifier&KEY_LCTRL) || (key_modifier&KEY_RCTRL) { |
if (key_scancode == SCAN_CODE_KEY_O) {EventOpenDialog();break;} |
} |
if (address_box.flags & 0b10) |
{ |
if (key_ascii == ASCII_KEY_ENTER) { |
OpenPage(#edit_path); |
} |
else { |
EAX = key_editbox; |
edit_box_key stdcall(#address_box); |
} |
} |
else |
{ |
#define KEY_SCROLL_N 11 |
if (SCAN_CODE_UP == key_scancode) for (i=0;i<KEY_SCROLL_N;i++) WB1.list.KeyUp(); |
if (SCAN_CODE_DOWN == key_scancode) for (i=0;i<KEY_SCROLL_N;i++) WB1.list.KeyDown(); |
if (WB1.list.ProcessKey(key_scancode)) WB1.DrawPage(); |
} |
break; |
case evReDraw: |
DefineAndDrawWindow(GetScreenWidth()-800/2-random(80),GetScreenHeight()-600/2-random(80),800,600,0x73,sc.work,0,0); |
GetProcessInfo(#Form, SelfInfo); |
sc.get(); |
if (Form.status_window>2) break; |
if (Form.height<120) { MoveSize(OLD,OLD,OLD,120); break; } |
if (Form.width<280) { MoveSize(OLD,OLD,280,OLD); break; } |
SetElementSizes(); |
draw_window(); |
break; |
} |
} |
void SetElementSizes() |
{ |
address_box.top = TOOLBAR_H/2-10; |
address_box.left = address_box.top+43; |
address_box.width = Form.cwidth - address_box.left - address_box.left -14; |
WB1.list.SetSizes(0, TOOLBAR_H, Form.width - 10 - scroll_wv.size_x, |
Form.cheight - TOOLBAR_H - STATUSBAR_H, BASIC_LINE_H); |
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!=DrawBuf.bufw) { |
DrawBuf.Init(WB1.list.x, WB1.list.y, WB1.list.w, 32700); |
OpenPage(#current_path); |
} |
} |
void draw_window() |
{ |
DrawBar(0,0, Form.cwidth,TOOLBAR_H-2, sc.work); |
DrawBar(0,TOOLBAR_H-2, Form.cwidth,1, 0xD7D0D3); |
DrawBar(0,TOOLBAR_H-1, Form.cwidth,1, sc.work_graph); |
DrawRectangle(address_box.left-3, address_box.top-3, address_box.width+4, 25,sc.work_graph); |
DrawBar(0,Form.cheight - STATUSBAR_H, Form.cwidth,STATUSBAR_H, sc.work); |
DrawBar(0,Form.cheight - STATUSBAR_H, Form.cwidth,1, sc.work_graph); |
DrawEditBoxWebView(); |
if (!WB1.header) { |
OpenPage(#current_path); |
} else { |
WB1.DrawPage(); |
DrawEditBoxWebView(); |
} |
DrawRectangle(scroll_wv.start_x, scroll_wv.start_y, scroll_wv.size_x, scroll_wv.size_y-1, scroll_wv.bckg_col); |
DrawTopPanelButton(OPEN_PAGE, 10, address_box.top-3, 0, false); |
} |
void OpenPage(dword _path) |
{ |
dword buf, size; |
strcpy(#current_path, _path); |
if (streq(_path, URL_SERVICE_HOME)) { |
LoadInternalPage(#homepage, sizeof(homepage)); |
return; |
} |
file_size stdcall (_path); |
if (EBX) |
{ |
size = EBX; |
buf = malloc(size); |
ReadFile(0, size, buf, _path); |
ShowCodeSource(); |
free(buf); |
return; |
} |
LoadInternalPage(NULL,NULL); |
} |
DrawEditBoxWebView() |
{ |
int skin_x_offset; |
DrawBar(address_box.left-2, address_box.top-2, address_box.width+3, 2, address_box.color); |
DrawBar(address_box.left-2, address_box.top, 2, 22, address_box.color); |
address_box.size = address_box.pos = address_box.shift = address_box.shift_old = strlen(#edit_path); |
address_box.offset = 0; |
edit_box_draw stdcall(#address_box); |
skin_x_offset = 51; |
} |
void LoadInternalPage(dword _bufpos, _bufsize) |
{ |
if (!_bufpos) || (!_bufsize) { |
LoadInternalPage(#page_not_found, sizeof(page_not_found)); |
return; |
} |
strcpy(#edit_path, #current_path); |
DrawEditBoxWebView(); |
WB1.list.first = 0; |
WB1.ParseHtml(_bufpos, _bufsize); |
WB1.DrawPage(); |
} |
void EventOpenDialog() |
{ |
OpenDialog_start stdcall (#o_dialog); |
if (o_dialog.status) { |
OpenPage(#openfile_path); |
} |
} |
void DrawStatusBar() {return;}; |
void EventClickLink() {return;}; |
void EventShowLinkMenu() {return;}; |
char anchor[256]; |
stop: |
/programs/cmm/codeview/highlight_c.h |
---|
0,0 → 1,121 |
enum { TAG, OPTION_VALUE, TEXT, COMMENT, INLINE_COMMENT, CODE }; |
char* C_HL_keywords[] = { |
"switch", "if", "while", "for", "break", "continue", "return", "else", |
"union", "typedef", "static", "class", "case", "#include", |
"volatile", "register", "sizeof", "typedef", "union", "goto", "const", "auto", |
"#define", "#endif", "#error", "#ifdef", "#ifndef", "#undef", "#if", "#else", |
"inline", |
"int ", "dword ", "long ", "double ", "float ", "char ", "unsigned ", "signed ", |
"void ", "bool ", "enum ", "byte ", "word ", "struct ", "NULL", "loop", "stdcall ", |
":void ", ":int ", ":bool ", ":dword ", NULL |
}; |
dword ShowCodeSource(dword _bufpointer, _bufsize) |
{ |
dword new_buf, new_buf_start, i; |
int mode = CODE; |
char spstr[64]; |
dword keylen; |
dword keyn; |
dword keycolor; |
new_buf = malloc(_bufsize*10); |
new_buf_start = new_buf; |
sprintf(new_buf,"<html><head><title>%s</title><body><pre>",#current_path); |
new_buf += strlen(new_buf); |
for (i=_bufpointer; i<_bufpointer+_bufsize; i++) |
{ |
if ('<' == ESBYTE[i]) { |
strcpy(new_buf, "<"); |
new_buf+=4; |
continue; |
} |
if ('>' == ESBYTE[i]) { |
strcpy(new_buf, ">"); |
new_buf+=4; |
continue; |
} |
if (ESBYTE[i] >= '0') && (ESBYTE[i] <= '9') && (CODE == mode) { |
strcpy(new_buf, "<font color=#CF00FF>?</font>"); |
ESBYTE[new_buf+20] = ESBYTE[i]; |
new_buf+=28; |
if (ESBYTE[i+1] == 'x') { |
strcpy(new_buf, "<font color=#CF00FF>x</font>"); |
new_buf+=28; |
i++; |
} |
continue; |
} |
if (CODE == mode) && ('\"' == ESBYTE[i]) { |
mode = TEXT; |
strcpy(new_buf, "<font color=#080>\""); |
new_buf+=18; |
continue; |
} |
if (TEXT == mode) && ('\"' == ESBYTE[i]) { |
mode = CODE; |
strcpy(new_buf, "\"</font>"); |
new_buf+=8; |
continue; |
} |
if (! strncmp(i, "//", 2) ) && (mode == CODE) { |
mode = INLINE_COMMENT; |
strcpy(new_buf, "<font color=#999>//"); |
new_buf+=19; |
i++; |
continue; |
} |
if (INLINE_COMMENT == mode) { |
if (13 == ESBYTE[i]) { |
mode = CODE; |
strcpy(new_buf, "\13</font>"); |
new_buf+=8; |
continue; |
} |
} |
if (! strncmp(i, "/*", 2) ) { |
mode = COMMENT; |
strcpy(new_buf, "<font color=#999>/*"); |
new_buf+=19; |
i++; |
continue; |
} |
if (! strncmp(i, "*/", 2) ) { |
mode = CODE; |
strcpy(new_buf, "*/</font>"); |
new_buf+=9; |
i++; |
continue; |
} |
if (CODE == mode) for (keyn=0; C_HL_keywords[keyn]!=NULL; keyn++) |
{ |
keylen = strlen(C_HL_keywords[keyn]); |
if (! strncmp(i, C_HL_keywords[keyn], keylen) ) { |
if (keyn<31) keycolor="#f00"; else keycolor="#00f"; |
sprintf(#spstr, "<font color=%s>%s</font>", keycolor, C_HL_keywords[keyn]); |
strcpy(new_buf, #spstr); |
new_buf += keylen + 24; |
i += keylen-1; |
goto _CONTINUE; |
} |
} |
ESBYTE[new_buf] = ESBYTE[i]; |
new_buf++; |
_CONTINUE: |
} |
ESBYTE[new_buf] = 0; |
LoadInternalPage(new_buf_start, new_buf - new_buf_start); |
free(new_buf_start); |
} |
/programs/cmm/codeview/html/homepage.htm |
---|
0,0 → 1,13 |
<html> |
<head> |
<title>Homepage</title> |
</head> |
<body> |
<br> |
CodeView is a sipmle C--/C/C++ code viewer based on TWB component.<br> |
<br> |
Press Ctrl+O to open a file. |
</body> |
</html> |
/programs/cmm/codeview/html/page_not_found_en.htm |
---|
0,0 → 1,10 |
<html> |
<head> |
<meta charset=cp-866 /> |
<title>File not found</title> |
</head> |
<body> |
<h1> File not found</h1> |
Please, check file address, there may have been made a typo. |
</body> |
</html> |
/programs/cmm/codeview/Tupfile.lua |
---|
0,0 → 1,6 |
if tup.getconfig("NO_CMM") ~= "" then return end |
if tup.getconfig("LANG") == "ru" |
then C_LANG = "LANG_RUS" |
else C_LANG = "LANG_ENG" -- this includes default case without config |
end |
tup.rule("codeview.c", "c-- /D=AUTOBUILD /D=$(C_LANG) %f" .. tup.getconfig("KPACK_CMD"), "codeview.com") |
/programs/cmm/codeview/compile_en.bat |
---|
0,0 → 1,5 |
@c-- CodeView.c |
@del CodeView |
@rename CodeView.com CodeView |
@del warning.txt |
@pause |
/data/Tupfile.lua |
---|
646,6 → 646,7 |
{"NETWORK/WEBVIEW", PROGS .. "/cmm/browser/WebView.com"}, |
}) |
tup.append_table(extra_files, { |
{"kolibrios/develop/utils/codeview", PROGS .. "/cmm/codeview/codeview.com"}, |
{"kolibrios/drivers/drvinst.kex", PROGS .. "/cmm/drvinst/drvinst.com"}, |
{"kolibrios/games/pig/pigex", PROGS .. "/cmm/examples/pigex.com"}, |
{"kolibrios/games/the_bus/the_bus", PROGS .. "/cmm/the_bus/the_bus.com"}, |