2
0
Эх сурвалжийг харах

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 жил өмнө
parent
commit
14426cdadc

+ 1 - 1
LuaEdit/EditorSettings.dfm

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

+ 4 - 4
LuaEdit/EditorSettings.pas

@@ -435,19 +435,19 @@ begin
     begin
     begin
       // Register file association for .lpr files
       // Register file association for .lpr files
       RegSetAssociation('.lpr', 'LuaEdit.lpr', 'LuaEdit Project', 'LuaEdit/LuaEdit.lpr', PChar(GetLuaEditInstallPath() + '\Graphics\Project.ico'));
       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
       // Register file association for .lua files
       RegSetAssociation('.lua', 'LuaEdit.lua', 'LuaEdit Unit', 'LuaEdit/LuaEdit.lua', PChar(GetLuaEditInstallPath() + '\Graphics\Unit.ico'));
       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
       // Register file association for .lmc files
       RegSetAssociation('.lmc', 'LuaEdit.lmc', 'LuaEdit Macro', 'LuaEdit/LuaEdit.lmc', PChar(GetLuaEditInstallPath() + '\Graphics\LuaMacros.ico'));
       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
       // Register file association for .gui files
       RegSetAssociation('.gui', 'LuaEdit.gui', 'LuaEdit GUI Form', 'LuaEdit/LuaEdit.gui', PChar(GetLuaEditInstallPath() + '\Graphics\LuaGUIForm.ico'));
       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
     end
     else
     else
     begin      
     begin      

+ 1 - 1
LuaEdit/FindWindow1.pas

@@ -198,7 +198,7 @@ procedure TfrmFindWindow1.lvwResultDblClick(Sender: TObject);
 begin
 begin
   // Bring the file in the editor and go directly to the line where it's defined
   // Bring the file in the editor and go directly to the line where it's defined
   if Assigned(lvwResult.Selected) then
   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;
 
 
 end.
 end.

+ 1 - 1
LuaEdit/FindWindow2.pas

@@ -198,7 +198,7 @@ procedure TfrmFindWindow2.lvwResultDblClick(Sender: TObject);
 begin
 begin
   // Bring the file in the editor and go directly to the line where it's defined
   // Bring the file in the editor and go directly to the line where it's defined
   if Assigned(lvwResult.Selected) then
   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;
 
 
 end.
 end.

+ 1 - 1
LuaEdit/FunctionList.dfm

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

+ 105 - 59
LuaEdit/LEMacros.pas

@@ -12,7 +12,7 @@ interface
 uses lua, lualib, lauxlib, Forms, SysUtils, LuaUtils, Misc, SynEdit,
 uses lua, lualib, lauxlib, Forms, SysUtils, LuaUtils, Misc, SynEdit,
      LuaEditMessages, Classes, Registry, Windows;
      LuaEditMessages, Classes, Registry, Windows;
 
 
-procedure LERegisterToLua(L: Plua_State);
+procedure LERegisterToLua(L: Plua_State; NeedLuaLibs: Boolean = True);
 
 
 implementation
 implementation
 
 
@@ -47,7 +47,7 @@ begin
       FilesName.Add(StrPas(lua_tostring(L, x)));
       FilesName.Add(StrPas(lua_tostring(L, x)));
 
 
   // Return the luaedit version as a string
   // Return the luaedit version as a string
-  lua_pushboolean(L, frmLuaEditMain.DoOpenFileExecute(FilesName));
+  lua_pushboolean(L, Integer(frmLuaEditMain.DoOpenFileExecute(FilesName)));
 
 
   // Free variables
   // Free variables
   FilesName.Free;
   FilesName.Free;
@@ -67,7 +67,7 @@ end;
 function LuaLEOpenProject(L: Plua_State): Integer; cdecl;
 function LuaLEOpenProject(L: Plua_State): Integer; cdecl;
 begin
 begin
   // Return the luaedit version as a string
   // 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
   // Return in Delphi the number of argument pushed on the stack
   Result := 1;
   Result := 1;
