summaryrefslogtreecommitdiff
path: root/examples/apps/ide
diff options
context:
space:
mode:
authorGraeme Geldenhuys <graemeg@gmail.com>2013-03-17 17:30:42 +0000
committerGraeme Geldenhuys <graemeg@gmail.com>2013-03-17 17:30:42 +0000
commitbad688e8bff861be35d38534be7fe385e53d5065 (patch)
treeb5e43bbb9668f8afd897541df8b1aa0c16fe2d18 /examples/apps/ide
parenta4e31a2c6404cf45a02ea3a481210af4fddf00fc (diff)
downloadfpGUI-bad688e8bff861be35d38534be7fe385e53d5065.tar.xz
ide: refactored out the creation of a new editor tab sheet.
Diffstat (limited to 'examples/apps/ide')
-rw-r--r--examples/apps/ide/src/frm_main.pas33
1 files changed, 21 insertions, 12 deletions
diff --git a/examples/apps/ide/src/frm_main.pas b/examples/apps/ide/src/frm_main.pas
index 821bcbf0..e3876da4 100644
--- a/examples/apps/ide/src/frm_main.pas
+++ b/examples/apps/ide/src/frm_main.pas
@@ -109,6 +109,7 @@ type
procedure ClearMessagesWindow;
procedure CloseAllTabs;
procedure LoadProject(const AFilename: TfpgString);
+ function CreateNewEditorTab(const ATitle: TfpgString): TfpgTabSheet;
function OpenEditorPage(const AFilename: TfpgString): TfpgTabSheet;
procedure miTest(Sender: TObject);
function GetUnitsNode: TfpgTreeNode;
@@ -673,6 +674,20 @@ begin
AddMessage('Project loaded');
end;
+function TMainForm.CreateNewEditorTab(const ATitle: TfpgString): TfpgTabSheet;
+var
+ m: TfpgTextEdit;
+begin
+ Result := pcEditor.AppendTabSheet(ATitle);
+ m := TfpgTextEdit.Create(Result);
+ m.SetPosition(1, 1, 200, 20);
+ m.Align := alClient;
+ m.FontDesc := gINI.ReadString(cEditor, 'Font', '#Edit2');
+ m.GutterVisible := True;
+ m.GutterShowLineNumbers := True;
+ m.RightEdge := True;
+end;
+
function TMainForm.OpenEditorPage(const AFilename: TfpgString): TfpgTabSheet;
var
s: TfpgString;
@@ -680,7 +695,6 @@ var
i: integer;
found: Boolean;
ts: TfpgTabSheet;
- m: TfpgTextEdit;
ext: TfpgString;
pos_h: integer;
pos_v: integer;
@@ -721,17 +735,12 @@ begin
else
begin
// we need a new tabsheet
- ts := pcEditor.AppendTabSheet(f);
- m := TfpgTextEdit.Create(ts);
- m.SetPosition(1, 1, 200, 20);
- m.Align := alClient;
- m.FontDesc := gINI.ReadString(cEditor, 'Font', '#Edit2');
- m.GutterVisible := True;
- m.GutterShowLineNumbers := True;
- m.RightEdge := True;
- TfpgTextEdit(ts.Components[0]).Lines.BeginUpdate;
- TfpgTextEdit(ts.Components[0]).Lines.LoadFromFile(s);
- TfpgTextEdit(ts.Components[0]).Lines.EndUpdate;
+ ts := CreateNewEditorTab(f);
+ editor := ts.Components[0] as TfpgTextEdit;
+ editor.Lines.BeginUpdate;
+ if fpgFileExists(s) then
+ editor.Lines.LoadFromFile(s);
+ editor.Lines.EndUpdate;
if gINI.ReadBool(cEditor, 'SyntaxHighlighting', True) then
begin
ext := fpgExtractFileExt(AFilename);