various fixes

This commit is contained in:
Alexander S. Aganichev 2000-11-27 06:15:29 +00:00
parent 8ef102eff3
commit 2bce072dd1
18 changed files with 116 additions and 179 deletions

View File

@ -12,6 +12,24 @@ ______________________________________________________________________
Notes for GoldED+ 1.1.4.7, November xx 2000 Notes for GoldED+ 1.1.4.7, November xx 2000
______________________________________________________________________ ______________________________________________________________________
- It is now possible to use filepicker if there's very long filenames.
- Fixed filelist parser for national languages.
+ It is now possible to edit Group field in addressbook even though
there's no sence for this :-)
- Added workaround for inserting of random line into message.
- Fixed incorrect help category display after EDITHeader.
! Removed unused help entries from READMainmenu.
- Fixed memory overrun in file attach creation.
- Fixed insertion of extra spaces around Origin line if entry is taken
from file.
+ Logged version name now combined with release date (for easy sorting + Logged version name now combined with release date (for easy sorting
out the logs received). out the logs received).

View File

@ -2146,8 +2146,6 @@ int IEclass::Start(int __mode, uint* __position, GMsg* __msg) {
if(marginquotes > margintext) if(marginquotes > margintext)
marginquotes = margintext; marginquotes = margintext;
whelppcat(H_Editor);
if(currline == NULL) { if(currline == NULL) {
currline = new Line("\n"); currline = new Line("\n");
throw_xnew(currline); throw_xnew(currline);
@ -2266,7 +2264,6 @@ int IEclass::Start(int __mode, uint* __position, GMsg* __msg) {
msgptr->lin = findfirstline(); msgptr->lin = findfirstline();
savefile(quitnow ? MODE_UPDATE : MODE_SAVE); savefile(quitnow ? MODE_UPDATE : MODE_SAVE);
whelpop();
// Prune killbuffer // Prune killbuffer
if(Edit__killbuf) { if(Edit__killbuf) {
@ -2336,6 +2333,7 @@ UndoStack::~UndoStack() {
while(last_item) { while(last_item) {
switch(last_item->action & EDIT_UNDO_ACTION) { switch(last_item->action & EDIT_UNDO_ACTION) {
case EDIT_UNDO_DEL_TEXT: case EDIT_UNDO_DEL_TEXT:
case EDIT_UNDO_INS_TEXT:
case EDIT_UNDO_WRAP_TEXT: case EDIT_UNDO_WRAP_TEXT:
throw_delete(last_item->data.text_ptr); throw_delete(last_item->data.text_ptr);
break; break;

View File

@ -92,6 +92,7 @@ void IEclass::windowopen() {
gwin.style = STYLE_NOCLEAR; gwin.style = STYLE_NOCLEAR;
editwin.open(win_minrow, win_mincol, win_maxrow, win_maxcol, 5, C_READB, C_READW, C_READPB); editwin.open(win_minrow, win_mincol, win_maxrow, win_maxcol, 5, C_READB, C_READW, C_READPB);
gwin.style = _tmp; gwin.style = _tmp;
whelppcat(H_Editor);
} }
@ -99,6 +100,7 @@ void IEclass::windowopen() {
void IEclass::windowclose() { void IEclass::windowclose() {
whelpop();
// Close editor window without removing the window itself // Close editor window without removing the window itself
editwin.unlink(); editwin.unlink();
} }
@ -629,13 +631,15 @@ void IEclass::BlockDel(Line* anchor) {
// The firstcutline and lastcutline pointers // The firstcutline and lastcutline pointers
// are now pointing where they should // are now pointing where they should
Undo->PushItem(EDIT_UNDO_DEL_TEXT, firstcutline, firstcol);
if(firstcutline != lastcutline) { if(firstcutline != lastcutline) {
Undo->PushItem(EDIT_UNDO_DEL_TEXT, firstcutline, firstcol);
firstcutline->txt.erase(firstcol); firstcutline->txt.erase(firstcol);
firstcutline->txt += lastcutline->txt.c_str()+lastcol; firstcutline->txt += lastcutline->txt.c_str()+lastcol;
} }
else else {
Undo->PushItem(EDIT_UNDO_DEL_TEXT, firstcutline, firstcol, lastcol-firstcol);
firstcutline->txt.erase(firstcol, lastcol-firstcol); firstcutline->txt.erase(firstcol, lastcol-firstcol);
}
setlinetype(firstcutline); setlinetype(firstcutline);
firstcutline->type &= ~GLINE_BLOK; firstcutline->type &= ~GLINE_BLOK;
blockcol = -1; blockcol = -1;
@ -901,10 +905,10 @@ void IEclass::editimport(Line* __line, char* __filename, bool imptxt) {
ImportMode = MenuImportTxt.Run(); ImportMode = MenuImportTxt.Run();
} }
Path filenamebuf, tmpfile; string filenamebuf;
Path tmpfile;
bool isPipe = NO; bool isPipe = NO;
char* _filenameptr = filenamebuf; bool fileselected = false;
char* _selectedfile = NULL;
// Should the imported text be quoted or uuencoded? // Should the imported text be quoted or uuencoded?
#define quoteit (ImportMode == 1) #define quoteit (ImportMode == 1)
@ -918,79 +922,71 @@ void IEclass::editimport(Line* __line, char* __filename, bool imptxt) {
AA->SetInputfile(CFG->inputfile); AA->SetInputfile(CFG->inputfile);
// Pointer to the filename string // Pointer to the filename string
_filenameptr = strcpy(filenamebuf, AA->Inputfile()); filenamebuf = AA->Inputfile();
if(_filenameptr[0] == '|'){ if(filenamebuf.c_str()[0] == '|'){
Path cmdline; Path cmdline;
isPipe = YES; isPipe = YES;
mktemp(strcpy(tmpfile, AddPath(CFG->goldpath, "GIXXXXXX"))); mktemp(strxcpy(tmpfile, AddPath(CFG->goldpath, "GIXXXXXX"), sizeof(Path)));
strxmerge(cmdline, sizeof(Path), _filenameptr+1, " > ", tmpfile, NULL); strxmerge(cmdline, sizeof(Path), filenamebuf.c_str()+1, " > ", tmpfile, NULL);
ShellToDos(cmdline, "", NO, NO); ShellToDos(cmdline, "", NO, NO);
_selectedfile = _filenameptr = tmpfile; filenamebuf = tmpfile;
fileselected = true;
} else { } else {
// Check for wildcards // Check for wildcards
// Is the filename a directory? // Is the filename a directory?
if(is_dir(_filenameptr)) { if(is_dir(filenamebuf)) {
// Does the filename contain wildcards? // Does the filename contain wildcards?
if(not strpbrk(_filenameptr, "*?")) { if(not strpbrk(filenamebuf.c_str(), "*?")) {
// Add match-all wildcards // Add match-all wildcards
strcat(AddBackslash(_filenameptr), "*"); AddBackslash(filenamebuf);
filenamebuf += "*";
} }
} }
// Pointer to selected filename or NULL if no file is selected fileselected = true;
_selectedfile = _filenameptr;
// Does the filename contain wildcards? // Does the filename contain wildcards?
if(strpbrk(_filenameptr, "*?")) { if(strpbrk(filenamebuf.c_str(), "*?")) {
// Set selection window title and statusline // Set selection window title and statusline
set_title(LNG->ImportTitle, TCENTER, C_MENUT); set_title(LNG->ImportTitle, TCENTER, C_MENUT);
update_statuslinef(LNG->ImportStatus, _filenameptr); update_statuslinef(LNG->ImportStatus, filenamebuf.c_str());
// Copy filename with wildcards to a temp buffer
Path _filenamebuf;
strcpy(_filenamebuf, _filenameptr);
// Start the file picker // Start the file picker
_selectedfile = wpickfile( fileselected = wpickfile(win_minrow, win_mincol, win_maxrow, win_maxcol, W_BMENU, C_MENUB, C_MENUW, C_MENUS, NO, filenamebuf, maketitle);
win_minrow,
win_mincol,
win_maxrow,
win_maxcol,
W_BMENU,
C_MENUB,
C_MENUW,
C_MENUS,
NO,
_filenamebuf,
_filenameptr,
maketitle
);
// If a file was selected, copy the filename
if(_selectedfile)
strcpy(_filenameptr, _selectedfile);
} }
} }
} }
if(_selectedfile or getclip) { if(fileselected or getclip) {
// Open the file/clipboard // Open the file/clipboard
FILE* fp = NULL; FILE* fp = NULL;
gclipbrd clipbrd; gclipbrd clipbrd;
if(getclip) if(getclip)
_filenameptr = strcpy(filenamebuf, CLIP_NAME); filenamebuf = CLIP_NAME;
if(getclip ? clipbrd.openread() : if(getclip ? clipbrd.openread() :
(fp = fsopen(_filenameptr, binary ? "rb" : "rt", CFG->sharemode))!=NULL) { (fp = fsopen(filenamebuf.c_str(), binary ? "rb" : "rt", CFG->sharemode))!=NULL) {
update_statuslinef(LNG->ImportStatus, _filenameptr); if (isPipe)
filenamebuf = AA->Inputfile();
const char *imp_filename = (getclip or isPipe) ? filenamebuf.c_str() : CleanFilename(filenamebuf.c_str());
// we need to truncate filename to prevent unpredictable results
int delta = strlen(imp_filename) - margintext;
if(delta > 0) {
filenamebuf.erase(filenamebuf.length()-delta);
imp_filename = (getclip or isPipe) ? filenamebuf.c_str() : CleanFilename(filenamebuf.c_str());
}
update_statuslinef(LNG->ImportStatus, filenamebuf.c_str());
// Allocate paragraph read buffer // Allocate paragraph read buffer
char* _parabuf = (char*)throw_malloc(EDIT_PARABUFLEN); char* _parabuf = (char*)throw_malloc(EDIT_PARABUFLEN);
@ -1004,15 +1000,18 @@ void IEclass::editimport(Line* __line, char* __filename, bool imptxt) {
// Add import begin text, if any // Add import begin text, if any
if(*CFG->importbegin) { if(*CFG->importbegin) {
sprintf(_parabuf, "%s\n", CFG->importbegin); sprintf(_parabuf, "%s\n", CFG->importbegin);
strischg(_parabuf, "@file", getclip ? _filenameptr : isPipe ? AA->Inputfile() : CleanFilename(_filenameptr)); strischg(_parabuf, "@file", imp_filename);
_parabuf[margintext] = NUL; _parabuf[margintext] = NUL;
_parabuf[margintext-1] = '\n';
__line = insertlinebelow(__line, _parabuf); __line = insertlinebelow(__line, _parabuf);
setlinetype(__line); setlinetype(__line);
} }
if(uuencode) { if(uuencode) {
sprintf(_parabuf, "begin 644 %s\n", CleanFilename(_filenameptr)); sprintf(_parabuf, "begin 644 %s\n", imp_filename);
_parabuf[margintext] = NUL;
_parabuf[margintext-1] = '\n';
__line = insertlinebelow(__line, _parabuf); __line = insertlinebelow(__line, _parabuf);
setlinetype(__line); setlinetype(__line);
@ -1046,7 +1045,8 @@ void IEclass::editimport(Line* __line, char* __filename, bool imptxt) {
base64_engine b64; base64_engine b64;
sprintf(_parabuf, "Content-type: application/octet-stream; name=\"%s\"\n", CleanFilename(_filenameptr)); sprintf(_parabuf, "Content-type: application/octet-stream; name=\"%s\"\n", imp_filename);
strcpy(_parabuf+margintext-2, "\"\n");
__line = insertlinebelow(__line, _parabuf); __line = insertlinebelow(__line, _parabuf);
setlinetype(__line); setlinetype(__line);
sprintf(_parabuf, "Content-transfer-encoding: base64\n"); sprintf(_parabuf, "Content-transfer-encoding: base64\n");
@ -1162,8 +1162,9 @@ void IEclass::editimport(Line* __line, char* __filename, bool imptxt) {
// Add import end text, if any // Add import end text, if any
if(*CFG->importend or *CFG->importbegin) { if(*CFG->importend or *CFG->importbegin) {
sprintf(_parabuf, "%s\n", *CFG->importend ? CFG->importend : CFG->importbegin); sprintf(_parabuf, "%s\n", *CFG->importend ? CFG->importend : CFG->importbegin);
strischg(_parabuf, "@file", getclip ? _filenameptr : isPipe ? AA->Inputfile() : CleanFilename(_filenameptr)); strischg(_parabuf, "@file", imp_filename);
_parabuf[margintext] = NUL; _parabuf[margintext] = NUL;
_parabuf[margintext-1] = '\n';
__line = insertlinebelow(__line, _parabuf); __line = insertlinebelow(__line, _parabuf);
setlinetype(__line); setlinetype(__line);
} }
@ -1176,7 +1177,7 @@ void IEclass::editimport(Line* __line, char* __filename, bool imptxt) {
fclose(fp); fclose(fp);
} }
else { else {
w_infof(LNG->CouldNotOpen, _filenameptr); w_infof(LNG->CouldNotOpen, filenamebuf.c_str());
waitkeyt(10000); waitkeyt(10000);
w_info(NULL); w_info(NULL);
} }

View File

@ -32,10 +32,10 @@
// ------------------------------------------------------------------ // ------------------------------------------------------------------
char CFG__frqinvfilechars[40] = { "\"()+,.\\/:;<=>[]| \xff@" }; char CFG__frqinvfilechars[40] = { "\"()+,.\\/:;<=>[]| @" };
char CFG__frqskipwordchars[40] = { "0123456789-[" }; char CFG__frqskipwordchars[40] = { "0123456789-[" };
inline char* invalidfilechar(char ch) { return strchr(CFG__frqinvfilechars, ch); } inline bool invalidfilechar(char ch) { return not isascii(ch&0xff) or strchr(CFG__frqinvfilechars, ch); }
// ------------------------------------------------------------------ // ------------------------------------------------------------------
@ -574,18 +574,15 @@ static int frqchkdesc(char* desc) {
if(*desc == NUL) if(*desc == NUL)
strcpy(desc, " "); strcpy(desc, " ");
else { else {
while(*ptr) { while(*ptr and not isxalnum(*ptr))
if(isalnum(*ptr))
break;
ptr++; ptr++;
}
if(*ptr == NUL) { if(*ptr == NUL) {
*desc = NUL; *desc = NUL;
return true; return true;
} }
} }
ptr = desc + strlen(desc) - 1; ptr = desc + strlen(desc) - 1;
while(((*ptr < '!') or (*ptr > '\x7F')) and (ptr>desc)) while(not isascii(*ptr&0xff) and not isxalnum(*ptr) and (ptr>desc))
*ptr-- = NUL; *ptr-- = NUL;
return false; return false;
@ -607,11 +604,11 @@ static int frqgetfile(char* file, char* desc, char* filesize, const char* txt) {
if(not invalidfilechar(*ptr) and ((ptr - txt) > 1)) { if(not invalidfilechar(*ptr) and ((ptr - txt) > 1)) {
// Find end of extension // Find end of extension
while(*ptr and (*ptr != ' ')) while(*ptr and ((*ptr == '.') or not invalidfilechar(*ptr)))
ptr++; ptr++;
// Strip invalid chars from the end of the extension // Strip dots from the end of the extension
while(invalidfilechar(*(ptr-1))) while(*(ptr-1) == '.')
ptr--; ptr--;
// Copy the filename // Copy the filename

View File

@ -428,7 +428,7 @@ int EditHeaderinfo(int mode, GMsgHeaderView &view) {
ChgAttrs(false, msg); ChgAttrs(false, msg);
whelpcat(help); // whelppcat(help);
if(not hedit.dropped and not gkbd.quitall) { if(not hedit.dropped and not gkbd.quitall) {

View File

@ -529,6 +529,7 @@ int SelectFromFile(const char* file, char* selection, const char* title, const c
n = wpickstr(6, 0, 6+n+1, -1, W_BASK, C_ASKB, C_ASKW, C_ASKS, Listi, 0, title_shadow); n = wpickstr(6, 0, 6+n+1, -1, W_BASK, C_ASKB, C_ASKW, C_ASKS, Listi, 0, title_shadow);
if(n != -1) { if(n != -1) {
strcpy(selection, Listi[n]); strcpy(selection, Listi[n]);
strtrim(selection);
retval = true; retval = true;
} }
for(n=0; n<lines; n++) for(n=0; n<lines; n++)

View File

@ -997,9 +997,6 @@ int GMenuNavigate::Run() {
TAG_UTIL_LIST = (int)KK_ReadMessageList, TAG_UTIL_LIST = (int)KK_ReadMessageList,
TAG_UTIL_WRITE = (int)KK_ReadWriteMsg, TAG_UTIL_WRITE = (int)KK_ReadWriteMsg,
TAG_UTIL_FREQ = (int)KK_ReadFileRequest, TAG_UTIL_FREQ = (int)KK_ReadFileRequest,
TAG_HELP = 104,
TAG_HELP_GENERAL,
TAG_HELP_ABOUT,
TAG_SEPARATOR, TAG_SEPARATOR,
TAG_END TAG_END
}; };
@ -1047,12 +1044,6 @@ int GMenuNavigate::Run() {
Item(TAG_UTIL_WRITE, "W Write to disk/printer "); Item(TAG_UTIL_WRITE, "W Write to disk/printer ");
Item(TAG_UTIL_FREQ, "F File request "); Item(TAG_UTIL_FREQ, "F File request ");
End(); End();
Item(TAG_UTIL, "H Help ");
BeginPullDown();
Item(TAG_HELP_GENERAL, "G General ");
Item(TAG_SEPARATOR, "----------", M_NOSEL);
Item(TAG_HELP_ABOUT, "A About ");
End();
End(); End();
Start(); Start();
if((finaltag >= TAG_MAIN) and (finaltag < (TAG_END*10))) if((finaltag >= TAG_MAIN) and (finaltag < (TAG_END*10)))

View File

@ -107,7 +107,7 @@ void CheckSubject(GMsg* msg, char* subj) {
fspec = (FileSpec*)throw_realloc(fspec, (fspecs+1)*sizeof(FileSpec)); fspec = (FileSpec*)throw_realloc(fspec, (fspecs+1)*sizeof(FileSpec));
memset(fspec+fspecs, 0, sizeof(FileSpec)); memset(fspec+fspecs, 0, sizeof(FileSpec));
fspec[fspecs].files = 1; fspec[fspecs].files = 1;
strcpy(fspec[fspecs].path, ptr); strxcpy(fspec[fspecs].path, ptr, sizeof(Path));
specfiles++; specfiles++;
fspecs++; fspecs++;
} }
@ -120,9 +120,9 @@ void CheckSubject(GMsg* msg, char* subj) {
ISub buf; ISub buf;
if(strblank(subj)) { if(strblank(subj)) {
if(*CFG->attachpath) if(*CFG->attachpath)
strcpy(subj, CFG->attachpath); strxcpy(subj, CFG->attachpath, sizeof(ISub));
else else
strcpy(subj, CFG->goldpath); strxcpy(subj, CFG->goldpath, sizeof(ISub));
} }
strcpy(buf, subj); strcpy(buf, subj);
char* ptr = strtok(buf, " "); char* ptr = strtok(buf, " ");
@ -133,7 +133,7 @@ void CheckSubject(GMsg* msg, char* subj) {
fspec[fspecs].delsent = YES; fspec[fspecs].delsent = YES;
ptr++; ptr++;
} }
strcpy(fspec[fspecs].path, ptr); strxcpy(fspec[fspecs].path, ptr, sizeof(Path));
FileSelect(msg, LNG->AttachFiles, &fspec[fspecs]); FileSelect(msg, LNG->AttachFiles, &fspec[fspecs]);
specfiles += fspec[fspecs].files; specfiles += fspec[fspecs].files;
if(fspec[fspecs].files) if(fspec[fspecs].files)
@ -156,7 +156,7 @@ void CheckSubject(GMsg* msg, char* subj) {
else { else {
fspec = (FileSpec*)throw_realloc(fspec, (fspecs+1)*sizeof(FileSpec)); fspec = (FileSpec*)throw_realloc(fspec, (fspecs+1)*sizeof(FileSpec));
memset(fspec+fspecs, 0, sizeof(FileSpec)); memset(fspec+fspecs, 0, sizeof(FileSpec));
strcpy(fspec[fspecs].path, ptr); strxcpy(fspec[fspecs].path, ptr, sizeof(Path));
FileSelect(msg, LNG->UpdreqFiles, &fspec[fspecs]); FileSelect(msg, LNG->UpdreqFiles, &fspec[fspecs]);
specfiles += fspec[fspecs].files; specfiles += fspec[fspecs].files;
if(fspec[fspecs].files) if(fspec[fspecs].files)

View File

@ -45,11 +45,10 @@ char* GetRandomLine(char* __buf, size_t __bufsize, const char* __file) {
if(FiletimeCmp(__file, idxfile) > 0) if(FiletimeCmp(__file, idxfile) > 0)
idxexist = false; idxexist = false;
FILE* fpi = fsopen(idxfile, idxexist ? "rb" : "wb+", CFG->sharemode); // Create index if one was missing
if(fpi) { if(not idxexist) {
FILE* fpi = fsopen(idxfile, "wb+", CFG->sharemode);
// Create index if one was missing if(fpi) {
if(not idxexist) {
setvbuf(fp, NULL, _IOFBF, 32000); setvbuf(fp, NULL, _IOFBF, 32000);
setvbuf(fpi, NULL, _IOFBF, 16000); setvbuf(fpi, NULL, _IOFBF, 16000);
long fpos = 0; long fpos = 0;
@ -58,7 +57,12 @@ char* GetRandomLine(char* __buf, size_t __bufsize, const char* __file) {
fwrite(&fpos, sizeof(long), 1, fpi); fwrite(&fpos, sizeof(long), 1, fpi);
fpos += strlen(buf); fpos += strlen(buf);
} }
fclose(fpi);
} }
}
FILE* fpi = fsopen(idxfile, "rb", CFG->sharemode);
if(fpi) {
// Get random line if there is at least one // Get random line if there is at least one
int _lines = (int)(fsize(fpi)/sizeof(long)); int _lines = (int)(fsize(fpi)/sizeof(long));

View File

@ -635,7 +635,7 @@ void UUDecode(GMsg* msg) {
w_progress(MODE_UPDATE, C_INFOW, n+1, AA->Mark.Count(), LNG->Preparing); w_progress(MODE_UPDATE, C_INFOW, n+1, AA->Mark.Count(), LNG->Preparing);
AA->LoadMsg(msg, AA->Mark[n], 79); AA->LoadMsg(msg, AA->Mark[n], 79);
SaveLines(overwrite ? MODE_WRITE : MODE_APPEND, infile, msg); SaveLines(overwrite ? MODE_WRITE : MODE_APPEND, infile, msg);
} }
if(AA->Mark.Count()) if(AA->Mark.Count())
w_progress(MODE_QUIT, 0, 0, 0, NULL); w_progress(MODE_QUIT, 0, 0, 0, NULL);
} }

View File

@ -270,6 +270,7 @@ void addressbook_form::LoadForm() {
voicephone= entry.voicephone; voicephone= entry.voicephone;
faxphone = entry.faxphone; faxphone = entry.faxphone;
dataphone = entry.dataphone; dataphone = entry.dataphone;
group = entry.group;
snail1 = entry.snail1; snail1 = entry.snail1;
snail2 = entry.snail2; snail2 = entry.snail2;
snail3 = entry.snail3; snail3 = entry.snail3;
@ -295,6 +296,7 @@ void addressbook_form::SaveForm() {
strcpy(entry.voicephone, voicephone.c_str()); strcpy(entry.voicephone, voicephone.c_str());
strcpy(entry.faxphone, faxphone.c_str()); strcpy(entry.faxphone, faxphone.c_str());
strcpy(entry.dataphone, dataphone.c_str()); strcpy(entry.dataphone, dataphone.c_str());
entry.group = group.c_str()[0];
strcpy(entry.snail1, snail1.c_str()); strcpy(entry.snail1, snail1.c_str());
strcpy(entry.snail2, snail2.c_str()); strcpy(entry.snail2, snail2.c_str());
strcpy(entry.snail3, snail3.c_str()); strcpy(entry.snail3, snail3.c_str());
@ -373,10 +375,11 @@ bool guserbase::edit_entry(uint idx) {
form.add_field(addressbook_form::id_voicephone, 5, 13, 20, form.voicephone, sizeof(entry.voicephone)); form.add_field(addressbook_form::id_voicephone, 5, 13, 20, form.voicephone, sizeof(entry.voicephone));
form.add_field(addressbook_form::id_faxphone, 6, 13, 20, form.faxphone, sizeof(entry.faxphone)); form.add_field(addressbook_form::id_faxphone, 6, 13, 20, form.faxphone, sizeof(entry.faxphone));
form.add_field(addressbook_form::id_dataphone, 7, 13, 20, form.dataphone, sizeof(entry.dataphone)); form.add_field(addressbook_form::id_dataphone, 7, 13, 20, form.dataphone, sizeof(entry.dataphone));
form.add_field(addressbook_form::id_group, 8, 13, 20, form.group, sizeof(entry.group)+1);
form.add_field(addressbook_form::id_snail1, 5, 46, 26, form.snail1, sizeof(entry.snail1)); form.add_field(addressbook_form::id_snail1, 5, 46, 26, form.snail1, sizeof(entry.snail1));
form.add_field(addressbook_form::id_snail2, 6, 46, 26, form.snail2, sizeof(entry.snail2)); form.add_field(addressbook_form::id_snail2, 6, 46, 26, form.snail2, sizeof(entry.snail2));
form.add_field(addressbook_form::id_snail3, 7, 46, 26, form.snail3, sizeof(entry.snail3)); form.add_field(addressbook_form::id_snail3, 7, 46, 26, form.snail3, sizeof(entry.snail3));
form.add_field(addressbook_form::id_homepage , 8, 46, 26, form.homepage, sizeof(entry.homepage)); form.add_field(addressbook_form::id_homepage, 8, 46, 26, form.homepage, sizeof(entry.homepage));
form.add_field(addressbook_form::id_comment1, 9, 13, 59, form.comment1, sizeof(entry.comment1)); form.add_field(addressbook_form::id_comment1, 9, 13, 59, form.comment1, sizeof(entry.comment1));
form.add_field(addressbook_form::id_comment2, 10, 13, 59, form.comment2, sizeof(entry.comment2)); form.add_field(addressbook_form::id_comment2, 10, 13, 59, form.comment2, sizeof(entry.comment2));
form.add_field(addressbook_form::id_comment3, 11, 13, 59, form.comment3, sizeof(entry.comment3)); form.add_field(addressbook_form::id_comment3, 11, 13, 59, form.comment3, sizeof(entry.comment3));

View File

@ -98,6 +98,7 @@ class addressbook_form : public gwinput2 {
string voicephone; string voicephone;
string faxphone; string faxphone;
string homepage; string homepage;
string group;
string comment1; string comment1;
string comment2; string comment2;
string comment3; string comment3;

View File

@ -117,11 +117,12 @@ void update_statusline(const char* info) {
void update_statuslinef(const char* format, ...) { void update_statuslinef(const char* format, ...) {
char winfobuf[350];
va_list argptr; va_list argptr;
va_start(argptr, format); va_start(argptr, format);
vsprintf(information, format, argptr); vsprintf(winfobuf, format, argptr);
va_end(argptr); va_end(argptr);
update_statuslines(); update_statusline(winfobuf);
} }

View File

@ -51,8 +51,9 @@ inline char toupper(char c) { return tu[c]; }
// ------------------------------------------------------------------ // ------------------------------------------------------------------
inline int iswhite(char c) { return c < '!' and c; } inline int iswhite(char c) { return c and (iscntrl(c) or (c == ' ')); }
inline int isxalnum(char c) { return isalnum(c) or (c >= 128); } // 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)))); }
// ------------------------------------------------------------------ // ------------------------------------------------------------------

View File

@ -34,6 +34,7 @@
// ------------------------------------------------------------------ // ------------------------------------------------------------------
#include <gdefs.h> #include <gdefs.h>
#include <gstrall.h>
#include <gkbdbase.h> #include <gkbdbase.h>
#include <gvidall.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); 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); } 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); 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 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 wprintc (int wrow, int wcol, int attr, vchar ch);
int wprintf (const char* format, ...) __attribute__ ((format (printf, 1, 2))); int wprintf (const char* format, ...) __attribute__ ((format (printf, 1, 2)));

View File

@ -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; 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); getcwd(tcwd, GMAXPATH);
// if drive was specified, change to it // 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 // split up input filespec into its current
// working directory and filename/extension // 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(*dir) {
if(gchdir(dir)) { if(gchdir(dir)) {
pre_exit(p, 0); 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; const char* name = NULL;
if(de->is_directory()) { if(de->is_directory()) {
if(de->name != ".") { 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; 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); picked = wpickstr(srow, scol, erow, ecol, btype, bordattr, winattr, barattr, p, 0, disp_title);
if(picked == -1 or files == 0) { if(picked == -1 or files == 0) {
pre_exit(p, files); pre_exit(p, files);
return NULL; return false;
} }
// see if a directory was selected. if so save // 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 { else {
finished = true; finished = true;
PathCopy(path, cwd); PathCopy(filespec, cwd);
strcat(path, p[picked]); filespec += p[picked];
} }
// free allocated strings // free allocated strings
@ -248,8 +248,7 @@ char* wpickfile(int srow, int scol, int erow, int ecol, int btype, int bordattr,
throw_xfree(p); throw_xfree(p);
// return normally // return normally
strcpy(selectedfile, path); return true;
return selectedfile;
} }

View File

@ -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; r.wheight = (erow-border)-(srow+border)+1;
// make sure longest string can fit in window // make sure longest string can fit in window
if(r.maxstrlen > r.wwidth) { if(r.maxstrlen > r.wwidth)
gwin.werrno=W_STRLONG; r.maxstrlen = r.wwidth;
return -1;
}
// open window which strings will reside in // open window which strings will reside in
hide_mouse_cursor_pck(); hide_mouse_cursor_pck();

View File

@ -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
// ------------------------------------------------------------------