From 34f68be95127c4779ebb98b08535ece2fe912b09 Mon Sep 17 00:00:00 2001
From: Stelios Bounanos ";
+ string postHelp =
+ "
";
+ i++;
+ } else
+ sHelp += "
";//"\n
";
+ } else
+ sHelp += theHelp[i];
+ htmlHelp += sHelp;
+ htmlHelp += postHelp;
+
+ help_dialog->value(htmlHelp.c_str());
+
+ help_dialog->show();
+}
cMixer mixer;
@@ -609,20 +644,18 @@ void cb_mnuCmdLineHelp(Fl_Widget*, void*)
{
extern std::string option_help;
- fl_message_font(FL_SCREEN, FL_NORMAL_SIZE - 1);
- fl_message("%s", option_help.c_str());
- fl_message_font(FL_HELVETICA, FL_NORMAL_SIZE);
+ fldigi_help(option_help);
+// fl_message_font(FL_SCREEN, FL_NORMAL_SIZE - 1);
+// fl_message("%s", option_help.c_str());
+// fl_message_font(FL_HELVETICA, FL_NORMAL_SIZE);
restoreFocus();
}
void cb_mnuBuildInfo(Fl_Widget*, void*)
{
- extern void print_versions(std::ostream&);
-
- std::ostringstream ss;
- print_versions(ss);
- std::string s = ss.str();
+ extern std::string version_text;
+ std::string s = version_text;
std::string::size_type i = 0;
// escape the at chars
@@ -631,9 +664,10 @@ void cb_mnuBuildInfo(Fl_Widget*, void*)
i += 2;
}
- fl_message_font(FL_SCREEN, FL_NORMAL_SIZE - 1);
- fl_message("%s", s.c_str());
- fl_message_font(FL_HELVETICA, FL_NORMAL_SIZE);
+ fldigi_help(s);
+// fl_message_font(FL_SCREEN, FL_NORMAL_SIZE - 1);
+// fl_message("%s", s.c_str());
+// fl_message_font(FL_HELVETICA, FL_NORMAL_SIZE);
restoreFocus();
}
@@ -997,7 +1031,7 @@ void make_pixmap(Pixmap *xpm, const char **data)
w.make_current();
Fl_Pixmap icon(data);
- int maxd = max(icon.w(), icon.h());
+ int maxd = MAX(icon.w(), icon.h());
*xpm = fl_create_offscreen(maxd, maxd);
fl_begin_offscreen(*xpm);
diff --git a/src/feld/feld.cxx b/src/feld/feld.cxx
index e364a71f..e7c72830 100644
--- a/src/feld/feld.cxx
+++ b/src/feld/feld.cxx
@@ -37,11 +37,6 @@
#include "Config.h"
#include "qrunner.h"
-#undef MAX
-#define MAX(a,b) (((a)>(b))?(a):(b))
-#undef CLAMP
-#define CLAMP(x,low,high) (((x)>(high))?(high):(((x)<(low))?(low):(x)))
-
char feldmsg[80];
void feld::tx_init(cSound *sc)
diff --git a/src/include/util.h b/src/include/util.h
index 7b0b950d..cfb70d89 100644
--- a/src/include/util.h
+++ b/src/include/util.h
@@ -12,7 +12,15 @@ extern "C" {
#ifndef powerof2
# define powerof2(n) ((((n) - 1) & (n)) == 0)
#endif
-
+#ifndef MAX
+# define MAX(a, b) (((a) > (b)) ? (a) : (b))
+#endif
+#ifndef MIN
+# define MIN(a, b) (((a) < (b)) ? (a) : (b))
+#endif
+#ifndef CLAMP
+# define CLAMP(x, low, high) (((x)>(high))?(high):(((x)<(low))?(low):(x)))
+#endif
#ifdef __GNUC__
# if (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 1)
diff --git a/src/main.cxx b/src/main.cxx
index be271a83..637800ab 100644
--- a/src/main.cxx
+++ b/src/main.cxx
@@ -101,15 +101,16 @@ int rxmsgid = -1;
TXMSGSTRUC txmsgst;
int txmsgid = -1;
-string option_help;
+string option_help, version_text;
qrunner *cbq[NUM_QRUNNER_THREADS];
void arqchecks(void);
void generate_option_help(void);
int parse_args(int argc, char **argv, int& idx);
-void print_versions(std::ostream& s);
+void generate_version_text(void);
void debug_exec(char** argv);
+void string_wrap(std::string& s, unsigned c);
int main(int argc, char ** argv)
{
@@ -133,6 +134,8 @@ int main(int argc, char ** argv)
HomeDir = szHomedir;
generate_option_help();
+ generate_version_text();
+ string_wrap(version_text, 80);
int arg_idx;
if (Fl::args(argc, argv, arg_idx, parse_args) != argc) {
cerr << PACKAGE_NAME << ": unrecognized option `" << argv[arg_idx]
@@ -288,127 +291,93 @@ void generate_option_help(void) {
ostringstream help;
- int width = 37;
- help << "Usage:\n " << PACKAGE_NAME << " [option...]\n";
+// int width = 72;
+ help << "Usage:\n"
+ << " " << PACKAGE_NAME << " [option...]\n\n";
- help << '\n' << PACKAGE_NAME << " options:\n"
+ help << PACKAGE_NAME << " options:\n\n"
+
+ << " --config-dir DIRECTORY\n"
+ << " Look for configuration files in DIRECTORY\n"
+ << " The default is: " << HomeDir << "\n\n"
+
+ << " --rx-ipc-key KEY" << "Set the receive message queue key\n"
+ << " May be given in hex if prefixed with \"0x\"\n"
+ << " The default is: " << progdefaults.rx_msgid
+ << " or 0x" << hex << progdefaults.rx_msgid << dec << "\n\n"
- << setw(width) << setiosflags(ios::left)
- << " --config-dir DIRECTORY"
- << "Look for configuration files in DIRECTORY\n"
- << setw(width) << setiosflags(ios::left)
- << "" << "The default is: " << HomeDir << '\n'
+ << " --tx-ipc-key KEY" << "Set the transmit message queue key\n"
+ << " May be given in hex if prefixed with \"0x\"\n"
+ << " The default is: " << progdefaults.tx_msgid
+ << " or 0x" << hex << progdefaults.tx_msgid << dec << "\n\n"
- << setw(width) << setiosflags(ios::left)
- << " --rx-ipc-key KEY" << "Set the receive message queue key\n"
- << setw(width) << setiosflags(ios::left)
- << "" << "May be given in hex if prefixed with \"0x\"\n"
- << setw(width) << setiosflags(ios::left)
- << "" << "The default is: " << progdefaults.rx_msgid
- << " or 0x" << hex << progdefaults.rx_msgid << dec << '\n'
+ << " --version\n"
+ << " Print version information\n\n"
- << setw(width) << setiosflags(ios::left)
- << " --tx-ipc-key KEY" << "Set the transmit message queue key\n"
- << setw(width) << setiosflags(ios::left)
- << "" << "May be given in hex if prefixed with \"0x\"\n"
- << setw(width) << setiosflags(ios::left)
- << "" << "The default is: " << progdefaults.tx_msgid
- << " or 0x" << hex << progdefaults.tx_msgid << dec << '\n'
+ << " --help\n"
+ << " Print this option help\n\n";
- << setw(width) << setiosflags(ios::left)
- << " --version" << "Print version information\n"
+// Fl::help looks ugly so we'll write our own
- << setw(width) << setiosflags(ios::left)
- << " --help" << "Print this option help\n";
+ help << "Standard FLTK options:\n\n"
+ << " -bg COLOR, -background COLOR\n"
+ << " Set the background color\n"
- // Fl::help looks ugly so we'll write our own
+ << " -bg2 COLOR, -background2 COLOR\n"
+ << " Set the secondary (text) background color\n\n"
- help << "\nStandard FLTK options:\n"
+ << " -di DISPLAY, -display DISPLAY\n"
+ << " Set the X display to use DISPLAY,\n"
+ << " format is ``host:n.n''\n\n"
- << setw(width) << setiosflags(ios::left)
- << " -bg COLOR, -background COLOR"
- << "Set the background color\n"
+ << " -dn, -dnd or -nodn, -nodnd\n"
+ << " Enable or disable drag and drop copy and\n"
+ << " paste in text fields\n\n"
- << setw(width) << setiosflags(ios::left)
- << " -bg2 COLOR, -background2 COLOR"
- << "Set the secondary (text) background color\n"
+ << " -fg COLOR, -foreground COLOR\n"
+ << " Set the foreground color\n\n"
- << setw(width) << setiosflags(ios::left)
- << " -di, -display DISPLAY"
- << "Set the X display to use\n"
- << setw(width) << setiosflags(ios::left)
- << "" << "DISPLAY format is ``host:n.n''\n"
+ << " -g GEOMETRY, -geometry GEOMETRY\n"
+ << " Set the initial window size and position\n"
+ << " GEOMETRY format is ``WxH+X+Y''\n"
+ << " ** " << PACKAGE_NAME << " may override this settting **\n\n"
- << setw(width) << setiosflags(ios::left)
- << " -dn, -dnd or -nodn, -nodnd"
- << "Enable or disable drag and drop copy and\n"
- << setw(width) << setiosflags(ios::left)
- << "" << "paste in text fields\n"
+ << " -i, -iconic\n"
+ << " Start " << PACKAGE_NAME << " in iconified state\n\n"
- << setw(width) << setiosflags(ios::left)
- << " -fg COLOR, -foreground COLOR"
- << "Set the foreground color\n"
+ << " -k, -kbd or -nok, -nokbd\n"
+ << " Enable or disable visible keyboard focus in non-text widgets\n\n"
- << setw(width) << setiosflags(ios::left)
- << " -g GEOMETRY, -geometry GEOMETRY"
- << "Set the initial window size and position\n"
- << setw(width) << setiosflags(ios::left)
- << "" << "GEOMETRY format is ``WxH+X+Y''\n"
- << setw(width) << setiosflags(ios::left)
- << "" << "** " << PACKAGE_NAME << " may override this settting **\n"
+ << " -na CLASSNAME, -name CLASSNAME\n"
+ << " Set the window class to CLASSNAME\n\n"
- << setw(width) << setiosflags(ios::left)
- << " -i, -iconic"
- << "Start " << PACKAGE_NAME << " in iconified state\n"
+ << " -s SCHEME, -scheme SCHEME\n"
+ << " Set the widget scheme\n"
+ << " SCHEME can be one of: " << schemes << "\n\n"
- << setw(width) << setiosflags(ios::left)
- << " -k, -kbd or -nok, -nokbd"
- << "Enable or disable visible keyboard focus\n"
- << setw(width) << setiosflags(ios::left)
- << "" << "in non-text widgets\n"
+ << " -ti WINDOWTITLE, -title WINDOWTITLE\n"
+ << " Set the window title\n\n"
- << setw(width) << setiosflags(ios::left)
- << " -na CLASSNAME, -name CLASSNAME"
- << "Set the window class to CLASSNAME\n"
+ << " -to, -tooltips or -not, -notooltips\n"
+ << " Enable or disable tooltips\n\n";
- << setw(width) << setiosflags(ios::left)
- << " -s SCHEME, -scheme SCHEME"
- << "Set the widget scheme\n"
- << setw(width) << setiosflags(ios::left)
- << "" << "SCHEME can be one of: " << schemes << '\n'
-
- << setw(width) << setiosflags(ios::left)
- << " -ti WINDOWTITLE, -title WINDOWTITLE"
- << "Set the window title\n"
-
- << setw(width) << setiosflags(ios::left)
- << " -to, -tooltips or -not, -notooltips"
- << "Enable or disable tooltips\n";
-
- help << "\nAdditional UI options:\n"
+ help << "Additional UI options:\n\n"
// << setw(width) << setiosflags(ios::left)
// << " --fast-text" << "Use fast text widgets\n"
- << setw(width) << setiosflags(ios::left)
- << " --font FONT[:SIZE]"
- << "Set the widget font and (optional) size\n"
- << setw(width) << setiosflags(ios::left)
- << "" << "The default is: " << Fl::get_font(FL_HELVETICA)
- << ':' << FL_NORMAL_SIZE << '\n'
+ << " --font FONT[:SIZE]\n"
+ << " Set the widget font and (optionally) size\n"
+ << " The default is: " << Fl::get_font(FL_HELVETICA)
+ << ':' << FL_NORMAL_SIZE << "\n\n"
- << setw(width) << setiosflags(ios::left)
- << " --profile PROFILE"
- << "If PROFILE is ``emc'', ``emcomm'', or\n"
- << setw(width) << setiosflags(ios::left)
- << "" << "``minimal'', widget sizes will be adjusted\n"
- << setw(width) << setiosflags(ios::left)
- << "" << "for a minimal screen footprint.\n"
+ << " --profile PROFILE\n"
+ << " If PROFILE is ``emc'', ``emcomm'', or ``minimal'',\n"
+ << " widget sizes will be adjusted for a minimal screen footprint\n\n"
- << setw(width) << setiosflags(ios::left)
- << " --usechkbtns"
- << "Use check buttons for AFC / SQL\n";
+ << " --usechkbtns\n"
+ << " Use check buttons for AFC / SQL.\n";
option_help = help.str();
@@ -558,7 +527,7 @@ int parse_args(int argc, char **argv, int& idx)
exit(EXIT_SUCCESS);
case OPT_VERSION:
- print_versions(cerr);
+ cerr << version_text;
exit(EXIT_SUCCESS);
case '?':
@@ -572,8 +541,9 @@ int parse_args(int argc, char **argv, int& idx)
return 0;
}
-void print_versions(std::ostream& s)
+void generate_version_text(void)
{
+ ostringstream s;
s << PACKAGE_NAME << ' ' << PACKAGE_VERSION << "\n\nSystem: ";
struct utsname u;
if (uname(&u) != -1) {
@@ -587,32 +557,34 @@ void print_versions(std::ostream& s)
s /*<< "\nConfigured with: " << COMPILE_CFG*/ << '\n'
<< "Built on " << COMPILE_DATE << " by " << COMPILE_USER
<< '@' << COMPILE_HOST << " with:\n"
- << ' ' << COMPILER << '\n'
- << " CFLAGS=" << CFLAGS << '\n'
- << " LDFLAGS=" << LDFLAGS << '\n';
+ << COMPILER << '\n'
+ << "CFLAGS=" << CFLAGS << '\n'
+ << "LDFLAGS=" << LDFLAGS << '\n';
#endif // HAVE_VERSIONS_H
s << "Libraries:\n"
- << " FLTK " << FL_MAJOR_VERSION << '.' << FL_MINOR_VERSION << '.'
+ << "FLTK " << FL_MAJOR_VERSION << '.' << FL_MINOR_VERSION << '.'
<< FL_PATCH_VERSION << '\n';
#if USE_HAMLIB
- s << ' ' << hamlib_version << '\n';
+ s << hamlib_version << '\n';
#endif
#if USE_PORTAUDIO
- s << ' ' << Pa_GetVersionText() << ' ' << Pa_GetVersion() << '\n';
+ s << Pa_GetVersionText() << ' ' << Pa_GetVersion() << '\n';
#endif
#if USE_SNDFILE
char sndfile_version[32];
sf_command(NULL, SFC_GET_LIB_VERSION, sndfile_version, sizeof(sndfile_version));
- s << ' ' << sndfile_version << '\n';
+ s << sndfile_version << '\n';
#endif
#ifdef src_get_version
s << ' ' << src_get_version() << '\n';
#endif
+
+ version_text = s.str();
}
// When debugging is enabled, reexec with malloc debugging hooks enabled, unless
@@ -641,3 +613,20 @@ void debug_exec(char** argv)
perror("execvp");
#endif
}
+
+void string_wrap(std::string& s, unsigned c)
+{
+ string::size_type spos = s.find(' '), prev = spos, line = 0;
+
+ while ((spos = s.find_first_of(" \n", spos+1)) != string::npos) {
+ if (spos - line > c) {
+ s[prev] = '\n';
+ line = prev + 1;
+ }
+ if (s[spos] == '\n')
+ line = spos + 1;
+ prev = spos;
+ }
+ if (s.length() - line > c)
+ s[prev] = '\n';
+}
diff --git a/src/mfsk/mfsk.cxx b/src/mfsk/mfsk.cxx
index 92a47fa1..e4449f4c 100644
--- a/src/mfsk/mfsk.cxx
+++ b/src/mfsk/mfsk.cxx
@@ -40,11 +40,6 @@
#include "qrunner.h"
-#undef MAX
-#define MAX(a,b) (((a)>(b))?(a):(b))
-#undef CLAMP
-#define CLAMP(x,low,high) (((x)>(high))?(high):(((x)<(low))?(low):(x)))
-
#define AFC_COUNT 32
diff --git a/src/misc/stacktrace.cxx b/src/misc/stacktrace.cxx
index 98119e5a..a41742a5 100644
--- a/src/misc/stacktrace.cxx
+++ b/src/misc/stacktrace.cxx
@@ -57,8 +57,8 @@ void diediedie(void)
" due to a fatal error.\nPlease report this to "
PACKAGE_BUGREPORT << "\n\n";
pstack(STDERR_FILENO);
- extern void print_versions(std::ostream&);
- print_versions(std::cerr << "\nVersion information:\n");
+ extern std::string version_text;
+ std::cerr << "\nVersion information:\n" << version_text;
abort();
}
diff --git a/src/misc/util.cxx b/src/misc/util.cxx
index d282b8d7..b72daf79 100644
--- a/src/misc/util.cxx
+++ b/src/misc/util.cxx
@@ -1,6 +1,8 @@
#include