@@ -84,7 +84,7 @@ end;
 function LuaLESaveAll(L: Plua_State): Integer; cdecl;
 function LuaLESaveAll(L: Plua_State): Integer; cdecl;
 begin
 begin
   // Return the luaedit version as a string
   // 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
   // Return in Delphi the number of argument pushed on the stack
   Result := 1;
   Result := 1;
@@ -101,7 +101,7 @@ end;
 function LuaLESavePrjAs(L: Plua_State): Integer; cdecl;
 function LuaLESavePrjAs(L: Plua_State): Integer; cdecl;
 begin
 begin
   // Return the luaedit version as a string
   // 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
   // Return in Delphi the number of argument pushed on the stack
   Result := 1;
   Result := 1;
@@ -109,16 +109,32 @@ end;
 
 
 ////////////////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////////////////
 // Desc: This function save the currently opened unit as...
 // 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,
 // Out:  (1) True if the operation ended successfully. False if canceled,
 //           unavailable (disabled) or failed.
 //           unavailable (disabled) or failed.
 //
 //
 // 14/05/2006 - Jean-Francois Goulet
 // 14/05/2006 - Jean-Francois Goulet
 ////////////////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////////////////
 function LuaLESaveUnitAs(L: Plua_State): Integer; cdecl;
 function LuaLESaveUnitAs(L: Plua_State): Integer; cdecl;
+var
+  bRes: Boolean;
+  sPath: String;
+  pFile: TLuaEditBasicTextFile; 
 begin
 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
   // Return in Delphi the number of argument pushed on the stack
   Result := 1;
   Result := 1;
@@ -126,16 +142,32 @@ end;
 
 
 ////////////////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////////////////
 // Desc: This function save the currently opened unit
 // 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,
 // Out:  (1) True if the operation ended successfully. False if canceled,
 //           unavailable (disabled) or failed.
 //           unavailable (disabled) or failed.
 //
 //
 // 14/05/2006 - Jean-Francois Goulet
 // 14/05/2006 - Jean-Francois Goulet
 ////////////////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////////////////
 function LuaLESaveUnit(L: Plua_State): Integer; cdecl;
 function LuaLESaveUnit(L: Plua_State): Integer; cdecl;
+var
+  bRes: Boolean;
+  sPath: String;
+  pFile: TLuaEditBasicTextFile; 
 begin
 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
   // Return in Delphi the number of argument pushed on the stack
   Result := 1;
   Result := 1;
@@ -160,7 +192,7 @@ end;
 //
 //
 // 14/05/2006 - Jean-Francois Goulet
 // 14/05/2006 - Jean-Francois Goulet
 ////////////////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////////////////
-function LuaLEGetUnit(L: Plua_State): Integer; cdecl;
+function LuaLEGetFile(L: Plua_State): Integer; cdecl;
 var
 var
   Index, x: Integer;
   Index, x: Integer;
   pLuaUnit: TLuaEditUnit;
   pLuaUnit: TLuaEditUnit;
@@ -196,27 +228,27 @@ begin
 
 
         // Push "Path" data
         // Push "Path" data
         lua_pushstring(L, 'Path');
         lua_pushstring(L, 'Path');
-        lua_pushstring(L, PChar(pLuaUnit.Path));
+        lua_pushstring(L, PChar(pLuaUnit.DisplayPath));
         lua_settable(L, -3);
         lua_settable(L, -3);
 
 
         // Push "IsLoaded" data
         // Push "IsLoaded" data
         lua_pushstring(L, 'IsLoaded');
         lua_pushstring(L, 'IsLoaded');
-        lua_pushboolean(L, pLuaUnit.IsLoaded);
+        lua_pushboolean(L, Integer(pLuaUnit.IsLoaded));
         lua_settable(L, -3);
         lua_settable(L, -3);
 
 
         // Push "IsReadOnly" data
         // Push "IsReadOnly" data
         lua_pushstring(L, 'IsReadOnly');
         lua_pushstring(L, 'IsReadOnly');
-        lua_pushboolean(L, pLuaUnit.IsReadOnly);
+        lua_pushboolean(L, Integer(pLuaUnit.IsReadOnly));
         lua_settable(L, -3);
         lua_settable(L, -3);
 
 
         // Push "IsNew" data
         // Push "IsNew" data
         lua_pushstring(L, 'IsNew');
         lua_pushstring(L, 'IsNew');
-        lua_pushboolean(L, pLuaUnit.IsNew);
+        lua_pushboolean(L, Integer(pLuaUnit.IsNew));
         lua_settable(L, -3);
         lua_settable(L, -3);
 
 
         // Push "HasChanged" data
         // Push "HasChanged" data
         lua_pushstring(L, 'HasChanged');
         lua_pushstring(L, 'HasChanged');
-        lua_pushboolean(L, pLuaUnit.HasChanged);
+        lua_pushboolean(L, Integer(pLuaUnit.HasChanged));
         lua_settable(L, -3);
         lua_settable(L, -3);
 
 
         // Push "Text" data
         // Push "Text" data
@@ -304,7 +336,7 @@ begin
 
 
     // Push "Path" data
     // Push "Path" data
     lua_pushstring(L, 'Path');
     lua_pushstring(L, 'Path');
-    lua_pushstring(L, PChar(ActiveProject.Path));
+    lua_pushstring(L, PChar(ActiveProject.DisplayPath));
     lua_settable(L, -3);
     lua_settable(L, -3);
 
 
     // Push "Initializer" data
     // Push "Initializer" data
@@ -344,22 +376,22 @@ begin
 
 
     // Push "AutoIncRevNumber" data
     // Push "AutoIncRevNumber" data
     lua_pushstring(L, 'AutoIncRevNumber');
     lua_pushstring(L, 'AutoIncRevNumber');
-    lua_pushboolean(L, ActiveProject.AutoIncRevNumber);
+    lua_pushboolean(L, Integer(ActiveProject.AutoIncRevNumber));
     lua_settable(L, -3);
     lua_settable(L, -3);
 
 
     // Push "IsReadOnly" data
     // Push "IsReadOnly" data
     lua_pushstring(L, 'IsReadOnly');
     lua_pushstring(L, 'IsReadOnly');
-    lua_pushboolean(L, ActiveProject.IsReadOnly);
+    lua_pushboolean(L, Integer(ActiveProject.IsReadOnly));
     lua_settable(L, -3);
     lua_settable(L, -3);
 
 
     // Push "IsNew" data
     // Push "IsNew" data
     lua_pushstring(L, 'IsNew');
     lua_pushstring(L, 'IsNew');
-    lua_pushboolean(L, ActiveProject.IsNew);
+    lua_pushboolean(L, Integer(ActiveProject.IsNew));
     lua_settable(L, -3);
     lua_settable(L, -3);
 
 
     // Push "HasChanged" data
     // Push "HasChanged" data
     lua_pushstring(L, 'HasChanged');
     lua_pushstring(L, 'HasChanged');
-    lua_pushboolean(L, ActiveProject.HasChanged);
+    lua_pushboolean(L, Integer(ActiveProject.HasChanged));
     lua_settable(L, -3);
     lua_settable(L, -3);
     
     
     // Push "VersionMajor" data
     // Push "VersionMajor" data
@@ -665,48 +697,62 @@ end;
 // This function register in the given lua state all luaedit related function
 // 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
 // to allow to the user some interface customization. Kind of like macros but
 // using lua.
 // using lua.
-procedure LERegisterToLua(L: Plua_State);
+procedure LERegisterToLua(L: Plua_State; NeedLuaLibs: Boolean);
 const
 const
   LETableName = 'luaedit';
   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
 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;
 
 
 end.
 end.

+ 1 - 1
LuaEdit/LuaConsole.pas

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

+ 3 - 3
LuaEdit/LuaEdit.dof

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

+ 2 - 4
LuaEdit/LuaEdit.dpr

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

BIN
LuaEdit/LuaEdit.res


