mirror of
https://github.com/ultimatepp/ultimatepp.git
synced 2026-07-11 22:03:01 -06:00
.ide Added "Go to line.." dialog as an alternative to navigator approche. It is also integrated with editor mode - that previously hasn't got that feature due to lack of navigator.
git-svn-id: svn://ultimatepp.org/upp/trunk@11036 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
parent
58b1f3741a
commit
dfee57a5be
7 changed files with 71 additions and 5 deletions
50
uppsrc/ide/GoToLine.cpp
Normal file
50
uppsrc/ide/GoToLine.cpp
Normal file
|
|
@ -0,0 +1,50 @@
|
|||
#include "ide.h"
|
||||
|
||||
static const int MIN_LINE_NUMBER = 1;
|
||||
|
||||
class GoToLineDialog : public WithGoToLineLayout<TopWindow> {
|
||||
public:
|
||||
GoToLineDialog(int currentLine, int maxLine)
|
||||
{
|
||||
CtrlLayoutOKCancel(*this, String(t_("Go to line")) << "..");
|
||||
|
||||
lineInformation.SetText(GenerateLineInfo(maxLine));
|
||||
lineEdit.Min(MIN_LINE_NUMBER).Max(maxLine);
|
||||
lineEdit.SetFocus();
|
||||
lineEdit.SetData(currentLine);
|
||||
lineEdit.SelectAll();
|
||||
}
|
||||
|
||||
int GetLine() const
|
||||
{
|
||||
return static_cast<int>(lineEdit.GetData());
|
||||
}
|
||||
|
||||
private:
|
||||
String GenerateLineInfo(int maxLine)
|
||||
{
|
||||
StringStream ss;
|
||||
|
||||
ss << t_("Go to line") << " (" << MIN_LINE_NUMBER << ", " << maxLine << "):";
|
||||
|
||||
return ss.GetResult();
|
||||
}
|
||||
};
|
||||
|
||||
void Ide::GoToLine()
|
||||
{
|
||||
const int currentLine = editor.GetCurrentLine() + 1;
|
||||
|
||||
GoToLineDialog dlg(currentLine, editor.GetLineCount());
|
||||
if(dlg.Execute() != IDOK)
|
||||
return;
|
||||
|
||||
const int newLine = dlg.GetLine();
|
||||
if (currentLine == newLine)
|
||||
return;
|
||||
|
||||
AddHistory();
|
||||
editor.SetCursor(editor.GetPos(newLine - 1));
|
||||
editor.SetFocus();
|
||||
AddHistory();
|
||||
}
|
||||
|
|
@ -777,12 +777,12 @@ public:
|
|||
void Print();
|
||||
void Diff();
|
||||
void GotoDiffLeft(int line, DiffDlg *df);
|
||||
void GotoDiffRight(int line, FileDiff *df);
|
||||
void GotoDiffRight(int line, FileDiff *df);
|
||||
void Patch();
|
||||
void SvnHistory();
|
||||
|
||||
void Edit(Bar& menu);
|
||||
bool IsDesignerFile(const String& path);
|
||||
bool IsDesignerFile(const String& path);
|
||||
void DoEditAsText(const String& path);
|
||||
void EditAsText();
|
||||
void EditAsHex();
|
||||
|
|
@ -927,6 +927,7 @@ public:
|
|||
void FindId(const String& id);
|
||||
void ContextGoto0(int pos);
|
||||
void ContextGoto();
|
||||
void GoToLine();
|
||||
void CtrlClick(int pos);
|
||||
void Qtf();
|
||||
void Xml();
|
||||
|
|
|
|||
|
|
@ -93,6 +93,7 @@ KEY(XML, "XML view", K_ALT_X)
|
|||
KEY(JSON, "JSON view", K_ALT_N)
|
||||
KEY(ASSIST, "Assist", ' '|K_CTRL)
|
||||
KEY(ABBR, "Complete abbreviation", K_CTRL_PERIOD)
|
||||
KEY(GO_TO_LINE, "Go to line..", K_CTRL|K_SHIFT_G)
|
||||
KEY(DCOPY, "Copy as definition/declaration", K_ALT_C)
|
||||
KEY(VIRTUALS, "Virtual methods..", K_ALT_V)
|
||||
KEY(THISBACKS, "THISBACKs..", K_ALT_T)
|
||||
|
|
|
|||
|
|
@ -805,10 +805,17 @@ LAYOUT(RenamePackage2Layout, 228, 100)
|
|||
END_LAYOUT
|
||||
|
||||
LAYOUT(NewPackageFileLayout, 260, 88)
|
||||
ITEM(EditString, name, HSizePosZ(44, 8).TopPosZ(28, 19))
|
||||
ITEM(Label, dv___1, SetLabel(t_("Name ")).LeftPosZ(4, 64).TopPosZ(28, 19))
|
||||
ITEM(EditString, name, HSizePosZ(48, 8).TopPosZ(28, 19))
|
||||
ITEM(Label, dv___1, SetLabel(t_("Name ")).LeftPosZ(4, 40).TopPosZ(28, 19))
|
||||
ITEM(DropList, type, HSizePosZ(4, 8).TopPosZ(4, 19))
|
||||
ITEM(Button, ok, SetLabel(t_("OK")).RightPosZ(76, 64).BottomPosZ(8, 24))
|
||||
ITEM(Button, cancel, SetLabel(t_("Cancel")).RightPosZ(8, 64).BottomPosZ(8, 24))
|
||||
END_LAYOUT
|
||||
|
||||
LAYOUT(GoToLineLayout, 260, 88)
|
||||
ITEM(StaticText, lineInformation, HSizePosZ(8, 8).TopPosZ(8, 19))
|
||||
ITEM(EditInt, lineEdit, NotNull(true).HSizePosZ(8, 8).TopPosZ(28, 19))
|
||||
ITEM(Button, ok, SetLabel(t_("OK")).RightPosZ(76, 64).BottomPosZ(8, 24))
|
||||
ITEM(Button, cancel, SetLabel(t_("Cancel")).RightPosZ(8, 64).BottomPosZ(8, 24))
|
||||
END_LAYOUT
|
||||
|
||||
|
|
|
|||
|
|
@ -51,6 +51,7 @@ file
|
|||
Assist.cpp,
|
||||
DCopy.cpp,
|
||||
ContextGoto.cpp,
|
||||
GoToLine.cpp,
|
||||
Swaps.cpp,
|
||||
ParamInfo.cpp,
|
||||
Navigator.cpp,
|
||||
|
|
|
|||
|
|
@ -610,6 +610,7 @@ void Ide::BrowseMenu(Bar& menu)
|
|||
menu.Add(!designer, AK_THISBACKS, callback(&editor, &AssistEditor::Thisbacks));
|
||||
menu.Add(!designer, AK_COMPLETE, callback(&editor, &AssistEditor::Complete));
|
||||
menu.Add(!designer, AK_ABBR, callback(&editor, &AssistEditor::Abbr));
|
||||
menu.Add(!designer, AK_GO_TO_LINE, THISBACK(GoToLine));
|
||||
menu.Add(!designer, "Insert", THISBACK(InsertMenu));
|
||||
menu.MenuSeparator();
|
||||
}
|
||||
|
|
@ -630,6 +631,11 @@ void Ide::BrowseMenu(Bar& menu)
|
|||
menu.MenuSeparator();
|
||||
}
|
||||
}
|
||||
else {
|
||||
menu.Add(!designer, AK_GO_TO_LINE, THISBACK(GoToLine));
|
||||
menu.MenuSeparator();
|
||||
}
|
||||
|
||||
if(menu.IsMenuBar()) {
|
||||
menu.AddMenu(AK_CALC, IdeImg::calc(), THISBACK1(ToggleBottom, BCALC))
|
||||
.Check(IsBottomShown() && btabs.GetCursor() == BCALC);
|
||||
|
|
|
|||
|
|
@ -46,7 +46,7 @@ void Ide::GotoPos(String path, int line)
|
|||
if(path.GetCount()) {
|
||||
AddHistory();
|
||||
if(IsDesignerFile(path))
|
||||
DoEditAsText(path);
|
||||
DoEditAsText(path);
|
||||
EditFile(path);
|
||||
}
|
||||
editor.SetCursor(editor.GetPos(line - 1));
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue