Table 0.99.1:

- autodetect separator
- open with param
- add accoc to fm

git-svn-id: svn://kolibrios.org@7516 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
Kirill Lipatov (Leency) 2018-10-31 21:22:48 +00:00
parent 6260ae112b
commit a192c7b7ee
17 changed files with 87 additions and 33 deletions

View File

@ -1 +1 @@
/sys/TinyPad: asm, inc, txt, mac, log, dat /sys/media/kiv: gif, bmp, png, tga, jpg, ico, cur, tif, tiff, jpeg, ppm, pgm, pbm, pnm, pcx, wbmp, xcf /sys/Network/Webview: htm, html, mht, xhtml /sys/fb2read: fb2 /sys/develop/cObj: obj /sys/skincfg: skn /sys/rtfRead: rtf /sys/develop/t_edit: cpp, h, c, c--, pas, set, ext, ini /sys/media/pixie/pixie: mp3 /sys/media/AC97SND: wav, xm /sys/media/MIDAMP: mid /sys/media/listplay: m3u, lap, asf /sys/shell: sh /sys/3d/view3ds: 3ds, asc /sys/graph: cvs /sys/unz: zip, 7z /kolibrios/media/updf: pdf /kolibrios/media/fplay: avi, mpg, mov, flv, wmv, vob, mkv, mp4, mpeg, divx, 3gp, webm /kolibrios/emul/zsnes: smc /kolibrios/emul/psx4all: mcr /kolibrios/emul/fceu/fceu: nes /kolibrios/emul/e80/e80: sna /kolibrios/emul/gameboy: gb, gbc /kolibrios/emul/pokemini: min /sys/develop/heed: /sys/TinyPad: asm, inc, txt, mac, log, dat /sys/media/kiv: gif, bmp, png, tga, jpg, ico, cur, tif, tiff, jpeg, ppm, pgm, pbm, pnm, pcx, wbmp, xcf /sys/Network/Webview: htm, html, mht, xhtml /sys/fb2read: fb2 /sys/develop/cObj: obj /sys/skincfg: skn /sys/rtfRead: rtf /sys/develop/t_edit: cpp, h, c, c--, pas, set, ext, ini /sys/media/pixie/pixie: mp3 /sys/media/AC97SND: wav, xm /sys/media/MIDAMP: mid /sys/media/listplay: m3u, lap, asf /sys/shell: sh /sys/3d/view3ds: 3ds, asc /sys/graph: cvs /sys/unz: zip, 7z /sys/table: csv /kolibrios/media/updf: pdf /kolibrios/media/fplay: avi, mpg, mov, flv, wmv, vob, mkv, mp4, mpeg, divx, 3gp, webm /kolibrios/emul/zsnes: smc /kolibrios/emul/psx4all: mcr /kolibrios/emul/fceu/fceu: nes /kolibrios/emul/e80/e80: sna /kolibrios/emul/gameboy: gb, gbc /kolibrios/emul/pokemini: min /sys/develop/heed:

View File

@ -165,6 +165,7 @@ c=27
java=27 java=27
pas=27 pas=27
fb2=29 fb2=29
csv=21
[icons32] [icons32]
<dir>=45 <dir>=45
@ -219,3 +220,4 @@ vox=30
rft=85 rft=85
mobi=85 mobi=85
djvu=85 djvu=85
csv=28

View File

@ -60,6 +60,7 @@ gbc=/kolibrios/emul/gameboy
min=/kolibrios/emul/pokemini min=/kolibrios/emul/pokemini
nc=/kolibrios/utils/cnc_editor/cnc_editor nc=/kolibrios/utils/cnc_editor/cnc_editor
kf=/sys/KF_VIEW kf=/sys/KF_VIEW
csv=/sys/table
[Menu] [Menu]
AsmMenu1=&Edit,/sys/TinyPad AsmMenu1=&Edit,/sys/TinyPad

View File

@ -179,9 +179,10 @@ mid /sys/media/midamp
rtf /sys/rtfread rtf /sys/rtfread
3ds /sys/3d/view3ds 3ds /sys/3d/view3ds
asc /sys/3d/view3ds asc /sys/3d/view3ds
lif /kolibrios/demos/life2
skn /sys/skincfg skn /sys/skincfg
kf /sys/KF_VIEW kf /sys/KF_VIEW
csv /sys/table
lif /kolibrios/demos/life2
pdf /kolibrios/media/updf pdf /kolibrios/media/updf
avi /kolibrios/media/fplay_run avi /kolibrios/media/fplay_run
mpg /kolibrios/media/fplay_run mpg /kolibrios/media/fplay_run

View File

@ -139,6 +139,8 @@ midi=/sys/media/midamp
rtf=/sys/rtfread rtf=/sys/rtfread
csv=/sys/table
grf=/sys/graph grf=/sys/graph
com=$DosBox com=$DosBox
@ -176,4 +178,3 @@ bas=/kolibrios/develop/TinyBasic/TinyBasic
vox=/kolibrios/3D/voxel_editor/VOXEL_EDITOR vox=/kolibrios/3D/voxel_editor/VOXEL_EDITOR

View File

@ -126,6 +126,7 @@ void main()
{ {
InitDlls(); InitDlls();
OpenDialog_init stdcall (#o_dialog); OpenDialog_init stdcall (#o_dialog);
if (param) strcpy(#openfile_path, #param);
LoadIniSettings(); LoadIniSettings();
EventSetColorScheme(curcol_scheme); EventSetColorScheme(curcol_scheme);
kfont.init(DEFAULT_FONT); kfont.init(DEFAULT_FONT);

View File

@ -4,4 +4,5 @@ call "C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\vcvarsall.bat"
@link /nologo /manifest:no /entry:crtStartUp /subsystem:native /base:0 /fixed /align:16 /nodefaultlib rforces.obj kosFile.obj kosSyst.obj mcsmemm.obj @link /nologo /manifest:no /entry:crtStartUp /subsystem:native /base:0 /fixed /align:16 /nodefaultlib rforces.obj kosFile.obj kosSyst.obj mcsmemm.obj
@pe2kos rforces.exe rforces @pe2kos rforces.exe rforces
@del rforces.exe @del rforces.exe
@del *.obj
pause pause

View File

@ -1,6 +1,5 @@
#include "func.h" #include "func.h"
#include "parser.h" #include "parser.h"
#include "kolibri.h"
#include "use_library.h" #include "use_library.h"
const char header[] = "Graph"; const char header[] = "Graph";

View File

@ -76,10 +76,6 @@ SOURCE=.\hello.cpp
# End Source File # End Source File
# Begin Source File # Begin Source File
SOURCE=.\kolibri.cpp
# End Source File
# Begin Source File
SOURCE=.\KosFile.cpp SOURCE=.\KosFile.cpp
# End Source File # End Source File
# Begin Source File # Begin Source File
@ -112,10 +108,6 @@ SOURCE=.\func.h
# End Source File # End Source File
# Begin Source File # Begin Source File
SOURCE=.\kolibri.h
# End Source File
# Begin Source File
SOURCE=.\KosFile.h SOURCE=.\KosFile.h
# End Source File # End Source File
# Begin Source File # Begin Source File

View File

@ -1 +0,0 @@

View File

@ -2,8 +2,8 @@ call "C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\vcvarsall.bat"
@cl /c /O2 /nologo /GS- /GR- /fp:fast *.cpp @cl /c /O2 /nologo /GS- /GR- /fp:fast *.cpp
@link /nologo /manifest:no /entry:crtStartUp /subsystem:native /base:0 /fixed /align:16 /nodefaultlib hello.obj *.obj @link /nologo /manifest:no /entry:crtStartUp /subsystem:native /base:0 /fixed /align:16 /nodefaultlib hello.obj *.obj
@del *.kex @del table
@pe2kos hello.exe hello.kex @pe2kos hello.exe table
@del hello.exe @del hello.exe
@del *.obj @del *.obj
pause pause

View File

@ -588,6 +588,31 @@ char *Kos_FileRead(kosFileInfo &fileInfo, int &code)
return r; return r;
} }
char GetCsvSeparator(char *fname)
{
char buffer[512];
kosFileInfo fileInfo;
rtlDebugOutString("hi");
rtlDebugOutString(fname);
strcpy(fileInfo.fileURL, fname);
fileInfo.OffsetLow = 0;
fileInfo.OffsetHigh = 0;
fileInfo.dataCount = 512;
fileInfo.rwMode = 0;
fileInfo.bufferPtr = (Byte *)buffer;
if (kos_FileSystemAccess(&fileInfo) == 0) {
int separ_coma = chrnum(buffer, ',');
int separ_semicolon = chrnum(buffer, ';');
//kos_DebugValue(",", separ_coma);
//kos_DebugValue(";", separ_semicolon);
if (separ_semicolon>separ_coma) return ';';
}
return ',';
}
int LoadCSV(char *fname) int LoadCSV(char *fname)
{ {
// clear the table // clear the table
@ -598,6 +623,8 @@ int LoadCSV(char *fname)
fileInfo.OffsetLow = 0; fileInfo.OffsetLow = 0;
fileInfo.OffsetHigh = 0; fileInfo.OffsetHigh = 0;
char separator = GetCsvSeparator(fileInfo.fileURL);
char *line; char *line;
int col = 1, row = 1; int col = 1, row = 1;
@ -626,7 +653,7 @@ int LoadCSV(char *fname)
{ {
char c = line[i]; char c = line[i];
if (!c) if (!c)
c = ';'; c = separator;
int yes_semicolon = 0; int yes_semicolon = 0;
switch (inPar) switch (inPar)
@ -638,7 +665,7 @@ int LoadCSV(char *fname)
} }
else else
{ {
if (c == ';') if (c == separator)
yes_semicolon = 1; yes_semicolon = 1;
} }
break; break;
@ -652,7 +679,7 @@ int LoadCSV(char *fname)
} }
/*else /*else
{ {
if (c == ';') if (c == separator)
yes_semicolon = 1; yes_semicolon = 1;
}*/ }*/
@ -660,7 +687,7 @@ int LoadCSV(char *fname)
} }
if (yes_semicolon) if (yes_semicolon)
{ {
// èòàê, line[i] = ';' // èòàê, line[i] = separator
int tmp = line[start] == '"' ? 1 : 0; int tmp = line[start] == '"' ? 1 : 0;
int sz = i - start - tmp * 2; int sz = i - start - tmp * 2;
if (sz > 0) if (sz > 0)

View File

@ -6,7 +6,12 @@
#include "calc.h" #include "calc.h"
#include "use_library.h" #include "use_library.h"
#define TABLE_VERSION "0.99" #ifdef AUTOBUILD
extern char params[1024];
#endif
char params[1024];
#define TABLE_VERSION "0.99.1"
// strings // strings
const char *sFileSign = "KolibriTable File\n"; const char *sFileSign = "KolibriTable File\n";
@ -1043,6 +1048,22 @@ void process_key()
} }
} }
void EventLoadFile()
{
stop_edit();
int r = LoadFile(fname);
char *result;
if (r > 0) {
calculate_values();
sel_moved = 0;
draw_grid();
result = (char*)msg_load;
}
else if (r == -1) result = (char*)er_file_not_found;
else if (r == -2) result = (char*)er_format;
kos_AppRun("/sys/@notify", result);
}
void process_button() void process_button()
{ {
Dword button; Dword button;
@ -1063,18 +1084,7 @@ void process_button()
break; break;
case LOAD_BUTTON: case LOAD_BUTTON:
stop_edit(); EventLoadFile();
int r = LoadFile(fname);
char *result;
if (r > 0) {
calculate_values();
sel_moved = 0;
draw_grid();
result = (char*)msg_load;
}
else if (r == -1) result = (char*)er_file_not_found;
else if (r == -2) result = (char*)er_format;
kos_AppRun("/sys/@notify", result);
break; break;
} }
if (button >= COL_HEAD_BUTTON && button < ROW_HEAD_BUTTON) if (button >= COL_HEAD_BUTTON && button < ROW_HEAD_BUTTON)
@ -1102,6 +1112,11 @@ void kos_Main()
kos_InitHeap(); kos_InitHeap();
load_edit_box(); load_edit_box();
init(); init();
if (params[0]) {
strcpy(fname, params);
file_box.size = file_box.pos = strlen(fname);
EventLoadFile();
}
kos_SetMaskForEvents(EVM_REDRAW + EVM_KEY + EVM_BUTTON + EVM_MOUSE + EVM_MOUSE_FILTER); kos_SetMaskForEvents(EVM_REDRAW + EVM_KEY + EVM_BUTTON + EVM_MOUSE + EVM_MOUSE_FILTER);
for (;;) for (;;)
{ {

View File

@ -9,6 +9,7 @@
#ifdef AUTOBUILD #ifdef AUTOBUILD
char kosExePath[1024]; char kosExePath[1024];
char exeStack[16384]; char exeStack[16384];
extern char params[1024];
// must be alphabetically first in the image // must be alphabetically first in the image
#pragma data_seg(".1seg") #pragma data_seg(".1seg")
extern "C" struct extern "C" struct
@ -28,7 +29,7 @@ extern "C" struct
0, // filled by doexe2.asm 0, // filled by doexe2.asm
0, // filled by doexe2.asm 0, // filled by doexe2.asm
exeStack + sizeof(exeStack), exeStack + sizeof(exeStack),
NULL, params,
kosExePath kosExePath
}; };
#pragma data_seg() #pragma data_seg()

View File

@ -928,3 +928,15 @@ int look_up(char *s)
return 0; // search command/function name return 0; // search command/function name
} }
unsigned int chrnum(char* text, char symbol)
{
int num = 0;
int i = 0;
while(text[i])
{
if (text[i] == symbol) num++;
i++;
}
return num;
}

View File

@ -57,6 +57,8 @@ int look_up(char *s);
bool strcmp(char *s1, char *s2); bool strcmp(char *s1, char *s2);
bool strncmp(char *s1, char *s2, int n); bool strncmp(char *s1, char *s2, int n);
unsigned int chrnum(char* text, char symbol);
extern double epsilon; extern double epsilon;