mouse_cfg: speed x>=1

lexer.h  : alloc tokens

git-svn-id: svn://kolibrios.org@5631 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
pavelyakov 2015-07-30 15:49:09 +00:00
parent 00fcd51abd
commit cdfc1d7c00
13 changed files with 176 additions and 100 deletions

View File

@ -9,13 +9,11 @@
//libraries
#define MEMSIZE 0x100000
#include "..\lib\kolibri.h"
#include "..\lib\strings.h"
#include "..\lib\gui.h"
#include "..\lib\encoding.h"
#include "..\lib\file_system.h"
#include "..\lib\mem.h"
#include "..\lib\dll.h"
#include "..\lib\draw_buf.h"
#include "..\lib\list_box.h"
#include "..\lib\cursor.h"
@ -47,6 +45,8 @@ char homepage[] = FROM "html\\homepage.htm";
char accept_language[]= "Accept-Language: en\n";
#endif
proc_info Form;
#define WIN_W 799
#define WIN_H 559
@ -141,8 +141,7 @@ void main()
CreateDir("/tmp0/1/downloads");
SetEventMask(0xa7);
loop()
{
BEGIN_LOOP_APPLICATION:
WaitEventTimeout(2);
switch(EAX & 0xFF)
{
@ -156,13 +155,8 @@ void main()
//Menu
if (m.y>WB1.list.y) && (m.y<Form.height) && (bufsize)
{
if (m.pkm)
if (m.pkm) && (m.up)
{
show_menu = 1;
}
if (!m.pkm) && (show_menu)
{
show_menu = 0;
SwitchToAnotherThread();
CreateThread(#menu_rmb,#stak+4092);
break;
@ -190,7 +184,7 @@ void main()
btn=WB1.list.first;
WB1.list.first = m.y -half_scroll_size -WB1.list.y * WB1.list.count / WB1.list.h;
if (WB1.list.visible+WB1.list.first>WB1.list.count) WB1.list.first=WB1.list.count-WB1.list.visible;
if (btn<>WB1.list.first) WB1.Parse();
if (btn!=WB1.list.first) WB1.Parse();
}
break;
case evButton:
@ -203,7 +197,7 @@ void main()
if (address_box.flags & 0b10)
{
if (key==ASCII_KEY_ENTER) Scan(key); else
if (key<>0x0d) && (key<>183) && (key<>184) {EAX=key<<8; edit_box_key stdcall(#address_box);}
if (key!=0x0d) && (key!=183) && (key!=184) {EAX=key<<8; edit_box_key stdcall(#address_box);}
}
else Scan(key);
break;
@ -282,7 +276,7 @@ void main()
}
}
}
}
goto BEGIN_LOOP_APPLICATION;
}
void SetElementSizes()
@ -382,7 +376,7 @@ void Scan(int id)
case 006: //download manager
if (!downloader_opened) {
strcpy(#DL_URL, "http://");
strncpy(#DL_URL, "http://",7);
CreateThread(#Downloader,#downloader_stak+4092);
}
return;
@ -402,15 +396,12 @@ void Scan(int id)
WB1.Parse();
break;
case 053: //F4
if (strncmp(#URL,"http:",5)==0)
if (!strncmp(#URL,"http:",5))
{
WriteFile(bufsize, bufpointer, "/tmp0/1/WebView_tmp.htm");
if (EAX==0) RunProgram("/rd/1/tinypad", "/tmp0/1/WebView_tmp.htm");
}
else
{
RunProgram("/rd/1/tinypad", #URL);
if (!EAX) RunProgram("/rd/1/tinypad", "/tmp0/1/WebView_tmp.htm");
}
else RunProgram("/rd/1/tinypad", #URL);
return;
case 054: //F5
IF(address_box.flags & 0b10) return;
@ -431,18 +422,14 @@ void Scan(int id)
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://");
}
if (strncmp(#editURL,"http:",5)) && (editURL[0]!='/') && (strncmp(#editURL,"WebView:",9)) strncpy(#URL,"http://",7);
else
URL[0] = 0;
strcat(#URL, #editURL);
OpenPage();
return;
case SEARCHWEB:
strcpy(#URL, #search_path);
strcat(#URL, #editURL);
sprintf(#URL,"%s%s",#search_path,#editURL);
OpenPage();
return;
@ -511,11 +498,11 @@ void ProcessLinks(int id)
if (URL[0] == '$')
{
if (URL[1]=='-') && (condition_href) condition_href--;
if (URL[1]=='+')
else if (URL[1]=='+')
{
if (condition_href<condition_max) condition_href++; else notify(T_LAST_SLIDE);
}
if (URL[1]!='-') && (URL[1]!='+') condition_href = atoi(#URL+1);
else condition_href = atoi(#URL+1);
strcpy(#URL, BrowserHistory.CurrentUrl());
ShowPage();
return;
@ -542,20 +529,17 @@ void ProcessLinks(int id)
|| (UrlExtIs(".7z")==1) || (UrlExtIs("netcfg")==1)
{
//notify(#URL);
if (strcmpn(#URL,"http://", 7)==0)
if (!strncmp(#URL,"http://", 7))
{
strcpy(#DL_URL, #URL);
CreateThread(#Downloader,#downloader_stak+4092);
}
else
{
RunProgram("@open", #URL);
}
else RunProgram("@open", #URL);
strcpy(#editURL, BrowserHistory.CurrentUrl());
strcpy(#URL, BrowserHistory.CurrentUrl());
return;
}
if (!strcmpn(#URL,"mailto:", 7))
if (!strncmp(#URL,"mailto:", 7))
{
notify(#URL);
strcpy(#editURL, BrowserHistory.CurrentUrl());
@ -568,17 +552,17 @@ void ProcessLinks(int id)
void StopLoading()
{
if (http_transfer<>0)
if (http_transfer)
{
EAX = http_transfer;
EAX = EAX.http_msg.content_ptr; // get pointer to data
$push EAX // save it on the stack
http_free stdcall (http_transfer); // abort connection
$pop EAX
mem_Free(EAX); // free data
free(EAX); // free data
http_transfer=0;
bufsize = 0;
bufpointer = mem_Free(bufpointer);
bufpointer = free(bufpointer);
}
wv_progress_bar.value = 0;
img_draw stdcall(skin.image, address_box.left+address_box.width+1, address_box.top-2, 17, skin.h, 52, 0);
@ -602,29 +586,23 @@ void OpenPage()
souce_mode = false;
strcpy(#editURL, #URL);
BrowserHistory.AddUrl();
if (strncmp(#URL,"WebView:",8)==0)
if (!strncmp(#URL,"WebView:",8))
{
SetPageDefaults();
if (strcmp(#URL, URL_SERVICE_HOME)==0)
{
WB1.Prepare(#homepage, sizeof(homepage));
}
if (strcmp(#URL, URL_SERVICE_HISTORY)==0)
{
ShowHistory();
}
if (!strcmp(#URL, URL_SERVICE_HOME)) WB1.Prepare(#homepage, sizeof(homepage));
else if (!strcmp(#URL, URL_SERVICE_HISTORY)) ShowHistory();
return;
}
if (strncmp(#URL,"http:",5)==0)
if (!strncmp(#URL,"http:",5))
{
img_draw stdcall(skin.image, address_box.left+address_box.width+1, address_box.top-2, 17, skin.h, 131, 0);
http_get stdcall (#URL, 0, 0, #accept_language);
http_transfer = EAX;
if (http_transfer == 0)
if (!http_transfer)
{
StopLoading();
bufsize = 0;
bufpointer = mem_Free(bufpointer);
bufpointer = free(bufpointer);
ShowPage();
return;
}
@ -635,8 +613,8 @@ void OpenPage()
bufsize = EBX;
if (bufsize)
{
mem_Free(bufpointer);
bufpointer = mem_Alloc(bufsize);
free(bufpointer);
bufpointer = malloc(bufsize);
SetPageDefaults();
ReadFile(0, bufsize, bufpointer, #URL);
//ShowSource();
@ -659,7 +637,7 @@ void ShowPage()
if (!bufsize)
{
PageLinks.Clear();
if (http_transfer<>0)
if (http_transfer)
{
WB1.Prepare(#loading, sizeof(loading));
}
@ -675,12 +653,10 @@ void ShowPage()
byte UrlExtIs(dword ext)
{
if (strcmpi(#URL + strlen(#URL) - strlen(ext), ext)==0) return 1; else return 0;
if (!strcmpi(#URL + strlen(#URL) - strlen(ext), ext)) return true;
return false;
}
stop:
char downloader_stak[4096];
stop:

View File

@ -35,7 +35,8 @@ void menu_rmb()
menu.SetSizes(2,2,177,menu.count*19,0,19);
SetEventMask(100111b);
loop() switch(WaitEvent())
_BEGIN_APPLICATION_MENU:
switch(WaitEvent())
{
case evMouse:
GetProcessInfo(#MenuForm, SelfInfo);
@ -43,7 +44,7 @@ void menu_rmb()
mm.get();
if (menu.ProcessMouse(mm.x, mm.y)) DrawMenuList();
if (mm.lkm) || (mm.pkm) { action_buf = ITEMS_LIST[menu.current*2+1]; ExitProcess(); }
if (mm.lkm)&&(mm.up) { action_buf = ITEMS_LIST[menu.current*2+1]; ExitProcess(); }
break;
case evKey:
@ -62,6 +63,7 @@ void menu_rmb()
DrawPopup(0,0,menu.w,menu.h+3,0, col_bg,border_color);
DrawMenuList();
}
goto _BEGIN_APPLICATION_MENU;
}
void DrawMenuList()

View File

@ -10,11 +10,8 @@ dword ShowSource()
souce_mode = true;
new_buf = malloc(bufsize*5);
new_buf_start = new_buf;
strcpy(new_buf, "<html><head><title>");
if (strlen(#header)-strlen(#version)>0) header[strlen(#header)-strlen(#version)-2] = 0; else strcpy(#header, "Source");
strcat(new_buf, #header);
strcat(new_buf, "</title><body><pre>");
new_buf += strlen(new_buf);
new_buf += sprintf(new_buf,"<html><head><title>%s</title><body><pre>",#header);
for (i=bufpointer; i<bufpointer+bufsize; i++)
{
ww = ESBYTE[i];

View File

@ -7,11 +7,9 @@
//libraries
#define MEMSIZE 0xD0000
#include "..\lib\kolibri.h"
#include "..\lib\clipboard.h"
#include "..\lib\strings.h"
#include "..\lib\mem.h"
#include "..\lib\dll.h"
#include "..\lib\file_system.h"
#include "..\lib\gui.h"
#include "..\lib\list_box.h"

View File

@ -44,7 +44,7 @@ void Put_icon(dword extension, xx, yy, fairing_color, icon_n)
PutPaletteImage(icon_n*16*15+#ficons,16,15,xx,yy,8,#ficons_pal);
if (fairing_color!=0xFFFfff) IconFairing(icon_n, xx, yy, fairing_color);
if (use_big_fonts) font_half_width=4; else font_half_width=3;
if (icon_n<>17) && (strlen(extension)<9) WriteText(-strlen(extension)*font_half_width+Form.cwidth-120,yy+4,font_type,0,extension);
if (icon_n!=17) && (strlen(extension)<9) WriteText(-strlen(extension)*font_half_width+Form.cwidth-120,yy+4,font_type,0,extension);
}

View File

@ -63,7 +63,7 @@ void Tip(int y, dword caption, id, arrow)
DrawBar(17,y,160,1,0xEFEDEE);
DrawFilledBar(17, y+1, 160, 16);
WriteText(25,y+5,0x80,sc.work_text,caption);
IF (id<>0) DefineButton(159,y+1,16,16,id+BT_HIDE+BT_NOFRAME,0); //arrow button
if (id) DefineButton(159,y+1,16,16,id+BT_HIDE+BT_NOFRAME,0); //arrow button
WriteText(165,y+5,0x80,sc.work_text,arrow); //arrow
DrawBar(17,y+17,160,1,sc.work_graph);
}

View File

@ -33,15 +33,16 @@ void Sort_by_Type(int a, b) //
filename2 = file_mas[b]*304 + buf+72;
n=strlen(filename1)-1;
WHILE (n>0) && (ESBYTE[filename1+n]<>'.') n--;
WHILE (n>0) && (ESBYTE[filename1+n]!='.') n--;
if (n) ext1 = filename1+n+1; else ext1=0;
n=strlen(filename2)-1;
WHILE (n>0) && (ESBYTE[filename2+n]<>'.') n--;
n=strlen(filename2);
n--;
WHILE (n>0) && (ESBYTE[filename2+n]!='.') n--;
if (n) ext2 = filename2+n+1; else ext2=0;
n=strcmp(ext1, ext2);
if (n<0) { file_mas[isn] >< file_mas[j]; isn++;}
if (n==0) && (strcmp(filename1, filename2)<=0) { file_mas[isn] >< file_mas[j]; isn++;}
if (!n) && (strcmp(filename1, filename2)<=0) { file_mas[isn] >< file_mas[j]; isn++;}
}
Sort_by_Type(a, isn-2);
Sort_by_Type(isn, b);

View File

@ -1,25 +1,24 @@
#ifndef INCLUDE_DLL_H
#define INCLUDE_DLL_H
#ifndef INCLUDE_KOLIBRI_H
#ifndef INCLUDE_FILESYSTEM_H
#include "../lib/file_system.h"
#endif
#ifdef LANG_RUS
#define _TEXT_ERROR_ADD "'Žè¨¡ª  ¯à¨ § £à㧪¥ ¡¨¡«¨®â¥ª¨"
#elif LANG_EST
#define _TEXT_ERROR_ADD "'Viga teegi laadimisel"
#else
#define _TEXT_ERROR_ADD "'Error while loading library"
#endif
char a_libdir[43] = "/sys/lib/\0";
:inline void error_init(dword text)
{
dword TEXT_ERROR = malloc(1024);
#ifdef LANG_RUS
strcpy(TEXT_ERROR,"'Žè¨¡ª  ¯à¨ § £à㧪¥ ¡¨¡«¨®â¥ª¨ `");
#elif LANG_EST
strcpy(TEXT_ERROR,"'Viga teegi laadimisel `");
#else
strcpy(TEXT_ERROR,"'Error while loading library `");
#endif
strcat(TEXT_ERROR,text);
strcat(TEXT_ERROR,"`' -E");
sprintf("%s `%s`' -E",_TEXT_ERROR_ADD,text);
notify(TEXT_ERROR);
free(TEXT_ERROR);
}
@ -118,9 +117,9 @@ asm {
push ebp
mov ebp, esp
pushad
mov eax, #mem_Alloc
mov ebx, #mem_Free;
mov ecx, #mem_ReAlloc;
mov eax, #malloc
mov ebx, #free;
mov ecx, #realloc;
mov edx, #dll_Load;
call SSDWORD[EBP+8]
popad
@ -239,9 +238,14 @@ int load_dll2(dword dllname, import_table, byte need_init)
return -1;
}
void load_dll(dword dllname, import_table, byte need_init)
byte load_dll(dword dllname, import_table, byte need_init)
{
if (load_dll2(dllname, import_table, need_init)!=0) error_init(dllname);
if (load_dll2(dllname, import_table, need_init))
{
error_init(dllname);
return false;
}
return true;
}

View File

@ -291,11 +291,6 @@ enum
return error;
}
:dword notify(dword notify_param)
{
return RunProgram("@notify", notify_param);
}
:dword abspath(dword relative_path) //GetAbsolutePathFromRelative()
{
char absolute_path[4096];
@ -324,7 +319,10 @@ enum
sprintf(#ConvertSize_size_prefix,"%d %s",bytes,#size_nm);
return #ConvertSize_size_prefix;
}
:dword notify(dword notify_param)
{
return RunProgram("@notify", notify_param);
}
:dword ConvertSizeToKb(unsigned int bytes)
{
unsigned char size[25]=0;

View File

@ -826,7 +826,6 @@ inline fastcall dword GetStartTime()
$int 0x40
}
:dword X_EventRedrawWindow,Y_EventRedrawWindow;
:void _EventRedrawWindow()
{

View File

@ -4,9 +4,14 @@
#ifndef INCLUDE_STRING_H
#include "../lib/strings.h"
#endif
#ifndef INCLUDE_MEM_H
#include "../lib/mem.h"
#endif
/** Splits text into tokens
* Author :Pavel Yakovlev
* Homepage:https://vk.com/pavelyakov39
* Ver. : 1.51
*/
/** Example:
@ -49,18 +54,75 @@
:struct lexer
{
byte cmd;
dword token,text;
dword token,text,mem_list,count,buffer_loading;
dword str_buffer;
byte type;
char quote;
signed count,length;
signed length;
dword next(void);
dword back(void);
dword list(void);
void free(void);
dword position(dword __);
void load(dword _text);
void expected(dword _text);
};
:dword back(void)
{
:void expected(dword _text)
}
:dword lexer::list(void)
{
dword count_mem,buf_loop,pos;
count_mem = 0;
buf_loop = 5000; // на тыс элементов.
count = 0;
buffer_loading = malloc(buf_loop);
pos = buffer_loading;
while(type!=LEX_END)
{
pos+=count_mem;
next();
DSDWORD[pos] = strndup(token,length);
pos+=4;
DSBYTE [pos] = type;
pos++;
count++;
if(pos-buffer_loading>buf_loop)
{
buf_loop*=2;
buffer_loading = realloc(buffer_loading,buf_loop);
}
}
return buffer_loading;
}
:void lexer::free(void)
{
dword z;
z = count;
while(z)
{
z--;
position(z);
::free(token);
}
count = 0;
::free(buffer_loading);
}
:dword lexer::position(dword __)
{
dword pos1;
if(!count)list();
if(__>=count)__=count-1;
else if(__<0)__=0;
pos1 = __*5;
pos1 += buffer_loading;
token = DSDWORD[pos1];
pos1++;
type = DSBYTE[pos1];
return token;
}
:void lexer::expected(dword _text)
{
notify(_text);
ExitProcess();
@ -69,15 +131,19 @@
:void lexer::load(dword _text)
{
text = _text;
count = 0;
str_buffer = 0;
}
:dword lexer::next(void)
{
char s;
dword len_str_buf,tmp;
dword pos,in;
pos = #const_token_lexer;
in = text;
//len_str_buf = 1024;
if(str_buffer)::free(str_buffer);
NEXT_TOKEN:
length = 0;
loop()
@ -184,6 +250,7 @@
{
quote = s;
in++;
tmp = in;
s = DSBYTE[in];
loop()
{
@ -210,9 +277,42 @@
DSBYTE[pos] = s;
pos++;
in++;
/*if(in-tmp>len_str_buf)
{
if(str_buffer)
{
tmp = len_str_buf;
len_str_buf+=1024;
str_buffer = realloc(str_buffer,len_str_buf+1);
strlcpy(str_buffer+tmp,#const_token_lexer,1024);
pos = #const_token_lexer;
}
else {
len_str_buf+=1024;
str_buffer = malloc(len_str_buf+1);
strlcpy(str_buffer,#const_token_lexer,1024);
pos = #const_token_lexer;
}
}*/
s = DSBYTE[in];
}
in++;
/*tmp = pos-in;
if(str_buffer)
{
if(tmp)
{
str_buffer = realloc(str_buffer,tmp+1);
strlcpy(str_buffer+len_str_buf,#const_token_lexer,tmp);
}
type = LEX_STR;
length = len_str_buf+tmp;
text = in;
tmp = str_buffer+length;
DSBYTE[tmp] = 0;
token = str_buffer;
return token;
}*/
type = LEX_STR;
}
else {

View File

@ -10,6 +10,7 @@
#include "../lib/dll.h"
#endif
dword NOT_INIT_LIBHTTP = true;
dword libHTTP = #alibHTTP;
char alibHTTP[23] = "/sys/lib/http.obj\0";

View File

@ -107,7 +107,7 @@ void main() {
mouse_cfg.pointer_speed++;
SetMouseSpeed(mouse_cfg.pointer_speed);
}
if (id==121) && (mouse_cfg.pointer_speed>0)
if (id==121) && (mouse_cfg.pointer_speed>1)
{
mouse_cfg.pointer_speed--;
SetMouseSpeed(mouse_cfg.pointer_speed);