Hi Dave,
True. In that case moving it as an option (with sane defaults) did seem like
a better way. So attached is a reworked patch that puts two options in
frmOptions.
1. A checkbox (in preferences tab) that applies to line numbers universally.
2. One checkbox (in the Query tab) specific to the SQL Query window.
The defaults ensure that the we maintain status quo (i.e. Line numbers are
enabled for Functions/Triggers but disabled for Query window).
Regards,
*Robins Tharakan*
---------- Forwarded message ----------
From: Dave Page <[EMAIL PROTECTED]>
Date: Tue, Mar 4, 2008 at 3:11 PM
Subject: Re: [pgadmin-hackers] Display line numbers in SQL view
To: Robins Tharakan <[EMAIL PROTECTED]>
Cc: [email protected]
On Mon, Mar 3, 2008 at 6:29 PM, Robins Tharakan <[EMAIL PROTECTED]> wrote:
> Hi,
>
> During constant debugging of triggers / functions in office, I see the
need
> to copy paste a specific SQL string and run it in the SQL view to trace a
> bug on a given nth line. The problem being that the SQL view doesn't have
> line numbers in the margin like the Create function SQL tab.
>
> This patch adds line numbers to the SQL view as well.
>
> (This patch just enables the line-numbers in the margin, in case its
> desirable to have a checkbox that allows the user to enable/disable this,
we
> could have a menu option for that in the View menu. Should we ?)
This has been turned on and off repeatedly over the years. I think the
main problem is that some people have quite long scripts for which the
line numbers start to take up a lot of room. I wouldn't be opposed to
making it a configurable option though... but many of the options in
the query tool actually affect other instances of the styled text
control as well. I wonder if now is the time to think about moving
them to the main options dialogue?
--
Dave Page
EnterpriseDB UK Ltd: http://www.enterprisedb.com
PostgreSQL UK 2008 Conference: http://www.postgresql.org.uk
Index: pgadmin/include/utils/sysSettings.h
===================================================================
--- pgadmin/include/utils/sysSettings.h (revision 7164)
+++ pgadmin/include/utils/sysSettings.h (working copy)
@@ -98,6 +98,12 @@
long GetIndentSpaces() const { return indentSpaces; }
void SetIndentSpaces(long l) { indentSpaces=l; }
+ bool GetLineNumbersUniversal() const { return displayLineNumbersUniversal; }
+ void SetLineNumbersUniversal(bool lnu) { displayLineNumbersUniversal=lnu; }
+
+ bool GetLineNumbersQuery() const { return displayLineNumbersQuery; }
+ void SetLineNumbersQuery(bool lnq) { displayLineNumbersQuery=lnq; }
+
bool GetSpacesForTabs() const { return spacesForTabs; }
void SetSpacesForTabs(const bool newval) { spacesForTabs = newval; }
@@ -223,6 +229,7 @@
long maxRows, maxColSize, autoRowCountThreshold, indentSpaces;
bool spacesForTabs, stickySql, indicateNull, unicodeFile, tabForCompletion;
bool doubleClickProperties;
+ bool displayLineNumbersUniversal, displayLineNumbersQuery;
long maxServerLogSize;
wxString searchPath, systemSchemas;
Index: pgadmin/frm/frmOptions.cpp
===================================================================
--- pgadmin/frm/frmOptions.cpp (revision 7164)
+++ pgadmin/frm/frmOptions.cpp (working copy)
@@ -61,6 +61,8 @@
#define txtAutoRowCount CTRL_TEXT("txtAutoRowCount")
#define txtIndent CTRL_TEXT("txtIndent")
#define chkSpacesForTabs CTRL_CHECKBOX("chkSpacesForTabs")
+#define chkLineNumbersQuery CTRL_CHECKBOX("chkLineNumbersQuery")
+#define chkLineNumbersUniversal CTRL_CHECKBOX("chkLineNumbersUniversal")
#define cbCopyQuote CTRL_COMBOBOX("cbCopyQuote")
#define cbCopyQuoteChar CTRL_COMBOBOX("cbCopyQuoteChar")
#define cbCopySeparator CTRL_COMBOBOX("cbCopySeparator")
@@ -125,7 +127,9 @@
chkShowUsersForPrivileges->SetValue(settings->GetShowUsersForPrivileges());
txtAutoRowCount->SetValue(NumToStr(settings->GetAutoRowCountThreshold()));
txtIndent->SetValue(NumToStr(settings->GetIndentSpaces()));
- chkSpacesForTabs->SetValue(settings->GetSpacesForTabs());
+ chkLineNumbersUniversal->SetValue(settings->GetLineNumbersUniversal());
+ chkLineNumbersQuery->SetValue(settings->GetLineNumbersQuery());
+ chkSpacesForTabs->SetValue(settings->GetSpacesForTabs());
cbCopyQuote->SetSelection(settings->GetCopyQuoting());
cbCopyQuoteChar->SetValue(settings->GetCopyQuoteChar());
@@ -358,6 +362,8 @@
settings->SetAutoRowCountThreshold(StrToLong(txtAutoRowCount->GetValue()));
settings->SetIndentSpaces(StrToLong(txtIndent->GetValue()));
settings->SetSpacesForTabs(chkSpacesForTabs->GetValue());
+ settings->SetLineNumbersQuery(chkLineNumbersQuery->GetValue());
+ settings->SetLineNumbersUniversal(chkLineNumbersUniversal->GetValue());
settings->SetCopyQuoting(cbCopyQuote->GetCurrentSelection());
settings->SetCopyQuoteChar(cbCopyQuoteChar->GetValue());
Index: pgadmin/frm/frmQuery.cpp
===================================================================
--- pgadmin/frm/frmQuery.cpp (revision 7164)
+++ pgadmin/frm/frmQuery.cpp (working copy)
@@ -303,7 +303,13 @@
// Query box
sqlQuery = new ctlSQLBox(this, CTL_SQLQUERY, wxDefaultPosition, wxDefaultSize, wxTE_MULTILINE | wxSIMPLE_BORDER | wxTE_RICH2);
sqlQuery->SetDatabase(conn);
- sqlQuery->SetMarginWidth(1, 16);
+
+ if (settings->GetLineNumbersQuery())
+ {
+ sqlQuery->SetMarginType(1, wxSTC_MARGIN_NUMBER);
+ sqlQuery->SetMarginWidth(1, ConvertDialogToPixels(wxPoint(16, 0)).x);
+ }
+
SetLineEndingStyle();
// Results pane
Index: pgadmin/utils/sysSettings.cpp
===================================================================
--- pgadmin/utils/sysSettings.cpp (revision 7164)
+++ pgadmin/utils/sysSettings.cpp (working copy)
@@ -148,6 +148,8 @@
showUsersForPrivileges=StrToBool(Read(wxT("ShowUsersForPrivileges"), wxT("No")));
Read(wxT("AutoRowCount"), &autoRowCountThreshold, 2000L);
Read(wxT("IndentSpaces"), &indentSpaces, 0L);
+ Read(wxT("DisplayLineNumbersUniversal"), &displayLineNumbersUniversal, true);
+ Read(wxT("DisplayLineNumbersQuery"), &displayLineNumbersQuery, false);
Read(wxT("SpacesForTabs"), &spacesForTabs, false);
Read(wxT("TabForCompletion"), &tabForCompletion, false);
Read(wxT("StickySql"), &stickySql, false);
@@ -434,6 +436,8 @@
Write(wxT("PostgreSQLPath"), postgresqlPath);
Write(wxT("EnterpriseDBPath"), enterprisedbPath);
Write(wxT("IndentSpaces"), indentSpaces);
+ Write(wxT("DisplayLineNumbersUniversal"), displayLineNumbersUniversal);
+ Write(wxT("DisplayLineNumbersQuery"), displayLineNumbersQuery);
Write(wxT("SpacesForTabs"), spacesForTabs);
Write(wxT("TabForCompletion"), tabForCompletion);
Index: pgadmin/dlg/dlgFunction.cpp
===================================================================
--- pgadmin/dlg/dlgFunction.cpp (revision 7164)
+++ pgadmin/dlg/dlgFunction.cpp (working copy)
@@ -117,8 +117,11 @@
txtArguments->Disable();
- txtSqlBox->SetMarginType(1, wxSTC_MARGIN_NUMBER);
- txtSqlBox->SetMarginWidth(1, ConvertDialogToPixels(wxPoint(16, 0)).x);
+ if (settings->GetLineNumbersUniversal())
+ {
+ txtSqlBox->SetMarginType(1, wxSTC_MARGIN_NUMBER);
+ txtSqlBox->SetMarginWidth(1, ConvertDialogToPixels(wxPoint(16, 0)).x);
+ }
btnAdd->Disable();
btnRemove->Disable();
Index: pgadmin/dlg/dlgPackage.cpp
===================================================================
--- pgadmin/dlg/dlgPackage.cpp (revision 7164)
+++ pgadmin/dlg/dlgPackage.cpp (working copy)
@@ -43,11 +43,14 @@
schema=sch;
package=node;
- txtHeader->SetMarginType(1, wxSTC_MARGIN_NUMBER);
- txtHeader->SetMarginWidth(1, ConvertDialogToPixels(wxPoint(16, 0)).x);
+ if (settings->GetLineNumbersUniversal())
+ {
+ txtHeader->SetMarginType(1, wxSTC_MARGIN_NUMBER);
+ txtHeader->SetMarginWidth(1, ConvertDialogToPixels(wxPoint(16, 0)).x);
- txtBody->SetMarginType(1, wxSTC_MARGIN_NUMBER);
- txtBody->SetMarginWidth(1, ConvertDialogToPixels(wxPoint(16, 0)).x);
+ txtBody->SetMarginType(1, wxSTC_MARGIN_NUMBER);
+ txtBody->SetMarginWidth(1, ConvertDialogToPixels(wxPoint(16, 0)).x);
+ }
}
Index: pgadmin/dlg/dlgTrigger.cpp
===================================================================
--- pgadmin/dlg/dlgTrigger.cpp (revision 7164)
+++ pgadmin/dlg/dlgTrigger.cpp (working copy)
@@ -62,8 +62,11 @@
table=parentNode;
wxASSERT(!table || table->GetMetaType() == PGM_TABLE);
- txtBody->SetMarginType(1, wxSTC_MARGIN_NUMBER);
- txtBody->SetMarginWidth(1, ConvertDialogToPixels(wxPoint(16, 0)).x);
+ if (settings->GetLineNumbersUniversal())
+ {
+ txtBody->SetMarginType(1, wxSTC_MARGIN_NUMBER);
+ txtBody->SetMarginWidth(1, ConvertDialogToPixels(wxPoint(16, 0)).x);
+ }
}
Index: pgadmin/ui/frmOptions.xrc
===================================================================
--- pgadmin/ui/frmOptions.xrc (revision 7164)
+++ pgadmin/ui/frmOptions.xrc (working copy)
@@ -150,6 +150,11 @@
<pos>5,97d</pos>
<size>226,12d</size>
</object>
+ <object class="wxCheckBox" name="chkLineNumbersUniversal">
+ <label>Display Line Numbers Universally (unless specifically disabled)</label>
+ <pos>5,109d</pos>
+ <size>226,12d</size>
+ </object>
</object>
</object>
<object class="notebookpage">
@@ -286,6 +291,16 @@
<pos>175,172d</pos>
<size>226,12d</size>
</object>
+ <object class="wxStaticText" name="stLineNumbersQuery">
+ <label>Show Line Numbers in Query</label>
+ <pos>5,187d</pos>
+ </object>
+ <object class="wxCheckBox" name="chkLineNumbersQuery">
+ <label></label>
+ <checked>0</checked>
+ <pos>175,187d</pos>
+ <size>226,12d</size>
+ </object>
</object>
</object>
<object class="notebookpage">
--
Sent via pgadmin-hackers mailing list ([email protected])
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgadmin-hackers