various fixes
This commit is contained in:
@@ -51,8 +51,9 @@ inline char toupper(char c) { return tu[c]; }
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
|
||||
inline int iswhite(char c) { return c < '!' and c; }
|
||||
inline int isxalnum(char c) { return isalnum(c) or (c >= 128); }
|
||||
inline int iswhite(char c) { return c and (iscntrl(c) or (c == ' ')); }
|
||||
// NLS chars detected by converting to lower or upper case and in case they don't match they treated as characters
|
||||
inline int isxalnum(char c) { return isalnum(c) or ((c >= 128) and ((c != tolower(c)) or (c != toupper(c)))); }
|
||||
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
|
@@ -34,6 +34,7 @@
|
||||
// ------------------------------------------------------------------
|
||||
|
||||
#include <gdefs.h>
|
||||
#include <gstrall.h>
|
||||
#include <gkbdbase.h>
|
||||
#include <gvidall.h>
|
||||
|
||||
@@ -368,7 +369,7 @@ int wmove (int nsrow, int nscol);
|
||||
int wopen (int srow, int scol, int erow, int ecol, int btype, int battr, int wattr, int sbattr=-1, int loattr=-1);
|
||||
inline int wopen_ (int srow, int scol, int vlen, int hlen, int btype, int battr, int wattr, int sbattr=-1, int loattr=-1) { return wopen(srow, scol, srow+vlen-1, scol+hlen-1, btype, battr, wattr, sbattr, loattr); }
|
||||
int wperror (const char* message);
|
||||
char* wpickfile (int srow, int scol, int erow, int ecol, int btype, int bordattr, int winattr, int barattr, bool title, const char* filespec, char* selectedfile, VfvCP open, bool casesens=false);
|
||||
bool wpickfile (int srow, int scol, int erow, int ecol, int btype, int bordattr, int winattr, int barattr, bool title, string &filespec, VfvCP open, bool casesens=false);
|
||||
int wpickstr (int srow, int scol, int erow, int ecol, int btype, int bordattr, int winattr, int barattr, char* strarr[], int initelem, VfvCP open);
|
||||
int wprintc (int wrow, int wcol, int attr, vchar ch);
|
||||
int wprintf (const char* format, ...) __attribute__ ((format (printf, 1, 2)));
|
||||
|
@@ -117,7 +117,7 @@ static void pre_exit(char** p, int numelems) {
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
|
||||
char* wpickfile(int srow, int scol, int erow, int ecol, int btype, int bordattr, int winattr, int barattr, bool title, const char* filespec, char* selectedfile, VfvCP open, bool casesens) {
|
||||
bool wpickfile(int srow, int scol, int erow, int ecol, int btype, int bordattr, int winattr, int barattr, bool title, string &filespec, VfvCP open, bool casesens) {
|
||||
|
||||
Path cwd, dir, namext, tcwd, path, spec;
|
||||
|
||||
@@ -138,7 +138,7 @@ char* wpickfile(int srow, int scol, int erow, int ecol, int btype, int bordattr,
|
||||
getcwd(tcwd, GMAXPATH);
|
||||
|
||||
// if drive was specified, change to it
|
||||
char* q = strcpy(spec, filespec);
|
||||
char* q = strxcpy(spec, filespec.c_str(), sizeof(Path));
|
||||
|
||||
// split up input filespec into its current
|
||||
// working directory and filename/extension
|
||||
@@ -168,7 +168,7 @@ char* wpickfile(int srow, int scol, int erow, int ecol, int btype, int bordattr,
|
||||
if(*dir) {
|
||||
if(gchdir(dir)) {
|
||||
pre_exit(p, 0);
|
||||
return NULL;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -187,7 +187,7 @@ char* wpickfile(int srow, int scol, int erow, int ecol, int btype, int bordattr,
|
||||
const char* name = NULL;
|
||||
if(de->is_directory()) {
|
||||
if(de->name != ".") {
|
||||
strcpy(stpcpy(path, de->name.c_str()), GOLD_SLASH_STR);
|
||||
strxmerge(path, sizeof(Path), de->name.c_str(), GOLD_SLASH_STR, NULL);
|
||||
name = path;
|
||||
}
|
||||
}
|
||||
@@ -215,7 +215,7 @@ char* wpickfile(int srow, int scol, int erow, int ecol, int btype, int bordattr,
|
||||
picked = wpickstr(srow, scol, erow, ecol, btype, bordattr, winattr, barattr, p, 0, disp_title);
|
||||
if(picked == -1 or files == 0) {
|
||||
pre_exit(p, files);
|
||||
return NULL;
|
||||
return false;
|
||||
}
|
||||
|
||||
// see if a directory was selected. if so save
|
||||
@@ -231,8 +231,8 @@ char* wpickfile(int srow, int scol, int erow, int ecol, int btype, int bordattr,
|
||||
}
|
||||
else {
|
||||
finished = true;
|
||||
PathCopy(path, cwd);
|
||||
strcat(path, p[picked]);
|
||||
PathCopy(filespec, cwd);
|
||||
filespec += p[picked];
|
||||
}
|
||||
|
||||
// free allocated strings
|
||||
@@ -248,8 +248,7 @@ char* wpickfile(int srow, int scol, int erow, int ecol, int btype, int bordattr,
|
||||
throw_xfree(p);
|
||||
|
||||
// return normally
|
||||
strcpy(selectedfile, path);
|
||||
return selectedfile;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
@@ -435,10 +435,8 @@ int wpickstr(int srow, int scol, int erow, int ecol, int btype, int bordattr, in
|
||||
r.wheight = (erow-border)-(srow+border)+1;
|
||||
|
||||
// make sure longest string can fit in window
|
||||
if(r.maxstrlen > r.wwidth) {
|
||||
gwin.werrno=W_STRLONG;
|
||||
return -1;
|
||||
}
|
||||
if(r.maxstrlen > r.wwidth)
|
||||
r.maxstrlen = r.wwidth;
|
||||
|
||||
// open window which strings will reside in
|
||||
hide_mouse_cursor_pck();
|
||||
|
@@ -1092,80 +1092,3 @@ bool gwinput2::run(int helpcat) {
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
|
||||
#if defined(TESTMAIN)
|
||||
|
||||
void main() {
|
||||
|
||||
enum {
|
||||
FIELD_A,
|
||||
FIELD_B,
|
||||
FIELD_C,
|
||||
FIELD_D,
|
||||
FIELD_E
|
||||
};
|
||||
|
||||
gwindow w;
|
||||
|
||||
w.open(0, 0, gvid->numrows-1, gvid->numcols-1, 5, YELLOW|_LGREY, BLUE|_LGREY);
|
||||
|
||||
w.horizontal_line(0, 0, w.width(), 0, YELLOW|_LGREY);
|
||||
w.horizontal_line(5, 0, w.width(), 0, YELLOW|_LGREY);
|
||||
|
||||
w.prints(1, 0, BLUE|_LGREY, " Msg : 117 of 123");
|
||||
w.prints(2, 0, BLUE|_LGREY, " From : ");
|
||||
w.prints(3, 0, BLUE|_LGREY, " To : ");
|
||||
w.prints(4, 0, BLUE|_LGREY, " Subj : ");
|
||||
|
||||
gwinput* i = new gwinput(w);
|
||||
|
||||
char str_a[128] = { "Odinn Sorensen" };
|
||||
char str_b[128] = { "2:236/77" };
|
||||
char str_c[128] = { "Who Knows" };
|
||||
char str_d[128] = { "2:236/77.123" };
|
||||
char str_e[128] = { "Testing my new input class" };
|
||||
|
||||
i->idle_attr = BLUE|_LGREY;
|
||||
i->active_attr = BLACK|_LGREY;
|
||||
i->edit_attr = RED|_LGREY;
|
||||
|
||||
i->active_fill = '\xB0';
|
||||
i->edit_fill = '\xB0';
|
||||
i->fill_acs = true;
|
||||
|
||||
i->add_field(FIELD_A, 2, 8, 35, str_a, 127);
|
||||
i->add_field(FIELD_B, 2, 44, 16, str_b, 127);
|
||||
i->add_field(FIELD_C, 3, 8, 35, str_c, 127);
|
||||
i->add_field(FIELD_D, 3, 44, 16, str_d, 127);
|
||||
i->add_field(FIELD_E, 4, 8, 71, str_e, 127);
|
||||
|
||||
i->start_id = FIELD_E;
|
||||
|
||||
i->prepare_form();
|
||||
|
||||
gkey key = 0;
|
||||
do {
|
||||
|
||||
{
|
||||
// DEBUG
|
||||
char buf[256];
|
||||
sprintf(buf, "bp:%i blp:%i", i->current->buf_pos, i->current->buf_left_pos);
|
||||
wprintfs(gvid->numrows-1, 0, WHITE|_BLUE, " %-*s ", gvid->numcols-2, buf);
|
||||
}
|
||||
|
||||
key = getxch();
|
||||
} while(i->handle_key(key));
|
||||
|
||||
i->finish_form();
|
||||
|
||||
delete i;
|
||||
|
||||
window.close();
|
||||
|
||||
gvid->restore_cursor();
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
|
||||
|
Reference in New Issue
Block a user