Skip to content

Commit

Permalink
The style definition file (keynote.kns) is now updated after each mod…
Browse files Browse the repository at this point in the history
…ification, and not just on exit the application

Among other things, this allows you to assign a keyboard shortcut to a newly created style without having to reopen the application.

Ref: #697
  • Loading branch information
dpradov committed May 9, 2024
1 parent 7fe9944 commit 0dfb8a6
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 5 deletions.
16 changes: 16 additions & 0 deletions editor/kn_StyleMng.pas
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ interface
procedure StyleDescribe( const FromEditor, LongDesc : boolean );
procedure StyleRedefine;

procedure CheckSaveStyleManagerInfo;

var
StylesModified : boolean; // styles are only saved if this flag is TRUE
LastStyleRange : TStyleRange; // obsolete
Expand Down Expand Up @@ -192,6 +194,8 @@ procedure StyleCreate( aRange : TStyleRange; ExistingStyle : TStyle );
Form_Main.Combo_Style.ItemIndex := idx;
Form_Main.StatusBar.Panels[PANEL_HINT].Text := Format( STR_10, [Name,STYLE_RANGES[aRange]] );

CheckSaveStyleManagerInfo;

except
on E : Exception do begin
messagedlg( STR_11 + E.Message, mtError, [mbOK], 0 );
Expand Down Expand Up @@ -331,6 +335,8 @@ procedure StyleRename( aName : string );

Form_Main.Combo_Style.ItemIndex := Form_Main.Combo_Style.Items.IndexOf( name );

CheckSaveStyleManagerInfo;

except
showmessage( STR_16 );
end;
Expand Down Expand Up @@ -360,6 +366,8 @@ procedure StyleDelete( aName : string );
if ( Form_Main.Combo_Style.Items.Count > 0 ) then
Form_Main.Combo_Style.ItemIndex := 0;

CheckSaveStyleManagerInfo;

except
showmessage( STR_18 );
end;
Expand Down Expand Up @@ -396,6 +404,14 @@ procedure StyleRedefine;
StyleCreate( LastStyleRange, TStyle( StyleManager.Objects[Form_Main.Combo_Style.ItemIndex] ));
end;

procedure CheckSaveStyleManagerInfo;
begin
if StylesModified and (not App.opt_NoSaveOpt) then begin
if SaveStyleManagerInfo( Style_FN ) then
StylesModified := false;
end;
end;

initialization
StylesModified := false;

Expand Down
6 changes: 1 addition & 5 deletions kn_Main.pas
Original file line number Diff line number Diff line change
Expand Up @@ -2053,11 +2053,7 @@ procedure TForm_Main.FormCloseQuery(Sender: TObject;
if ( not App.opt_NoSaveOpt ) then
begin
SaveFileManagerInfo( MGR_FN );
if StylesModified then
begin
SaveStyleManagerInfo( Style_FN );
StylesModified := false;
end;
CheckSaveStyleManagerInfo;
SaveFavorites( FAV_FN );
if App.opt_NoRegistry then
IniSaveToolbarPositions( Self, changefileext( INI_FN, ext_MRU ), 'TB97a' )
Expand Down

0 comments on commit 0dfb8a6

Please sign in to comment.