Forráskód Böngészése

Multiple fixes + related changes to new LuaCore + new features such as the LuaOutput (which is more becoming a Lua console) + more

Jean-Francois Goulet 18 éve
szülő
commit
14426cdadc

+ 1 - 1
LuaEdit/EditorSettings.dfm

@@ -258,7 +258,7 @@ object frmEditorSettings: TfrmEditorSettings
           Top = 56
           Width = 161
           Height = 17
-          Caption = 'Save Units Incrementally'
+          Caption = 'Save Files Incrementally'
           TabOrder = 4
         end
         object chkSaveBreakpoints: TCheckBox

+ 4 - 4
LuaEdit/EditorSettings.pas

@@ -435,19 +435,19 @@ begin
     begin
       // Register file association for .lpr files
       RegSetAssociation('.lpr', 'LuaEdit.lpr', 'LuaEdit Project', 'LuaEdit/LuaEdit.lpr', PChar(GetLuaEditInstallPath() + '\Graphics\Project.ico'));
-      RegSetOpenWith('LuaEdit.lpr', PChar(Application.ExeName + ' %1'));
+      RegSetOpenWith('LuaEdit.lpr', PChar(Application.ExeName+ ' "%1"'));
 
       // Register file association for .lua files
       RegSetAssociation('.lua', 'LuaEdit.lua', 'LuaEdit Unit', 'LuaEdit/LuaEdit.lua', PChar(GetLuaEditInstallPath() + '\Graphics\Unit.ico'));
-      RegSetOpenWith('LuaEdit.lua', PChar(Application.ExeName + ' %1'));
+      RegSetOpenWith('LuaEdit.lua', PChar(Application.ExeName + ' "%1"'));
 
       // Register file association for .lmc files
       RegSetAssociation('.lmc', 'LuaEdit.lmc', 'LuaEdit Macro', 'LuaEdit/LuaEdit.lmc', PChar(GetLuaEditInstallPath() + '\Graphics\LuaMacros.ico'));
-      RegSetOpenWith('LuaEdit.lmc', PChar(Application.ExeName + ' %1'));
+      RegSetOpenWith('LuaEdit.lmc', PChar(Application.ExeName + ' "%1"'));
 
       // Register file association for .gui files
       RegSetAssociation('.gui', 'LuaEdit.gui', 'LuaEdit GUI Form', 'LuaEdit/LuaEdit.gui', PChar(GetLuaEditInstallPath() + '\Graphics\LuaGUIForm.ico'));
-      RegSetOpenWith('LuaEdit.gui', PChar(Application.ExeName + ' %1'));
+      RegSetOpenWith('LuaEdit.gui', PChar(Application.ExeName + ' "%1"'));
     end
     else
     begin      

+ 1 - 1
LuaEdit/FindWindow1.pas

@@ -198,7 +198,7 @@ procedure TfrmFindWindow1.lvwResultDblClick(Sender: TObject);
 begin
   // Bring the file in the editor and go directly to the line where it's defined
   if Assigned(lvwResult.Selected) then
-    frmLuaEditMain.PopUpUnitToScreen(lvwResult.Selected.Caption, StrToInt(lvwResult.Selected.SubItems[0]), False, HIGHLIGHT_STACK);
+    frmLuaEditMain.PopUpUnitToScreen(lvwResult.Selected.Caption, StrToInt(lvwResult.Selected.SubItems[0]), False, HIGHLIGHT_SELECT);
 end;
 
 end.

+ 1 - 1
LuaEdit/FindWindow2.pas

@@ -198,7 +198,7 @@ procedure TfrmFindWindow2.lvwResultDblClick(Sender: TObject);
 begin
   // Bring the file in the editor and go directly to the line where it's defined
   if Assigned(lvwResult.Selected) then
-    frmLuaEditMain.PopUpUnitToScreen(lvwResult.Selected.Caption, StrToInt(lvwResult.Selected.SubItems[0]), False, HIGHLIGHT_STACK);
+    frmLuaEditMain.PopUpUnitToScreen(lvwResult.Selected.Caption, StrToInt(lvwResult.Selected.SubItems[0]), False, HIGHLIGHT_SELECT);
 end;
 
 end.

+ 1 - 1
LuaEdit/FunctionList.dfm

@@ -77,7 +77,7 @@ object frmFunctionList: TfrmFunctionList
   end
   object JvDockClient1: TJvDockClient
     DirectDrag = False
-    DockStyle = frmMain.jvDockVSNet
+    DockStyle = frmLuaEditMain.jvDockVSNet
     Left = 8
     Top = 40
   end

+ 105 - 59
LuaEdit/LEMacros.pas

@@ -12,7 +12,7 @@ interface
 uses lua, lualib, lauxlib, Forms, SysUtils, LuaUtils, Misc, SynEdit,
      LuaEditMessages, Classes, Registry, Windows;
 
-procedure LERegisterToLua(L: Plua_State);
+procedure LERegisterToLua(L: Plua_State; NeedLuaLibs: Boolean = True);
 
 implementation
 
@@ -47,7 +47,7 @@ begin
       FilesName.Add(StrPas(lua_tostring(L, x)));
 
   // Return the luaedit version as a string
-  lua_pushboolean(L, frmLuaEditMain.DoOpenFileExecute(FilesName));
+  lua_pushboolean(L, Integer(frmLuaEditMain.DoOpenFileExecute(FilesName)));
 
   // Free variables
   FilesName.Free;
@@ -67,7 +67,7 @@ end;
 function LuaLEOpenProject(L: Plua_State): Integer; cdecl;
 begin
   // Return the luaedit version as a string
-  lua_pushboolean(L, frmLuaEditMain.DoOpenProjectExecute());
+  lua_pushboolean(L, Integer(frmLuaEditMain.DoOpenProjectExecute()));
 
   // Return in Delphi the number of argument pushed on the stack
   Result := 1;
@@ -84,7 +84,7 @@ end;
 function LuaLESaveAll(L: Plua_State): Integer; cdecl;
 begin
   // Return the luaedit version as a string
-  lua_pushboolean(L, frmLuaEditMain.DoSaveAllExecute());
+  lua_pushboolean(L, Integer(frmLuaEditMain.DoSaveAllExecute()));
 
   // Return in Delphi the number of argument pushed on the stack
   Result := 1;
@@ -101,7 +101,7 @@ end;
 function LuaLESavePrjAs(L: Plua_State): Integer; cdecl;
 begin
   // Return the luaedit version as a string
-  lua_pushboolean(L, frmLuaEditMain.DoSaveProjectAsExecute());
+  lua_pushboolean(L, Integer(frmLuaEditMain.DoSaveProjectAsExecute()));
 
   // Return in Delphi the number of argument pushed on the stack
   Result := 1;
@@ -109,16 +109,32 @@ end;
 
 ////////////////////////////////////////////////////////////////////////////////
 // Desc: This function save the currently opened unit as...
-// In:   None
+// In:   (1) Path of unit to save as
 // Out:  (1) True if the operation ended successfully. False if canceled,
 //           unavailable (disabled) or failed.
 //
 // 14/05/2006 - Jean-Francois Goulet
 ////////////////////////////////////////////////////////////////////////////////
 function LuaLESaveUnitAs(L: Plua_State): Integer; cdecl;
+var
+  bRes: Boolean;
+  sPath: String;
+  pFile: TLuaEditBasicTextFile; 
 begin
-  // Return the luaedit version as a string
-  lua_pushboolean(L, frmLuaEditMain.DoSaveAsExecute());
+  // Initialize result
+  bRes := False;
+
+  // Retrieve SAFELY the first parameter
+  if lua_type(L, -1) = LUA_TSTRING then
+    sPath := lua_tostring(L, -1);
+
+  pFile := frmLuaEditMain.GetOpenedFile(sPath);
+
+  // Save the specified file
+  if Assigned(pFile) then
+    bRes := frmLuaEditMain.DoSaveAsExecute(pFile);
+
+  lua_pushboolean(L, Integer(bRes));
 
   // Return in Delphi the number of argument pushed on the stack
   Result := 1;
@@ -126,16 +142,32 @@ end;
 
 ////////////////////////////////////////////////////////////////////////////////
 // Desc: This function save the currently opened unit
-// In:   None
+// In:   (1) Path of unit to save
 // Out:  (1) True if the operation ended successfully. False if canceled,
 //           unavailable (disabled) or failed.
 //
 // 14/05/2006 - Jean-Francois Goulet
 ////////////////////////////////////////////////////////////////////////////////
 function LuaLESaveUnit(L: Plua_State): Integer; cdecl;
+var
+  bRes: Boolean;
+  sPath: String;
+  pFile: TLuaEditBasicTextFile; 
 begin
-  // Return the luaedit version as a string
-  lua_pushboolean(L, frmLuaEditMain.DoSaveExecute());
+  // Initialize result
+  bRes := False;
+
+  // Retrieve SAFELY the first parameter
+  if lua_type(L, -1) = LUA_TSTRING then
+    sPath := lua_tostring(L, -1);
+
+  pFile := frmLuaEditMain.GetOpenedFile(sPath);
+
+  // Save the specified file
+  if Assigned(pFile) then
+    bRes := frmLuaEditMain.DoSaveExecute(pFile);
+
+  lua_pushboolean(L, Integer(bRes));
 
   // Return in Delphi the number of argument pushed on the stack
   Result := 1;
@@ -160,7 +192,7 @@ end;
 //
 // 14/05/2006 - Jean-Francois Goulet
 ////////////////////////////////////////////////////////////////////////////////
-function LuaLEGetUnit(L: Plua_State): Integer; cdecl;
+function LuaLEGetFile(L: Plua_State): Integer; cdecl;
 var
   Index, x: Integer;
   pLuaUnit: TLuaEditUnit;
@@ -196,27 +228,27 @@ begin
 
         // Push "Path" data
         lua_pushstring(L, 'Path');
-        lua_pushstring(L, PChar(pLuaUnit.Path));
+        lua_pushstring(L, PChar(pLuaUnit.DisplayPath));
         lua_settable(L, -3);
 
         // Push "IsLoaded" data
         lua_pushstring(L, 'IsLoaded');
-        lua_pushboolean(L, pLuaUnit.IsLoaded);
+        lua_pushboolean(L, Integer(pLuaUnit.IsLoaded));
         lua_settable(L, -3);
 
         // Push "IsReadOnly" data
         lua_pushstring(L, 'IsReadOnly');
-        lua_pushboolean(L, pLuaUnit.IsReadOnly);
+        lua_pushboolean(L, Integer(pLuaUnit.IsReadOnly));
         lua_settable(L, -3);
 
         // Push "IsNew" data
         lua_pushstring(L, 'IsNew');
-        lua_pushboolean(L, pLuaUnit.IsNew);
+        lua_pushboolean(L, Integer(pLuaUnit.IsNew));
         lua_settable(L, -3);
 
         // Push "HasChanged" data
         lua_pushstring(L, 'HasChanged');
-        lua_pushboolean(L, pLuaUnit.HasChanged);
+        lua_pushboolean(L, Integer(pLuaUnit.HasChanged));
         lua_settable(L, -3);
 
         // Push "Text" data
@@ -304,7 +336,7 @@ begin
 
     // Push "Path" data
     lua_pushstring(L, 'Path');
-    lua_pushstring(L, PChar(ActiveProject.Path));
+    lua_pushstring(L, PChar(ActiveProject.DisplayPath));
     lua_settable(L, -3);
 
     // Push "Initializer" data
@@ -344,22 +376,22 @@ begin
 
     // Push "AutoIncRevNumber" data
     lua_pushstring(L, 'AutoIncRevNumber');
-    lua_pushboolean(L, ActiveProject.AutoIncRevNumber);
+    lua_pushboolean(L, Integer(ActiveProject.AutoIncRevNumber));
     lua_settable(L, -3);
 
     // Push "IsReadOnly" data
     lua_pushstring(L, 'IsReadOnly');
-    lua_pushboolean(L, ActiveProject.IsReadOnly);
+    lua_pushboolean(L, Integer(ActiveProject.IsReadOnly));
     lua_settable(L, -3);
 
     // Push "IsNew" data
     lua_pushstring(L, 'IsNew');
-    lua_pushboolean(L, ActiveProject.IsNew);
+    lua_pushboolean(L, Integer(ActiveProject.IsNew));
     lua_settable(L, -3);
 
     // Push "HasChanged" data
     lua_pushstring(L, 'HasChanged');
-    lua_pushboolean(L, ActiveProject.HasChanged);
+    lua_pushboolean(L, Integer(ActiveProject.HasChanged));
     lua_settable(L, -3);
     
     // Push "VersionMajor" data
@@ -665,48 +697,62 @@ end;
 // This function register in the given lua state all luaedit related function
 // to allow to the user some interface customization. Kind of like macros but
 // using lua.
-procedure LERegisterToLua(L: Plua_State);
+procedure LERegisterToLua(L: Plua_State; NeedLuaLibs: Boolean);
 const
   LETableName = 'luaedit';
+  LuaEditFuncPackage: array [0..14] of LuaL_Reg = (// LuaEdit's core system functions
+                                                   (name: 'getver'; func: LuaLEGetVersion),
+                                                   (name: 'getproductname'; func: LuaLEGetProductName),
+                                                   (name: 'exit'; func: LuaLEExit),
+
+                                                   // LuaEdit's interfaces functions
+                                                   (name: 'print'; func: LuaLEPrint),
+
+                                                   // LuaEdit's file manipulation functions
+                                                   (name: 'openfile'; func: LuaLEOpenFile),
+                                                   (name: 'openprj'; func: LuaLEOpenProject),
+                                                   (name: 'saveall'; func: LuaLESaveAll),
+                                                   (name: 'saveprjas'; func: LuaLESavePrjAs),
+                                                   (name: 'saveunit'; func: LuaLESaveUnit),
+                                                   (name: 'saveunitas'; func: LuaLESaveUnitAs),
+                                                   (name: 'getfile'; func: LuaLEGetFile),
+                                                   (name: 'getactiveprj'; func: LuaLEGetActivePrj),
+
+                                                   // Win32 system functions
+                                                   (name: 'regread'; func: LuaLERegRead),
+                                                   (name: 'regwrite'; func: LuaLERegWrite),
+                                                   (name: nil; func: nil)
+                                                  );
+
+  procedure LuaRegisterVarStrInPackage(L: PLua_State; const Package: PChar; const VarName: PChar; const VarValue: PChar);
+  begin
+    // Get package table from globals
+    lua_getglobal(L, Package);
+
+    // Pushes variable name on the stack
+    lua_pushstring(L, VarName);
+    lua_pushstring(L, VarValue);
+    lua_settable(L, -3);
+    lua_pop(L, 1);
+  end;
 begin
