Subversion Repositories SvarDOS

Compare Revisions

Ignore whitespace Rev 1354 → Rev 1355

/sved/trunk/deflang.c
1,8 → 1,8
/* THIS FILE HAS BEEN GENERATED BY TLUMACZ (PART OF THE SVARLANG LIBRARY) */
const unsigned short svarlang_memsz = 244u;
const unsigned short svarlang_memsz = 232u;
const unsigned short svarlang_string_count = 18u;
 
char svarlang_mem[244] = {
char svarlang_mem[232] = {
0x45,0x53,0x43,0x3d,0x4d,0x45,0x4e,0x55,0x00,
0x4e,0x45,0x57,0x20,0x46,0x49,0x4c,0x45,0x00,
0x53,0x41,0x56,0x45,0x44,0x00,
19,12 → 19,11
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,
0x43,0x6c,0x6f,0x73,0x65,0x00,
0x43,0x68,0x61,0x6e,0x67,0x65,0x20,0x45,0x4f,0x4c,0x00,
0x51,0x75,0x69,0x74,0x00
};
 
42,9 → 41,9
0x000b,0x0086,
0x0100,0x0095,
0x0801,0x00ac,
0x0802,0x00b5,
0x0803,0x00bf,
0x0804,0x00c4,
0x0805,0x00cf,
0x0806,0x00e3
0x0802,0x00b6,
0x0803,0x00bb,
0x0804,0x00c6,
0x0805,0x00cc,
0x0806,0x00d7
};
/sved/trunk/nls/en_utf8.txt
28,9 → 28,9
# HELP SCREEN #
###############
 
8.1:New file
8.2:Open file
8.3:Save
8.4:Save as...
8.5:Change line endings
8.1:Open file
8.2:Save
8.3:Save as...
8.4:Close
8.5:Change EOL
8.6:Quit
/sved/trunk/sved.c
77,6 → 77,7
unsigned short curline;
char lfonly; /* set if line endings are LF (CR/LF otherwise) */
char modflag; /* non-zero if file has been modified since last save */
char modflagprev;
char fname[128];
};
 
208,18 → 209,29
}
 
 
static void ui_basic(const struct file *db) {
static void ui_basic(const struct file *db, unsigned short slotnum) {
const char *s = svarlang_strid(0); /* HELP */
unsigned short helpcol = screenw - strlen(s);
 
/* fill status bar with background (without modflag as it is refreshed by ui_refresh) */
mdr_cout_char_rep(screenh - 1, 1, ' ', SCHEME_STBAR1, screenw - 1);
/* slot number */
{
char slot[4] = "#00";
slotnum++;
slot[1] += (slotnum / 10);
slot[2] += (slotnum % 10);
mdr_cout_str(screenh - 1, 0, slot, SCHEME_STBAR2, 3);
}
 
/* fill rest of status bar with background */
mdr_cout_char_rep(screenh - 1, 3, ' ', SCHEME_STBAR1, screenw - 1);
 
/* filename */
{
const char *fn = db->fname;
unsigned short x;
if (*fn == 0) fn = svarlang_str(0, 1);
mdr_cout_str(screenh - 1, 1, fn, SCHEME_STBAR1, screenw);
x = mdr_cout_str(screenh - 1, 4, fn, SCHEME_STBAR1, screenw);
if (db->modflag) mdr_cout_char(screenh - 1, 5 + x, '*', SCHEME_STBAR1);
}
 
/* eol type */
258,13 → 270,18
 
 
static unsigned char ui_confirm_if_unsaved(struct file *db) {
unsigned char r = 0;
if (db->modflag == 0) return(0);
 
mdr_cout_cursor_hide();
 
/* if file has been modified then ask for confirmation */
ui_msg(svarlang_str(0,4), svarlang_str(0,5), SCHEME_MSG);
if (keyb_getkey() == '\r') return(0);
if (keyb_getkey() != '\r') r = 1;
 
return(1);
mdr_cout_cursor_show();
 
return(r);
}
 
 
317,9 → 334,6
}
}
 
/* "file changed" flag */
mdr_cout_char(screenh - 1, 0, db->modflag, SCHEME_STBAR1);
 
