diff --git a/ctl/ctlSQLBox.cpp b/ctl/ctlSQLBox.cpp
index 0825539..67ae549 100644
--- a/ctl/ctlSQLBox.cpp
+++ b/ctl/ctlSQLBox.cpp
@@ -929,7 +929,7 @@ void ctlSQLBox::OnEndProcess(wxProcessEvent &ev)
}
}
-wxString ctlSQLBox::ExternalFormat()
+wxString ctlSQLBox::ExternalFormat(int typecmd)
{
wxString msg;
processOutput = wxEmptyString;
@@ -945,9 +945,14 @@ wxString ctlSQLBox::ExternalFormat()
return _("Nothing to format.");
wxString formatCmd = settings->GetExtFormatCmd();
+ wxString msgword = "formatt";
+ if (typecmd == 1) {
+ formatCmd = settings->GetExtAlignCmd();
+ msgword = "align";
+ }
if (formatCmd.IsEmpty())
{
- return _("You need to setup a formatting command");
+ return _("You need to setup a "+msgword+"ing command");
}
if (process)
@@ -967,7 +972,7 @@ wxString ctlSQLBox::ExternalFormat()
delete process;
process = NULL;
processID = 0;
- msg = _("Couldn't run formatting command: ") + formatCmd;
+ msg = _("Couldn't run " + msgword + "ing command: ") + formatCmd;
return msg;
}
process->WriteOutputStream(processInput);
@@ -989,7 +994,7 @@ wxString ctlSQLBox::ExternalFormat()
if (process)
{
AbortProcess();
- return wxString::Format(_("Formatting command did not respond in %d ms"), timeoutMs);
+ return wxString::Format(_("" + msgword + "ing command did not respond in %d ms"), timeoutMs);
}
if (processExitCode != 0)
@@ -1000,7 +1005,7 @@ wxString ctlSQLBox::ExternalFormat()
}
else if (processOutput.Trim().IsEmpty())
{
- return _("Formatting command error: Output is empty.");
+ return _("" + msgword + "ing command error: Output is empty.");
}
if (isSelected)
@@ -1008,7 +1013,7 @@ wxString ctlSQLBox::ExternalFormat()
else
SetText(processOutput);
- return _("Formatting complete.");
+ return _("" + msgword + "ing complete.");
}
void ctlSQLBox::AbortProcess()
diff --git a/frm/frmOptions.cpp b/frm/frmOptions.cpp
index 974304b..833281f 100644
--- a/frm/frmOptions.cpp
+++ b/frm/frmOptions.cpp
@@ -108,6 +108,7 @@
#define pickerMacrosFile CTRL_FILEPICKER("pickerMacrosFile")
#define pickerHistoryFile CTRL_FILEPICKER("pickerHistoryFile")
#define pickerExtFormatCmd CTRL_FILEPICKER("pickerExtFormatCmd")
+#define pickerExtAlignCmd CTRL_FILEPICKER("pickerExtAlignCmd")
#define txtHistoryMaxQueries CTRL_TEXT("txtHistoryMaxQueries")
#define txtHistoryMaxQuerySize CTRL_TEXT("txtHistoryMaxQuerySize")
#define chkSQLUseSystemBackgroundColour CTRL_CHECKBOX("chkSQLUseSystemBackgroundColour")
@@ -339,6 +340,7 @@ frmOptions::frmOptions(frmMain *parent)
pickerMacrosFile->SetPath(settings->GetMacrosFile());
pickerHistoryFile->SetPath(settings->GetHistoryFile());
pickerExtFormatCmd->SetPath(settings->GetExtFormatCmd());
+ pickerExtAlignCmd->SetPath(settings->GetExtAlignCmd());
txtHistoryMaxQueries->SetValue(NumToStr(settings->GetHistoryMaxQueries()));
txtHistoryMaxQuerySize->SetValue(NumToStr(settings->GetHistoryMaxQuerySize()));
@@ -799,6 +801,7 @@ void frmOptions::OnOK(wxCommandEvent &ev)
settings->SetMacrosFile(pickerMacrosFile->GetPath());
settings->SetHistoryFile(pickerHistoryFile->GetPath());
settings->SetExtFormatCmd(pickerExtFormatCmd->GetPath());
+ settings->SetExtAlignCmd(pickerExtAlignCmd->GetPath());
// Change SQL Syntax colours
if (settings->GetSQLBoxUseSystemBackground() != chkSQLUseSystemBackgroundColour->GetValue())
diff --git a/frm/frmQuery.cpp b/frm/frmQuery.cpp
index b87d572..a12bc08 100644
--- a/frm/frmQuery.cpp
+++ b/frm/frmQuery.cpp
@@ -173,6 +173,7 @@ BEGIN_EVENT_TABLE(frmQuery, pgFrame)
EVT_MENU(MNU_DOUBLEQUOTE_TEXT, frmQuery::OnDoubleText)
EVT_MENU(MNU_UNDOUBLEQUOTE_TEXT,frmQuery::OnUnDoubleText)
EVT_MENU(MNU_EXTERNALFORMAT, frmQuery::OnExternalFormat)
+ EVT_MENU(MNU_EXTERNALALIGN, frmQuery::OnExternalAlign)
EVT_MENU(MNU_LF, frmQuery::OnSetEOLMode)
EVT_MENU(MNU_CRLF, frmQuery::OnSetEOLMode)
EVT_MENU(MNU_CR, frmQuery::OnSetEOLMode)
@@ -392,6 +393,7 @@ frmQuery::frmQuery(frmMain *form, const wxString &_title, pgConn *_conn, const w
formatMenu->Append(MNU_UNDOUBLEQUOTE_TEXT, _("Undouble the single quote\tCtrl-Shift-'"), _("Undouble the single quote"));
formatMenu->AppendSeparator();
formatMenu->Append(MNU_EXTERNALFORMAT, _("External Format\tCtrl-Shift-F"), _("Call external formatting command"));
+ formatMenu->Append(MNU_EXTERNALALIGN, _("External Align\tCtrl-Shift-A"), _("Call external align command"));
editMenu->AppendSubMenu(formatMenu, _("F&ormat"));
editMenu->Append(MNU_LINEENDS, _("&Line ends"), lineEndMenu);
editMenu->Append(MNU_AUTOREPLACE_MANAGE, _("Manage autoreplace..."), _("Edit and delete autoreplace strings"));
@@ -4070,6 +4072,16 @@ void frmQuery::OnExternalFormat(wxCommandEvent &event)
sqlQuery->SetFocus(); // could loose focus after running formatting process
}
}
+void frmQuery::OnExternalAlign(wxCommandEvent& event)
+{
+ if (FindFocus()->GetId() == CTL_SQLQUERY)
+ {
+ wxBusyCursor wait;
+ SetStatusText(_("Running formatting command..."), STATUSPOS_MSGS);
+ SetStatusText(sqlQuery->ExternalFormat(1), STATUSPOS_MSGS);
+ sqlQuery->SetFocus(); // could loose focus after running formatting process
+ }
+}
wxBitmap frmQuery::CreateBitmap(const wxColour &colour)
{
diff --git a/include/ctl/ctlSQLBox.h b/include/ctl/ctlSQLBox.h
index 94c61c4..7cb9f77 100644
--- a/include/ctl/ctlSQLBox.h
+++ b/include/ctl/ctlSQLBox.h
@@ -81,7 +81,7 @@ public:
bool BlockComment(bool uncomment = false);
bool BlockDouble(bool undouble = false);
void UpdateLineNumber();
- wxString ExternalFormat();
+ wxString ExternalFormat(int typecmd = 0);
void AbortProcess();
void SetDefFunction(wxArrayString &name, wxArrayString &def);
CharacterRange RegexFindText(int minPos, int maxPos, const wxString &text);
diff --git a/include/frm/frmQuery.h b/include/frm/frmQuery.h
index 62f23b0..08f66ab 100644
--- a/include/frm/frmQuery.h
+++ b/include/frm/frmQuery.h
@@ -262,6 +262,7 @@ private:
void OnDoubleText(wxCommandEvent& event);
void OnUnDoubleText(wxCommandEvent& event);
void OnExternalFormat(wxCommandEvent &event);
+ void OnExternalAlign(wxCommandEvent& event);
void OnDeleteCurrent(wxCommandEvent &event);
void OnDeleteAll(wxCommandEvent &event);
diff --git a/include/frm/menu.h b/include/frm/menu.h
index d4491c8..fa13afe 100644
--- a/include/frm/menu.h
+++ b/include/frm/menu.h
@@ -119,6 +119,7 @@ enum
MNU_DOUBLEQUOTE_TEXT,
MNU_UNDOUBLEQUOTE_TEXT,
MNU_EXTERNALFORMAT,
+ MNU_EXTERNALALIGN,
MNU_PLUGINBUTTONLIST,
diff --git a/include/utils/sysSettings.h b/include/utils/sysSettings.h
index 700a57e..210007e 100644
--- a/include/utils/sysSettings.h
+++ b/include/utils/sysSettings.h
@@ -477,6 +477,16 @@ public:
{
Write(wxT("ExtFormatCmd"), newval);
}
+ wxString GetExtAlignCmd()
+ {
+ wxString s;
+ Read(wxT("ExtAlignCmd"), &s, wxEmptyString);
+ return s;
+ }
+ void SetExtAlignCmd(const wxString& newval)
+ {
+ Write(wxT("ExtAlignCmd"), newval);
+ }
long GetExtFormatTimeout() const
{
long l;
diff --git a/ui/frmOptions.xrc b/ui/frmOptions.xrc
index 0786f63..a707b66 100644
--- a/ui/frmOptions.xrc
+++ b/ui/frmOptions.xrc
@@ -535,6 +535,23 @@
wxEXPAND|wxTOP|wxLEFT|wxRIGHT
4
+
+
+
+ Select utility to format text
+ *
+
+ A command line utility which reads STDIN and directs output to STDOUT.
+
+ wxEXPAND|wxTOP|wxLEFT|wxRIGHT
+ 4
+