-  // Open basic lua libraries
-  lua_baselibopen(L);
-  lua_packlibopen(L);
-  lua_tablibopen(L);
-  lua_strlibopen(L);
-  lua_iolibopen(L);
-  lua_mathlibopen(L);
-  lua_dblibopen(L);
-
-  // LuaEdit's core system functions
-  LuaRegister(L, LETableName+'.getver', LuaLEGetVersion);
-  LuaRegister(L, LETableName+'.getproductname', LuaLEGetProductName);
-  LuaRegister(L, LETableName+'.exit', LuaLEExit);
-
-  // LuaEdit's interfaces functions
-  LuaRegister(L, LETableName+'.print', LuaLEPrint);
-
-  // LuaEdit's file manipulation functions
-  LuaRegister(L, LETableName+'.openfile', LuaLEOpenFile);
-  LuaRegister(L, LETableName+'.openprj', LuaLEOpenProject);
-  LuaRegister(L, LETableName+'.saveall', LuaLESaveAll);
-  LuaRegister(L, LETableName+'.saveprjas', LuaLESavePrjAs);
-  LuaRegister(L, LETableName+'.saveunit', LuaLESaveUnit);
-  LuaRegister(L, LETableName+'.saveunitas', LuaLESaveUnitAs);
-  LuaRegister(L, LETableName+'.getunit', LuaLEGetUnit);
-  LuaRegister(L, LETableName+'.getactiveprj', LuaLEGetActivePrj);
-
-  // Win32 system functions
-  LuaRegister(L, LETableName+'.regread', LuaLERegRead);
-  LuaRegister(L, LETableName+'.regwrite', LuaLERegWrite);
+  // Open basic lua libraries (if required)
+  if NeedLuaLibs then
+  begin
+    lua_baselibopen(L);
+    lua_packlibopen(L);
+    lua_tablibopen(L);
+    lua_strlibopen(L);
+    lua_iolibopen(L);
+    lua_mathlibopen(L);
+    lua_dblibopen(L);
+  end;
 
-  // Register variables
-  lua_getglobal(L, LETableName);
+  // Register functions
+  luaL_Register(L, LETableName, @LuaEditFuncPackage);
 
-  // Push LuaEdit's version
-  lua_pushstring(L, '_VERSION');
-  lua_pushstring(L, _LuaEditVersion);
-  lua_settable(L, -3);
+  // Register variables
+  LuaRegisterVarStrInPackage(L, LETableName, '_VERSION', PChar(_LuaEditVersion));
 end;
 
 end.

+ 1 - 1
LuaEdit/LuaConsole.pas

@@ -5,7 +5,7 @@ interface
 uses
   Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
   Dialogs, StdCtrls, ComCtrls, ExtCtrls, JvComponent, JvDockControlForm,
-  VirtualTrees, Menus, Clipbrd, Lua, LuaUtils;
+  VirtualTrees, Menus, Clipbrd, lua, lauxlib, luaconf, LuaUtils;
 
 type
   PLuaConsoleLine = ^TPLuaConsoleLine;

+ 3 - 3
LuaEdit/LuaEdit.dof

@@ -114,8 +114,8 @@ IncludeVerInfo=1
 AutoIncBuild=1
 MajorVer=3
 MinorVer=0
-Release=3
-Build=205
+Release=4
+Build=51
 Debug=0
 PreRelease=0
 Special=0
@@ -126,7 +126,7 @@ CodePage=1252
 [Version Info Keys]
 CompanyName=Open Source
 FileDescription=IDE for Lua 5.0.2
-FileVersion=3.0.3.205
+FileVersion=3.0.4.51
 InternalName=LuaEdit
 LegalCopyright=LuaEdit Copyright 2004-2006 ©
 LegalTrademarks=

+ 2 - 4
LuaEdit/LuaEdit.dpr

@@ -32,13 +32,11 @@ uses
   Watch in 'Watch.pas' {frmWatch},
   FunctionList in 'FunctionList.pas' {frmFunctionList},
   AddToPrj in 'AddToPrj.pas' {frmAddToPrj},
-  RemFromPrj in 'RemFromPrj.pas' {frmRemoveFile},
   ErrorLookup in 'ErrorLookup.pas' {frmErrorLookup},
   LuaStack in 'LuaStack.pas' {frmLuaStack},
   PrintSetup in 'PrintSetup.pas' {frmPrintSetup},
   PrjSettings in 'PrjSettings.pas' {frmPrjOptions},
   Contributors in 'Contributors.pas' {frmContributors},
-  LuaOutput in 'LuaOutput.pas' {frmLuaOutput},
   LuaUtils in 'LuaCore\LuaUtils.pas',
   Breakpoints in 'Breakpoints.pas' {frmBreakpoints},
   RegSetFileType in 'RegSetFileType.pas',
@@ -69,7 +67,8 @@ uses
   GUIDesigner in 'GUIDesigner.pas' {GUIForm1},
   GUIControls in 'GUIControls.pas' {frmGUIControls},
   GUIFormType in 'GUIFormType.pas' {frmGUIFormType},
-  ConvertPath in 'ConvertPath.pas' {frmConvertPath};
+  ConvertPath in 'ConvertPath.pas' {frmConvertPath},
+  LuaConsole in 'LuaConsole.pas' {frmLuaConsole};
 
 {$R *.res}
 
@@ -142,7 +141,6 @@ begin
   Application.CreateForm(TfrmReplaceQuerry, frmReplaceQuerry);
   Application.CreateForm(TfrmSearch, frmSearch);
   Application.CreateForm(TfrmAddToPrj, frmAddToPrj);
-  Application.CreateForm(TfrmRemoveFile, frmRemoveFile);
   Application.CreateForm(TfrmErrorLookup, frmErrorLookup);
   Application.CreateForm(TfrmPrintSetup, frmPrintSetup);
   Application.CreateForm(TfrmPrjOptions, frmPrjOptions);

BIN
LuaEdit/LuaEdit.res


+ 8 - 0
LuaEdit/LuaEditMessages.pas

@@ -52,6 +52,10 @@ begin
   pData.MsgType := MsgType;
   pData.LineNumber := LineNumber;
 
+  // Popup luaedit messages window if it's an error message
+  if MsgType = LUAEDIT_ERROR_MSG then
+    Self.Show;
+
   vstLuaEditMessages.FullExpand();
   Result := pNode;
 end;
@@ -68,6 +72,10 @@ begin
   pData.MsgType := MsgType;
   pData.LineNumber := LineNumber;
 
+  // Popup luaedit messages window if it's an error message
+  if MsgType = LUAEDIT_ERROR_MSG then
+    Self.Show;
+
   vstLuaEditMessages.FullExpand();
   Result := pNode;
 end;

+ 15 - 1
LuaEdit/LuaLocals.pas

@@ -5,7 +5,7 @@ interface
 uses
   Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
   Dialogs, JvComponent, JvDockControlForm, ComCtrls, StdCtrls,
-  JvExStdCtrls, JvListBox;
+  JvExStdCtrls, JvListBox, LuaUtils;
 
 type
   TfrmLuaLocals = class(TForm)
@@ -15,6 +15,7 @@ type
     { Private declarations }
   public
     { Public declarations }
+    procedure FillLocalsList(Locals: TList);
   end;
 
 var
@@ -24,4 +25,17 @@ implementation
 
 {$R *.dfm}
 
+procedure TfrmLuaLocals.FillLocalsList(Locals: TList);
+var
+  x: Integer;
+begin
+  lstLocals.Clear;
+  lstLocals.Items.BeginUpdate;
+
+  for x := 0 to Locals.Count - 1 do
+    lstLocals.AddItem(TLuaVariable(Locals[x]).Name + '=' + TLuaVariable(Locals[x]).Value, nil);
+
+  lstLocals.Items.EndUpdate;
+end;
+
 end.

