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
pas=27
fb2=29
csv=21
[icons32]
<dir>=45
@ -219,3 +220,4 @@ vox=30
rft=85
mobi=85
djvu=85
csv=28

View File

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

View File

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

View File

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

View File

@ -126,6 +126,7 @@ void main()
{
InitDlls();
OpenDialog_init stdcall (#o_dialog);
if (param) strcpy(#openfile_path, #param);
LoadIniSettings();
EventSetColorScheme(curcol_scheme);
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
@pe2kos rforces.exe rforces
@del rforces.exe
@del *.obj
pause

View File

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

View File

@ -76,10 +76,6 @@ SOURCE=.\hello.cpp
# End Source File
# Begin Source File
SOURCE=.\kolibri.cpp
# End Source File
# Begin Source File
SOURCE=.\KosFile.cpp
# End Source File
# Begin Source File
@ -112,10 +108,6 @@ SOURCE=.\func.h
# End Source File
# Begin Source File
SOURCE=.\kolibri.h
# End Source File
# Begin Source File
SOURCE=.\KosFile.h
# End 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
@link /nologo /manifest:no /entry:crtStartUp /subsystem:native /base:0 /fixed /align:16 /nodefaultlib hello.obj *.obj
@del *.kex
@pe2kos hello.exe hello.kex
@del table
@pe2kos hello.exe table
@del hello.exe
@del *.obj
pause

View File

@ -588,6 +588,31 @@ char *Kos_FileRead(kosFileInfo &fileInfo, int &code)
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)
{
// clear the table
@ -598,6 +623,8 @@ int LoadCSV(char *fname)
fileInfo.OffsetLow = 0;
fileInfo.OffsetHigh = 0;
char separator = GetCsvSeparator(fileInfo.fileURL);
char *line;
int col = 1, row = 1;
@ -626,7 +653,7 @@ int LoadCSV(char *fname)
{
char c = line[i];
if (!c)
c = ';';
c = separator;
int yes_semicolon = 0;
switch (inPar)
@ -638,7 +665,7 @@ int LoadCSV(char *fname)
}
else
{
if (c == ';')
if (c == separator)
yes_semicolon = 1;
}
break;
@ -652,7 +679,7 @@ int LoadCSV(char *fname)
}
/*else
{
if (c == ';')
if (c == separator)
yes_semicolon = 1;
}*/
@ -660,7 +687,7 @@ int LoadCSV(char *fname)
}
if (yes_semicolon)
{
// èòàê, line[i] = ';'
// èòàê, line[i] = separator
int tmp = line[start] == '"' ? 1 : 0;
int sz = i - start - tmp * 2;
if (sz > 0)

View File

@ -6,7 +6,12 @@
#include "calc.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
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()
{
Dword button;
@ -1063,18 +1084,7 @@ void process_button()
break;
case LOAD_BUTTON:
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);
EventLoadFile();
break;
}
if (button >= COL_HEAD_BUTTON && button < ROW_HEAD_BUTTON)
@ -1102,6 +1112,11 @@ void kos_Main()
kos_InitHeap();
load_edit_box();
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);
for (;;)
{

View File

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

View File

@ -928,3 +928,15 @@ int look_up(char *s)
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 strncmp(char *s1, char *s2, int n);
unsigned int chrnum(char* text, char symbol);
extern double epsilon;