Refactoring. Added URLSCHEME config keyword (not active yet).
This commit is contained in:
@@ -386,6 +386,7 @@ const word CRC_TWITSUBJ = 0x08C0;
|
||||
const word CRC_TWITTO = 0x9DFE;
|
||||
const word CRC_UNPACKER = 0x5691;
|
||||
const word CRC_URLHANDLER = 0x688E;
|
||||
const word CRC_URLSCHEME = 0x89FC;
|
||||
const word CRC_USEAREA = 0x2FD4;
|
||||
const word CRC_USECHARSET = 0xE1B9;
|
||||
const word CRC_USEFLAGS = 0xE2B6;
|
||||
|
@@ -588,6 +588,7 @@ SwitchU:
|
||||
switch(crc) {
|
||||
case CRC_UNPACKER : CfgUnpacker (); break;
|
||||
case CRC_URLHANDLER : CfgUrlhandler (); break;
|
||||
case CRC_URLSCHEME : CfgUrlscheme (); break;
|
||||
case CRC_USEAREA : CfgUsearea (); break;
|
||||
case CRC_USECHARSET : CfgUsecharset (); break;
|
||||
case CRC_USEFWD : CfgUsefwd (); break;
|
||||
|
@@ -41,7 +41,7 @@ void CfgExcludenodes() {
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
|
||||
|
||||
void CfgExternoptions() {
|
||||
|
||||
const word CRC_CLS = 0x34F4;
|
||||
@@ -64,7 +64,7 @@ void CfgExternoptions() {
|
||||
|
||||
if(*val == '-')
|
||||
val++;
|
||||
|
||||
|
||||
char* _key;
|
||||
word _crc = getkeyvalcrc(&_key, &val);
|
||||
|
||||
@@ -119,8 +119,8 @@ void CfgExternoptions() {
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
|
||||
void CfgExternutil() {
|
||||
|
||||
void CfgExternutil()
|
||||
{
|
||||
ExtUtil extutil;
|
||||
|
||||
// Get util number
|
||||
@@ -131,16 +131,18 @@ void CfgExternutil() {
|
||||
|
||||
// Get options
|
||||
int _optbak = CFG->externoptions;
|
||||
while(strchr("-", *_val)) {
|
||||
|
||||
while(strchr("-", *_val))
|
||||
{
|
||||
getkeyval(&_key, &_val);
|
||||
val = _key;
|
||||
CfgExternoptions();
|
||||
}
|
||||
|
||||
extutil.options = CFG->externoptions;
|
||||
CFG->externoptions = _optbak;
|
||||
|
||||
// Get commandline
|
||||
strxcpy(extutil.cmdline, _val, sizeof(extutil.cmdline));
|
||||
extutil.cmdline = _val; // Get commandline
|
||||
|
||||
// Count it
|
||||
CFG->externutil.push_back(extutil);
|
||||
@@ -293,14 +295,14 @@ void CfgGedhandshake() {
|
||||
|
||||
CFG->gedhandshake = make_bool(GetYesno(val));
|
||||
}
|
||||
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
|
||||
void CfgGermankeyboard() {
|
||||
|
||||
right_alt_same_as_left = not GetYesno(val);
|
||||
}
|
||||
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
|
||||
void CfgGoldbasepath(const char *path, bool force) {
|
||||
@@ -369,4 +371,3 @@ void CfgGroup() {
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
|
||||
|
@@ -329,24 +329,34 @@ void CfgUnpacker() {
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
|
||||
void CfgUrlhandler() {
|
||||
|
||||
void CfgUrlhandler()
|
||||
{
|
||||
// Get util number
|
||||
char* _key;
|
||||
char* _val = val;
|
||||
|
||||
// Get options
|
||||
int _optbak = CFG->externoptions;
|
||||
while(strchr("-", *_val)) {
|
||||
|
||||
while (strchr("-", *_val))
|
||||
{
|
||||
getkeyval(&_key, &_val);
|
||||
val = _key;
|
||||
CfgExternoptions();
|
||||
}
|
||||
CFG->urlhandler.options = CFG->externoptions;
|
||||
|
||||
UrlHandler url;
|
||||
url.handler.cmdline = _val;
|
||||
url.handler.options = CFG->externoptions;
|
||||
CFG->externoptions = _optbak;
|
||||
|
||||
// Get commandline
|
||||
strxcpy(CFG->urlhandler.cmdline, _val, sizeof(CFG->urlhandler.cmdline));
|
||||
CFG->urlhandler.push_back(url);
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
|
||||
void CfgUrlscheme()
|
||||
{
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
|
@@ -366,6 +366,7 @@ void CfgTwitsubj ();
|
||||
void CfgTwitto ();
|
||||
void CfgUnpacker ();
|
||||
void CfgUrlhandler ();
|
||||
void CfgUrlscheme ();
|
||||
void CfgUsearea ();
|
||||
void CfgUsecharset ();
|
||||
void CfgUseflags ();
|
||||
|
@@ -302,7 +302,7 @@ public:
|
||||
uint disptabsize; // tabsize;
|
||||
bool encodeemailheaders;
|
||||
std::vector<GEvent> event;
|
||||
int externoptions;
|
||||
uint32_t externoptions;
|
||||
std::vector<ExtUtil> externutil;
|
||||
Ezycom ezycom;
|
||||
int ezycomuserno;
|
||||
@@ -451,7 +451,7 @@ public:
|
||||
std::vector<Node> twitname;
|
||||
gstrarray twitsubj;
|
||||
std::vector< std::pair<std::string, std::string> > unpacker;
|
||||
ExtUtil urlhandler;
|
||||
std::vector<UrlHandler> urlhandler;
|
||||
bool usearea;
|
||||
bool usecharset;
|
||||
int usefwd;
|
||||
|
@@ -25,6 +25,7 @@
|
||||
// ------------------------------------------------------------------
|
||||
|
||||
#include <fcntl.h>
|
||||
#include <algorithm>
|
||||
#include <golded.h>
|
||||
#include <gwildmat.h>
|
||||
#include <gdirposx.h>
|
||||
@@ -622,9 +623,9 @@ void CreateFileMsgs(int mode, GMsg* msg) {
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
|
||||
static int FreqCmp(const char** a, const char** b) {
|
||||
|
||||
return stricmp(*a, *b);
|
||||
static bool FreqCmp(const std::string &a, const std::string &b)
|
||||
{
|
||||
return (stricmp(a.c_str(), b.c_str()) < 0);
|
||||
}
|
||||
|
||||
|
||||
@@ -722,27 +723,25 @@ static int frqgetfile(char* file, char* desc, char* filesize, const char* txt) {
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
|
||||
void FileRequest(GMsg* msg) {
|
||||
|
||||
void FileRequest(GMsg* msg)
|
||||
{
|
||||
GFTRK("FileRequest");
|
||||
|
||||
int oldtopline = reader_topline;
|
||||
|
||||
if(AA->Msgn.Count() and msg->line and msg->lines) {
|
||||
|
||||
if (AA->Msgn.Count() and msg->line and msg->lines)
|
||||
{
|
||||
gstrarray freqfile;
|
||||
char buf[256];
|
||||
const char* ptr;
|
||||
const char* ptr1 = NULL;
|
||||
const char* ptr2;
|
||||
const char* txtptr;
|
||||
char** freqfile = NULL;
|
||||
int gotticket = false;
|
||||
int getnextdesc = false;
|
||||
Line** lin = msg->line;
|
||||
char file[GMAXPATH], desc[200], filesize[10];
|
||||
int freqfiles = 0;
|
||||
bool esc = true;
|
||||
int n;
|
||||
byte numlines = 0;
|
||||
|
||||
*desc = *file = *filesize = NUL;
|
||||
@@ -753,8 +752,9 @@ void FileRequest(GMsg* msg) {
|
||||
int tline = reader_topline;
|
||||
if(CFG->frqoptions & FREQ_FROMTOP)
|
||||
tline = 0;
|
||||
for(n=tline; n<msg->lines; n++) {
|
||||
|
||||
for (size_t n = tline; n < msg->lines; n++)
|
||||
{
|
||||
// Don't look in control info for files
|
||||
if(lin[n]->type & (GLINE_KLUDGE|GLINE_TEAR|GLINE_ORIG))
|
||||
continue;
|
||||
@@ -895,13 +895,11 @@ void FileRequest(GMsg* msg) {
|
||||
if (*file and *desc)
|
||||
{
|
||||
// Yes, so add it to the list
|
||||
freqfile = (char**)throw_realloc(freqfile, (freqfiles+3)*sizeof(char*));
|
||||
gsprintf(PRINTF_DECLARE_BUFFER(buf), " %-12s %8s %s", file, filesize, desc);
|
||||
strsetsz(buf, 76);
|
||||
freqfile[freqfiles] = throw_strdup(buf);
|
||||
freqfile.push_back(buf);
|
||||
*desc = *file = *filesize = NUL;
|
||||
numlines = 0;
|
||||
freqfiles++;
|
||||
}
|
||||
|
||||
// Maybe there was a false match, so re-initialize if
|
||||
@@ -919,27 +917,24 @@ void FileRequest(GMsg* msg) {
|
||||
{
|
||||
strcpy(file, "FILES");
|
||||
gsprintf(PRINTF_DECLARE_BUFFER(desc), LNG->FilelistFrom, msg->By());
|
||||
freqfile = (char**)throw_realloc(freqfile, (freqfiles+3)*sizeof(char*));
|
||||
gsprintf(PRINTF_DECLARE_BUFFER(buf), " %-12.12s %-52.52s ", file, desc);
|
||||
freqfile[freqfiles] = throw_strdup(buf);
|
||||
freqfile.push_back(buf);
|
||||
*desc = *file = NUL;
|
||||
freqfiles++;
|
||||
}
|
||||
|
||||
w_info(NULL);
|
||||
|
||||
// Let user select the file(s) to be requested
|
||||
if(freqfile) {
|
||||
|
||||
// NULL terminate list
|
||||
freqfile[freqfiles] = NULL;
|
||||
|
||||
if (freqfile.size())
|
||||
{
|
||||
// Sort list if requested
|
||||
if(CFG->frqoptions & FREQ_SORT)
|
||||
qsort(freqfile, freqfiles, sizeof(char*), (StdCmpCP)FreqCmp);
|
||||
if (CFG->frqoptions & FREQ_SORT)
|
||||
{
|
||||
sort(freqfile.begin(), freqfile.end(), FreqCmp);
|
||||
}
|
||||
|
||||
// Run the picker
|
||||
int items = MinV(freqfiles, (MAXROW-10));
|
||||
int items = MinV(freqfile.size(), MAXROW-10);
|
||||
set_title(LNG->FreqMenuTitle, TCENTER, C_ASKT);
|
||||
update_statusline(LNG->FreqStat);
|
||||
whelppcat(H_FileRequest);
|
||||
@@ -963,10 +958,16 @@ void FileRequest(GMsg* msg) {
|
||||
|
||||
// Handle picked files
|
||||
msg->re[0] = NUL;
|
||||
for(n=0; n<freqfiles; n++) {
|
||||
if(*freqfile[n] != ' ') {
|
||||
|
||||
gstrarray::iterator it = freqfile.begin();
|
||||
gstrarray::iterator end = freqfile.end();
|
||||
|
||||
for (; it != end; it++)
|
||||
{
|
||||
if((*it)[0] != ' ')
|
||||
{
|
||||
msg->attr.frq1();
|
||||
ptr = freqfile[n]+1; // 01234567890123456
|
||||
ptr = &(*it)[1]; // 01234567890123456
|
||||
ptr2 = strskip_txt(ptr);
|
||||
#if defined(__USE_ALLOCA__)
|
||||
char *tmpbuf = (char*)alloca(ptr2-ptr+1);
|
||||
@@ -987,10 +988,12 @@ void FileRequest(GMsg* msg) {
|
||||
}
|
||||
}
|
||||
}
|
||||
if(freqs == 0) {
|
||||
|
||||
if (freqs == 0)
|
||||
{
|
||||
// AARRRGGGHH!! More bloody duplicate code :-((
|
||||
msg->attr.frq1();
|
||||
ptr = freqfile[crsr]+1; // 01234567890123456
|
||||
ptr = &freqfile[crsr][1]; // 01234567890123456
|
||||
ptr2 = strskip_txt(ptr);
|
||||
#if defined(__USE_ALLOCA__)
|
||||
char *tmpbuf = (char*)alloca(ptr2-ptr+1);
|
||||
@@ -1033,8 +1036,10 @@ void FileRequest(GMsg* msg) {
|
||||
int destarea = CurrArea;
|
||||
reader_topline = 0;
|
||||
AA->attr().hex0();
|
||||
if(*AA->Areafreqto()) {
|
||||
for(n=0; (uint) n<AL.size(); n++) {
|
||||
if (*AA->Areafreqto())
|
||||
{
|
||||
for (size_t n = 0; n < AL.size(); n++)
|
||||
{
|
||||
if(strieql(AL[n]->echoid(), AA->Areafreqto())) {
|
||||
destarea = AL[n]->areaid();
|
||||
break;
|
||||
@@ -1065,12 +1070,6 @@ void FileRequest(GMsg* msg) {
|
||||
}
|
||||
}
|
||||
|
||||
if(freqfile) {
|
||||
for(n=0; n<freqfiles; n++)
|
||||
throw_release(freqfile[n]);
|
||||
throw_free(freqfile);
|
||||
}
|
||||
|
||||
if(gkbd.quitall)
|
||||
QuitNow();
|
||||
}
|
||||
|
@@ -502,6 +502,14 @@ BOOL WINAPI GoldedCtrlHandler(DWORD dwCtrlType) {
|
||||
#endif
|
||||
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
|
||||
void Uninitialize()
|
||||
{
|
||||
delete WideUsername;
|
||||
}
|
||||
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
// Initialize defaults and generally get the system up and running
|
||||
|
||||
|
@@ -26,7 +26,22 @@
|
||||
|
||||
#include <golded.h>
|
||||
#include <gutlos.h>
|
||||
#include <memleak.h>
|
||||
|
||||
#if defined(_MSC_VER) && defined(_DEBUG)
|
||||
static struct LeakFinder
|
||||
{
|
||||
LeakFinder()
|
||||
{
|
||||
InitAllocCheck();
|
||||
}
|
||||
|
||||
~LeakFinder()
|
||||
{
|
||||
DeInitAllocCheck();
|
||||
}
|
||||
} leakFinder;
|
||||
#endif
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
// Main function
|
||||
@@ -35,6 +50,7 @@ int main(int argc, char *argv[]) {
|
||||
|
||||
Initialize(argc, argv);
|
||||
Reader();
|
||||
Uninitialize();
|
||||
return errorlevel;
|
||||
}
|
||||
|
||||
|
@@ -387,7 +387,7 @@ static void DispAttrWindow(int show=-1) {
|
||||
|
||||
if(show) {
|
||||
wh_background = whandle();
|
||||
int wide = MaxV(strlen(LNG->AttrTitle)+2, strlen(LNG->AttrPvt)+2);
|
||||
size_t wide = MaxV(strlen(LNG->AttrTitle)+2, strlen(LNG->AttrPvt)+2);
|
||||
wide = MinV(wide, MAXCOL-4);
|
||||
wh_attributes = wopen_(6, 0, 17, wide, W_BMENU, C_MENUB, C_MENUW);
|
||||
set_title(LNG->AttrTitle, TCENTER, C_MENUT);
|
||||
@@ -606,9 +606,7 @@ void AskAttributes(GMsg* __msg) {
|
||||
int SelectFromFile(const char* file, char* selection, const char* title, const char* nolines)
|
||||
{
|
||||
char buf[256];
|
||||
int n;
|
||||
bool retval=false;
|
||||
char** Listi;
|
||||
int lines = 0;
|
||||
|
||||
gfile fp(AddPath(CFG->goldpath, file), "rt", CFG->sharemode);
|
||||
@@ -620,8 +618,10 @@ int SelectFromFile(const char* file, char* selection, const char* title, const c
|
||||
|
||||
if (lines)
|
||||
{
|
||||
Listi = (char**)throw_calloc(lines+1, sizeof(char*));
|
||||
gstrarray Listi;
|
||||
fp.Rewind();
|
||||
|
||||
size_t n;
|
||||
for (n = 0; n < lines; n++)
|
||||
{
|
||||
fp.Fgets(buf, sizeof(buf)-2);
|
||||
@@ -632,20 +632,21 @@ int SelectFromFile(const char* file, char* selection, const char* title, const c
|
||||
buf[MAXCOL-2-2] = NUL;
|
||||
Listi[n] = throw_strdup(buf);
|
||||
}
|
||||
|
||||
n = MinV(n, (MAXROW-10));
|
||||
set_title(title, TCENTER, C_ASKT);
|
||||
n = wpickstr(6, 0, 6+n+1, -1, W_BASK, C_ASKB, C_ASKW, C_ASKS, Listi, 0, title_shadow);
|
||||
if(n != -1) {
|
||||
strcpy(selection, Listi[n]);
|
||||
|
||||
if (n != -1)
|
||||
{
|
||||
strcpy(selection, Listi[n].c_str());
|
||||
strtrim(selection);
|
||||
strltrim(selection);
|
||||
retval = true;
|
||||
}
|
||||
for(n=0; n<lines; n++)
|
||||
throw_free(Listi[n]);
|
||||
throw_free(Listi);
|
||||
}
|
||||
else {
|
||||
else
|
||||
{
|
||||
w_info(nolines);
|
||||
waitkeyt(10000);
|
||||
w_info(NULL);
|
||||
@@ -657,29 +658,36 @@ int SelectFromFile(const char* file, char* selection, const char* title, const c
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
|
||||
int ChangeTagline() {
|
||||
int ChangeTagline()
|
||||
{
|
||||
bool retval = false;
|
||||
|
||||
char buf[256];
|
||||
int n;
|
||||
bool retval=false;
|
||||
char** Listi;
|
||||
if (not CFG->tagline.empty())
|
||||
{
|
||||
char buf[256];
|
||||
gstrarray Listi;
|
||||
|
||||
if(not CFG->tagline.empty()) {
|
||||
Listi = (char**)throw_calloc(CFG->tagline.size()+1, sizeof(char*));
|
||||
gstrarray::iterator i;
|
||||
for(n = 0, i = CFG->tagline.begin(); i != CFG->tagline.end(); i++, n++) {
|
||||
if((*i)[0] == '@')
|
||||
strxmerge(buf, MAXCOL-2-2, " [", CleanFilename(i->c_str()+1), "] ", NULL);
|
||||
gstrarray::iterator it = CFG->tagline.begin();
|
||||
gstrarray::iterator end = CFG->tagline.end();
|
||||
|
||||
for (; it != end; it++)
|
||||
{
|
||||
if((*it)[0] == '@')
|
||||
strxmerge(buf, MAXCOL-2-2, " [", CleanFilename(it->c_str() + 1), "] ", NULL);
|
||||
else
|
||||
strxmerge(buf, MAXCOL-2-2, " ", i->c_str(), " ", NULL);
|
||||
Listi[n] = throw_strdup(buf);
|
||||
strxmerge(buf, MAXCOL-2-2, " ", it->c_str(), " ", NULL);
|
||||
|
||||
Listi.push_back(buf);
|
||||
}
|
||||
n = MinV(n, (MAXROW-10));
|
||||
|
||||
size_t n = MinV(Listi.size(), (MAXROW-10));
|
||||
set_title(LNG->Taglines, TCENTER, C_ASKT);
|
||||
update_statusline(LNG->ChangeTagline);
|
||||
whelppcat(H_ChangeTagline);
|
||||
n = wpickstr(6, 0, 6+n+1, -1, W_BASK, C_ASKB, C_ASKW, C_ASKS, Listi, CFG->taglineno, title_shadow);
|
||||
if(n != -1) {
|
||||
|
||||
if (n != -1)
|
||||
{
|
||||
const char *tagl = CFG->tagline[n].c_str();
|
||||
if(tagl[0] == '@') {
|
||||
strxmerge(buf, MAXCOL-2-2, LNG->Taglines, " [", CleanFilename(tagl+1), "] ", NULL);
|
||||
@@ -694,45 +702,52 @@ int ChangeTagline() {
|
||||
retval = true;
|
||||
}
|
||||
}
|
||||
for(n=CFG->tagline.size(); n; n--)
|
||||
throw_free(Listi[n-1]);
|
||||
throw_free(Listi);
|
||||
|
||||
whelpop();
|
||||
}
|
||||
else {
|
||||
else
|
||||
{
|
||||
w_info(LNG->NoTagline);
|
||||
waitkeyt(10000);
|
||||
w_info(NULL);
|
||||
}
|
||||
return(retval);
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
|
||||
int ChangeOrigin() {
|
||||
int ChangeOrigin()
|
||||
{
|
||||
bool retval = false;
|
||||
|
||||
char buf[256];
|
||||
int n;
|
||||
bool retval=false;
|
||||
char** Listi;
|
||||
if (not CFG->origin.empty())
|
||||
{
|
||||
char buf[256];
|
||||
gstrarray Listi;
|
||||
|
||||
if(not CFG->origin.empty()) {
|
||||
Listi = (char**)throw_calloc(CFG->origin.size()+1, sizeof(char*));
|
||||
gstrarray::iterator i;
|
||||
for(n = 0, i = CFG->origin.begin(); i != CFG->origin.end(); n++, i++) {
|
||||
if((*i)[0] == '@')
|
||||
strxmerge(buf, MAXCOL-2-2, " [", CleanFilename(i->c_str()+1), "] ", NULL);
|
||||
gstrarray::iterator it = CFG->origin.begin();
|
||||
gstrarray::iterator end = CFG->origin.end();
|
||||
|
||||
for (; it !=end; it++)
|
||||
{
|
||||
if ((*it)[0] == '@')
|
||||
strxmerge(buf, MAXCOL-2-2, " [", CleanFilename(it->c_str() + 1), "] ", NULL);
|
||||
else
|
||||
strxmerge(buf, MAXCOL-2-2, " ", i->c_str(), " ", NULL);
|
||||
Listi[n] = throw_strdup(buf);
|
||||
strxmerge(buf, MAXCOL-2-2, " ", it->c_str(), " ", NULL);
|
||||
|
||||
Listi.push_back(buf);
|
||||
}
|
||||
n = MinV(n, (MAXROW-10));
|
||||
|
||||
size_t n = MinV(Listi.size(), (MAXROW-10));
|
||||
set_title(LNG->Origins, TCENTER, C_ASKT);
|
||||
update_statusline(LNG->ChangeOrigin);
|
||||
whelppcat(H_ChangeOrigin);
|
||||
n = wpickstr(6, 0, 6+n+1, -1, W_BASK, C_ASKB, C_ASKW, C_ASKS, Listi, CFG->originno, title_shadow);
|
||||
if(n != -1) {
|
||||
|
||||
if (n != -1)
|
||||
{
|
||||
const char *orig = CFG->origin[n].c_str();
|
||||
if(orig[0] == '@') {
|
||||
strxmerge(buf, MAXCOL-2-2, LNG->Origins, " [", CleanFilename(orig+1), "] ", NULL);
|
||||
@@ -747,43 +762,48 @@ int ChangeOrigin() {
|
||||
retval = true;
|
||||
}
|
||||
}
|
||||
for(n = CFG->origin.size(); n; n--)
|
||||
throw_free(Listi[n-1]);
|
||||
throw_free(Listi);
|
||||
|
||||
whelpop();
|
||||
}
|
||||
else {
|
||||
else
|
||||
{
|
||||
w_info(LNG->NoOrigDefined);
|
||||
waitkeyt(10000);
|
||||
w_info(NULL);
|
||||
}
|
||||
return(retval);
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
|
||||
int ChangeUsername() {
|
||||
int ChangeUsername()
|
||||
{
|
||||
if(not CFG->username.empty())
|
||||
{
|
||||
char buf[256];
|
||||
char adrs[40];
|
||||
gstrarray Listi;
|
||||
|
||||
char buf[256], adrs[40];
|
||||
int n;
|
||||
char** Listi;
|
||||
std::vector<Node>::iterator it = CFG->username.begin();
|
||||
std::vector<Node>::iterator end = CFG->username.end();
|
||||
|
||||
if(not CFG->username.empty()) {
|
||||
Listi = (char**)throw_calloc(CFG->username.size()+1, sizeof(char*));
|
||||
std::vector<Node>::iterator i;
|
||||
for (n = 0, i = CFG->username.begin(); i != CFG->username.end(); n++, i++)
|
||||
for (; it != end; it++)
|
||||
{
|
||||
i->addr.make_string(adrs);
|
||||
gsprintf(PRINTF_DECLARE_BUFFER(buf), " %-35s %s ", i->name, adrs);
|
||||
Listi[n] = throw_strdup(buf);
|
||||
it->addr.make_string(adrs);
|
||||
gsprintf(PRINTF_DECLARE_BUFFER(buf), " %-35s %s ", it->name, adrs);
|
||||
Listi.push_back(buf);
|
||||
}
|
||||
n = MinV(n, (MAXROW-10));
|
||||
|
||||
size_t n = MinV(Listi.size(), (MAXROW-10));
|
||||
set_title(LNG->Usernames, TCENTER, C_ASKT);
|
||||
update_statusline(LNG->ChangeUsername);
|
||||
whelppcat(H_ChangeUsername);
|
||||
n = wpickstr(6, 0, 6+n+1, -1, W_BASK, C_ASKB, C_ASKW, C_ASKS, Listi, CFG->usernameno, title_shadow);
|
||||
if(n != -1) {
|
||||
|
||||
if (n != -1)
|
||||
{
|
||||
CFG->usernameno = n;
|
||||
AA->SetUsername(CFG->username[n]);
|
||||
for(std::vector<gaka>::iterator a = CFG->aka.begin(); a != CFG->aka.end(); a++) {
|
||||
@@ -793,94 +813,101 @@ int ChangeUsername() {
|
||||
}
|
||||
}
|
||||
}
|
||||
for(n = CFG->username.size(); n; n--)
|
||||
throw_free(Listi[n-1]);
|
||||
throw_free(Listi);
|
||||
|
||||
whelpop();
|
||||
}
|
||||
else {
|
||||
else
|
||||
{
|
||||
w_info(LNG->NoUserDefined);
|
||||
waitkeyt(10000);
|
||||
w_info(NULL);
|
||||
}
|
||||
return(YES);
|
||||
|
||||
return YES;
|
||||
}
|
||||
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
|
||||
int ChangeTemplate() {
|
||||
int ChangeTemplate()
|
||||
{
|
||||
if (not CFG->tpl.empty())
|
||||
{
|
||||
char buf[256];
|
||||
char adrs[40];
|
||||
gstrarray Listi;
|
||||
|
||||
char buf[256], adrs[40];
|
||||
int n;
|
||||
int selected=-1;
|
||||
char** Listi;
|
||||
std::vector<Tpl>::iterator it = CFG->tpl.begin();
|
||||
std::vector<Tpl>::iterator end = CFG->tpl.end();
|
||||
|
||||
if(not CFG->tpl.empty()) {
|
||||
Listi = (char**)throw_calloc(CFG->tpl.size()+1, sizeof(char*));
|
||||
std::vector<Tpl>::iterator t;
|
||||
for (n = 0, t = CFG->tpl.begin(); t != CFG->tpl.end(); n++, t++)
|
||||
for (; it != end; it++)
|
||||
{
|
||||
t->match.make_string(adrs);
|
||||
gsprintf(PRINTF_DECLARE_BUFFER(buf), " %-45s %s ", t->name, adrs);
|
||||
Listi[n] = throw_strdup(buf);
|
||||
it->match.make_string(adrs);
|
||||
gsprintf(PRINTF_DECLARE_BUFFER(buf), " %-45s %s ", it->name, adrs);
|
||||
Listi.push_back(buf);
|
||||
}
|
||||
n = MinV(n, (MAXROW-10));
|
||||
|
||||
size_t n = MinV(Listi.size(), (MAXROW-10));
|
||||
set_title(LNG->Templates, TCENTER, C_ASKT);
|
||||
update_statusline(LNG->ChangeTemplate);
|
||||
whelppcat(H_ChangeTemplate);
|
||||
n = wpickstr(6, 0, 6+n+1, -1, W_BASK, C_ASKB, C_ASKW, C_ASKS, Listi, CFG->tplno, title_shadow);
|
||||
whelpop();
|
||||
if(n != -1) {
|
||||
|
||||
if (n != -1)
|
||||
{
|
||||
AA->SetTpl(CFG->tpl[n].file);
|
||||
CFG->tplno = n;
|
||||
}
|
||||
selected = n;
|
||||
for(n = CFG->tpl.size(); n; n--)
|
||||
throw_free(Listi[n-1]);
|
||||
throw_free(Listi);
|
||||
|
||||
return n;
|
||||
}
|
||||
else {
|
||||
w_info(LNG->NoTplDefined);
|
||||
waitkeyt(10000);
|
||||
w_info(NULL);
|
||||
}
|
||||
return selected;
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
|
||||
int ChangeAka() {
|
||||
int n;
|
||||
std::vector<gaka>::iterator i;
|
||||
int startat = 0;
|
||||
char** Listi;
|
||||
char addr[100], buf[100];
|
||||
int ChangeAka()
|
||||
{
|
||||
if (CFG->aka.size() > 1)
|
||||
{
|
||||
size_t startat = 0;
|
||||
char addr[100];
|
||||
char buf[100];
|
||||
gstrarray Listi;
|
||||
|
||||
if(CFG->aka.size() > 1) {
|
||||
Listi = (char**)throw_calloc(CFG->aka.size()+1, sizeof(char*));
|
||||
for (i = CFG->aka.begin(), n=0; i != CFG->aka.end(); n++, i++)
|
||||
std::vector<gaka>::iterator it = CFG->aka.begin();
|
||||
std::vector<gaka>::iterator end = CFG->aka.end();
|
||||
|
||||
for (; it != end; it++)
|
||||
{
|
||||
i->addr.make_string(addr, i->domain);
|
||||
it->addr.make_string(addr, it->domain);
|
||||
gsprintf(PRINTF_DECLARE_BUFFER(buf), " %s ", addr);
|
||||
Listi[n] = throw_strdup(buf);
|
||||
if(AA->Aka().addr.equals(i->addr))
|
||||
startat = n;
|
||||
Listi.push_back(buf);
|
||||
|
||||
if (AA->Aka().addr.equals(it->addr))
|
||||
startat = Listi.size() - 1;
|
||||
}
|
||||
n = MinV(n, (MAXROW-10));
|
||||
|
||||
size_t n = MinV(Listi.size(), (MAXROW-10));
|
||||
set_title(LNG->Akas, TCENTER, C_ASKT);
|
||||
update_statusline(LNG->ChangeAka);
|
||||
whelppcat(H_ChangeAka);
|
||||
n = wpickstr(6, 0, 6+n+1, -1, W_BASK, C_ASKB, C_ASKW, C_ASKS, Listi, startat, title_shadow);
|
||||
whelpop();
|
||||
if(n != -1)
|
||||
|
||||
if (n != -1)
|
||||
AA->SetAka(CFG->aka[n].addr);
|
||||
for(n=CFG->aka.size(); n; n--)
|
||||
throw_free(Listi[n-1]);
|
||||
throw_free(Listi);
|
||||
}
|
||||
else {
|
||||
else
|
||||
{
|
||||
w_info(LNG->NoAkaDefined);
|
||||
waitkeyt(10000);
|
||||
w_info(NULL);
|
||||
@@ -891,61 +918,71 @@ int ChangeAka() {
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
|
||||
int ChangeXlatImport() {
|
||||
int ChangeXlatImport()
|
||||
{
|
||||
if (not CFG->xlatcharset.empty())
|
||||
{
|
||||
size_t startat = 0;
|
||||
int maximport = 0;
|
||||
int maxexport = 0;
|
||||
|
||||
int n, startat = 0;
|
||||
int xlatimports = 1;
|
||||
int maximport = 0;
|
||||
int maxexport = 0;
|
||||
char** Listi;
|
||||
char buf[100];
|
||||
char buf[100];
|
||||
gstrarray Listi;
|
||||
|
||||
std::vector<Map>::iterator xlt = CFG->xlatcharset.begin();
|
||||
std::vector<Map>::iterator end = CFG->xlatcharset.end();
|
||||
|
||||
if(not CFG->xlatcharset.empty()) {
|
||||
Listi = (char**)throw_calloc(CFG->xlatcharset.size()+2, sizeof(char*));
|
||||
std::vector<Map>::iterator xlt;
|
||||
for(xlt = CFG->xlatcharset.begin(); xlt != CFG->xlatcharset.end(); xlt++) {
|
||||
if(strieql(xlt->exp, CFG->xlatlocalset)) {
|
||||
for (size_t xlatimports = 1; xlt != end; xlt++)
|
||||
{
|
||||
if (strieql(xlt->exp, CFG->xlatlocalset))
|
||||
{
|
||||
maximport = MaxV(maximport, (int)strlen(xlt->imp));
|
||||
maxexport = MaxV(maxexport, (int)strlen(xlt->exp));
|
||||
if((CFG->ignorecharset == true) and strieql(xlt->imp, AA->Xlatimport()))
|
||||
if ((CFG->ignorecharset == true) and strieql(xlt->imp, AA->Xlatimport()))
|
||||
startat = xlatimports;
|
||||
xlatimports++;
|
||||
}
|
||||
}
|
||||
Listi[0] = throw_strdup(LNG->CharsetAuto);
|
||||
xlatimports = 1;
|
||||
for (xlt = CFG->xlatcharset.begin(); xlt != CFG->xlatcharset.end(); xlt++)
|
||||
|
||||
Listi.push_back(LNG->CharsetAuto);
|
||||
|
||||
for (xlt = CFG->xlatcharset.begin(); xlt != end; xlt++)
|
||||
{
|
||||
if (strieql(xlt->exp, CFG->xlatlocalset))
|
||||
{
|
||||
gsprintf(PRINTF_DECLARE_BUFFER(buf), " %*.*s -> %-*.*s ",
|
||||
maximport, maximport, xlt->imp, maxexport, maxexport, xlt->exp);
|
||||
Listi[xlatimports++] = throw_strdup(buf);
|
||||
Listi.push_back(buf);
|
||||
}
|
||||
}
|
||||
n = MinV(xlatimports, (MAXROW-10));
|
||||
|
||||
size_t n = MinV(Listi.size(), (MAXROW-10));
|
||||
set_title(LNG->Charsets, TCENTER, C_ASKT);
|
||||
update_statusline(LNG->ChangeXlatImp);
|
||||
whelppcat(H_ChangeXlatImport);
|
||||
n = wpickstr(6, 0, 6+n+1, -1, W_BASK, C_ASKB, C_ASKW, C_ASKS, Listi, startat, title_shadow);
|
||||
whelpop();
|
||||
if(n == 0) {
|
||||
|
||||
if (n == 0)
|
||||
{
|
||||
CFG->ignorecharset = false;
|
||||
}
|
||||
else if(n != -1) {
|
||||
else if (n != -1)
|
||||
{
|
||||
CFG->ignorecharset = true;
|
||||
AA->SetXlatimport(strtok(Listi[n], " "));
|
||||
std::string xlatImport = Listi[n].substr(0, Listi[n].find(" "));
|
||||
AA->SetXlatimport(xlatImport.c_str());
|
||||
}
|
||||
|
||||
LoadCharset(AA->Xlatimport(), CFG->xlatlocalset);
|
||||
for(n=0; n<xlatimports; n++)
|
||||
throw_free(Listi[n]);
|
||||
throw_free(Listi);
|
||||
}
|
||||
else {
|
||||
else
|
||||
{
|
||||
w_info(LNG->NoXlatImport);
|
||||
waitkeyt(10000);
|
||||
w_info(NULL);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@@ -681,13 +681,51 @@ void TokenXlat(int mode, std::string &input, GMsg* msg, GMsg* oldmsg, int __orig
|
||||
if (tokenxchg(input, dst, "@tr", "", 0, 1, (int)true))
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
#if 0
|
||||
if (strnieql(it2str(input, dst), "@uptime", 7))
|
||||
{
|
||||
size_t days = 0;
|
||||
size_t hours = 0;
|
||||
size_t minutes = 0;
|
||||
size_t seconds = 0;
|
||||
size_t useconds = 0;
|
||||
|
||||
#ifdef __WIN32__
|
||||
LARGE_INTEGER counter;
|
||||
LARGE_INTEGER frequency;
|
||||
QueryPerformanceCounter(&counter);
|
||||
QueryPerformanceFrequency(&frequency);
|
||||
seconds = counter.QuadPart / frequency.QuadPart;
|
||||
useconds = size_t(double(counter.QuadPart % frequency.QuadPart)*1000 / frequency.QuadPart);
|
||||
#endif
|
||||
|
||||
days = seconds/(60*60*24); seconds %= 60*60*24;
|
||||
hours = seconds/(60*60); seconds %= 60*60;
|
||||
minutes = seconds/60; seconds %= 60;
|
||||
|
||||
char uptime[1024];
|
||||
/*
|
||||
FormatString(
|
||||
FormatString(
|
||||
FormatString(
|
||||
FormatString(
|
||||
FormatString("%days day(s) %hours:%minutes:%seconds.%useconds",
|
||||
"%days", days),
|
||||
"%hours", hours),
|
||||
"%minutes", minutes),
|
||||
"%seconds", seconds),
|
||||
"%useconds", useconds);
|
||||
*/
|
||||
|
||||
tokenxchg(input, dst, "@uptime", uptime);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
dst++;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
|
||||
void TokenXlat(int mode, char *&input, size_t size, bool resize, GMsg* msg, GMsg* oldmsg, int origarea)
|
||||
|
@@ -161,6 +161,7 @@ int IsMacro(gkey key, int type);
|
||||
// ------------------------------------------------------------------
|
||||
// GEINIT prototypes
|
||||
|
||||
void Uninitialize();
|
||||
void Initialize(int argc, char* argv[]);
|
||||
|
||||
|
||||
@@ -357,7 +358,7 @@ void NextArea();
|
||||
void PrevArea();
|
||||
void Reader();
|
||||
void UpdateArea(GMsg* msg);
|
||||
int ExternUtil(GMsg* msg, int utilno);
|
||||
int ExternUtil(GMsg* msg, uint32_t utilno);
|
||||
void ExternUtilMenu(GMsg* msg);
|
||||
void ReadPeekURLs(GMsg* msg);
|
||||
uint next_msg(int direction);
|
||||
@@ -545,3 +546,4 @@ void RemoveHTML(char *&txt);
|
||||
#endif
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
|
||||
|
@@ -1390,15 +1390,15 @@ struct ReplySel {
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
|
||||
void GotoReplies() {
|
||||
|
||||
void GotoReplies()
|
||||
{
|
||||
reader_direction = DIR_NEXT;
|
||||
|
||||
GMsg* msg = reader_msg;
|
||||
const int list_max = msg->link.list_max();
|
||||
|
||||
char buf[200];
|
||||
int replies = 0;
|
||||
size_t replies = 0;
|
||||
int cursorbar = -1;
|
||||
uint maxname = 0;
|
||||
uint maxaddr = 0;
|
||||
@@ -1447,40 +1447,38 @@ void GotoReplies() {
|
||||
throw_free(rmsg);
|
||||
|
||||
int selected = 0;
|
||||
if(replies > 1) {
|
||||
if(replies > 1)
|
||||
{
|
||||
uint maxname2 = MAXCOL-16-maxmsgno-maxaddr-maxwritten;
|
||||
maxname = MinV(maxname, maxname2);
|
||||
char** listr = (char**)throw_calloc(list_max+3, sizeof(char*));
|
||||
gstrarray listr;
|
||||
|
||||
int n;
|
||||
for(n=0; n<list_max+3; n++) {
|
||||
if(n<replies) {
|
||||
sprintf(buf, "%c %c %*s : %-*.*s %-*s %-*s ",
|
||||
rlist[n].isread,
|
||||
rlist[n].msgno[0],
|
||||
maxmsgno, rlist[n].msgno+1,
|
||||
(int) maxname, (int) maxname, rlist[n].name,
|
||||
maxaddr, rlist[n].addr,
|
||||
maxwritten, rlist[n].written
|
||||
);
|
||||
listr[n] = throw_strdup(buf);
|
||||
}
|
||||
else {
|
||||
listr[n] = NULL;
|
||||
for (n = 0; n < list_max + 3; n++)
|
||||
{
|
||||
if (n >= replies)
|
||||
break;
|
||||
}
|
||||
|
||||
sprintf(buf, "%c %c %*s : %-*.*s %-*s %-*s ",
|
||||
rlist[n].isread,
|
||||
rlist[n].msgno[0],
|
||||
maxmsgno, rlist[n].msgno+1,
|
||||
(int) maxname, (int) maxname, rlist[n].name,
|
||||
maxaddr, rlist[n].addr,
|
||||
maxwritten, rlist[n].written
|
||||
);
|
||||
|
||||
listr.push_back(buf);
|
||||
}
|
||||
set_title(LNG->Replies, TCENTER, C_ASKT);
|
||||
update_statusline(LNG->SelectReply);
|
||||
whelppcat(H_GotoReplies);
|
||||
int pick_max = MinV(replies, (MAXROW-10));
|
||||
size_t pick_max = MinV(replies, (MAXROW-10));
|
||||
if(cursorbar < 0)
|
||||
cursorbar = 0;
|
||||
selected = wpickstr(6, 0, 6+pick_max+1, -1, W_BASK, C_ASKB, C_ASKW, C_ASKS, listr, cursorbar, title_shadow);
|
||||
whelpop();
|
||||
gotolink = (selected != -1) ? rlist[selected].reln : 0;
|
||||
for(n=0; n<replies; n++)
|
||||
throw_free(listr[n]);
|
||||
throw_free(listr);
|
||||
}
|
||||
|
||||
throw_free(rlist);
|
||||
|
@@ -24,10 +24,11 @@
|
||||
// Reader secondary functions
|
||||
// ------------------------------------------------------------------
|
||||
|
||||
#include <vector>
|
||||
#include <algorithm>
|
||||
#include <golded.h>
|
||||
#include <gwinput.h>
|
||||
#include <gftnall.h>
|
||||
#include <vector>
|
||||
#define PROTOTYPES
|
||||
#include <uudeview.h>
|
||||
|
||||
@@ -534,14 +535,14 @@ void TouchNetscan(int popup)
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
|
||||
int ExternUtil(GMsg *msg, ExtUtil *extutil) {
|
||||
|
||||
int ExternUtil(GMsg *msg, const ExtUtil &extutil)
|
||||
{
|
||||
Path editorfile, tmpfile, buf;
|
||||
strxcpy(editorfile, AddPath(CFG->goldpath, EDIT->File()), sizeof(Path));
|
||||
|
||||
std::string cmdline = extutil->cmdline;
|
||||
std::string cmdline = extutil.cmdline;
|
||||
|
||||
int mode = (extutil->options & EXTUTIL_KEEPCTRL) ? MODE_SAVE : MODE_SAVENOCTRL;
|
||||
int mode = (extutil.options & EXTUTIL_KEEPCTRL) ? MODE_SAVE : MODE_SAVENOCTRL;
|
||||
SaveLines(mode, editorfile, msg, 79);
|
||||
strcpy(buf, editorfile);
|
||||
strchg(buf, GOLD_WRONG_SLASH_CHR, GOLD_SLASH_CHR);
|
||||
@@ -562,20 +563,20 @@ int ExternUtil(GMsg *msg, ExtUtil *extutil) {
|
||||
TokenXlat(MODE_NEW, cmdline, msg, msg, CurrArea);
|
||||
|
||||
int pauseval = 0;
|
||||
if(extutil->options & EXTUTIL_PAUSEONERROR)
|
||||
if(extutil.options & EXTUTIL_PAUSEONERROR)
|
||||
pauseval = -1;
|
||||
if(extutil->options & EXTUTIL_PAUSE)
|
||||
if(extutil.options & EXTUTIL_PAUSE)
|
||||
pauseval = 1;
|
||||
|
||||
ShellToDos(cmdline.c_str(), "",
|
||||
extutil->options & EXTUTIL_CLS ? LGREY_|_BLACK : BLACK_|_BLACK,
|
||||
extutil->options & EXTUTIL_CURSOR,
|
||||
extutil.options & EXTUTIL_CLS ? LGREY_|_BLACK : BLACK_|_BLACK,
|
||||
extutil.options & EXTUTIL_CURSOR,
|
||||
pauseval
|
||||
);
|
||||
|
||||
if(extutil->options & EXTUTIL_RELOAD) {
|
||||
if(extutil.options & EXTUTIL_RELOAD) {
|
||||
|
||||
if(not (extutil->options & EXTUTIL_KEEPCTRL)) {
|
||||
if(not (extutil.options & EXTUTIL_KEEPCTRL)) {
|
||||
if (*msg->tearline or *msg->origin)
|
||||
{
|
||||
gfile fp(editorfile, "at");
|
||||
@@ -621,7 +622,7 @@ int ExternUtil(GMsg *msg, ExtUtil *extutil) {
|
||||
msg->charsetlevel = LoadCharset(msg->charset, CFG->xlatlocalset);
|
||||
}
|
||||
|
||||
if(extutil->options & EXTUTIL_WIPE)
|
||||
if(extutil.options & EXTUTIL_WIPE)
|
||||
WipeFile(editorfile, 0);
|
||||
if(tmpfile[0] != NUL)
|
||||
WipeFile(tmpfile, 0);
|
||||
@@ -632,15 +633,15 @@ int ExternUtil(GMsg *msg, ExtUtil *extutil) {
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
|
||||
int ExternUtil(GMsg *msg, int utilno) {
|
||||
|
||||
std::vector<ExtUtil>::iterator extutil = CFG->externutil.begin();
|
||||
|
||||
for(int utlno=0; extutil != CFG->externutil.end(); utlno++, extutil++) {
|
||||
|
||||
if(extutil->utilno == utilno) {
|
||||
return ExternUtil(msg, &(*extutil));
|
||||
}
|
||||
int ExternUtil(GMsg *msg, uint32_t utilno)
|
||||
{
|
||||
std::vector<ExtUtil>::iterator it = CFG->externutil.begin();
|
||||
std::vector<ExtUtil>::iterator end = CFG->externutil.end();
|
||||
|
||||
for (uint32_t i = 0; it != end; i++, it++)
|
||||
{
|
||||
if (it->utilno != i) continue;
|
||||
return ExternUtil(msg, *it);
|
||||
}
|
||||
|
||||
SayBibi();
|
||||
@@ -650,147 +651,181 @@ int ExternUtil(GMsg *msg, int utilno) {
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
|
||||
void ExternUtilMenu(GMsg* msg) {
|
||||
int n;
|
||||
std::vector<ExtUtil>::iterator i;
|
||||
void ExternUtilMenu(GMsg* msg)
|
||||
{
|
||||
static int startat = 0;
|
||||
char** Listi;
|
||||
char buf[100];
|
||||
static char cmdline[1024] = "";
|
||||
gstrarray Listi;
|
||||
|
||||
Listi = (char**)throw_calloc(CFG->externutil.size()+2, sizeof(char*));
|
||||
Listi[0] = throw_strdup(LNG->EnterCmdLine);
|
||||
for(i = CFG->externutil.begin(), n=1; i != CFG->externutil.end(); n++, i++) {
|
||||
sprintf(buf, " %02d %.59s%s ", i->utilno, i->cmdline, strlen(i->cmdline) > 59 ? ">" : "" );
|
||||
Listi[n] = throw_strdup(buf);
|
||||
Listi.push_back(LNG->EnterCmdLine);
|
||||
|
||||
std::vector<ExtUtil>::iterator it = CFG->externutil.begin();
|
||||
std::vector<ExtUtil>::iterator end = CFG->externutil.end();
|
||||
for (; it != end; it++)
|
||||
{
|
||||
char buf[100];
|
||||
sprintf(buf, " %02d %.59s%s ", it->utilno, it->cmdline, (it->cmdline.length() > 59) ? ">" : "" );
|
||||
Listi.push_back(buf);
|
||||
}
|
||||
n = MinV(n, (MAXROW-10));
|
||||
|
||||
size_t n = MinV(Listi.size(), (MAXROW-10));
|
||||
set_title(LNG->ExternUtil, TCENTER, C_ASKT);
|
||||
update_statusline(LNG->SelectExternUtil);
|
||||
whelppcat(H_ReadExternUtil);
|
||||
n = wpickstr(6, 0, 6+n+1, -1, W_BASK, C_ASKB, C_ASKW, C_ASKS, Listi, startat, title_shadow);
|
||||
whelpop();
|
||||
if(n != -1) {
|
||||
if(n == 0) {
|
||||
if(edit_string(cmdline, sizeof(cmdline), LNG->ExecCmdLine, H_ReadExternUtil)) {
|
||||
|
||||
if (n != -1)
|
||||
{
|
||||
if (n == 0)
|
||||
{
|
||||
if (edit_string(cmdline, sizeof(cmdline), LNG->ExecCmdLine, H_ReadExternUtil))
|
||||
{
|
||||
ExtUtil extutil;
|
||||
extutil.utilno = 0;
|
||||
strxcpy(extutil.cmdline, cmdline, sizeof(extutil.cmdline));
|
||||
extutil.cmdline = cmdline;
|
||||
extutil.options = CFG->externoptions;
|
||||
reader_keyok = ExternUtil(msg, &extutil);
|
||||
reader_keyok = ExternUtil(msg, extutil);
|
||||
}
|
||||
}
|
||||
else {
|
||||
reader_keyok = ExternUtil(msg, &CFG->externutil[n-1]);
|
||||
else
|
||||
{
|
||||
reader_keyok = ExternUtil(msg, CFG->externutil[n-1]);
|
||||
}
|
||||
}
|
||||
for(n=CFG->externutil.size()+1; n; n--)
|
||||
throw_free(Listi[n-1]);
|
||||
throw_free(Listi);
|
||||
}
|
||||
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
|
||||
static int PeekURLCmp(const char** a, const char** b) {
|
||||
|
||||
return stricmp(*a, *b);
|
||||
static bool PeekURLCmp(const std::string &a, const std::string b)
|
||||
{
|
||||
return stricmp(a.c_str(), b.c_str()) > 0;
|
||||
}
|
||||
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
|
||||
void ReadPeekURLs(GMsg* msg) {
|
||||
|
||||
Line **lin = msg->line;
|
||||
const char *ptr, *end, *begin;
|
||||
char buf[256];
|
||||
std::vector<char *> urls;
|
||||
std::vector<char *>::iterator i;
|
||||
int n;
|
||||
|
||||
void ReadPeekURLs(GMsg* msg)
|
||||
{
|
||||
w_info(LNG->Wait);
|
||||
|
||||
// Scan the current msg for urls
|
||||
int tline = reader_topline;
|
||||
if(CFG->peekurloptions & PEEK_FROMTOP)
|
||||
if (CFG->peekurloptions & PEEK_FROMTOP)
|
||||
tline = 0;
|
||||
for(n=tline; n<msg->lines; n++) {
|
||||
|
||||
ptr = lin[n]->txt.c_str();
|
||||
Line **lin = msg->line;
|
||||
std::vector<char *> urls;
|
||||
|
||||
while(*ptr) {
|
||||
if(((begin = url_begin(ptr)) != NULL) and not strneql(ptr, "mailto:", 7)) {
|
||||
end = begin+strcspn(begin, " \t\"\'<>()[]");
|
||||
if(ispunct(end[-1]) and (end[-1] != '/'))
|
||||
--end;
|
||||
if(begin < end) {
|
||||
char* bufurl=(char*)throw_malloc(end-ptr+3);
|
||||
for (int n = tline; n < msg->lines; n++)
|
||||
{
|
||||
const char *ptr = lin[n]->txt.c_str();
|
||||
|
||||
while (*ptr)
|
||||
{
|
||||
const char *urlBegin = url_begin(ptr);
|
||||
if (urlBegin and not strneql(ptr, "mailto:", 7))
|
||||
{
|
||||
const char *urlEnd = urlBegin + strcspn(urlBegin, " \t\"\'<>()[]");
|
||||
if (ispunct(urlEnd[-1]) and (urlEnd[-1] != '/'))
|
||||
--urlEnd;
|
||||
|
||||
if (urlBegin < urlEnd)
|
||||
{
|
||||
char* bufurl=(char*)throw_malloc(urlEnd - ptr + 3);
|
||||
bufurl[0] = ' ';
|
||||
strxcpy(bufurl+1, ptr, (end-ptr)+1);
|
||||
strxcpy(bufurl + 1, ptr, (urlEnd - ptr) + 1);
|
||||
strcat(bufurl, " ");
|
||||
for(i = urls.begin(); i != urls.end(); i++)
|
||||
if(strieql(*i, bufurl))
|
||||
|
||||
std::vector<char *>::iterator it = urls.begin();
|
||||
std::vector<char *>::iterator end = urls.end();
|
||||
for (; it != end; it++)
|
||||
{
|
||||
if (strieql(*it, bufurl))
|
||||
break;
|
||||
if(i == urls.end())
|
||||
}
|
||||
|
||||
if (it == end)
|
||||
urls.push_back(bufurl);
|
||||
else
|
||||
throw_free(bufurl);
|
||||
ptr = end-1;
|
||||
|
||||
ptr = urlEnd - 1;
|
||||
}
|
||||
}
|
||||
|
||||
ptr++;
|
||||
}
|
||||
}
|
||||
|
||||
w_info(NULL);
|
||||
|
||||
if(not urls.empty()) {
|
||||
if (not urls.empty())
|
||||
{
|
||||
gstrarray Listi;
|
||||
|
||||
char** Listi = (char**)throw_calloc(urls.size()+1, sizeof(char*));
|
||||
|
||||
for(n = 0, i = urls.begin(); i != urls.end(); i++, n++)
|
||||
Listi[n] = *i;
|
||||
std::vector<char *>::iterator it = urls.begin();
|
||||
std::vector<char *>::iterator end = urls.end();
|
||||
for (; it != end; it++)
|
||||
{
|
||||
Listi.push_back(*it);
|
||||
}
|
||||
|
||||
// Sort list if requested
|
||||
if(CFG->peekurloptions & FREQ_SORT)
|
||||
qsort(Listi, urls.size(), sizeof(char*), (StdCmpCP)PeekURLCmp);
|
||||
sort(Listi.begin(), Listi.end(), PeekURLCmp);
|
||||
|
||||
// Run the picker
|
||||
n = MinV((int)urls.size(), (MAXROW-10));
|
||||
size_t n = MinV(urls.size(), (MAXROW-10));
|
||||
set_title(LNG->PeekURLMenuTitle, TCENTER, C_ASKT);
|
||||
update_statusline(LNG->PeekURLStat);
|
||||
whelppcat(H_PeekURL);
|
||||
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);
|
||||
whelpop();
|
||||
|
||||
if(n != -1) {
|
||||
std::string cmdline = CFG->urlhandler.cmdline;
|
||||
strxmerge(buf, sizeof(buf), "\"", strtrim(strltrim(Listi[n])), "\"", NULL);
|
||||
strischg(cmdline, "@url", buf);
|
||||
strxcpy(buf, CFG->goldpath, sizeof(buf));
|
||||
if(n != -1)
|
||||
{
|
||||
std::vector<UrlHandler>::iterator it = CFG->urlhandler.begin();
|
||||
std::vector<UrlHandler>::iterator end = CFG->urlhandler.end();
|
||||
#if 0 // will be implemented later
|
||||
for (; it != end; it++)
|
||||
{
|
||||
if (it->scheme.match(Listi[n].c_str(), gregex::extended | gregex::icase))
|
||||
break;
|
||||
}
|
||||
#else
|
||||
it = end;
|
||||
#endif
|
||||
|
||||
if (it == end) it = CFG->urlhandler.begin();
|
||||
|
||||
std::string cmdline = it->handler.cmdline;
|
||||
std::string buf = "\"" + strtrim(strltrim(Listi[n])) + "\"";
|
||||
strischg(cmdline, "@url", buf.c_str());
|
||||
|
||||
buf = CFG->goldpath;
|
||||
strchg(buf, GOLD_WRONG_SLASH_CHR, GOLD_SLASH_CHR);
|
||||
strischg(cmdline, "@path", buf);
|
||||
strischg(cmdline, "@path", buf.c_str());
|
||||
|
||||
TokenXlat(MODE_NEW, cmdline, msg, msg, CurrArea);
|
||||
|
||||
int pauseval = 0;
|
||||
if(CFG->urlhandler.options & EXTUTIL_PAUSEONERROR)
|
||||
if (it->handler.options & EXTUTIL_PAUSEONERROR)
|
||||
pauseval = -1;
|
||||
if(CFG->urlhandler.options & EXTUTIL_PAUSE)
|
||||
|
||||
if (it->handler.options & EXTUTIL_PAUSE)
|
||||
pauseval = 1;
|
||||
|
||||
ShellToDos(cmdline.c_str(), "",
|
||||
CFG->urlhandler.options & EXTUTIL_CLS ? LGREY_|_BLACK : BLACK_|_BLACK,
|
||||
CFG->urlhandler.options & EXTUTIL_CURSOR,
|
||||
it->handler.options & EXTUTIL_CLS ? LGREY_|_BLACK : BLACK_|_BLACK,
|
||||
it->handler.options & EXTUTIL_CURSOR,
|
||||
pauseval
|
||||
);
|
||||
}
|
||||
|
||||
for(n = 0, i = urls.begin(); i != urls.end(); i++, n++)
|
||||
throw_free(Listi[n]);
|
||||
throw_free(Listi);
|
||||
}
|
||||
else {
|
||||
else
|
||||
{
|
||||
w_info(LNG->PeekInfoNoURLs);
|
||||
waitkeyt(10000);
|
||||
w_info(NULL);
|
||||
|
@@ -26,7 +26,6 @@
|
||||
#ifndef __GESRCH_H
|
||||
#define __GESRCH_H
|
||||
|
||||
#include <gstrarr.h>
|
||||
#include <gsrchmgr.h>
|
||||
|
||||
|
||||
|
@@ -66,7 +66,6 @@
|
||||
#include <gprnall.h>
|
||||
#include <gsearch.h>
|
||||
#include <gstrbags.h>
|
||||
#include <gstrarr.h>
|
||||
#include <gtimall.h>
|
||||
#include <gtxtpara.h>
|
||||
#include <gutlgrp.h>
|
||||
|
Reference in New Issue
Block a user