+ 24 - 15
LuaEdit/Main.dfm

@@ -122,8 +122,8 @@ object frmLuaEditMain: TfrmLuaEditMain
             AutoFreeClosed = False
             SelectBeforeClose = True
             AllowTabMoving = True
-            Tabs = <>
             Painter = jvModernUnitBarPainter
+            Tabs = <>
             OnTabClosed = jvUnitBarTabClosed
             OnTabSelecting = jvUnitBarTabSelecting
             OnChange = jvUnitBarChange
@@ -145,7 +145,7 @@ object frmLuaEditMain: TfrmLuaEditMain
     TabOrder = 1
     OnDockOver = ctrlBarDockOver
     object tlbRun: TToolBar
-      Left = 389
+      Left = 387
       Top = 2
       Width = 283
       Height = 22
@@ -255,7 +255,7 @@ object frmLuaEditMain: TfrmLuaEditMain
     object tlbBaseFile: TToolBar
       Left = 11
       Top = 2
-      Width = 365
+      Width = 352
       Height = 22
       Align = alLeft
       AutoSize = True
@@ -798,8 +798,8 @@ object frmLuaEditMain: TfrmLuaEditMain
     end
     object actRemoveFromPrj: TAction
       Category = 'Project Manipulations'
-      Caption = 'Remove File From Project...'
-      Hint = 'Remove File from Project...'
+      Caption = 'Remove File From Project'
+      Hint = 'Remove File from Project'
       ImageIndex = 36
       ShortCut = 8315
       OnExecute = actRemoveFromPrjExecute
@@ -924,12 +924,12 @@ object frmLuaEditMain: TfrmLuaEditMain
       ImageIndex = 49
       OnExecute = actShowLuaStackExecute
     end
-    object actShowLuaOutput: TAction
+    object actShowLuaConsole: TAction
       Category = 'View Actions'
-      Caption = 'Lua Output'
-      Hint = 'Show Lua Output'
+      Caption = 'Lua Console'
+      Hint = 'Show Lua Console'
       ImageIndex = 48
-      OnExecute = actShowLuaOutputExecute
+      OnExecute = actShowLuaConsoleExecute
     end
     object actShowLuaGlobals: TAction
       Category = 'View Actions'
@@ -1081,7 +1081,7 @@ object frmLuaEditMain: TfrmLuaEditMain
     Left = 48
     Top = 217
     Bitmap = {
-      494C010148004A00040010001000FF00FF00FF00FFFFFFFFFFFFFFFF424D3600
+      494C010148004A00040010001000FF00FF00FF10FFFFFFFFFFFFFFFF424D3600
       0000000000003600000028000000400000003001000001002000000000000030
       0100000000000000000000000000000000000000000000000000000000000000
       0000000000000000000000000000000000000000000000000000000000000000
@@ -3593,7 +3593,8 @@ object frmLuaEditMain: TfrmLuaEditMain
       0000000000000000000000000000000000000000000000000000000000000000
       0000000000000000000000000000000000000000000000000000000000000000
       0000000000000000000000000000000000000000000000000000000000000000
-      00000000000000000000000000000000}
+      0000000000000000000000000000000000000000000000000000000000000000
+      000000000000}
   end
   object odlgOpenUnit: TOpenDialog
     Filter = 
@@ -4828,9 +4829,6 @@ object frmLuaEditMain: TfrmLuaEditMain
       object N27: TMenuItem
         Caption = '-'
       end
-      object BringGUIFormtoFront1: TMenuItem
-        Action = actBringGUIFormToFront
-      end
     end
     object View1: TMenuItem
       Action = actMainMenuView
@@ -4876,7 +4874,7 @@ object frmLuaEditMain: TfrmLuaEditMain
           Action = actShowLuaStack
         end
         object LuaOutput1: TMenuItem
-          Action = actShowLuaOutput
+          Action = actShowLuaConsole
         end
         object LuaGlobals1: TMenuItem
           Action = actShowLuaGlobals
@@ -4905,6 +4903,12 @@ object frmLuaEditMain: TfrmLuaEditMain
           Caption = 'Run'
         end
       end
+      object N28: TMenuItem
+        Caption = '-'
+      end
+      object BringGUIFormtoFront1: TMenuItem
+        Action = actBringGUIFormToFront
+      end
     end
     object Project2: TMenuItem
       Action = actMainMenuProject
@@ -5124,4 +5128,9 @@ object frmLuaEditMain: TfrmLuaEditMain
     Left = 144
     Top = 249
   end
+  object XMLDocument1: TXMLDocument
+    Left = 184
+    Top = 200
+    DOMVendorDesc = 'MSXML'
+  end
 end

A különbségek nem kerülnek megjelenítésre, a fájl túl nagy
+ 5409 - 5269
LuaEdit/Main.pas


+ 251 - 198
LuaEdit/Misc.pas

@@ -242,8 +242,8 @@ type
   public
     constructor Create(Path: String; otType: TLuaEditFileType = otTextFile);
 
-    function  Save(Path: String): Boolean; virtual;
-    function  SaveInc(Path: String): Boolean; virtual;
+    function  Save(Path: String; bNoDialog: Boolean = False; bForceDialog: Boolean = False): Boolean; virtual;
+    function  SaveInc(Path: String; bNoDialog: Boolean = False; bForceDialog: Boolean = False): Boolean; virtual;
   published
     property FileType: TLuaEditFileType read FOTFileType write FOTFileType;
     property LastTimeModified: TDateTime read FLastTimeModified write FLastTimeModified;
@@ -279,8 +279,8 @@ type
     constructor Create(Path: String; otType: TLuaEditFileType = otTextFile);
     destructor Destroy; override;
 
-    function  Save(Path: String; bNoDialog: Boolean = False; bForceDialog: Boolean = False): Boolean; overload;
-    function  SaveInc(Path: String; bNoDialog: Boolean = False; bForceDialog: Boolean = False): Boolean; overload;
+    function  Save(Path: String; bNoDialog: Boolean = False; bForceDialog: Boolean = False): Boolean; override;
+    function  SaveInc(Path: String; bNoDialog: Boolean = False; bForceDialog: Boolean = False): Boolean; override;
   published
     property LastEditedLine:   Integer read FLastEditedLine write FLastEditedLine;
     property SynUnit:          TSynEdit read FSynUnit write FSynUnit;
@@ -298,8 +298,8 @@ type
     constructor Create(Path: String; otType: TLuaEditFileType = otTextFile);
     destructor Destroy; override;
 
-    function  Save(Path: String; bNoDialog: Boolean = False; bForceDialog: Boolean = False): Boolean; overload;
-    function  SaveInc(Path: String; bNoDialog: Boolean = False; bForceDialog: Boolean = False): Boolean; overload;
+    function  Save(Path: String; bNoDialog: Boolean = False; bForceDialog: Boolean = False): Boolean; override;
+    function  SaveInc(Path: String; bNoDialog: Boolean = False; bForceDialog: Boolean = False): Boolean; override;
     procedure SaveBreakpoints();
     procedure GetBreakpoints();
   published
@@ -349,9 +349,11 @@ type
     constructor Create(Path: String; otType: TLuaEditFileType = otLuaEditProject);
     destructor  Destroy; override;
 
+    procedure AddFile(pFile: TLuaEditFile); overload;
+    function AddFile(FileName: String; IsNew: Boolean): TLuaEditBasicTextFile; overload;
     procedure GetProjectFromDisk(Path: String);
