1
0
mirror of https://github.com/moparisthebest/Simba synced 2024-11-21 08:45:06 -05:00

Resolve bug #222.

This commit is contained in:
Merlijn Wajer 2011-09-28 23:00:21 +02:00
parent c7a6f55b66
commit b11cf8bd53
2 changed files with 163 additions and 95 deletions

View File

@ -0,0 +1,55 @@
ssCheckUpdate = 'Settings/Updater/CheckForUpdates';
ssCheckUpdateMinutes = 'Settings/Updater/CheckEveryXMinutes';
ssUpdaterLink = 'Settings/Updater/RemoteLink';
ssUpdaterVersionLink = 'Settings/Updater/RemoteVersionLink';
ssLoadFontsOnStart = 'Settings/Fonts/LoadOnStartUp';
ssFontsVersion = 'Settings/Fonts/Version';
ssFontsLink = 'Settings/Fonts/UpdateLink';
ssFontsVersionLink = 'Settings/Fonts/VersionLink';
ssFontsPath = 'Settings/Fonts/Path';
ssIncludesPath = 'Settings/Includes/Path';
ssInterpreterType = 'Settings/Interpreter/Type';
ssTabsOpenNextOnClose = 'Settings/Tabs/OpenNextOnClose';
ssTabsOpenScriptInNewTab = 'Settings/Tabs/OpenScriptInNewTab';
ssTabsCheckBeforeOpen = 'Settings/Tabs/CheckTabsBeforeOpen';
ssColourPickerShowHistoryOnPick = 'Settings/ColourPicker/ShowHistoryOnPick';
ssColourPickerAddToHistoryOnPick = 'Settings/ColourPicker/AddToHistoryOnPick';
ssScriptsPath = 'Settings/Scripts/Path';
ssCodeHintsShowAutomatically = 'Settings/CodeHints/ShowAutomatically';
ssCodeCompletionShowAutomatically = 'Settings/CodeCompletion/ShowAutomatically';
ssExtensionsFileExtension = 'Settings/Extensions/FileExtension';
ssSourceEditorLazColors = 'Settings/SourceEditor/LazColors';
ssSourceEditorDefScriptPath = 'Settings/SourceEditor/DefScriptPath';
ssNewsLink = 'Settings/News/URL';
ssPluginsPath = 'Settings/Plugins/Path';
ssExtensionsExtensionN = 'Extensions/Extension';
ssExtensionsPath = 'Settings/Extensions/Path';
ssExtensionsCount = 'Extensions/ExtensionCount';
ssTrayAlwaysVisible = 'Settings/Tray/AlwaysVisible';
ssConsoleVisible = 'LastConfig/Console/Visible';
ssMainFormPosition = 'LastConfig/MainForm/Position';
ssMainFormState = 'LastConfig/MainForm/State';
ssMainFormNormalSize = 'Settings/MainForm/NormalSize';
ssFunctionListShown = 'LastConfig/MainForm/FunctionListShown';
ssFunctionListShowOnStart = 'Settings/FunctionList/ShowOnStart';
ssMaxRecentFiles = 'Settings/General/MaxRecentFiles';
ssRecentFiles = 'LastConfig/MainForm/RecentFiles';
ssRecentFilesCount = 'LastConfig/MainForm/RecentFiles/Count';
ssRecentFileN = 'LastConfig/MainForm/RecentFiles/File';

View File

