A few assorted cleanups.
This commit is contained in:
@ -39,6 +39,8 @@
|
|||||||
|
|
||||||
#include "../dpip/dpip.h"
|
#include "../dpip/dpip.h"
|
||||||
|
|
||||||
|
using namespace std::literals::string_literals;
|
||||||
|
|
||||||
#define DPI_EXT (".dpi" EXEEXT)
|
#define DPI_EXT (".dpi" EXEEXT)
|
||||||
|
|
||||||
#define QUEUE 5
|
#define QUEUE 5
|
||||||
@ -52,10 +54,8 @@ char *SharedKey = NULL;
|
|||||||
*/
|
*/
|
||||||
void cleanup(void)
|
void cleanup(void)
|
||||||
{
|
{
|
||||||
char *fname;
|
std::string fname = dGethomedir() + "/"s + dotDILLO_DPID_COMM_KEYS;
|
||||||
fname = dStrconcat(dGethomedir(), "/", dotDILLO_DPID_COMM_KEYS, NULL);
|
unlink(fname.c_str());
|
||||||
unlink(fname);
|
|
||||||
dFree(fname);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*! Free memory used to describe
|
/*! Free memory used to describe
|
||||||
|
|||||||
@ -558,11 +558,6 @@ void DilloHtml::write(char *Buf, int BufSize, int Eof)
|
|||||||
int bufsize = BufSize - Start_Ofs;
|
int bufsize = BufSize - Start_Ofs;
|
||||||
|
|
||||||
_MSG("DilloHtml::write BufSize=%d Start_Ofs=%d\n", BufSize, Start_Ofs);
|
_MSG("DilloHtml::write BufSize=%d Start_Ofs=%d\n", BufSize, Start_Ofs);
|
||||||
#if 0
|
|
||||||
char *aux = dStrndup(Buf, BufSize);
|
|
||||||
MSG(" {%s}\n", aux);
|
|
||||||
dFree(aux);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Update Start_Buf. It may be used after the parser is stopped */
|
/* Update Start_Buf. It may be used after the parser is stopped */
|
||||||
Start_Buf = Buf;
|
Start_Buf = Buf;
|
||||||
|
|||||||
14
src/ui.cc
14
src/ui.cc
@ -36,6 +36,8 @@
|
|||||||
#include "history.hh"
|
#include "history.hh"
|
||||||
#include "nav.hh"
|
#include "nav.hh"
|
||||||
|
|
||||||
|
using namespace std::literals::string_literals;
|
||||||
|
|
||||||
struct iconset {
|
struct iconset {
|
||||||
Fl_Image *ImgMeterOK, *ImgMeterBug,
|
Fl_Image *ImgMeterOK, *ImgMeterBug,
|
||||||
*ImgHome, *ImgReload, *ImgSave, *ImgBook, *ImgTools,
|
*ImgHome, *ImgReload, *ImgSave, *ImgBook, *ImgTools,
|
||||||
@ -239,19 +241,17 @@ static void search_cb(Fl_Widget *wid, void *data)
|
|||||||
*/
|
*/
|
||||||
static void help_cb(Fl_Widget *w, void *)
|
static void help_cb(Fl_Widget *w, void *)
|
||||||
{
|
{
|
||||||
char *path = dStrconcat(DILLO_DOCDIR, "user_help.html", NULL);
|
std::string path = DILLO_DOCDIR + "user_help.html"s;
|
||||||
BrowserWindow *bw = a_UIcmd_get_bw_by_widget(w);
|
BrowserWindow *bw = a_UIcmd_get_bw_by_widget(w);
|
||||||
|
|
||||||
if (access(path, R_OK) == 0) {
|
if (access(path.c_str(), R_OK) == 0) {
|
||||||
char *urlstr = dStrconcat("file:", path, NULL);
|
std::string urlstr = "file:" + path;
|
||||||
a_UIcmd_open_urlstr(bw, urlstr);
|
a_UIcmd_open_urlstr(bw, urlstr.c_str());
|
||||||
dFree(urlstr);
|
|
||||||
} else {
|
} else {
|
||||||
MSG("Can't read local help file at \"%s\"."
|
MSG("Can't read local help file at \"%s\"."
|
||||||
" Getting remote help...\n", path);
|
" Getting remote help...\n", path.c_str());
|
||||||
a_UIcmd_open_urlstr(bw, "https://dillo-browser.github.io/user_help.html");
|
a_UIcmd_open_urlstr(bw, "https://dillo-browser.github.io/user_help.html");
|
||||||
}
|
}
|
||||||
dFree(path);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
39
src/uicmd.cc
39
src/uicmd.cc
@ -52,6 +52,8 @@
|
|||||||
|
|
||||||
#include "nav.hh"
|
#include "nav.hh"
|
||||||
|
|
||||||
|
#include <algorithm>
|
||||||
|
|
||||||
//#define DEFAULT_TAB_LABEL "-.untitled.-"
|
//#define DEFAULT_TAB_LABEL "-.untitled.-"
|
||||||
#define DEFAULT_TAB_LABEL "-.new.-"
|
#define DEFAULT_TAB_LABEL "-.new.-"
|
||||||
|
|
||||||
@ -63,6 +65,8 @@ using namespace dw::core;
|
|||||||
// FLTK related
|
// FLTK related
|
||||||
using namespace dw::fltk;
|
using namespace dw::fltk;
|
||||||
|
|
||||||
|
using namespace std::literals::string_literals;
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Local data
|
* Local data
|
||||||
@ -105,13 +109,13 @@ public:
|
|||||||
void ui(UI *pui) { ui_ = pui; }
|
void ui(UI *pui) { ui_ = pui; }
|
||||||
UI *ui(void) { return ui_; }
|
UI *ui(void) { return ui_; }
|
||||||
void focus_num(uint_t fn) { focus_num_ = fn; }
|
void focus_num(uint_t fn) { focus_num_ = fn; }
|
||||||
uint_t focus_num(void) { return focus_num_; }
|
uint_t focus_num() const { return focus_num_; }
|
||||||
};
|
};
|
||||||
|
|
||||||
static int btn_cmp(const void *p1, const void *p2)
|
static int
|
||||||
|
btn_cmp( const CustTabButton *const p1, const CustTabButton *const p2 )
|
||||||
{
|
{
|
||||||
return ((*(CustTabButton * const *)p1)->focus_num() -
|
return p1->focus_num() - p2->focus_num();
|
||||||
(*(CustTabButton * const *)p2)->focus_num() );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -135,14 +139,13 @@ class CustTabs : public Fl_Group {
|
|||||||
++focus_counter;
|
++focus_counter;
|
||||||
else {
|
else {
|
||||||
/* wrap & normalize old numbers here */
|
/* wrap & normalize old numbers here */
|
||||||
CustTabButton **btns = dNew(CustTabButton*, num_tabs());
|
std::vector< CustTabButton * > btns;
|
||||||
for (int i = 0; i < num_tabs(); ++i)
|
for (int i = 0; i < num_tabs(); ++i)
|
||||||
btns[i] = (CustTabButton*)Pack->child(i);
|
btns.push_back( (CustTabButton*)Pack->child( i ) ) ;
|
||||||
qsort(btns, num_tabs(), sizeof(CustTabButton *), btn_cmp);
|
std::ranges::sort( btns, btn_cmp );
|
||||||
focus_counter = 0;
|
focus_counter = 0;
|
||||||
for (int i = 0; i < num_tabs(); ++i)
|
for( auto *btn: btns )
|
||||||
btns[i]->focus_num(focus_counter++);
|
btn->focus_num(focus_counter++);
|
||||||
dFree(btns);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -760,7 +763,7 @@ void a_UIcmd::a_UIcmd_open_urlstr(BrowserWindow *bw, const char *urlstr)
|
|||||||
{
|
{
|
||||||
char *new_urlstr;
|
char *new_urlstr;
|
||||||
char *search_urlstr = NULL;
|
char *search_urlstr = NULL;
|
||||||
DilloUrl *url;
|
std::unique_ptr< DilloUrl > url;
|
||||||
int ch;
|
int ch;
|
||||||
|
|
||||||
if ((search_urlstr = UIcmd_find_search_str(urlstr))) {
|
if ((search_urlstr = UIcmd_find_search_str(urlstr))) {
|
||||||
@ -774,20 +777,19 @@ void a_UIcmd::a_UIcmd_open_urlstr(BrowserWindow *bw, const char *urlstr)
|
|||||||
/* file URI */
|
/* file URI */
|
||||||
ch = new_urlstr[5];
|
ch = new_urlstr[5];
|
||||||
if (!ch || ch == '.') {
|
if (!ch || ch == '.') {
|
||||||
url = a_Url_new(Paths::getOldWorkingDir(), "file:").release();
|
url = a_Url_new(Paths::getOldWorkingDir(), "file:");
|
||||||
} else {
|
} else {
|
||||||
url = a_Url_new(new_urlstr, "file:").release();
|
url = a_Url_new(new_urlstr, "file:");
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
/* common case */
|
/* common case */
|
||||||
url = a_Url_new(new_urlstr, NULL).release();
|
url = a_Url_new(new_urlstr, NULL);
|
||||||
}
|
}
|
||||||
dFree(new_urlstr);
|
dFree(new_urlstr);
|
||||||
|
|
||||||
if (url) {
|
if (url) {
|
||||||
a_UIcmd_open_url(bw, url);
|
a_UIcmd_open_url(bw, url.release());
|
||||||
delete url;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
dFree(search_urlstr);
|
dFree(search_urlstr);
|
||||||
@ -1215,9 +1217,8 @@ const char *a_UIcmd::a_UIcmd_get_passwd(const char *user)
|
|||||||
{
|
{
|
||||||
const char *passwd;
|
const char *passwd;
|
||||||
const char *title = "Flenser: Password";
|
const char *title = "Flenser: Password";
|
||||||
char *msg = dStrconcat("Password for user \"", user, "\"", NULL);
|
std::string msg= "Password for user \""s + user + "\"";
|
||||||
passwd = a_Dialog_passwd(title, msg);
|
passwd = a_Dialog_passwd(title, msg.c_str());
|
||||||
dFree(msg);
|
|
||||||
return passwd;
|
return passwd;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user