-    function  Save(Path: String; bNoDialog: Boolean = False; bForceDialog: Boolean = False): Boolean; overload;
-    function  SaveInc(Path: String; bNoDialog: Boolean = False; bForceDialog: Boolean = False): Boolean; overload;
+    function  Save(Path: String; bNoDialog: Boolean = False; bForceDialog: Boolean = False): Boolean; override;
+    function  SaveInc(Path: String; bNoDialog: Boolean = False; bForceDialog: Boolean = False): Boolean; override;
     procedure RealoadProject();
   end;
 
@@ -373,7 +375,7 @@ function FileExistsAbs(FileName: String): Boolean;
 implementation
 
 uses
-  Main, Breakpoints, ReadOnlyMsgBox, ProjectTree, GUIDesigner;
+  Main, Breakpoints, ReadOnlyMsgBox, ProjectTree, GUIDesigner, LuaEditMessages;
 
 ///////////////////////////////////////////////////////////////////
 // Misc functions
@@ -499,7 +501,7 @@ begin
 end;
 
 ///////////////////////////////////////////////////////////////////
-//TFctInfo
+// TFctInfo
 ///////////////////////////////////////////////////////////////////
 constructor TFctInfo.Create;
 begin
@@ -509,7 +511,7 @@ begin
 end;
 
 ///////////////////////////////////////////////////////////////////
-//TBreakInfo
+// TBreakInfo
 ///////////////////////////////////////////////////////////////////
 constructor TBreakInfo.Create;
 begin
@@ -520,7 +522,7 @@ begin
 end;
 
 ///////////////////////////////////////////////////////////////////
-//TBreakpoint class
+// TBreakpoint class
 ///////////////////////////////////////////////////////////////////
 constructor TBreakpoint.Create;
 begin
@@ -531,7 +533,7 @@ begin
 end;
 
 ///////////////////////////////////////////////////////////////////
-//TLineDebugInfos class
+// TLineDebugInfos class
 ///////////////////////////////////////////////////////////////////
 constructor TLineDebugInfos.Create;
 begin
@@ -773,12 +775,12 @@ begin
   FName := ChangeFileExt(ExtractFileName(Path), '');
 end;
 
-function TLuaEditFile.Save(Path: String): Boolean;
+function TLuaEditFile.Save(Path: String; bNoDialog: Boolean = False; bForceDialog: Boolean = False): Boolean;
 begin
   FDisplayPath := Path;
 end;
 
-function TLuaEditFile.SaveInc(Path: String): Boolean;
+function TLuaEditFile.SaveInc(Path: String; bNoDialog: Boolean = False; bForceDialog: Boolean = False): Boolean;
 begin
   FDisplayPath := Path;
 end;
@@ -859,111 +861,120 @@ var
   xPos, IncValue, iAnswer, TempIncValue: Integer;
   bResult: Boolean;
   pMsgBox: TfrmReadOnlyMsgBox;
-begin  
-  frmLuaEditMain.jvchnNotifier.Active := False;
-  Result := True;
-
-  // save only if the file is opened in the tab...
-  // if not, there is no way that the file was modified so no needs to save
-  if Assigned(Self.AssociatedTab) then
-  begin
-    // Popup a open dialog according to parameters and the state of the file
-    if ((IsNew and not bNoDialog) or (bForceDialog)) then
-    begin
-      frmLuaEditMain.sdlgSaveAsUnit.FileName := ExtractFileName(FName);
-
-      if ExtractFileExt(FPath) = '.lua' then
-        frmLuaEditMain.sdlgSaveAsUnit.FilterIndex := 1
-      else if ExtractFileExt(FPath) = '.lmc' then
-        frmLuaEditMain.sdlgSaveAsUnit.FilterIndex := 2
-      else if ExtractFileExt(FPath) = '.txt' then
-        frmLuaEditMain.sdlgSaveAsUnit.FilterIndex := 3
-      else
-        frmLuaEditMain.sdlgSaveAsUnit.FilterIndex := 4;
-
-      if frmLuaEditMain.sdlgSaveAsUnit.Execute then
-      begin
-        Path := frmLuaEditMain.sdlgSaveAsUnit.FileName;
-
-        if IsNew then
-          frmLuaEditMain.MonitorFileToRecent(Path);
-      end
-      else
-      begin
-        // Return false because action was cancel and quit function
-        Result := False;
-        Exit;
-      end;
-    end;
+begin
+  try
+    try
+      frmLuaEditMain.jvchnNotifier.Active := False;
+      Result := True;
 
-    // Getting currently assigned number
-    IncValue := -1;  // For future testing
-    xPos := Length(ExtractFileExt(Path)) + 1;  // Assign initial try position
-    bResult := True;  // For a first try
-    while bResult do
-    begin
-      bResult := TryStrToInt(Copy(Path, Length(Path) - xPos + 1, xPos - Length(ExtractFileExt(Path))), TempIncValue);
-      if bResult then
+      // save only if the file is opened in the tab...
+      // if not, there is no way that the file was modified so no needs to save
+      if Assigned(Self.AssociatedTab) then
       begin
-        IncValue := TempIncValue;
-        Inc(XPos);
-      end;
-    end;
+        // Popup a open dialog according to parameters and the state of the file
+        if ((IsNew and not bNoDialog) or (bForceDialog)) then
+        begin
+          frmLuaEditMain.sdlgSaveAsUnit.FileName := ExtractFileName(FName);
+
+          if ExtractFileExt(FPath) = '.lua' then
+            frmLuaEditMain.sdlgSaveAsUnit.FilterIndex := 1
+          else if ExtractFileExt(FPath) = '.lmc' then
+            frmLuaEditMain.sdlgSaveAsUnit.FilterIndex := 2
+          else if ExtractFileExt(FPath) = '.txt' then
+            frmLuaEditMain.sdlgSaveAsUnit.FilterIndex := 3
+          else
+            frmLuaEditMain.sdlgSaveAsUnit.FilterIndex := 4;
+
+          if frmLuaEditMain.sdlgSaveAsUnit.Execute then
+          begin
+            Path := frmLuaEditMain.sdlgSaveAsUnit.FileName;
+
+            if IsNew then
+              frmLuaEditMain.MonitorFileToRecent(Path);
+          end
+          else
+          begin
+            // Return false because action was cancel and quit function
+            Result := False;
+            Exit;
+          end;
+        end;
 
-    if IncValue = -1 then
-      IncValue := 1 // Give an initial value
-    else
-      Inc(IncValue);  // Increment actual value
+        // Getting currently assigned number
+        IncValue := -1;  // For future testing
+        xPos := Length(ExtractFileExt(Path)) + 1;  // Assign initial try position
+        bResult := True;  // For a first try
+        while bResult do
+        begin
+          bResult := TryStrToInt(Copy(Path, Length(Path) - xPos + 1, xPos - Length(ExtractFileExt(Path))), TempIncValue);
+          if bResult then
+          begin
+            IncValue := TempIncValue;
+            Inc(XPos);
+          end;
+        end;
 
-    // Build the new name
-    Path := Copy(Self.Path, 1, Length(Self.Path) - xPos + 1) + IntToStr(IncValue) + ExtractFileExt(Self.Path);
+        if IncValue = -1 then
+          IncValue := 1 // Give an initial value
+        else
+          Inc(IncValue);  // Increment actual value
 