@ -82,6 +82,8 @@ const
shortcut_PickColourKey = VK_P; shortcut_PickColourKey = VK_P;
{$ENDIF} {$ENDIF}
{$I settings_const.inc}
type type
{ TMufasaTab } { TMufasaTab }
@ -768,7 +770,7 @@ end;
function TSimbaForm.GetInterpreter: Integer; function TSimbaForm.GetInterpreter: Integer;
begin begin
result := StrToIntDef(LoadSettingDef('Settings/Interpreter/Type','0'),0); result := StrToIntDef(LoadSettingDef(ssInterpreterType, '0'),0);
if (result < 0) or (result > 2) then if (result < 0) or (result > 2) then
begin begin
SetInterpreter(0); SetInterpreter(0);
@ -778,12 +780,12 @@ end;
function TSimbaForm.GetDefScriptPath: string; function TSimbaForm.GetDefScriptPath: string;
begin begin
result :=LoadSettingDef('Settings/SourceEditor/DefScriptPath', ExpandFileName(MainDir+DS+'default.simba')); result :=LoadSettingDef(ssSourceEditorDefScriptPath, ExpandFileName(MainDir+DS+'default.simba'));
end; end;
function TSimbaForm.GetScriptPath: string; function TSimbaForm.GetScriptPath: string;
begin begin
result :=IncludeTrailingPathDelimiter(LoadSettingDef('Settings/Scripts/Path', ExpandFileName(MainDir+DS+'Scripts' + DS))); result :=IncludeTrailingPathDelimiter(LoadSettingDef(ssScriptsPath, ExpandFileName(MainDir+DS+'Scripts' + DS)));
end; end;
procedure TSimbaForm.HandleOpenFileData; procedure TSimbaForm.HandleOpenFileData;
@ -992,7 +994,7 @@ var
begin begin
UpdateTimer.Interval:= MaxInt; UpdateTimer.Interval:= MaxInt;
FontUpdate; FontUpdate;
chk := LowerCase(LoadSettingDef('Settings/Updater/CheckForUpdates','True')); chk := LowerCase(LoadSettingDef(ssCheckUpdate, 'True'));
if chk <> 'true' then if chk <> 'true' then
Exit; Exit;
@ -1008,7 +1010,7 @@ begin
mDebugLn(format('Current Simba version: %d',[SimbaVersion])); mDebugLn(format('Current Simba version: %d',[SimbaVersion]));
mDebugLn('Latest Simba Version: ' + IntToStr(LatestVersion)); mDebugLn('Latest Simba Version: ' + IntToStr(LatestVersion));
end; end;
time := StrToIntDef(LoadSettingDef('Settings/Updater/CheckEveryXMinutes','30'),30); time := StrToIntDef(LoadSettingDef(ssCheckUpdateMinutes, '30'),30);
UpdateTimer.Interval:= time {mins} * 60 {secs} * 1000 {ms};//Every half hour UpdateTimer.Interval:= time {mins} * 60 {secs} * 1000 {ms};//Every half hour
end; end;
@ -1154,7 +1156,7 @@ begin
OldIndex := PageControl1.TabIndex; OldIndex := PageControl1.TabIndex;
if TabIndex = OldIndex then if TabIndex = OldIndex then
begin; begin;
if lowercase(LoadSettingDef('Settings/Tabs/OpenNextOnClose','False')) = 'false' then if lowercase(LoadSettingDef(ssTabsOpenNextOnClose, 'False')) = 'false' then
OldIndex := LastTab //We are closing the 'current' tab, lets go back in history OldIndex := LastTab //We are closing the 'current' tab, lets go back in history
else else
OldIndex := Min(Tabs.Count - 1,OldIndex + 1); OldIndex := Min(Tabs.Count - 1,OldIndex + 1);
@ -1364,43 +1366,52 @@ procedure TSimbaForm.CreateDefaultEnvironment;
var var
PluginsPath,extensionsPath : string; PluginsPath,extensionsPath : string;
begin begin
CreateSetting('Settings/Updater/CheckForUpdates','True'); CreateSetting(ssCheckUpdate, 'True');
CreateSetting('Settings/Updater/CheckEveryXMinutes','30'); CreateSetting(ssCheckUpdateMinutes, '30');
CreateSetting('Settings/Interpreter/Type', '0'); CreateSetting(ssInterpreterType, '0');
CreateSetting('Settings/Fonts/LoadOnStartUp', 'True'); CreateSetting(ssLoadFontsOnStart, 'True');
CreateSetting('Settings/Fonts/Version','-1'); CreateSetting(ssFontsVersion, '-1');
CreateSetting('Settings/Tabs/OpenNextOnClose','False'); CreateSetting(ssTabsOpenNextOnClose, 'False');
CreateSetting('Settings/Tabs/OpenScriptInNewTab','True'); CreateSetting(ssTabsOpenScriptInNewTab, 'True');
CreateSetting('Settings/Tabs/CheckTabsBeforeOpen','True'); CreateSetting(ssTabsCheckBeforeOpen, 'True');
CreateSetting('Settings/ColourPicker/ShowHistoryOnPick', 'True'); CreateSetting(ssColourPickerShowHistoryOnPick, 'True');
CreateSetting('Settings/General/MaxRecentFiles','10'); CreateSetting(ssMaxRecentFiles, '10');
CreateSetting('Settings/MainForm/NormalSize','739:555'); CreateSetting(ssMainFormNormalSize, '739:555');
CreateSetting('Settings/FunctionList/ShowOnStart','True'); CreateSetting(ssFunctionListShowOnStart, 'True');
CreateSetting('Settings/CodeHints/ShowAutomatically','True'); CreateSetting(ssCodeHintsShowAutomatically, 'True');
CreateSetting('Settings/CodeCompletion/ShowAutomatically','True'); CreateSetting(ssCodeCompletionShowAutomatically, 'True');
CreateSetting('Settings/SourceEditor/LazColors','True'); CreateSetting(ssSourceEditorLazColors, 'True');
{$IFDEF USE_EXTENSIONS}CreateSetting('Settings/Extensions/FileExtension','sex');{$ENDIF}
CreateSetting('Settings/Updater/RemoteLink',SimbaURL + 'Simba'{$IFDEF WINDOWS} +'.exe'{$ENDIF}); {$IFDEF USE_EXTENSIONS}
CreateSetting('Settings/Updater/RemoteVersionLink',SimbaURL + 'Version'); CreateSetting(ssExtensionsFileExtension, 'sex');
CreateSetting('Settings/Fonts/VersionLink', FontURL + 'Version'); {$ENDIF}
CreateSetting('Settings/Fonts/UpdateLink', FontURL + 'Fonts.tar.bz2');
CreateSetting('Settings/News/URL', 'http://simba.villavu.com/bin/news'); CreateSetting(ssUpdaterLink, SimbaURL + 'Simba'{$IFDEF WINDOWS} +'.exe'{$ENDIF});
CreateSetting(ssUpdaterVersionLink, SimbaURL + 'Version');
CreateSetting(ssFontsVersionLink, FontURL + 'Version');
CreateSetting(ssFontsLink, FontURL + 'Fonts.tar.bz2');
CreateSetting(ssNewsLink, 'http://simba.villavu.com/bin/news');
{Creates the paths and returns the path} {Creates the paths and returns the path}
PluginsPath := CreateSetting('Settings/Plugins/Path', ExpandFileName(MainDir+ DS+ 'Plugins' + DS)); PluginsPath := CreateSetting(ssPluginsPath, ExpandFileName(MainDir + DS + 'Plugins' + DS));
{$IFDEF USE_EXTENSIONS} {$IFDEF USE_EXTENSIONS}
extensionsPath := CreateSetting('Settings/Extensions/Path',ExpandFileName(MainDir +DS + 'Extensions' + DS)); extensionsPath := CreateSetting(ssExtensionsPath,
CreateSetting('Extensions/ExtensionCount','0'); ExpandFileName(MainDir +DS + 'Extensions' + DS));
CreateSetting(ssExtensionsCount, '0');
{$ENDIF} {$ENDIF}
CreateSetting('LastConfig/MainForm/Position','');
CreateSetting('LastConfig/MainForm/State','Normal'); CreateSetting(ssMainFormPosition, '');
CreateSetting(ssMainFormState, 'Normal');
{$ifdef MSWindows} {$ifdef MSWindows}
CreateSetting('LastConfig/Console/Visible','False'); CreateSetting(ssConsoleVisible, 'False');
ShowConsole(False); ShowConsole(False);
{$endif} {$endif}
CreateSetting('Settings/Tray/AlwaysVisible', 'True');
CreateSetting(ssTrayAlwaysVisible, 'True');
if not DirectoryExists(IncludePath) then if not DirectoryExists(IncludePath) then
CreateDir(IncludePath); CreateDir(IncludePath);
if not DirectoryExists(FontPath) then if not DirectoryExists(FontPath) then
@ -1429,7 +1440,7 @@ var
i,ii : integer; i,ii : integer;
begin begin
self.BeginFormUpdate; self.BeginFormUpdate;
str := LoadSettingDef('LastConfig/MainForm/Position',''); str := LoadSettingDef(ssMainFormPosition, '');
if str <> '' then if str <> '' then
begin; begin;
Data := Explode(':',str); Data := Explode(':',str);
@ -1440,36 +1451,38 @@ begin
Self.Width:= StrToIntDef(Data[2],self.width); Self.Width:= StrToIntDef(Data[2],self.width);
Self.Height:= StrToIntDef(Data[3],self.height); Self.Height:= StrToIntDef(Data[3],self.height);
end; end;
str := lowercase(LoadSettingDef('LastConfig/MainForm/State','Normal')); str := lowercase(LoadSettingDef(ssMainFormState, 'Normal'));
if str = 'maximized' then if str = 'maximized' then
self.windowstate := wsMaximized self.windowstate := wsMaximized
else else
// if str = 'normal' then // if str = 'normal' then
Self.WindowState := wsNormal; Self.WindowState := wsNormal;
if SettingExists('LastConfig/MainForm/RecentFiles/Count') then if SettingExists(ssRecentFilesCount) then
begin; begin;
ii := StrToIntDef(LoadSettingDef('LastConfig/MainForm/RecentFiles/Count','-1'),-1); ii := StrToIntDef(LoadSettingDef(ssRecentFilesCount, '-1'), -1);
for i := 0 to ii do for i := 0 to ii do
begin begin
str := LoadSettingDef('LastConfig/MainForm/RecentFiles/File' + inttostr(I),''); str := LoadSettingDef(ssRecentFileN + inttostr(I),'');
if str <> '' then if str <> '' then
AddRecentFile(str); AddRecentFile(str);
end; end;
end; end;
str := LowerCase(LoadSettingDef('Settings/FunctionList/ShowOnStart','True')); str := LowerCase(LoadSettingDef(ssFunctionListShowOnStart, 'True'));
str2 := lowercase(LoadSettingDef('LastConfig/MainForm/FunctionListShown','')); str2 := lowercase(LoadSettingDef(ssFunctionListShown, ''));
if (str = 'true') or (str2 = 'true') then if (str = 'true') or (str2 = 'true') then
FunctionListShown(True) FunctionListShown(True)
else else
FunctionListShown(false); FunctionListShown(false);
{$ifdef MSWindows} {$ifdef MSWindows}
str := LowerCase(LoadSettingDef('LastConfig/Console/Visible','True')); str := LowerCase(LoadSettingDef(ssConsoleVisible, 'True'));
if str = 'true' then if str = 'true' then
ShowConsole(True) ShowConsole(True)
else else
ShowConsole(false); ShowConsole(false);
{$endif} {$endif}
if Lowercase(LoadSettingDef('Settings/Tray/AlwaysVisible', 'True')) <> 'true' then
if Lowercase(LoadSettingDef(ssTrayAlwaysVisible, 'True')) <> 'true' then
begin begin
MTrayIcon.Hide; MTrayIcon.Hide;
writeln('Hiding tray.'); writeln('Hiding tray.');
@ -1488,36 +1501,36 @@ begin
with SettingsForm.Settings do with SettingsForm.Settings do
begin begin
if Self.WindowState = wsMaximized then if Self.WindowState = wsMaximized then
SetSetting('LastConfig/MainForm/State','maximized') SetSetting(ssMainFormState, 'maximized')
else else
begin; //Only save the form position if its not maximized. begin; //Only save the form position if its not maximized.
SetSetting('LastConfig/MainForm/State','normal'); SetSetting(ssMainFormState, 'normal');
Data := ConvArr([inttostr(Self.left),inttostr(self.top),inttostr(self.width),inttostr(self.height)]); Data := ConvArr([inttostr(Self.left),inttostr(self.top),inttostr(self.width),inttostr(self.height)]);
SetSetting('LastConfig/MainForm/Position', Implode(':',Data )); SetSetting(ssMainFormPosition, Implode(':',Data ));
end; end;
DeleteKey('LastConfig/MainForm/RecentFiles'); DeleteKey(ssRecentFiles);
if RecentFiles.Count > 0 then if RecentFiles.Count > 0 then
begin begin
SetSetting('LastConfig/MainForm/RecentFiles/Count',inttostr(RecentFiles.Count)); SetSetting(ssRecentFiles + '/Count', inttostr(RecentFiles.Count));
SetLength(data,RecentFiles.Count); SetLength(data,RecentFiles.Count);
for i := 0 to RecentFiles.Count - 1 do for i := 0 to RecentFiles.Count - 1 do
SetSetting('LastConfig/MainForm/RecentFiles/File'+inttostr(i),RecentFiles[i]); SetSetting(ssRecentFileN + inttostr(i),RecentFiles[i]);
end; end;
if MenuItemFunctionList.Checked then if MenuItemFunctionList.Checked then
SetSetting('LastConfig/MainForm/FunctionListShown','True') SetSetting(ssFunctionListShown, 'True')
else else
SetSetting('LastConfig/MainForm/FunctionListShown','False'); SetSetting(ssFunctionListShown, 'False');
{$ifdef MSWindows} {$ifdef MSWindows}
if ConsoleVisible then if ConsoleVisible then
SetSetting('LastConfig/Console/Visible','True') SetSetting(ssConsoleVisible, 'True')
else else
SetSetting('LastConfig/Console/Visible','False'); SetSetting(ssConsoleVisible, 'False');
{$endif} {$endif}
{$IFDEF USE_EXTENSIONS} {$IFDEF USE_EXTENSIONS}
SetSetting('Extensions/ExtensionCount',inttostr(ExtManager.Extensions.Count)); SetSetting(ssExtensionsCount, inttostr(ExtManager.Extensions.Count));
for i := 0 to ExtManager.Extensions.Count-1 do for i := 0 to ExtManager.Extensions.Count-1 do
begin; begin;
path :='Extensions/Extension' + inttostr(I); path := ssExtensionsExtensionN + inttostr(I);
SetSetting(Path + '/Path',TVirtualSimbaExtension(ExtManager.Extensions[i]).Filename); SetSetting(Path + '/Path',TVirtualSimbaExtension(ExtManager.Extensions[i]).Filename);
SetSetting(Path + '/Enabled',BoolToStr(TVirtualSimbaExtension(ExtManager.Extensions[i]).Enabled,True)); SetSetting(Path + '/Enabled',BoolToStr(TVirtualSimbaExtension(ExtManager.Extensions[i]).Enabled,True));
end; end;
@ -1539,7 +1552,7 @@ var
result := false; result := false;
if (number < 0) or (number >= extCount) then if (number < 0) or (number >= extCount) then
exit; exit;
path := 'Extensions/Extension' + inttostr(number); path := ssExtensionsExtensionN + inttostr(number);
if SettingExists(Path) = false then if SettingExists(Path) = false then
exit; exit;
ExtPath := LoadSettingDef(Path + '/Path',''); ExtPath := LoadSettingDef(Path + '/Path','');
@ -1555,11 +1568,11 @@ var
i : integer; i : integer;
path : string; path : string;
begin; begin;
path := 'Extensions/Extension'; path := ssExtensionsExtensionN;
SettingsForm.Settings.DeleteKey(path + inttostr(number)); SettingsForm.Settings.DeleteKey(path + inttostr(number));
for i := number + 1 to extCount - 1 do for i := number + 1 to extCount - 1 do
SettingsForm.Settings.RenameKey(path + inttostr(i),'Extension' + inttostr(i-1)); SettingsForm.Settings.RenameKey(path + inttostr(i),'Extension' + inttostr(i-1));
SetSetting('Extensions/ExtensionCount',inttostr(extCount - 1),true); SetSetting(ssExtensionsCount, inttostr(extCount - 1),true);
dec(extCount); dec(extCount);
end; end;
@ -1567,13 +1580,13 @@ var
str,str2 : string; str,str2 : string;
i : integer; i : integer;
begin begin
extCount := StrToIntDef(LoadSettingDef('Extensions/ExtensionCount/','0'),0); extCount := StrToIntDef(LoadSettingDef(ssExtensionsCount, '0'),0);
for i := 0 to extCount - 1 do for i := 0 to extCount - 1 do
while (i < extCount) and not LoadExtension(i) do while (i < extCount) and not LoadExtension(i) do
DeleteExtension(i); DeleteExtension(i);
SetSetting('Extensions/ExtensionCount',inttostr(extCount)); SetSetting(ssExtensionsCount, inttostr(extCount));
str := LoadSettingDef('Settings/Extensions/Path',ExpandFileName(MainDir +DS + 'Extensions' + DS)); str := LoadSettingDef(ssExtensionsPath, ExpandFileName(MainDir +DS + 'Extensions' + DS));
str2 := LoadSettingDef('Settings/Extensions/FileExtension','sex'); str2 := LoadSettingDef(ssExtensionsFileExtension, 'sex');
ExtManager.LoadPSExtensionsDir(str,str2); ExtManager.LoadPSExtensionsDir(str,str2);
{$ELSE} {$ELSE}
begin begin
@ -1585,7 +1598,7 @@ var
MaxRecentFiles : integer; MaxRecentFiles : integer;
Len,i : integer; Len,i : integer;
begin begin
MaxRecentFiles:= StrToIntDef(LoadSettingDef('Settings/General/MaxRecentFiles','10'),10); MaxRecentFiles:= StrToIntDef(LoadSettingDef(ssMaxRecentFiles, '10'), 10);
i := RecentFiles.IndexOf(filename); i := RecentFiles.IndexOf(filename);
if i <> -1 then if i <> -1 then
RecentFiles.Delete(i); RecentFiles.Delete(i);
@ -1674,7 +1687,7 @@ begin
if selector.haspicked then if selector.haspicked then
Thread.Client.IOManager.SetTarget(Selector.LastPick); Thread.Client.IOManager.SetTarget(Selector.LastPick);
loadFontsOnScriptStart := (lowercase(LoadSettingDef('Settings/Fonts/LoadOnStartUp', 'True')) = 'true'); loadFontsOnScriptStart := (lowercase(LoadSettingDef(ssLoadFontsOnStart, 'True')) = 'true');
if (loadFontsOnScriptStart) then if (loadFontsOnScriptStart) then
begin begin
@ -1930,12 +1943,12 @@ var
SizeStr : string; SizeStr : string;
Data : TStringArray; Data : TStringArray;
begin begin
SizeStr := LoadSettingDef('Settings/MainForm/NormalSize','739:555'); SizeStr := LoadSettingDef(ssMainFormNormalSize, '739:555');
Data := Explode(':',SizeStr); Data := Explode(':',SizeStr);
if length(Data) = 2 then if length(Data) = 2 then
begin begin
Self.Width:= StrToIntDef(Data[0],739); Self.Width:= StrToIntDef(Data[0], 739);
Self.Height:= StrToIntDef(Data[1],555); Self.Height:= StrToIntDef(Data[1], 555);
end else end else
begin; begin;
self.width := 739; self.width := 739;
@ -2812,7 +2825,7 @@ end;
procedure TSimbaForm.MTrayIconClick(Sender: TObject); procedure TSimbaForm.MTrayIconClick(Sender: TObject);
begin begin
self.Show; self.Show;
if Lowercase(LoadSettingDef('Settings/Tray/AlwaysVisible', 'True')) <> 'true' then if Lowercase(LoadSettingDef(ssTrayAlwaysVisible, 'True')) <> 'true' then
MTrayIcon.Hide; MTrayIcon.Hide;
if Self.CanFocus then if Self.CanFocus then
self.SetFocus; self.SetFocus;
@ -2822,7 +2835,7 @@ function TSimbaForm.GetSimbaNews: String;
var var
t: TDownloadThread; t: TDownloadThread;
begin begin
t := TDownloadThread.Create(LoadSettingDef('Settings/News/URL', 'http://Simba.villavu.com/bin/news'), t := TDownloadThread.Create(LoadSettingDef(ssNewsLink, 'http://Simba.villavu.com/bin/news'),
@Result); @Result);
t.Resume; t.Resume;
while not t.done do while not t.done do
@ -2834,13 +2847,13 @@ end;
procedure TSimbaForm.SetDefScriptPath(const AValue: string); procedure TSimbaForm.SetDefScriptPath(const AValue: string);
begin begin
SetSetting('Settings/SourceEditor/DefScriptPath',AValue,True); SetSetting(ssSourceEditorDefScriptPath, AValue,True);
end; end;
{$IFDEF USE_EXTENSIONS} {$IFDEF USE_EXTENSIONS}
procedure TSimbaForm.SetExtPath(const AValue: string); procedure TSimbaForm.SetExtPath(const AValue: string);
begin begin
SetSetting('Settings/Extensions/Path',AValue,true); SetSetting(ssExtensionsPath, AValue,true);
end; end;
{$ENDIF} {$ENDIF}
@ -2881,10 +2894,10 @@ begin
cobj := TColourPickerObject.Create(c, Classes.Point(x,y), ''); cobj := TColourPickerObject.Create(c, Classes.Point(x,y), '');
{ TODO: This should be no problem if the form is hidden? } { TODO: This should be no problem if the form is hidden? }
if lowercase(LoadSettingDef('Settings/ColourPicker/AddToHistoryOnPick', 'True')) = 'true' then if lowercase(LoadSettingDef(ssColourPickerAddToHistoryOnPick, 'True')) = 'true' then
ColourHistoryForm.AddColObj(cobj, true); ColourHistoryForm.AddColObj(cobj, true);
if lowercase(LoadSettingDef('Settings/ColourPicker/ShowHistoryOnPick', 'True')) = 'true' then if lowercase(LoadSettingDef(ssColourPickerShowHistoryOnPick, 'True')) = 'true' then
ColourHistoryForm.Show; ColourHistoryForm.Show;
FormWritelnEx('Picked colour: ' + inttostr(c) + ' at (' + inttostr(x) + ', ' + inttostr(y) + ')'); FormWritelnEx('Picked colour: ' + inttostr(c) + ' at (' + inttostr(x) + ', ' + inttostr(y) + ')');
@ -3004,34 +3017,34 @@ end;
function TSimbaForm.GetShowParamHintAuto: boolean; function TSimbaForm.GetShowParamHintAuto: boolean;
begin begin
Result := LowerCase(LoadSettingDef('Settings/CodeHints/ShowAutomatically','True')) = 'true'; Result := LowerCase(LoadSettingDef(ssCodeHintsShowAutomatically, 'True')) = 'true';
end; end;
function TSimbaForm.GetShowCodeCompletionAuto: boolean; function TSimbaForm.GetShowCodeCompletionAuto: boolean;
begin begin
Result := LowerCase(LoadSettingDef('Settings/CodeCompletion/ShowAutomatically','True')) = 'true'; Result := LowerCase(LoadSettingDef(ssCodeCompletionShowAutomatically, 'True')) = 'true';
end; end;
procedure TSimbaForm.SetFontPath(const AValue: String); procedure TSimbaForm.SetFontPath(const AValue: String);
begin begin
SetSetting('Settings/Fonts/Path',AValue,true); SetSetting(ssFontsPath, AValue,true);
end; end;
function TSimbaForm.GetFontPath: String; function TSimbaForm.GetFontPath: String;
begin begin
Result := IncludeTrailingPathDelimiter(LoadSettingDef('Settings/Fonts/Path', ExpandFileName(MainDir+DS+'Fonts' + DS))); Result := IncludeTrailingPathDelimiter(LoadSettingDef(ssFontsPath, ExpandFileName(MainDir+DS+'Fonts' + DS)));
end; end;
{$IFDEF USE_EXTENSIONS} {$IFDEF USE_EXTENSIONS}
function TSimbaForm.GetExtPath: string; function TSimbaForm.GetExtPath: string;
begin begin
Result := IncludeTrailingPathDelimiter(LoadSettingDef('Settings/Extensions/Path', ExpandFileName(MainDir+DS+'Extensions' + DS))); Result := IncludeTrailingPathDelimiter(LoadSettingDef(ssExtensionsPath, ExpandFileName(MainDir+DS+'Extensions' + DS)));
end; end;
{$ENDIF} {$ENDIF}
function TSimbaForm.GetHighlighter: TSynCustomHighlighter; function TSimbaForm.GetHighlighter: TSynCustomHighlighter;
begin begin
if lowercase(LoadSettingDef('Settings/SourceEditor/LazColors','True')) = 'true' then if lowercase(LoadSettingDef(ssSourceEditorLazColors, 'True')) = 'true' then
result := LazHighlighter result := LazHighlighter
else else
result := SCARHighlighter; result := SCARHighlighter;
@ -3039,17 +3052,17 @@ end;
function TSimbaForm.GetIncludePath: String; function TSimbaForm.GetIncludePath: String;
begin begin
Result := IncludeTrailingPathDelimiter(LoadSettingDef('Settings/Includes/Path', ExpandFileName(MainDir+DS+'Includes' + DS))); Result := IncludeTrailingPathDelimiter(LoadSettingDef(ssIncludesPath, ExpandFileName(MainDir+DS+'Includes' + DS)));
end; end;
function TSimbaForm.GetPluginPath: string; function TSimbaForm.GetPluginPath: string;
begin begin
Result := IncludeTrailingPathDelimiter(LoadSettingDef('Settings/Plugins/Path', ExpandFileName(MainDir+DS+'Plugins' + DS))); Result := IncludeTrailingPathDelimiter(LoadSettingDef(ssPluginsPath, ExpandFileName(MainDir+DS+'Plugins' + DS)));
end; end;
procedure TSimbaForm.SetIncludePath(const AValue: String); procedure TSimbaForm.SetIncludePath(const AValue: String);
begin begin
SetSetting('Settings/Includes/Path',AValue,true); SetSetting(ssIncludesPath, AValue,true);
end; end;
procedure TSimbaForm.SetInterpreter(const AValue: Integer); procedure TSimbaForm.SetInterpreter(const AValue: Integer);
@ -3061,7 +3074,7 @@ begin
with CurrScript.Synedit do with CurrScript.Synedit do
if (Lines.text = DefaultScript) and not(CanUndo or CanRedo) then if (Lines.text = DefaultScript) and not(CanUndo or CanRedo) then
UpdateCurrScript := true; UpdateCurrScript := true;
SetSetting('Settings/Interpreter/Type',Inttostr(AValue),true); SetSetting(ssInterpreterType, Inttostr(AValue),true);
UpdateInterpreter; UpdateInterpreter;
if UpdateCurrScript then if UpdateCurrScript then
CurrScript.SynEdit.Lines.text := DefaultScript; CurrScript.SynEdit.Lines.text := DefaultScript;
@ -3069,12 +3082,12 @@ end;
procedure TSimbaForm.SetPluginPath(const AValue: string); procedure TSimbaForm.SetPluginPath(const AValue: string);
begin begin
SetSetting('Settings/Plugins/Path',AValue,true); SetSetting(ssPluginsPath, AValue,true);
end; end;
procedure TSimbaForm.SetScriptPath(const AValue: string); procedure TSimbaForm.SetScriptPath(const AValue: string);
begin begin
SetSetting('Settings/Scripts/Path',AValue,True); SetSetting(ssScriptsPath, AValue,True);
end; end;
procedure TSimbaForm.SetScriptState(const State: TScriptState); procedure TSimbaForm.SetScriptState(const State: TScriptState);
@ -3147,12 +3160,12 @@ begin
if UpdatingFonts then if UpdatingFonts then
exit; exit;
UpdatingFonts := True; UpdatingFonts := True;
CurrVersion := StrToIntDef(LoadSettingDef('Settings/Fonts/Version','-1'),-1); CurrVersion := StrToIntDef(LoadSettingDef(ssFontsVersion, '-1'), -1);
LatestVersion := SimbaUpdateForm.GetLatestFontVersion; LatestVersion := SimbaUpdateForm.GetLatestFontVersion;
if LatestVersion > CurrVersion then if LatestVersion > CurrVersion then
begin; begin;
formWriteln(format('New fonts available. Current version: %d. Latest version: %d',[CurrVersion,LatestVersion])); formWriteln(format('New fonts available. Current version: %d. Latest version: %d',[CurrVersion,LatestVersion]));
FontDownload := TDownloadThread.Create(LoadSettingDef('Settings/Fonts/UpdateLink',FontURL + 'Fonts.tar.bz2'), FontDownload := TDownloadThread.Create(LoadSettingDef(ssFontsLink, FontURL + 'Fonts.tar.bz2'),
@Fonts); @Fonts);
FontDownload.resume; FontDownload.resume;
while FontDownload.Done = false do while FontDownload.Done = false do
@ -3173,7 +3186,7 @@ begin
if UnTarrer.Result then if UnTarrer.Result then
begin; begin;
FormWriteln('Successfully installed the new fonts!'); FormWriteln('Successfully installed the new fonts!');
SetSetting('Settings/Fonts/Version',IntToStr(LatestVersion),true); SetSetting(ssFontsVersion, IntToStr(LatestVersion),true);
if Assigned(self.OCR_Fonts) then if Assigned(self.OCR_Fonts) then
self.OCR_Fonts.Free; self.OCR_Fonts.Free;
FormWriteln('Freeing the current fonts. Creating new ones now'); FormWriteln('Freeing the current fonts. Creating new ones now');
@ -3202,12 +3215,12 @@ end;
procedure TSimbaForm.SetShowParamHintAuto(const AValue: boolean); procedure TSimbaForm.SetShowParamHintAuto(const AValue: boolean);
begin begin
SetSetting('Settings/CodeHints/ShowAutomatically', Booltostr(AValue,true)); SetSetting(ssCodeHintsShowAutomatically, Booltostr(AValue,true));
end; end;
procedure TSimbaForm.SetShowCodeCompletionAuto(const AValue: boolean); procedure TSimbaForm.SetShowCodeCompletionAuto(const AValue: boolean);
begin begin
SetSetting('Settings/CodeCompletion/ShowAutomatically', Booltostr(AValue,true)); SetSetting(ssCodeCompletionShowAutomatically, Booltostr(AValue,true));
end; end;
{$ifdef mswindows} {$ifdef mswindows}
@ -3335,7 +3348,7 @@ var
OpenInNewTab : boolean; OpenInNewTab : boolean;
begin begin
Result := False; Result := False;
OpenInNewTab:= (LowerCase(LoadSettingDef('Settings/Tabs/OpenScriptInNewTab','True')) = 'true'); OpenInNewTab:= (LowerCase(LoadSettingDef(ssTabsOpenScriptInNewTab, 'True')) = 'true');
if not OpenInNewTab then if not OpenInNewTab then
if CanExitOrOpen = false then if CanExitOrOpen = false then
Exit; Exit;
@ -3347,7 +3360,7 @@ begin
InitialDir := ScriptDir; InitialDir := ScriptDir;
Options := [ofAllowMultiSelect, ofExtensionDifferent, ofPathMustExist, ofFileMustExist, ofEnableSizing, ofViewDetail]; Options := [ofAllowMultiSelect, ofExtensionDifferent, ofPathMustExist, ofFileMustExist, ofEnableSizing, ofViewDetail];
Filter:= 'Simba Files|*.simba;*.simb;*.cogat;*.mufa;*.txt' + Filter:= 'Simba Files|*.simba;*.simb;*.cogat;*.mufa;*.txt' +
{$IFDEF USE_EXTENSIONS}';*.' + LoadSettingDef('Settings/Extensions/FileExtension', 'sex') + {$ENDIF} {$IFDEF USE_EXTENSIONS}';*.' + LoadSettingDef(ssExtensionsFileExtension, 'sex') + {$ENDIF}
'|Any files|*.*'; '|Any files|*.*';
if Execute then if Execute then
begin begin
@ -3376,11 +3389,11 @@ begin
if AlwaysOpenInNewTab then if AlwaysOpenInNewTab then
OpenInNewTab := true OpenInNewTab := true
else else
OpenInNewTab:= (LowerCase(LoadSettingDef('Settings/Tabs/OpenScriptInNewTab','True')) = 'true'); OpenInNewTab:= (LowerCase(LoadSettingDef(ssTabsOpenScriptInNewTab,'True')) = 'true');
if CheckOtherTabs then if CheckOtherTabs then
CheckTabsFirst := True CheckTabsFirst := True
else else
CheckTabsFirst := (Lowercase(LoadSettingDef('Settings/Tabs/CheckTabsBeforeOpen','True')) = 'true'); CheckTabsFirst := (Lowercase(LoadSettingDef(ssTabsCheckBeforeOpen, 'True')) = 'true');
if FileExistsUTF8(FileName) then if FileExistsUTF8(FileName) then
begin; begin;
if CheckTabsFirst then if CheckTabsFirst then
@ -3455,7 +3468,7 @@ begin
else else
InitialDir := ScriptDir; InitialDir := ScriptDir;
filter := 'Simba Files|*.simba;*.simb;*.cogat;*.mufa;*.txt' + filter := 'Simba Files|*.simba;*.simb;*.cogat;*.mufa;*.txt' +
{$IFDEF USE_EXTENSIONS}';*.' + LoadSettingDef('Settings/Extensions/FileExtension','sex') + {$ENDIF} {$IFDEF USE_EXTENSIONS}';*.' + LoadSettingDef(ssExtensionsFileExtension, 'sex') + {$ENDIF}
'|Any files|*.*'; '|Any files|*.*';
if Execute then if Execute then
begin; begin;