/* scroll bar */
for (y = 0; y < (screenh - 1); y++) {
mdr_cout_char(y, screenw - 1, SCROLL_CURSOR, SCHEME_SCROLL);
519,11 → 533,22
int fd;
unsigned char eolfound;
 
bzero(db, sizeof(db));
memcpy(db->fname, fname, strlen(fname));
/* free the entire linked list of lines */
db_rewind(db);
while (db->cursor) {
struct line far *victim;
victim = db->cursor;
db->cursor = db->cursor->next;
line_free(victim);
}
 
/* zero out the struct */
bzero(db, sizeof(struct file));
 
if (*fname == 0) goto SKIPLOADING;
 
memcpy(db->fname, fname, strlen(fname));
 
if (_dos_open(fname, O_RDONLY, &fd) != 0) {
return(1);
}
666,22 → 691,6
}
 
 
static void clear_file(struct file *db) {
 
/* free the entire linked list of lines */
db_rewind(db);
while (db->cursor) {
struct line far *victim;
victim = db->cursor;
db->cursor = db->cursor->next;
line_free(victim);
}
 
/* zero out the struct */
bzero(db, sizeof(struct file));
}
 
 
/* recompute db->curline by counting nodes in linked list */
static void recompute_curline(struct file *db) {
const struct line far *l = db->cursor;
696,10 → 705,10
 
enum MENU_ACTION {
MENU_NONE = 0,
MENU_NEW = 1,
MENU_OPEN = 2,
MENU_SAVE = 3,
MENU_SAVEAS = 4,
MENU_OPEN = 1,
MENU_SAVE = 2,
MENU_SAVEAS = 3,
MENU_CLOSE = 4,
MENU_CHGEOL = 5,
MENU_QUIT = 6
};
712,12 → 721,12
 
/* find out the longest string */
slen = 0;
for (i = MENU_NEW; i <= MENU_QUIT; i++) {
for (i = MENU_OPEN; i <= MENU_QUIT; i++) {
x = strlen(svarlang_str(8, i));
if (x > slen) slen = x;
}
 
curchoice = MENU_NEW;
curchoice = MENU_OPEN;
for (;;) {
/* render menu */
for (i = MENU_NONE; i <= MENU_QUIT + 1; i++) {
739,13 → 748,13
case '\r': return(curchoice); /* ENTER */
case 0x150: /* down */
if (curchoice == MENU_QUIT) {
curchoice = MENU_NEW;
curchoice = MENU_OPEN;
} else {
curchoice++;
}
break;
case 0x148: /* up */
if (curchoice == MENU_NEW) {
if (curchoice == MENU_OPEN) {
curchoice = MENU_QUIT;
} else {
curchoice--;
757,12 → 766,25
}
 
 
static struct file *select_slot(struct file *dbarr, unsigned short curfile) {
uidirty.from = 0;
uidirty.to = 0xff;
uidirty.statusbar = 1;
 
dbarr = &(dbarr[curfile]);
ui_basic(dbarr, curfile);
ui_refresh(dbarr);
return(dbarr);
}
 
 
/* 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[10];
const char *fname;
struct file *db = dbarr;
unsigned short curfile;
struct file *db = dbarr; /* visible file is the first slot by default */
 
{
char nlspath[128], lang[8];
776,8 → 798,14
return;
}
 
/* load file */
{
/* preload all slots with empty files */
for (curfile = 9;; curfile--) {
loadfile(&(dbarr[curfile]), "");
if (curfile == 0) break;
}
 
/* load file, if any given */
if (*fname != 0) {
unsigned char err = loadfile(db, fname);
if (err == 1) {
mdr_coutraw_puts(svarlang_str(0,11)); /* file not found */
812,9 → 840,10
ui_refresh(db);
uidirty.from = 0xff;
}
if (uidirty.statusbar) {
ui_basic(db);
if ((uidirty.statusbar != 0) || (db->modflagprev != db->modflag)) {
ui_basic(db, curfile);
uidirty.statusbar = 0;
db->modflagprev = db->modflag;
}
#ifdef DBG_LINENUM
{
898,15 → 927,6
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);
915,7 → 935,6
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) {
924,7 → 943,7
ui_msg(svarlang_str(0,10), NULL, SCHEME_ERR); /* ERROR */
}
mdr_bios_tickswait(44); /* 3s */
clear_file(db);
loadfile(db, "");
}
}
break;
952,6 → 971,15
}
break;
 
case MENU_CLOSE:
if (ui_confirm_if_unsaved(db) == 0) {
loadfile(db, "");
}
uidirty.from = 0;
uidirty.to = 0xff;
uidirty.statusbar = 1;
break;
 
case MENU_CHGEOL:
db->modflag = '*';
db->lfonly ^= 1;
958,7 → 986,13
break;
 
case MENU_QUIT:
if (ui_confirm_if_unsaved(db) == 0) quitnow = 1;
quitnow = 1;
for (curfile = 0; curfile < 10; curfile++) {
if (dbarr[curfile].modflag) {
db = select_slot(dbarr, curfile);
if (ui_confirm_if_unsaved(db) != 0) quitnow = 0;
}
}
break;
}
 
995,9 → 1029,9
} else if (k == 0x009) { /* TAB */
insert_in_line(db, " ", 8);
 
} else if ((k >= 0x13b) && (k <= 0x146)) { /* F1..F12 */
uidirty.from = 0;
uidirty.to = 0xff;
} else if ((k >= 0x13b) && (k <= 0x144)) { /* F1..F10 */
curfile = k - 0x13b;
db = select_slot(dbarr, curfile);
 
} 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 */
/sved/trunk/sved.lng
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/sved/trunk/sved.txt
18,6 → 18,7
- low disk footprint (8 KiB)
- loads files larger than 64 KiB
- no limit on line lengths
- can load up to 10 files simulteanously
- handles CR/LF and LF line endings (+can convert between the two)
 
What Sved does NOT have:
42,7 → 43,10
 
Program's menu is accessible under the ESC key.
 
Sved can load up to 10 files simulteanously. To switch from one file to
another use the F1..F10 function keys (F1 = slot 1, F2 = slot 2, etc).
 
 
### LICENSE ##################################################################
 
Sved is released under the terms of the MIT license.