-    // Check if file is read only first
-    while (GetFileReadOnlyAttr(PChar(Path)) and (FileExistsAbs(Path))) do
-    begin
-      pMsgBox := TfrmReadOnlyMsgBox.Create(nil);
-      iAnswer := pMsgBox.MessageBox('The project '+Path+' is read-only. Save anyway?      ', 'LuaEdit');
-      pMsgBox.Free;
-      if iAnswer = mrOk then
-      begin
-        ToggleFileReadOnlyAttr(PChar(Path));
-        // Now that we wrote on the disk we may retrieve the time it has been writen
-        LastTimeModified := GetFileLastTimeModified(PChar(Path));
-        IsReadOnly := False;
-      end
-      else if iAnswer = mrYes then
-      begin
-        // Popup an open dialog according to parameters and the state of the file
-        frmLuaEditMain.sdlgSaveAsUnit.FileName := ExtractFileName(Self.Name);
+        // Build the new name
+        Path := Copy(Self.Path, 1, Length(Self.Path) - xPos + 1) + IntToStr(IncValue) + ExtractFileExt(Self.Path);
 
-        if frmLuaEditMain.sdlgSaveAsUnit.Execute then
+        // Check if file is read only first
+        while (GetFileReadOnlyAttr(PChar(Path)) and (FileExistsAbs(Path))) do
         begin
-          Path := frmLuaEditMain.sdlgSaveAsUnit.FileName;
-        end
-        else
-        begin
-          // Return false because action was cancel and quit function
-          Result := False;
-          Exit;
+          pMsgBox := TfrmReadOnlyMsgBox.Create(nil);
+          iAnswer := pMsgBox.MessageBox('The project '+Path+' is read-only. Save anyway?      ', 'LuaEdit');
+          pMsgBox.Free;
+          if iAnswer = mrOk then
+          begin
+            ToggleFileReadOnlyAttr(PChar(Path));
+            // Now that we wrote on the disk we may retrieve the time it has been writen
+            LastTimeModified := GetFileLastTimeModified(PChar(Path));
+            IsReadOnly := False;
+          end
+          else if iAnswer = mrYes then
+          begin
+            // Popup an open dialog according to parameters and the state of the file
+            frmLuaEditMain.sdlgSaveAsUnit.FileName := ExtractFileName(Self.Name);
+
+            if frmLuaEditMain.sdlgSaveAsUnit.Execute then
+            begin
+              Path := frmLuaEditMain.sdlgSaveAsUnit.FileName;
+            end
+            else
+            begin
+              // Return false because action was cancel and quit function
+              Result := False;
+              Exit;
+            end;
+          end
+          else
+          begin
+            Result := False;
+            Exit;
+          end;
         end;
-      end
-      else
-      begin
-        Result := False;
-        Exit;
+
+        FPath := Path;
+        PrjOwner.HasChanged := True;  // Since the name has changed, the project must be saved
+        SynUnit.Lines.SaveToFile(FPath);  // Save to file to hard drive
+        FName := ExtractFileName(FPath);  // Get short name for fast display
+        IsNew := False;  // The file is no more new
+        HasChanged := False;  // The has no more changes
+        SynUnit.Modified := False;  // The actual editor must not notice any changes now
+        LastTimeModified := GetFileLastTimeModified(PChar(Path));  // Now we wrote on the disk we may retrieve the time it has been writen
+        
+        inherited SaveInc(Path);
       end;
+    except
+      frmLuaEditMessages.Put('Could not save file "'+FPath+'" on disk!', LUAEDIT_ERROR_MSG, FPath);
+      Result := False;
     end;
-
-    FPath := Path;
-    PrjOwner.HasChanged := True;  // Since the name has changed, the project must be saved
-    SynUnit.Lines.SaveToFile(FPath);  // Save to file to hard drive
-    FName := ExtractFileName(FPath);  // Get short name for fast display
-    IsNew := False;  // The file is no more new
-    HasChanged := False;  // The has no more changes
-    SynUnit.Modified := False;  // The actual editor must not notice any changes now
-    LastTimeModified := GetFileLastTimeModified(PChar(Path));  // Now we wrote on the disk we may retrieve the time it has been writen
-
-    // Reinitialize stuff...
+  finally
+    // Refresh interface
     frmLuaEditMain.RefreshOpenedUnits;
     frmLuaEditMain.jvUnitBarChange(frmLuaEditMain.jvUnitBar);
     frmProjectTree.BuildProjectTree;
@@ -971,100 +982,108 @@ begin
     frmLuaEditMain.stbMain.Panels[5].Text := '';
     frmLuaEditMain.stbMain.Refresh;
     SynUnit.Refresh;
-  end;
 
-  frmLuaEditMain.jvchnNotifier.Active := True;
-  inherited SaveInc(Path);
+    frmLuaEditMain.jvchnNotifier.Active := True;
+  end;
 end;
 
 function TLuaEditBasicTextFile.Save(Path: String; bNoDialog: Boolean = False; bForceDialog: Boolean = False): Boolean;
 var
   iAnswer: Integer;
   pMsgBox: TfrmReadOnlyMsgBox;
-begin  
-  frmLuaEditMain.jvchnNotifier.Active := False;
-  Result := True;
-
-  // save only if the file is opened in the tab...
-  // if not, there is no way that the file was modified so no needs to save
-  if Assigned(Self.AssociatedTab) then
-  begin
-    // Popup a open dialog according to parameters and the state of the file
-    if ((IsNew and not bNoDialog) or (bForceDialog)) then
-    begin
-      frmLuaEditMain.sdlgSaveAsUnit.FileName := ExtractFileName(Self.Name);
-
-      if ExtractFileExt(FPath) = '.lua' then
-        frmLuaEditMain.sdlgSaveAsUnit.FilterIndex := 1
-      else if ExtractFileExt(FPath) = '.lmc' then
-        frmLuaEditMain.sdlgSaveAsUnit.FilterIndex := 2
-      else if ExtractFileExt(FPath) = '.txt' then
-        frmLuaEditMain.sdlgSaveAsUnit.FilterIndex := 3
-      else
-        frmLuaEditMain.sdlgSaveAsUnit.FilterIndex := 4;
-
-      if frmLuaEditMain.sdlgSaveAsUnit.Execute then
-      begin
-        Path := frmLuaEditMain.sdlgSaveAsUnit.FileName;
-        PrjOwner.HasChanged := True;
-
-        if IsNew then
-          frmLuaEditMain.MonitorFileToRecent(Path);
-      end
-      else
-      begin
-        // Return false because action was cancel and quit function
-        Result := False;
-        Exit;
-      end;
-    end;
+begin
+  try
+    try
+      frmLuaEditMain.jvchnNotifier.Active := False;
+      Result := True;
 
-    // Check if file is read only first
-    while (GetFileReadOnlyAttr(PChar(Path)) and (FileExistsAbs(Path))) do
-    begin
-      pMsgBox := TfrmReadOnlyMsgBox.Create(nil);
-      iAnswer := pMsgBox.MessageBox('The project '+Path+' is read-only. Save anyway?      ', 'LuaEdit');
-      pMsgBox.Free;
-      if iAnswer = mrOk then
+      // save only if the file is opened in the tab...
+      // if not, there is no way that the file was modified so no needs to save
+      if Assigned(Self.AssociatedTab) then
       begin
-        ToggleFileReadOnlyAttr(PChar(Path));
-        // Now that we wrote on the disk we may retrieve the time it has been writen
-        LastTimeModified := GetFileLastTimeModified(PChar(Path));
-        IsReadOnly := False;
-      end
-      else if iAnswer = mrYes then
-      begin
-        // Popup an open dialog according to parameters and the state of the file
-        frmLuaEditMain.sdlgSaveAsUnit.FileName := ExtractFileName(Self.Name);
-
-        if frmLuaEditMain.sdlgSaveAsUnit.Execute then
+        // Popup a open dialog according to parameters and the state of the file
+        if ((IsNew and not bNoDialog) or (bForceDialog)) then
         begin
