mirror of
https://github.com/levinsv/pgadmin3.git
synced 2026-05-15 14:15:49 -06:00
New features UI query tools.
1. Добавлена подсветка строки с курсором. В настройках можно выбрать цвет фона. 2. Можно указать ширину курсора для раскладки отличной от 0x409 "En" (только Windows). 3. Исправлена проблема с выделением найденного UNICODE текста.
This commit is contained in:
parent
925c8e119f
commit
f92c101ace
5 changed files with 158 additions and 12 deletions
|
|
@ -53,6 +53,7 @@ BEGIN_EVENT_TABLE(ctlSQLBox, wxStyledTextCtrl)
|
|||
EVT_MENU(MNU_COPY, ctlSQLBox::OnCopy)
|
||||
EVT_MENU(MNU_AUTOCOMPLETE, ctlSQLBox::OnAutoComplete)
|
||||
EVT_KILL_FOCUS(ctlSQLBox::OnKillFocus)
|
||||
EVT_TIMER(TIMER_REFRESHUICARRET_ID, ctlSQLBox::OnRefreshUITimer)
|
||||
// EVT_ERASE_BACKGROUND(ctlSQLBox::OnBackGround)
|
||||
#ifdef __WXMAC__
|
||||
EVT_STC_PAINTED(-1, ctlSQLBox::OnPositionStc)
|
||||
|
|
@ -113,6 +114,11 @@ void ctlSQLBox::SetQueryBook(ctlAuiNotebook *query_book)
|
|||
{
|
||||
sql_query_book=query_book;
|
||||
}
|
||||
void ctlSQLBox::OnRefreshUITimer(wxTimerEvent& event) {
|
||||
refreshUITimer->Stop();
|
||||
SetCaretWidthForKeyboardLayout();
|
||||
refreshUITimer->Start(250);
|
||||
}
|
||||
void ctlSQLBox::Create(wxWindow *parent, wxWindowID id, const wxPoint &pos, const wxSize &size, long style)
|
||||
{
|
||||
wxStyledTextCtrl::Create(parent, id , pos, size, style);
|
||||
|
|
@ -121,8 +127,14 @@ void ctlSQLBox::Create(wxWindow *parent, wxWindowID id, const wxPoint &pos, cons
|
|||
// Clear all styles
|
||||
StyleClearAll();
|
||||
m_name=NULL;
|
||||
|
||||
// Font
|
||||
extern sysSettings *settings;
|
||||
|
||||
|
||||
caretWidth=settings->GetWidthCaretForKeyboardLayout();
|
||||
refreshUITimer = new wxTimer(this, TIMER_REFRESHUICARRET_ID);
|
||||
refreshUITimer->Start(250);
|
||||
wxFont fntSQLBox = settings->GetSQLFont();
|
||||
wxColour bgColor=SetSQLBoxColourBackground(false);
|
||||
//wxColour bgColor = settings->GetSQLBoxColourBackground();
|
||||
|
|
@ -144,6 +156,16 @@ void ctlSQLBox::Create(wxWindow *parent, wxWindowID id, const wxPoint &pos, cons
|
|||
SetSelForeground(true, wxSystemSettings::GetColour(wxSYS_COLOUR_HIGHLIGHTTEXT));
|
||||
|
||||
SetCaretForeground(settings->GetSQLColourCaret());
|
||||
if (!settings->GetCaretUseSystemBackground()) {
|
||||
int r = bgColor.GetRed(); int g = bgColor.GetGreen(); int b = bgColor.GetBlue();
|
||||
if (r > 130) r = r - 20; else r = r + 20;
|
||||
if (g > 130) g = g - 20; else g = g + 20;
|
||||
if (b > 130) b = b - 20; else b = b + 20;
|
||||
//wxColour caretLine(r, g, b);
|
||||
wxColour caretLine(settings->GetCaretColourBackground());
|
||||
SetCaretLineBackground(caretLine);
|
||||
SetCaretLineVisible(true);
|
||||
}
|
||||
autoreplace=0;
|
||||
SetMarginWidth(1, 0);
|
||||
SetTabWidth(settings->GetIndentSpaces());
|
||||
|
|
@ -509,7 +531,8 @@ bool ctlSQLBox::DoFind(const wxString &find, const wxString &replace, bool doRep
|
|||
else
|
||||
{
|
||||
selStart = FindText(startPos, endPos, find, flags);
|
||||
selEnd = selStart + find.Length();
|
||||
selEnd = PositionRelative(selStart, find.Length());
|
||||
//selEnd = selStart + find.Length();
|
||||
}
|
||||
|
||||
if (selStart != (size_t)(-1))
|
||||
|
|
@ -550,7 +573,7 @@ void ctlSQLBox::OnFuncHelp(wxCommandEvent& ev) {
|
|||
wxPoint p = ClientToScreen( PointFromPosition(pos));
|
||||
wxString current = GetSelectedText();
|
||||
wxString key = "";
|
||||
if (!current.IsEmpty())
|
||||
if (!current.IsEmpty())
|
||||
key = current;
|
||||
else {
|
||||
wxChar ch;
|
||||
|
|
@ -576,6 +599,8 @@ void ctlSQLBox::OnFuncHelp(wxCommandEvent& ev) {
|
|||
|
||||
void ctlSQLBox::OnKeyDown(wxKeyEvent &event)
|
||||
{
|
||||
|
||||
|
||||
if (event.GetKeyCode() == WXK_ESCAPE && m_PopupHelp) { delete m_PopupHelp; m_PopupHelp = NULL; }
|
||||
int pos = GetCurrentPos();
|
||||
wxChar ch = GetCharAt(pos - 1);
|
||||
|
|
@ -590,7 +615,7 @@ void ctlSQLBox::OnKeyDown(wxKeyEvent &event)
|
|||
if ((fix_pos!=-1)) {
|
||||
//GetIndicatorCurrent()==s_indicHighlight
|
||||
IndicatorClearRange(0,GetTextLength());
|
||||
fix_pos=-1;
|
||||
fix_pos=-1;
|
||||
}
|
||||
|
||||
// Check for braces that aren't in comment styles,
|
||||
|
|
@ -636,7 +661,7 @@ void ctlSQLBox::OnKeyDown(wxKeyEvent &event)
|
|||
#ifdef __WXGTK__
|
||||
event.m_metaDown = false;
|
||||
#endif
|
||||
if (m_name)
|
||||
if (m_name)
|
||||
{
|
||||
if (((event.GetKeyCode() == '0')&&(event.GetModifiers() == (wxMOD_SHIFT)))
|
||||
||event.GetKeyCode() == WXK_UP
|
||||
|
|
@ -692,12 +717,12 @@ void ctlSQLBox::OnKeyDown(wxKeyEvent &event)
|
|||
)) {
|
||||
//int ptip=CallTipPosAtStart();
|
||||
int direction=1;
|
||||
if (event.GetKeyCode() == WXK_LEFT)
|
||||
if (event.GetKeyCode() == WXK_LEFT)
|
||||
direction=-1;
|
||||
char c=GetCharAt(GetCurrentPos());
|
||||
if (event.GetKeyCode() != ','&&c!=',' ) {
|
||||
//direction=ct_hl;
|
||||
} else
|
||||
} else
|
||||
{
|
||||
int pos=ct_hl+direction;
|
||||
int a=0;
|
||||
|
|
@ -1089,7 +1114,7 @@ wxString ctlSQLBox::ExternalFormat(int typecmd)
|
|||
else
|
||||
SetText(processOutput);
|
||||
return _("Formatting Ok");
|
||||
} else
|
||||
} else
|
||||
return wxString::Format("Error parse sql %d",rez);
|
||||
}
|
||||
return _("You need to setup a "+msgword+"ing command");
|
||||
|
|
@ -1187,7 +1212,7 @@ long ctlSQLBox::SelectQuery(int startposition)
|
|||
ch = GetCharAt(pos);
|
||||
st = GetStyleAt(pos) & 0x1F;
|
||||
if ((ch == ';') &&
|
||||
st != wxSTC_SQL_COMMENTLINE &&
|
||||
st != wxSTC_SQL_COMMENTLINE &&
|
||||
st != wxSTC_SQL_STRING &&
|
||||
st != wxSTC_SQL_CHARACTER &&
|
||||
st!= wxSTC_SQL_COMMENT)
|
||||
|
|
@ -1287,6 +1312,23 @@ void ctlSQLBox::OnDoubleClick(wxStyledTextEvent &event)
|
|||
}
|
||||
}
|
||||
}
|
||||
void ctlSQLBox::SetCaretWidthForKeyboardLayout() {
|
||||
int currentwidth = GetCaretWidth();
|
||||
int newwidth = currentwidth;
|
||||
#ifdef __WXMSW__
|
||||
HKL la = GetKeyboardLayout(0);
|
||||
if (((int)la & 0xFFFF) == 0x409) {
|
||||
//en
|
||||
newwidth = 1;
|
||||
}
|
||||
else {
|
||||
// locale
|
||||
newwidth = caretWidth;
|
||||
}
|
||||
#endif
|
||||
if (newwidth != currentwidth) SetCaretWidth(newwidth);
|
||||
return;
|
||||
}
|
||||
void ctlSQLBox::OnPositionStc(wxStyledTextEvent &event)
|
||||
{
|
||||
int pos = GetCurrentPos();
|
||||
|
|
@ -1719,7 +1761,7 @@ void ctlSQLBox::OnAutoComplete(wxCommandEvent &rev)
|
|||
while ( k>=0&&m_name->Item(k).StartsWith(f_name) ) k--;
|
||||
k++;
|
||||
wxString prev;
|
||||
while ( (k<m_name->GetCount())&&m_name->Item(k).StartsWith(f_name) )
|
||||
while ( (k<m_name->GetCount())&&m_name->Item(k).StartsWith(f_name) )
|
||||
{
|
||||
if (prev!=m_name->Item(k)) wxRet+=m_name->Item(k)+wxT("\t");
|
||||
prev=m_name->Item(k);
|
||||
|
|
@ -1752,6 +1794,7 @@ void ctlSQLBox::OnAutoComplete(wxCommandEvent &rev)
|
|||
|
||||
ctlSQLBox::~ctlSQLBox()
|
||||
{
|
||||
delete refreshUITimer;
|
||||
if (m_dlgFindReplace)
|
||||
{
|
||||
m_dlgFindReplace->Destroy();
|
||||
|
|
|
|||
|
|
@ -114,11 +114,15 @@
|
|||
#define pickerExtAlignCmd CTRL_FILEPICKER("pickerExtAlignCmd")
|
||||
#define txtHistoryMaxQueries CTRL_TEXT("txtHistoryMaxQueries")
|
||||
#define txtHistoryMaxQuerySize CTRL_TEXT("txtHistoryMaxQuerySize")
|
||||
#define txtWidthCaretKeyboardLayout CTRL_TEXT("txtWidthCaretKeyboardLayout")
|
||||
#define chkSQLUseSystemBackgroundColour CTRL_CHECKBOX("chkSQLUseSystemBackgroundColour")
|
||||
#define chkCaretUseSystemBackgroundColour CTRL_CHECKBOX("chkCaretUseSystemBackgroundColour")
|
||||
#define chkSQLUseSystemForegroundColour CTRL_CHECKBOX("chkSQLUseSystemForegroundColour")
|
||||
#define pickerSQLBackgroundColour CTRL_COLOURPICKER("pickerSQLBackgroundColour")
|
||||
#define pickerCaretBackgroundColour CTRL_COLOURPICKER("pickerCaretBackgroundColour")
|
||||
#define pickerSQLForegroundColour CTRL_COLOURPICKER("pickerSQLForegroundColour")
|
||||
#define stSQLCustomBackgroundColour CTRL_STATIC("stSQLCustomBackgroundColour")
|
||||
#define stCaretCustomBackgroundColour CTRL_STATIC("stCaretCustomBackgroundColour")
|
||||
#define stSQLCustomForegroundColour CTRL_STATIC("stSQLCustomForegroundColour")
|
||||
#define pickerSQLMarginBackgroundColour CTRL_COLOURPICKER("pickerSQLMarginBackgroundColour")
|
||||
#define pickerSQLColour1 CTRL_COLOURPICKER("pickerSQLColour1")
|
||||
|
|
@ -165,6 +169,7 @@ BEGIN_EVENT_TABLE(frmOptions, pgDialog)
|
|||
EVT_CHECKBOX(XRCID("chkSuppressHints"), frmOptions::OnSuppressHints)
|
||||
EVT_CHECKBOX(XRCID("chkResetHints"), frmOptions::OnResetHints)
|
||||
EVT_CHECKBOX(XRCID("chkSQLUseSystemBackgroundColour"), frmOptions::OnChangeSQLUseCustomColour)
|
||||
EVT_CHECKBOX(XRCID("chkCaretUseSystemBackgroundColour"), frmOptions::OnChangeSQLUseCustomColour)
|
||||
EVT_CHECKBOX(XRCID("chkSQLUseSystemForegroundColour"), frmOptions::OnChangeSQLUseCustomColour)
|
||||
EVT_BUTTON (wxID_OK, frmOptions::OnOK)
|
||||
EVT_BUTTON (wxID_HELP, frmOptions::OnHelp)
|
||||
|
|
@ -299,6 +304,7 @@ frmOptions::frmOptions(frmMain *parent)
|
|||
txtIndent->SetValidator(numval);
|
||||
txtHistoryMaxQueries->SetValidator(numval);
|
||||
txtHistoryMaxQuerySize->SetValidator(numval);
|
||||
txtWidthCaretKeyboardLayout->SetValidator(numval);
|
||||
|
||||
pickerLogfile->SetPath(settings->GetLogFile());
|
||||
radLoglevel->SetSelection(settings->GetLogLevel());
|
||||
|
|
@ -360,8 +366,9 @@ frmOptions::frmOptions(frmMain *parent)
|
|||
|
||||
txtHistoryMaxQueries->SetValue(NumToStr(settings->GetHistoryMaxQueries()));
|
||||
txtHistoryMaxQuerySize->SetValue(NumToStr(settings->GetHistoryMaxQuerySize()));
|
||||
|
||||
txtWidthCaretKeyboardLayout->SetValue(NumToStr((long)settings->GetWidthCaretForKeyboardLayout()));
|
||||
chkSQLUseSystemBackgroundColour->SetValue(settings->GetSQLBoxUseSystemBackground());
|
||||
chkCaretUseSystemBackgroundColour->SetValue(settings->GetCaretUseSystemBackground());
|
||||
chkSQLUseSystemForegroundColour->SetValue(settings->GetSQLBoxUseSystemForeground());
|
||||
UpdateColourControls();
|
||||
|
||||
|
|
@ -544,6 +551,19 @@ void frmOptions::UpdateColourControls()
|
|||
pickerSQLBackgroundColour->SetColour(settings->GetSQLBoxColourBackground());
|
||||
stSQLCustomBackgroundColour->Enable(true);
|
||||
}
|
||||
if (chkCaretUseSystemBackgroundColour->GetValue())
|
||||
{
|
||||
pickerCaretBackgroundColour->Enable(false);
|
||||
pickerCaretBackgroundColour->SetColour(wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW));
|
||||
stCaretCustomBackgroundColour->Enable(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
pickerCaretBackgroundColour->Enable(true);
|
||||
pickerCaretBackgroundColour->SetColour(settings->GetCaretColourBackground());
|
||||
stCaretCustomBackgroundColour->Enable(true);
|
||||
stCaretCustomBackgroundColour->Enable(true);
|
||||
}
|
||||
|
||||
if (chkSQLUseSystemForegroundColour->GetValue())
|
||||
{
|
||||
|
|
@ -693,6 +713,8 @@ void frmOptions::OnOK(wxCommandEvent &ev)
|
|||
settings->SetCopyQuoteChar(cbCopyQuoteChar->GetValue());
|
||||
settings->SetHistoryMaxQueries(StrToLong(txtHistoryMaxQueries->GetValue()));
|
||||
settings->SetHistoryMaxQuerySize(StrToLong(txtHistoryMaxQuerySize->GetValue()));
|
||||
settings->SetWidthCaretForKeyboardLayout((int)StrToLong(txtWidthCaretKeyboardLayout->GetValue()));
|
||||
|
||||
settings->SetRefreshOnClick(cbRefreshOnClick->GetSelection());
|
||||
|
||||
wxString copySeparator = cbCopySeparator->GetValue();
|
||||
|
|
@ -833,6 +855,11 @@ void frmOptions::OnOK(wxCommandEvent &ev)
|
|||
changed = true;
|
||||
settings->SetSQLBoxUseSystemBackground(chkSQLUseSystemBackgroundColour->GetValue());
|
||||
}
|
||||
if (settings->GetCaretUseSystemBackground() != chkCaretUseSystemBackgroundColour->GetValue())
|
||||
{
|
||||
changed = true;
|
||||
settings->SetCaretUseSystemBackground(chkCaretUseSystemBackgroundColour->GetValue());
|
||||
}
|
||||
|
||||
if (settings->GetSQLBoxUseSystemForeground() != chkSQLUseSystemForegroundColour->GetValue())
|
||||
{
|
||||
|
|
@ -846,6 +873,12 @@ void frmOptions::OnOK(wxCommandEvent &ev)
|
|||
changed = true;
|
||||
settings->SetSQLBoxColourBackground(pickerSQLBackgroundColour->GetColourString());
|
||||
}
|
||||
if (!settings->GetCaretUseSystemBackground())
|
||||
{
|
||||
if (pickerCaretBackgroundColour->GetColourString() != settings->GetCaretColourBackground())
|
||||
changed = true;
|
||||
settings->SetCaretColourBackground(pickerCaretBackgroundColour->GetColourString());
|
||||
}
|
||||
|
||||
if (!settings->GetSQLBoxUseSystemForeground())
|
||||
{
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@ struct TextToFind
|
|||
};
|
||||
|
||||
class sysProcess;
|
||||
|
||||
enum { TIMER_REFRESHUICARRET_ID =300 };
|
||||
// Class declarations
|
||||
class ctlSQLBox : public wxStyledTextCtrl
|
||||
{
|
||||
|
|
@ -108,14 +108,17 @@ public:
|
|||
|
||||
protected:
|
||||
void OnEndProcess(wxProcessEvent &ev);
|
||||
void OnRefreshUITimer(wxTimerEvent& event);
|
||||
void UpdateTitle();
|
||||
|
||||
sysProcess *process;
|
||||
long processID;
|
||||
wxString processOutput, processErrorOutput;
|
||||
int processExitCode;
|
||||
|
||||
int caretWidth = 1;
|
||||
wxTimer* refreshUITimer;
|
||||
private:
|
||||
void SetCaretWidthForKeyboardLayout();
|
||||
void OnPositionStc(wxStyledTextEvent &event);
|
||||
void OnDoubleClick(wxStyledTextEvent &event);
|
||||
void OnMarginClick(wxStyledTextEvent &event);
|
||||
|
|
|
|||
|
|
@ -453,6 +453,17 @@ public:
|
|||
{
|
||||
WriteInt(wxT("LineEndingType"), newval);
|
||||
}
|
||||
int GetWidthCaretForKeyboardLayout() const
|
||||
{
|
||||
int i;
|
||||
int defval = 1;
|
||||
Read(wxT("WidthCaretForKeyboardLayout"), &i, defval);
|
||||
return i;
|
||||
}
|
||||
void SetWidthCaretForKeyboardLayout(const int newval)
|
||||
{
|
||||
WriteInt(wxT("WidthCaretForKeyboardLayout"), newval);
|
||||
}
|
||||
wxString GetFavouritesFile();
|
||||
void SetFavouritesFile(const wxString &newval)
|
||||
{
|
||||
|
|
@ -599,6 +610,16 @@ public:
|
|||
{
|
||||
WriteBool(wxT("ctlSQLBox/UseSystemBackground"), newval);
|
||||
}
|
||||
bool GetCaretUseSystemBackground() const
|
||||
{
|
||||
bool b;
|
||||
Read(wxT("ctlSQLBox/CaretUseSystemBackground"), &b, true);
|
||||
return b;
|
||||
}
|
||||
void SetCaretUseSystemBackground(const bool newval)
|
||||
{
|
||||
WriteBool(wxT("ctlSQLBox/CaretUseSystemBackground"), newval);
|
||||
}
|
||||
bool GetSQLBoxUseSystemForeground() const
|
||||
{
|
||||
bool b;
|
||||
|
|
@ -609,6 +630,16 @@ public:
|
|||
{
|
||||
WriteBool(wxT("ctlSQLBox/UseSystemForeground"), newval);
|
||||
}
|
||||
wxString GetCaretColourBackground() const
|
||||
{
|
||||
wxString s;
|
||||
Read(wxT("ctlSQLBox/CaretColourBackground"), &s, wxT("#ffffff"));
|
||||
return s;
|
||||
}
|
||||
void SetCaretColourBackground(const wxString& newval)
|
||||
{
|
||||
Write(wxT("ctlSQLBox/CaretColourBackground"), newval);
|
||||
}
|
||||
|
||||
wxString GetSQLBoxColourBackground() const
|
||||
{
|
||||
|
|
|
|||
|
|
@ -733,6 +733,29 @@
|
|||
<flag>wxEXPAND|wxTOP|wxLEFT|wxRIGHT</flag>
|
||||
<border>4</border>
|
||||
</object>
|
||||
<object class="sizeritem">
|
||||
<object class="wxCheckBox" name="chkCaretUseSystemBackgroundColour">
|
||||
<label>Use system background color caret line</label>
|
||||
<style></style>
|
||||
</object>
|
||||
<flag>wxEXPAND|wxTOP|wxLEFT|wxRIGHT</flag>
|
||||
<border>4</border>
|
||||
</object>
|
||||
<object class="sizeritem">
|
||||
<object class="wxStaticText" name="stCaretCustomBackgroundColour">
|
||||
<label>Custom background</label>
|
||||
</object>
|
||||
<flag>wxEXPAND|wxTOP|wxLEFT|wxRIGHT</flag>
|
||||
<border>4</border>
|
||||
</object>
|
||||
<object class="sizeritem">
|
||||
<object class="ctlColourPicker" name="pickerCaretBackgroundColour">
|
||||
<size>70,12d</size>
|
||||
</object>
|
||||
<flag>wxEXPAND|wxTOP|wxLEFT|wxRIGHT</flag>
|
||||
<border>4</border>
|
||||
</object>
|
||||
|
||||
</object>
|
||||
<flag>wxEXPAND|wxTOP|wxLEFT|wxRIGHT</flag>
|
||||
<border>4</border>
|
||||
|
|
@ -765,6 +788,19 @@
|
|||
<flag>wxEXPAND|wxTOP|wxLEFT|wxRIGHT</flag>
|
||||
<border>4</border>
|
||||
</object>
|
||||
<object class="sizeritem">
|
||||
<object class="wxStaticText" name="stCaretKeyboardLayout">
|
||||
<label>Width for keyboard layout</label>
|
||||
</object>
|
||||
<flag>wxEXPAND|wxTOP|wxLEFT|wxRIGHT</flag>
|
||||
<border>4</border>
|
||||
</object>
|
||||
<object class="sizeritem">
|
||||
<object class="wxTextCtrl" name="txtWidthCaretKeyboardLayout"/>
|
||||
<flag>wxEXPAND|wxTOP|wxLEFT|wxRIGHT</flag>
|
||||
<value>1</value>
|
||||
<border>4</border>
|
||||
</object>
|
||||
</object>
|
||||
<flag>wxEXPAND|wxTOP|wxLEFT|wxRIGHT</flag>
|
||||
<border>4</border>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue