kopia lustrzana https://github.com/jamescoxon/dl-fldigi
Macro tag changes
Added macro tag <FILE:> with selected file target Added macro tag <MACROS:> with selected file target Deleted update_main_title() from macro save / load Corrected bugs associated with executing /Files/Open macros... a. title bar not changed in macro editor b. altMacros / btnAltMacros not correctly resetpull/2/head
rodzic
5af4ad7e08
commit
5d305c9717
|
@ -56,6 +56,7 @@ struct MACROTEXT {
|
|||
}
|
||||
private:
|
||||
string expanded;
|
||||
void loadnewMACROS(string &s, size_t &i);
|
||||
};
|
||||
|
||||
extern MACROTEXT macros;
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
#include "macroedit.h"
|
||||
#include "globals.h"
|
||||
#include "status.h"
|
||||
#include "fileselect.h"
|
||||
|
||||
#include <string>
|
||||
|
||||
|
@ -85,6 +86,10 @@ void loadBrowser(Fl_Widget *widget) {
|
|||
w->add("<VER>\tFldigi + version");
|
||||
w->add("<TIMER>\trepeat every NNN sec");
|
||||
w->add("<IDLE>\tidle signal for NNN sec");
|
||||
|
||||
w->add(LINE_SEP);
|
||||
w->add("<FILE:>\tinsert text file");
|
||||
w->add("<MACROS:>\tchange macro defs file");
|
||||
|
||||
w->add(LINE_SEP);
|
||||
char s[256];
|
||||
|
@ -145,6 +150,23 @@ void cbInsertMacro(Fl_Widget *, void *)
|
|||
text.erase(tab);
|
||||
if (text == LINE_SEP)
|
||||
return;
|
||||
if (text == "<FILE:>") {
|
||||
string filters = "Text\t*." "txt";
|
||||
const char* p = FSEL::select("Text file to insert", filters.c_str(),
|
||||
"text." "txt");
|
||||
if (p) {
|
||||
text.insert(6, p);
|
||||
} else
|
||||
text = "";
|
||||
} else if (text == "<MACROS:>") {
|
||||
string filters = "Macrost\t*." "mdf";
|
||||
const char* p = FSEL::select("Change to Macro file", filters.c_str(),
|
||||
"macros." "mdf");
|
||||
if (p) {
|
||||
text.insert(8, p);
|
||||
} else
|
||||
text = "";
|
||||
}
|
||||
macrotext->insert(text.c_str());
|
||||
macrotext->take_focus();
|
||||
}
|
||||
|
@ -181,6 +203,11 @@ Fl_Double_Window* make_macroeditor(void)
|
|||
void editMacro(int n)
|
||||
{
|
||||
if (!MacroEditDialog) MacroEditDialog = make_macroeditor();
|
||||
else {
|
||||
editor_label = "";
|
||||
editor_label.append("Macro editor - ").append(progStatus.LastMacroFile);
|
||||
MacroEditDialog->label(editor_label.c_str());
|
||||
}
|
||||
macrotext->value(macros.text[n].c_str());
|
||||
labeltext->value(macros.name[n].c_str());
|
||||
iMacro = n;
|
||||
|
|
|
@ -70,6 +70,8 @@ void pGET(string &, size_t &);
|
|||
void pINFO1(string &, size_t &);
|
||||
void pINFO2(string &, size_t &);
|
||||
void pCLRRX(string &, size_t &);
|
||||
void pFILE(string &, size_t &);
|
||||
//void pMACROS(string &, size_t &);
|
||||
|
||||
MTAGS mtags[] = {
|
||||
{"<CALL>", pCALL},
|
||||
|
@ -112,6 +114,8 @@ MTAGS mtags[] = {
|
|||
{"<CONT>", pCONT},
|
||||
{"<GET>", pGET},
|
||||
{"<CLRRX>", pCLRRX},
|
||||
{"<FILE:", pFILE},
|
||||
//{"<MACROS:", pMACROS},
|
||||
{0, 0}
|
||||
};
|
||||
|
||||
|
@ -125,6 +129,24 @@ size_t mystrftime( char *s, size_t max, const char *fmt, const struct tm *tm) {
|
|||
return strftime(s, max, fmt, tm);
|
||||
}
|
||||
|
||||
void pFILE(string &s, size_t &i)
|
||||
{
|
||||
size_t endbracket = s.find('>',i);
|
||||
string fname = s.substr(i+6, endbracket - i - 6);
|
||||
if (fname.length() > 0) {
|
||||
FILE *toadd = fopen(fname.c_str(), "r");
|
||||
string buffer;
|
||||
char c = getc(toadd);
|
||||
while (c && !feof(toadd)) {
|
||||
if (c != '\r') buffer += c; // damn MSDOS txt files
|
||||
c = getc(toadd);
|
||||
}
|
||||
s.replace(i, endbracket - i + 1, buffer);
|
||||
fclose(toadd);
|
||||
} else
|
||||
s.replace(i, endbracket - i + 1, "");
|
||||
}
|
||||
|
||||
void pINFO1(string &s, size_t &i)
|
||||
{
|
||||
s.replace( i, 7, info1msg );
|
||||
|
@ -646,6 +668,9 @@ int MACROTEXT::loadMacros(string filename)
|
|||
text[mNumber] = text[mNumber] + mLine;
|
||||
}
|
||||
mFile.close();
|
||||
altMacros = 0;
|
||||
btnAltMacros->label("1");
|
||||
btnAltMacros->redraw_label();
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -675,7 +700,6 @@ void MACROTEXT::openMacroFile()
|
|||
if (p) {
|
||||
loadMacros(p);
|
||||
progStatus.LastMacroFile = fl_filename_name(p);
|
||||
update_main_title();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -687,10 +711,19 @@ void MACROTEXT::saveMacroFile()
|
|||
if (p) {
|
||||
saveMacros(p);
|
||||
progStatus.LastMacroFile = fl_filename_name(p);
|
||||
update_main_title();
|
||||
}
|
||||
}
|
||||
|
||||
void MACROTEXT::loadnewMACROS(string &s, size_t &i)
|
||||
{
|
||||
size_t endbracket = s.find('>',i);
|
||||
string fname = s.substr(i+8, endbracket - i - 8);
|
||||
if (fname.length() > 0) {
|
||||
loadMacros(fname);
|
||||
progStatus.LastMacroFile = fl_filename_name(fname.c_str());
|
||||
}
|
||||
s.replace(i, endbracket - i + 1, "");
|
||||
}
|
||||
|
||||
string MACROTEXT::expandMacro(int n)
|
||||
{
|
||||
|
@ -702,6 +735,11 @@ string MACROTEXT::expandMacro(int n)
|
|||
MTAGS *pMtags;
|
||||
|
||||
while ((idx = expanded.find('<', idx)) != string::npos) {
|
||||
if (expanded.find("<MACROS:",idx) == idx) {
|
||||
loadnewMACROS(expanded, idx);
|
||||
idx++;
|
||||
continue;
|
||||
}
|
||||
// we must handle this specially
|
||||
if (expanded.find("<CONT>", idx) == idx)
|
||||
pCONT(expanded, idx);
|
||||
|
|
Ładowanie…
Reference in New Issue