-          Path := frmLuaEditMain.sdlgSaveAsUnit.FileName;
-          PrjOwner.HasChanged := True;
-        end
-        else
+          frmLuaEditMain.sdlgSaveAsUnit.FileName := ExtractFileName(Self.Name);
+
+          if ExtractFileExt(FPath) = '.lua' then
+            frmLuaEditMain.sdlgSaveAsUnit.FilterIndex := 1
+          else if ExtractFileExt(FPath) = '.lmc' then
+            frmLuaEditMain.sdlgSaveAsUnit.FilterIndex := 2
+          else if ExtractFileExt(FPath) = '.txt' then
+            frmLuaEditMain.sdlgSaveAsUnit.FilterIndex := 3
+          else
+            frmLuaEditMain.sdlgSaveAsUnit.FilterIndex := 4;
+
+          if frmLuaEditMain.sdlgSaveAsUnit.Execute then
+          begin
+            Path := frmLuaEditMain.sdlgSaveAsUnit.FileName;
+            PrjOwner.HasChanged := True;
+
+            if IsNew then
+              frmLuaEditMain.MonitorFileToRecent(Path);
+          end
+          else
+          begin
+            // Return false because action was cancel and quit function
+            Result := False;
+            Exit;
+          end;
+        end;
+
+        // Check if file is read only first
+        while (GetFileReadOnlyAttr(PChar(Path)) and (FileExistsAbs(Path))) do
         begin
-          // Return false because action was cancel and quit function
-          Result := False;
-          Exit;
+          pMsgBox := TfrmReadOnlyMsgBox.Create(nil);
+          iAnswer := pMsgBox.MessageBox('The project '+Path+' is read-only. Save anyway?      ', 'LuaEdit');
+          pMsgBox.Free;
+          if iAnswer = mrOk then
+          begin
+            ToggleFileReadOnlyAttr(PChar(Path));
+            // Now that we wrote on the disk we may retrieve the time it has been writen
+            LastTimeModified := GetFileLastTimeModified(PChar(Path));
+            IsReadOnly := False;
+          end
+          else if iAnswer = mrYes then
+          begin
+            // Popup an open dialog according to parameters and the state of the file
+            frmLuaEditMain.sdlgSaveAsUnit.FileName := ExtractFileName(Self.Name);
+
+            if frmLuaEditMain.sdlgSaveAsUnit.Execute then
+            begin
+              Path := frmLuaEditMain.sdlgSaveAsUnit.FileName;
+              PrjOwner.HasChanged := True;
+            end
+            else
+            begin
+              // Return false because action was cancel and quit function
+              Result := False;
+              Exit;
+            end;
+          end
+          else
+          begin
+            Result := False;
+            Exit;
+          end;
         end;
-      end
-      else
-      begin
-        Result := False;
-        Exit;
-      end;
-    end;
 
-    synUnit.Lines.SaveToFile(Path);  // Save the file to hard drive
-    Self.Name := ExtractFileName(Path);  // Get short name for fast display
-    Self.Path := Path;  // Assign filepath to class filepath
-    IsNew := False;  // The file is not new anymore
-    HasChanged := False;  // The file does't have anymore changes
-    synUnit.Modified := False;  // The actual editor must not notice any changes now
-    LastTimeModified := GetFileLastTimeModified(PChar(Path));  // Now we wrote on the disk we may retrieve the time it has been writen
+        synUnit.Lines.SaveToFile(Path);  // Save the file to hard drive
+        Self.Name := ExtractFileName(Path);  // Get short name for fast display
+        Self.Path := Path;  // Assign filepath to class filepath
+        IsNew := False;  // The file is not new anymore
+        HasChanged := False;  // The file does't have anymore changes
+        synUnit.Modified := False;  // The actual editor must not notice any changes now
+        LastTimeModified := GetFileLastTimeModified(PChar(Path));  // Now we wrote on the disk we may retrieve the time it has been writen
 
-    // Initialize stuff...
+        inherited Save(Path);
+      end;
+    except
+      frmLuaEditMessages.Put('Could not save file "'+FPath+'" on disk!', LUAEDIT_ERROR_MSG, FPath);
+      Result := False;
+    end;
+  finally
+    // Refresh interface
     frmLuaEditMain.RefreshOpenedUnits;
     frmLuaEditMain.jvUnitBarChange(frmLuaEditMain.jvUnitBar);
     frmProjectTree.BuildProjectTree;
@@ -1072,10 +1091,9 @@ begin
     frmLuaEditMain.stbMain.Panels[5].Text := '';
     frmLuaEditMain.stbMain.Refresh;
     synUnit.Refresh;
-  end;
 
-  frmLuaEditMain.jvchnNotifier.Active := True;
-  inherited Save(Path);
+    frmLuaEditMain.jvchnNotifier.Active := True;
+  end;
 end;
 
 ///////////////////////////////////////////////////////////////////
@@ -1108,7 +1126,7 @@ end;
 
 function TLuaEditDebugFile.Save(Path: String; bNoDialog: Boolean; bForceDialog: Boolean): Boolean;
 begin
-  inherited Save(Path, bNoDialog, bForceDialog);
+  Result := inherited Save(Path, bNoDialog, bForceDialog);
 
   // Reinitialize variables
   DebugInfos.iLineError := -1;  // Do not display anymore the current line error
@@ -1124,7 +1142,7 @@ end;
 
 function TLuaEditDebugFile.SaveInc(Path: String; bNoDialog: Boolean; bForceDialog: Boolean): Boolean;
 begin
-  inherited SaveInc(Path, bNoDialog, bForceDialog);
+  Result := inherited SaveInc(Path, bNoDialog, bForceDialog);
 
   // Reinitialize variables
   DebugInfos.iLineError := -1;  // Do not display anymore the current line error
@@ -1250,10 +1268,45 @@ end;
 destructor TLuaEditProject.Destroy;
 begin
   inherited Destroy;
-  
+
   lstUnits.Free;
 end;
 
+procedure TLuaEditProject.AddFile(pFile: TLuaEditFile);
+begin
+  if FName = '[@@SingleUnits@@]' then
+    lstUnits.Insert(lstUnits.Count, pFile)
+  else
+    lstUnits.Add(pFile);
+
+  FHasChanged := True;
+end;
+
+function TLuaEditProject.AddFile(FileName: String; IsNew: Boolean): TLuaEditBasicTextFile;
+var
+  pFile: TLuaEditFile;
+begin
+  if ExtractFileExt(FileName) = '.gui' then
+    pFile := TLuaEditGUIForm.Create(FileName)
+  else if ExtractFileExt(FileName) = '.lua' then
+    pFile := TLuaEditDebugFile(TLuaEditUnit.Create(FileName))
+  else if ExtractFileExt(FileName) = '.lmc' then
+    pFile := TLuaEditDebugFile(TLuaEditMacro.Create(FileName))
+  else
+    pFile := TLuaEditBasicTextFile.Create(FileName);
+
+  pFile.PrjOwner := Self;
+  pFile.IsNew := IsNew;
+
+  if FName = '[@@SingleUnits@@]' then
+    lstUnits.Insert(lstUnits.Count, pFile)
+  else
+    lstUnits.Add(pFile);
+
+  Result := TLuaEditBasicTextFile(pFile);
+  FHasChanged := True;
+end;
+
 procedure TLuaEditProject.GetProjectFromDisk(Path: String);
 var
   x: Integer;
@@ -1309,7 +1362,7 @@ begin
       if FileExistsAbs(sUnitName) then
       begin
         // Initialize unit and global variables considering the fact that open was a success