+ 8 - 0
LuaEdit/LuaEditMessages.pas

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

+ 15 - 1
LuaEdit/LuaLocals.pas

@@ -5,7 +5,7 @@ interface
 uses
 uses
   Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
   Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
   Dialogs, JvComponent, JvDockControlForm, ComCtrls, StdCtrls,
   Dialogs, JvComponent, JvDockControlForm, ComCtrls, StdCtrls,
-  JvExStdCtrls, JvListBox;
+  JvExStdCtrls, JvListBox, LuaUtils;
 
 
 type
 type
   TfrmLuaLocals = class(TForm)
   TfrmLuaLocals = class(TForm)
@@ -15,6 +15,7 @@ type
     { Private declarations }
     { Private declarations }
   public
   public
     { Public declarations }
     { Public declarations }
+    procedure FillLocalsList(Locals: TList);
   end;
   end;
 
 
 var
 var
@@ -24,4 +25,17 @@ implementation
 
 
 {$R *.dfm}
 {$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.
 end.

+ 24 - 15
LuaEdit/Main.dfm

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

Файлын зөрүү хэтэрхий том тул дарагдсан байна
+ 5409 - 5269
LuaEdit/Main.pas


+ 251 - 198
LuaEdit/Misc.pas

@@ -242,8 +242,8 @@ type
   public
   public
     constructor Create(Path: String; otType: TLuaEditFileType = otTextFile);
     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
   published
     property FileType: TLuaEditFileType read FOTFileType write FOTFileType;
     property FileType: TLuaEditFileType read FOTFileType write FOTFileType;
     property LastTimeModified: TDateTime read FLastTimeModified write FLastTimeModified;
     property LastTimeModified: TDateTime read FLastTimeModified write FLastTimeModified;
@@ -279,8 +279,8 @@ type
     constructor Create(Path: String; otType: TLuaEditFileType = otTextFile);
     constructor Create(Path: String; otType: TLuaEditFileType = otTextFile);
     destructor Destroy; override;
     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
   published
     property LastEditedLine:   Integer read FLastEditedLine write FLastEditedLine;
     property LastEditedLine:   Integer read FLastEditedLine write FLastEditedLine;
     property SynUnit:          TSynEdit read FSynUnit write FSynUnit;
     property SynUnit:          TSynEdit read FSynUnit write FSynUnit;
@@ -298,8 +298,8 @@ type
     constructor Create(Path: String; otType: TLuaEditFileType = otTextFile);
     constructor Create(Path: String; otType: TLuaEditFileType = otTextFile);
     destructor Destroy; override;
     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 SaveBreakpoints();
     procedure GetBreakpoints();
     procedure GetBreakpoints();
   published
   published
@@ -349,9 +349,11 @@ type
     constructor Create(Path: String; otType: TLuaEditFileType = otLuaEditProject);
     constructor Create(Path: String; otType: TLuaEditFileType = otLuaEditProject);
     destructor  Destroy; override;
     destructor  Destroy; override;
 
 
+    procedure AddFile(pFile: TLuaEditFile); overload;
+    function AddFile(FileName: String; IsNew: Boolean): TLuaEditBasicTextFile; overload;
     procedure GetProjectFromDisk(Path: String);
     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();
     procedure RealoadProject();
   end;
   end;
 
 
@@ -373,7 +375,7 @@ function FileExistsAbs(FileName: String): Boolean;
 implementation
 implementation
 
 
 uses
 uses
-  Main, Breakpoints, ReadOnlyMsgBox, ProjectTree, GUIDesigner;
+  Main, Breakpoints, ReadOnlyMsgBox, ProjectTree, GUIDesigner, LuaEditMessages;
 
 
 ///////////////////////////////////////////////////////////////////
 ///////////////////////////////////////////////////////////////////
 // Misc functions
 // Misc functions
@@ -499,7 +501,7 @@ begin
 end;
 end;
 
 
 ///////////////////////////////////////////////////////////////////
 ///////////////////////////////////////////////////////////////////
-//TFctInfo
+// TFctInfo
 ///////////////////////////////////////////////////////////////////
 ///////////////////////////////////////////////////////////////////
 constructor TFctInfo.Create;
 constructor TFctInfo.Create;
 begin
 begin
@@ -509,7 +511,7 @@ begin
 end;
 end;
 
 
 ///////////////////////////////////////////////////////////////////
 ///////////////////////////////////////////////////////////////////
-//TBreakInfo
+// TBreakInfo
 ///////////////////////////////////////////////////////////////////
 ///////////////////////////////////////////////////////////////////
 constructor TBreakInfo.Create;
 constructor TBreakInfo.Create;
 begin
 begin
@@ -520,7 +522,7 @@ begin
 end;
 end;
 
 
 ///////////////////////////////////////////////////////////////////
 ///////////////////////////////////////////////////////////////////
-//TBreakpoint class
+// TBreakpoint class
 ///////////////////////////////////////////////////////////////////
 ///////////////////////////////////////////////////////////////////
 constructor TBreakpoint.Create;
 constructor TBreakpoint.Create;
 begin
 begin
@@ -531,7 +533,7 @@ begin
 end;
 end;
 
 
 ///////////////////////////////////////////////////////////////////
 ///////////////////////////////////////////////////////////////////
-//TLineDebugInfos class
+// TLineDebugInfos class
 ///////////////////////////////////////////////////////////////////
 ///////////////////////////////////////////////////////////////////
 constructor TLineDebugInfos.Create;
 constructor TLineDebugInfos.Create;
 begin
 begin
@@ -773,12 +775,12 @@ begin
   FName := ChangeFileExt(ExtractFileName(Path), '');
   FName := ChangeFileExt(ExtractFileName(Path), '');
 end;
 end;
 
 
-function TLuaEditFile.Save(Path: String): Boolean;
+function TLuaEditFile.Save(Path: String; bNoDialog: Boolean = False; bForceDialog: Boolean = False): Boolean;
 begin
 begin
   FDisplayPath := Path;
   FDisplayPath := Path;
 end;
 end;
 
 
-function TLuaEditFile.SaveInc(Path: String): Boolean;
+function TLuaEditFile.SaveInc(Path: String; bNoDialog: Boolean = False; bForceDialog: Boolean = False): Boolean;
 begin
 begin
   FDisplayPath := Path;
   FDisplayPath := Path;
 end;
 end;
@@ -859,111 +861,120 @@ var
   xPos, IncValue, iAnswer, TempIncValue: Integer;
   xPos, IncValue, iAnswer, TempIncValue: Integer;
   bResult: Boolean;
   bResult: Boolean;
   pMsgBox: TfrmReadOnlyMsgBox;
   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
       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
         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;
-      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;
       end;
+    except
+      frmLuaEditMessages.Put('Could not save file "'+FPath+'" on disk!', LUAEDIT_ERROR_MSG, FPath);
+      Result := False;
     end;
     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.RefreshOpenedUnits;
     frmLuaEditMain.jvUnitBarChange(frmLuaEditMain.jvUnitBar);
     frmLuaEditMain.jvUnitBarChange(frmLuaEditMain.jvUnitBar);
     frmProjectTree.BuildProjectTree;
     frmProjectTree.BuildProjectTree;
@@ -971,100 +982,108 @@ begin
     frmLuaEditMain.stbMain.Panels[5].Text := '';
     frmLuaEditMain.stbMain.Panels[5].Text := '';
     frmLuaEditMain.stbMain.Refresh;
     frmLuaEditMain.stbMain.Refresh;
     SynUnit.Refresh;
     SynUnit.Refresh;
-  end;
 
 
-  frmLuaEditMain.jvchnNotifier.Active := True;
-  inherited SaveInc(Path);
+    frmLuaEditMain.jvchnNotifier.Active := True;
+  end;
 end;
 end;
 
 
 function TLuaEditBasicTextFile.Save(Path: String; bNoDialog: Boolean = False; bForceDialog: Boolean = False): Boolean;
 function TLuaEditBasicTextFile.Save(Path: String; bNoDialog: Boolean = False; bForceDialog: Boolean = False): Boolean;
 var
 var
   iAnswer: Integer;
   iAnswer: Integer;
   pMsgBox: TfrmReadOnlyMsgBox;
   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
       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
         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
         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;
-      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.RefreshOpenedUnits;
     frmLuaEditMain.jvUnitBarChange(frmLuaEditMain.jvUnitBar);
     frmLuaEditMain.jvUnitBarChange(frmLuaEditMain.jvUnitBar);
     frmProjectTree.BuildProjectTree;
     frmProjectTree.BuildProjectTree;
@@ -1072,10 +1091,9 @@ begin
     frmLuaEditMain.stbMain.Panels[5].Text := '';
     frmLuaEditMain.stbMain.Panels[5].Text := '';
     frmLuaEditMain.stbMain.Refresh;
     frmLuaEditMain.stbMain.Refresh;
     synUnit.Refresh;
     synUnit.Refresh;
-  end;
 
 
-  frmLuaEditMain.jvchnNotifier.Active := True;
-  inherited Save(Path);
+    frmLuaEditMain.jvchnNotifier.Active := True;
+  end;
 end;
 end;
 
 
 ///////////////////////////////////////////////////////////////////
 ///////////////////////////////////////////////////////////////////
@@ -1108,7 +1126,7 @@ end;
 
 
 function TLuaEditDebugFile.Save(Path: String; bNoDialog: Boolean; bForceDialog: Boolean): Boolean;
 function TLuaEditDebugFile.Save(Path: String; bNoDialog: Boolean; bForceDialog: Boolean): Boolean;
 begin
 begin
-  inherited Save(Path, bNoDialog, bForceDialog);
+  Result := inherited Save(Path, bNoDialog, bForceDialog);
 
 
   // Reinitialize variables
   // Reinitialize variables
   DebugInfos.iLineError := -1;  // Do not display anymore the current line error
   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;
 function TLuaEditDebugFile.SaveInc(Path: String; bNoDialog: Boolean; bForceDialog: Boolean): Boolean;
 begin
 begin
-  inherited SaveInc(Path, bNoDialog, bForceDialog);
+  Result := inherited SaveInc(Path, bNoDialog, bForceDialog);
 
 
   // Reinitialize variables
   // Reinitialize variables
   DebugInfos.iLineError := -1;  // Do not display anymore the current line error
   DebugInfos.iLineError := -1;  // Do not display anymore the current line error
@@ -1250,10 +1268,45 @@ end;
 destructor TLuaEditProject.Destroy;
 destructor TLuaEditProject.Destroy;
 begin
 begin
   inherited Destroy;
   inherited Destroy;
-  
+
   lstUnits.Free;
   lstUnits.Free;
 end;
 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);
 procedure TLuaEditProject.GetProjectFromDisk(Path: String);
 var
 var
   x: Integer;
   x: Integer;
@@ -1309,7 +1362,7 @@ begin
       if FileExistsAbs(sUnitName) then
       if FileExistsAbs(sUnitName) then
       begin
       begin
         // Initialize unit and global variables considering the fact that open was a success
         // 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.Path := sUnitName;
         pLuaUnit.Name := ExtractFileName(sUnitName);
         pLuaUnit.Name := ExtractFileName(sUnitName);
         pLuaUnit.IsLoaded := True;
         pLuaUnit.IsLoaded := True;
@@ -1322,7 +1375,7 @@ begin
       begin
       begin
         // Initialize unit and global variables considering the fact that open was a failure
         // 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);
         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;
         pLuaUnit.IsLoaded := False;
       end;
       end;
 
 

+ 3 - 2
LuaEdit/Profiler.dfm

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

+ 15 - 5
LuaEdit/ProjectTree.dfm

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

+ 52 - 3
LuaEdit/ProjectTree.pas

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

Энэ ялгаанд хэт олон файл өөрчлөгдсөн тул зарим файлыг харуулаагүй болно