/sved/trunk/deflang.c |
---|
1,9 → 1,9 |
/* THIS FILE HAS BEEN GENERATED BY TLUMACZ (PART OF THE SVARLANG LIBRARY) */ |
const unsigned short svarlang_memsz = 244u; |
const unsigned short svarlang_string_count = 18u; |
const unsigned short svarlang_memsz = 370u; |
const unsigned short svarlang_string_count = 27u; |
char svarlang_mem[244] = { |
0x45,0x53,0x43,0x3d,0x4d,0x45,0x4e,0x55,0x00, |
char svarlang_mem[370] = { |
0x46,0x31,0x3d,0x48,0x45,0x4c,0x50,0x00, |
0x4e,0x45,0x57,0x20,0x46,0x49,0x4c,0x45,0x00, |
0x53,0x41,0x56,0x45,0x44,0x00, |
0x53,0x41,0x56,0x49,0x4e,0x47,0x20,0x46,0x41,0x49,0x4c,0x45,0x44,0x00, |
19,32 → 19,52 |
0x46,0x49,0x4c,0x45,0x20,0x4e,0x4f,0x54,0x20,0x46,0x4f,0x55,0x4e,0x44,0x00, |
0x75,0x73,0x61,0x67,0x65,0x3a,0x20,0x73,0x76,0x65,0x64,0x20,0x5b,0x66,0x69,0x6c, |
0x65,0x2e,0x74,0x78,0x74,0x5d,0x00, |
0x4e,0x65,0x77,0x20,0x66,0x69,0x6c,0x65,0x00, |
0x4f,0x70,0x65,0x6e,0x20,0x66,0x69,0x6c,0x65,0x00, |
0x53,0x61,0x76,0x65,0x00, |
0x53,0x61,0x76,0x65,0x20,0x61,0x73,0x2e,0x2e,0x2e,0x00, |
0x43,0x68,0x61,0x6e,0x67,0x65,0x20,0x6c,0x69,0x6e,0x65,0x20,0x65,0x6e,0x64,0x69, |
0x6e,0x67,0x73,0x00, |
0x51,0x75,0x69,0x74,0x00 |
0x2e,0x00, |
0x46,0x32,0x20,0x20,0x4e,0x65,0x77,0x20,0x66,0x69,0x6c,0x65,0x00, |
0x46,0x33,0x20,0x20,0x4f,0x70,0x65,0x6e,0x20,0x66,0x69,0x6c,0x65,0x00, |
0x46,0x35,0x20,0x20,0x53,0x61,0x76,0x65,0x00, |
0x46,0x36,0x20,0x20,0x53,0x61,0x76,0x65,0x20,0x61,0x73,0x2e,0x2e,0x2e,0x00, |
0x46,0x31,0x30,0x20,0x43,0x68,0x61,0x6e,0x67,0x65,0x20,0x6c,0x69,0x6e,0x65,0x20, |
0x65,0x6e,0x64,0x69,0x6e,0x67,0x73,0x00, |
0x45,0x53,0x43,0x20,0x51,0x75,0x69,0x74,0x00, |
0x2e,0x00, |
0x4e,0x61,0x76,0x69,0x67,0x61,0x74,0x69,0x6f,0x6e,0x3a,0x00, |
0x2e,0x00, |
0x43,0x54,0x52,0x4c,0x2b,0x52,0x69,0x67,0x68,0x74,0x20,0x20,0x4a,0x75,0x6d,0x70, |
0x20,0x74,0x6f,0x20,0x6e,0x65,0x78,0x74,0x20,0x77,0x6f,0x72,0x64,0x00, |
0x43,0x54,0x52,0x4c,0x2b,0x4c,0x65,0x66,0x74,0x20,0x20,0x20,0x4a,0x75,0x6d,0x70, |
0x20,0x74,0x6f,0x20,0x70,0x72,0x65,0x76,0x20,0x77,0x6f,0x72,0x64,0x00, |
0x2e,0x00, |
0x50,0x72,0x65,0x73,0x73,0x20,0x61,0x6e,0x79,0x20,0x6b,0x65,0x79,0x00, |
0x2e,0x00 |
}; |
unsigned short svarlang_dict[36] = { |
unsigned short svarlang_dict[54] = { |
0x0000,0x0000, |
0x0001,0x0009, |
0x0002,0x0012, |
0x0003,0x0018, |
0x0004,0x0026, |
0x0005,0x0044, |
0x0006,0x005c, |
0x0007,0x0065, |
0x0008,0x006b, |
0x000a,0x0080, |
0x000b,0x0086, |
0x0100,0x0095, |
0x0801,0x00ac, |
0x0802,0x00b5, |
0x0803,0x00bf, |
0x0804,0x00c4, |
0x0805,0x00cf, |
0x0806,0x00e3 |
0x0001,0x0008, |
0x0002,0x0011, |
0x0003,0x0017, |
0x0004,0x0025, |
0x0005,0x0043, |
0x0006,0x005b, |
0x0007,0x0064, |
0x0008,0x006a, |
0x000a,0x007f, |
0x000b,0x0085, |
0x0100,0x0094, |
0x0803,0x00ab, |
0x0804,0x00ad, |
0x0805,0x00ba, |
0x0806,0x00c8, |
0x0807,0x00d1, |
0x0808,0x00e0, |
0x0809,0x00f8, |
0x080a,0x0101, |
0x080b,0x0103, |
0x080c,0x010f, |
0x080d,0x0111, |
0x080e,0x012f, |
0x080f,0x014d, |
0x0810,0x014f, |
0x0811,0x015d |
}; |
/sved/trunk/nls/en_utf8.txt |
---|
4,7 → 4,7 |
# MAIN SCREEN # |
############### |
0.0:ESC=MENU |
0.0:F1=HELP |
0.1:NEW FILE |
0.2:SAVED |
0.3:SAVING FAILED |
28,9 → 28,18 |
# HELP SCREEN # |
############### |
8.1:New file |
8.2:Open file |
8.3:Save |
8.4:Save as... |
8.5:Change line endings |
8.6:Quit |
8.3:. |
8.4:F2 New file |
8.5:F3 Open file |
8.6:F5 Save |
8.7:F6 Save as... |
8.8:F10 Change line endings |
8.9:ESC Quit |
8.10:. |
8.11:Navigation: |
8.12:. |
8.13:CTRL+Right Jump to next word |
8.14:CTRL+Left Jump to prev word |
8.15:. |
8.16:Press any key |
8.17:. |
/sved/trunk/sved.c |
---|
41,9 → 41,6 |
/* preload the mono scheme (to be overloaded at runtime if color adapter present) */ |
static unsigned char SCHEME_TEXT = 0x07, |
SCHEME_MENU = 0x70, |
SCHEME_MENU_CUR= 0x0f, |
SCHEME_MENU_SEL= 0x00, |
SCHEME_STBAR1 = 0x70, |
SCHEME_STBAR2 = 0x70, |
SCHEME_STBAR3 = 0xf0, |
268,6 → 265,24 |
} |
static void ui_help(void) { |
#define MAXLINLEN 39 |
unsigned short i, offset; |
offset = (screenw - MAXLINLEN) >> 1; |
for (i = 3; i < 25; i++) { |
const char *s = svarlang_str(8, i); |
if (s[0] == 0) break; |
mdr_cout_char_rep(i, offset, ' ', SCHEME_STBAR1, MAXLINLEN); |
if (s[0] == '.') continue; |
mdr_cout_locate(i, offset + 2 + mdr_cout_str(i, offset + 2, s, SCHEME_STBAR1, MAXLINLEN - 2)); |
} |
keyb_getkey(); |
#undef MAXLINLEN |
} |
static void ui_refresh(const struct file *db) { |
unsigned char x; |
const struct line far *l; |
694,73 → 709,10 |
} |
enum MENU_ACTION { |
MENU_NONE = 0, |
MENU_NEW = 1, |
MENU_OPEN = 2, |
MENU_SAVE = 3, |
MENU_SAVEAS = 4, |
MENU_CHGEOL = 5, |
MENU_QUIT = 6 |
}; |
static enum MENU_ACTION ui_menu(void) { |
unsigned short i, curchoice, attr, x, slen; |
uidirty.from = 0; |
uidirty.to = 0xff; |
uidirty.statusbar = 1; |
/* find out the longest string */ |
slen = 0; |
for (i = MENU_NEW; i <= MENU_QUIT; i++) { |
x = strlen(svarlang_str(8, i)); |
if (x > slen) slen = x; |
} |
curchoice = MENU_NEW; |
for (;;) { |
/* render menu */ |
for (i = MENU_NONE; i <= MENU_QUIT + 1; i++) { |
mdr_cout_char_rep(i, 0, ' ', SCHEME_MENU, slen+4); |
if (i == curchoice) { |
attr = SCHEME_MENU_CUR; |
mdr_cout_char(i, 1, '>', SCHEME_MENU_SEL); |
} else { |
attr = SCHEME_MENU; |
} |
x = mdr_cout_str(i, 2, svarlang_str(8, i), attr, slen); |
if (i == curchoice) { |
mdr_cout_char_rep(i, x + 2, ' ', SCHEME_MENU_SEL, slen - x + 1); |
mdr_cout_locate(i, x + 2); |
} |
} |
/* wait for key */ |
switch (keyb_getkey()) { |
case '\r': return(curchoice); /* ENTER */ |
case 0x150: /* down */ |
if (curchoice == MENU_QUIT) { |
curchoice = MENU_NEW; |
} else { |
curchoice++; |
} |
break; |
case 0x148: /* up */ |
if (curchoice == MENU_NEW) { |
curchoice = MENU_QUIT; |
} else { |
curchoice--; |
} |
break; |
default: return(MENU_NONE); |
} |
} |
} |
/* main returns nothing, ie. sved always exits with a zero exit code |
* (this saves 20 bytes of executable footprint) */ |
void main(void) { |
static struct file dbarr[12]; |
static struct file dbarr[1]; |
const char *fname; |
struct file *db = dbarr; |
791,9 → 743,6 |
if (mdr_cout_init(&screenw, &screenh)) { |
/* load color scheme if mdr_cout_init returns a color flag */ |
SCHEME_TEXT = 0x17; |
SCHEME_MENU = 0x70; |
SCHEME_MENU_CUR = 0x2f; |
SCHEME_MENU_SEL = 0x22; |
SCHEME_STBAR1 = 0x70; |
SCHEME_STBAR2 = 0x78; |
SCHEME_STBAR3 = 0xf0; |
889,81 → 838,8 |
cursor_eol(db); |
} else if (k == 0x1B) { /* ESC */ |
int quitnow = 0; |
char fname[25]; |
int saveflag = 0; |
if (ui_confirm_if_unsaved(db) == 0) break; |
switch (ui_menu()) { |
case MENU_NONE: |
break; |
case MENU_NEW: |
if (ui_confirm_if_unsaved(db) == 0) { |
clear_file(db); |
/* add a single empty line */ |
line_add(db, NULL, 0); |
} |
uidirty.statusbar = 1; |
break; |
case MENU_OPEN: |
/* display a warning if unsaved changes are pending */ |
if (db->modflag != 0) ui_msg(svarlang_str(0,4), svarlang_str(0,8), SCHEME_MSG); |
/* ask for filename */ |
ui_getstring(svarlang_str(0,7), fname, sizeof(fname)); |
if (fname[0] != 0) { |
unsigned char err; |
clear_file(db); |
err = loadfile(db, fname); |
if (err != 0) { |
if (err == 1) { |
ui_msg(svarlang_str(0,11), NULL, SCHEME_ERR); /* file not found */ |
} else { |
ui_msg(svarlang_str(0,10), NULL, SCHEME_ERR); /* ERROR */ |
} |
mdr_bios_tickswait(44); /* 3s */ |
clear_file(db); |
} |
} |
break; |
case MENU_SAVEAS: |
saveflag = 1; |
/* FALLTHRU */ |
case MENU_SAVE: |
if ((saveflag != 0) || (db->fname[0] == 0)) { /* save as... */ |
ui_getstring(svarlang_str(0,6), fname, sizeof(fname)); |
if (*fname == 0) break; |
saveflag = savefile(db, fname); |
if (saveflag == 0) memcpy(db->fname, fname, sizeof(fname)); |
} else { |
saveflag = savefile(db, NULL); |
} |
if (saveflag == 0) { |
db->modflag = 0; |
ui_msg(svarlang_str(0, 2), NULL, SCHEME_MSG); |
mdr_bios_tickswait(11); /* 11 ticks is about 600 ms */ |
} else { |
ui_msg(svarlang_str(0, 3), NULL, SCHEME_ERR); |
mdr_bios_tickswait(36); /* 2s */ |
} |
break; |
case MENU_CHGEOL: |
db->modflag = '*'; |
db->lfonly ^= 1; |
break; |
case MENU_QUIT: |
if (ui_confirm_if_unsaved(db) == 0) quitnow = 1; |
break; |
} |
if (quitnow) break; |
} else if (k == 0x0D) { /* ENTER */ |
unsigned short off = db->xoffset + db->cursorposx; |
/* add a new line */ |
995,10 → 871,79 |
} else if (k == 0x009) { /* TAB */ |
insert_in_line(db, " ", 8); |
} else if ((k >= 0x13b) && (k <= 0x146)) { /* F1..F12 */ |
} else if (k == 0x13b) { /* F1 */ |
ui_help(); |
uidirty.from = 0; |
uidirty.to = 0xff; |
} else if (k == 0x13c) { /* F2 (new file) */ |
if (ui_confirm_if_unsaved(db) == 0) { |
clear_file(db); |
/* add a single empty line */ |
line_add(db, NULL, 0); |
} |
uidirty.from = 0; |
uidirty.to = 0xff; |
uidirty.statusbar = 1; |
} else if (k == 0x13d) { /* F3 (load file) */ |
char fname[25]; |
/* display a warning if unsaved changes are pending */ |
if (db->modflag != 0) ui_msg(svarlang_str(0,4), svarlang_str(0,8), SCHEME_MSG); |
/* ask for filename */ |
ui_getstring(svarlang_str(0,7), fname, sizeof(fname)); |
if (fname[0] != 0) { |
unsigned char err; |
clear_file(db); |
err = loadfile(db, fname); |
if (err != 0) { |
if (err == 1) { |
ui_msg(svarlang_str(0,11), NULL, SCHEME_ERR); /* file not found */ |
} else { |
ui_msg(svarlang_str(0,10), NULL, SCHEME_ERR); /* ERROR */ |
} |
mdr_bios_tickswait(44); /* 3s */ |
clear_file(db); |
} |
} |
uidirty.from = 0; |
uidirty.to = 0xff; |
uidirty.statusbar = 1; |
} else if ((k == 0x13f) || (k == 0x140)) { /* F5 or F6 */ |
int saveres; |
if ((k == 0x140) || (db->fname[0] == 0)) { /* save as... */ |
char fname[25]; |
ui_getstring(svarlang_str(0,6), fname, sizeof(fname)); |
if (*fname == 0) continue; |
saveres = savefile(db, fname); |
if (saveres == 0) memcpy(db->fname, fname, sizeof(fname)); |
} else { |
saveres = savefile(db, NULL); |
} |
if (saveres == 0) { |
db->modflag = 0; |
ui_msg(svarlang_str(0, 2), NULL, SCHEME_MSG); |
mdr_bios_tickswait(11); /* 11 ticks is about 600 ms */ |
} else { |
ui_msg(svarlang_str(0, 3), NULL, SCHEME_ERR); |
mdr_bios_tickswait(36); /* 2s */ |
} |
ui_refresh(db); |
uidirty.statusbar = 1; |
} else if (k == 0x144) { /* F10 */ |
db->modflag = '*'; |
db->lfonly ^= 1; |
uidirty.statusbar = 1; |
uidirty.from = 0; |
uidirty.to = 0; |
} else if (k == 0x174) { /* CTRL+ArrRight - jump to next word */ |
/* if currently cursor is on a non-space, then fast-forward to nearest space or EOL */ |
for (;;) { |
/sved/trunk/sved.lng |
---|
Cannot display: file marked as a binary type. |
svn:mime-type = application/octet-stream |
/sved/trunk/sved.txt |
---|
1,10 → 1,8 |
SVED, THE SVARDOS EDITOR |
Sved, the SvarDOS editor |
### WHAT IS IT ############################################################### |
Sved is the default editor that comes with SvarDOS. Sved is not meant to be a |
full-featured text editor, it is designed for basic editing of configuration |
files and such. On the pro side, Sved has a very low memory footprint and |
22,29 → 20,15 |
What Sved does NOT have: |
- stylish pull-down menus |
- mouse support |
- any integrated file browser |
- multiple files interface |
- copy/paste support |
- undo |
- search |
- ... |
### USAGE AND KEY BINDINGS ################################################### |
Navigation within the text file is achieved through the usual, standard keys: |
- up, down, right and left arrows |
- PageUp / PageDown |
- Home / End |
Jumping to previous or next word is possible with the CTRL+LEFT and CTRL+RIGHT |
combinations. |
Program's menu is accessible under the ESC key. |
### LICENSE ################################################################## |
Sved is released under the terms of the MIT license. |
Copyright (C) 2023 Mateusz Viste |
66,6 → 50,3 |
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
SOFTWARE. |
###################################################################### EOF ### |