-        pLuaUnit := TLuaEditUnit(frmLuaEditMain.AddFileInProject(sUnitName, False, Self));
+        pLuaUnit := TLuaEditUnit(AddFile(sUnitName, False));
         pLuaUnit.Path := sUnitName;
         pLuaUnit.Name := ExtractFileName(sUnitName);
         pLuaUnit.IsLoaded := True;
@@ -1322,7 +1375,7 @@ begin
       begin
         // Initialize unit and global variables considering the fact that open was a failure
         Application.MessageBox(PChar('The file "'+sUnitName+'" is innexistant!'), 'LuaEdit', MB_OK+MB_ICONERROR);
-        pLuaUnit := TLuaEditUnit(frmLuaEditMain.AddFileInProject(sUnitName, False, Self));
+        pLuaUnit := TLuaEditUnit(AddFile(sUnitName, False));
         pLuaUnit.IsLoaded := False;
       end;
 

+ 3 - 2
LuaEdit/Profiler.dfm

@@ -1,7 +1,7 @@
 object frmProfiler: TfrmProfiler
   Left = 356
   Top = 236
-  Width = 612
+  Width = 862
   Height = 211
   BorderStyle = bsSizeToolWin
   Caption = 'Profiler'
@@ -14,6 +14,7 @@ object frmProfiler: TfrmProfiler
   Font.Height = -11
   Font.Name = 'MS Sans Serif'
   Font.Style = []
+  FormStyle = fsStayOnTop
   OldCreateOrder = False
   Position = poOwnerFormCenter
   OnCreate = FormCreate
@@ -23,7 +24,7 @@ object frmProfiler: TfrmProfiler
   object vstLuaProfiler: TVirtualStringTree
     Left = 0
     Top = 0
-    Width = 604
+    Width = 854
     Height = 184
     Align = alClient
     Header.AutoSizeIndex = 0

+ 15 - 5
LuaEdit/ProjectTree.dfm

@@ -71,20 +71,30 @@ object frmProjectTree: TfrmProjectTree
     OnPopup = ppmProjectTreePopup
     Left = 8
     Top = 72
-    object ActivateSelectedProject1: TMenuItem
-      Action = frmLuaEditMain.actActiveSelPrj
+    object N3: TMenuItem
+      Caption = 'Save'
+      ImageIndex = 5
+      OnClick = N3Click
     end
-    object UnloadFileProject1: TMenuItem
-      Caption = 'Unload File/Project'
-      OnClick = UnloadFileProject1Click
+    object SaveAs1: TMenuItem
+      Caption = 'Save As...'
+      ImageIndex = 7
+      OnClick = SaveAs1Click
     end
     object mnuFindTarget: TMenuItem
       Caption = 'Find Target...'
       OnClick = mnuFindTargetClick
     end
+    object UnloadFileProject1: TMenuItem
+      Caption = 'Unload File/Project'
+      OnClick = UnloadFileProject1Click
+    end
     object N2: TMenuItem
       Caption = '-'
     end
+    object ActivateSelectedProject1: TMenuItem
+      Action = frmLuaEditMain.actActiveSelPrj
+    end
     object AddUnittoProject1: TMenuItem
       Action = frmLuaEditMain.actAddToPrj
     end

+ 52 - 3
LuaEdit/ProjectTree.pas

@@ -5,7 +5,7 @@ interface
 uses
   Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
   Dialogs, ComCtrls, CommCtrl, ExtCtrls, ImgList, Menus, JvComponent, ShellAPI,
-  JvDockControlForm, JvExComCtrls, JvComCtrls, JvDotNetControls, Main, Misc,
+  JvDockControlForm, JvExComCtrls, JvComCtrls, JvDotNetControls, Misc,
   VirtualTrees;
 
 type
@@ -35,6 +35,8 @@ type
     vstProjectTree: TVirtualDrawTree;
     SystemImages: TImageList;
     StatesImages: TImageList;
+    N3: TMenuItem;
+    SaveAs1: TMenuItem;
     procedure UnloadFileProject1Click(Sender: TObject);
     procedure ppmProjectTreePopup(Sender: TObject);
     procedure vstProjectTreeGetNodeDataSize(Sender: TBaseVirtualTree; var NodeDataSize: Integer);
@@ -47,6 +49,8 @@ type
     procedure vstProjectTreeDrawNode(Sender: TBaseVirtualTree; const PaintInfo: TVTPaintInfo);
     procedure FormCreate(Sender: TObject);
     procedure vstProjectTreeInitNode(Sender: TBaseVirtualTree; ParentNode, Node: PVirtualNode; var InitialStates: TVirtualNodeInitStates);
+    procedure N3Click(Sender: TObject);
+    procedure SaveAs1Click(Sender: TObject);
   private
     { Private declarations }
   public
@@ -59,6 +63,8 @@ var
 
 implementation
 
+uses Main;
+
 {$R *.dfm}
 
 // Returns the index of the system icon for the given file object.
@@ -142,7 +148,7 @@ begin
 
       if pFile.IsLoaded then
       begin
-        frmLuaEditMain.PopUpUnitToScreen(pFile.Path);
+        frmLuaEditMain.PopUpUnitToScreen(pFile.DisplayPath);
       end;
     end
     else if pData.pLuaEditFile.FileType = otLuaEditForm then
@@ -505,7 +511,8 @@ var
   pData: PProjectTreeData;
   pNode: PVirtualNode;
 begin
-  pNode := vstProjectTree.GetFirstSelected;
+  frmLuaEditMain.CheckButtons();
+  pNode := vstProjectTree.GetFirstSelected();
   mnuFindTarget.Enabled := Assigned(pNode);
 
   if Assigned(pNode) then
@@ -717,4 +724,46 @@ begin
     GetOpenAndClosedIcons(pData.pLuaEditFile.Path, pData.OpenIndex, pData.CloseIndex);
 end;
 
+procedure TfrmProjectTree.N3Click(Sender: TObject);
+var
+  pNode: PVirtualNode;
+  pData: PProjectTreeData;
+begin
+  pNode := vstProjectTree.GetFirstSelected();
+
+  if Assigned(pNode) then
+  begin
+    pData := vstProjectTree.GetNodeData(pNode);
+
+    if TLuaEditFile(pData).FileType = otLuaEditProject then
+      if SaveProjectsInc then
+        TLuaEditProject(pData).SaveInc(TLuaEditProject(pData).Path)
+      else
+        TLuaEditProject(pData).Save(TLuaEditProject(pData).Path)
+    else
+      frmLuaEditMain.DoSaveExecute(TLuaEditBasicTextFile(pData));
+  end;
+end;
+
+procedure TfrmProjectTree.SaveAs1Click(Sender: TObject);
+var
+  pNode: PVirtualNode;
+  pData: PProjectTreeData;
+begin
+  pNode := vstProjectTree.GetFirstSelected();
+
+  if Assigned(pNode) then
+  begin
+    pData := vstProjectTree.GetNodeData(pNode);
+
+    if TLuaEditFile(pData).FileType = otLuaEditProject then
+      if SaveProjectsInc then
+        TLuaEditProject(pData).SaveInc(TLuaEditProject(pData).Path, False, True)
+      else
+        TLuaEditProject(pData).Save(TLuaEditProject(pData).Path, False, True)
+    else
+      frmLuaEditMain.DoSaveAsExecute(TLuaEditBasicTextFile(pData));
+  end;
+end;
+
 end.

Nem az összes módosított fájl került megjelenítésre, mert túl sok fájl változott