Skip to content

Commit

Permalink
New release
Browse files Browse the repository at this point in the history
New release
  • Loading branch information
vladk1973 committed Nov 15, 2022
1 parent ce8fc5c commit edaf5cb
Show file tree
Hide file tree
Showing 3 changed files with 557 additions and 44 deletions.
162 changes: 160 additions & 2 deletions lib/NppForms.pas
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,41 @@ interface

uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants,
System.Classes, Vcl.Forms,
Vcl.Dialogs, NppPlugin;
System.Classes, Vcl.Forms, Vcl.ExtCtrls, Vcl.Controls, System.UITypes,
Vcl.Dialogs, Graphics, NppPlugin;

type
TNppForm = class(TForm)
private
FColorEdge: TColor;
FColorSofterBackground: TColor;
FColorText: TColor;
FColorDefaultForeground: TColor;
FColorDefaultBackground: TColor;
FColorLinkText: TColor;
FColorErrorBackground: TColor;
FColorPureBackground: TColor;
FColorDarkerText: TColor;
FColorBackground: TColor;
FColorHotBackground: TColor;
FColorDisabledText: TColor;
procedure SetColorBackground(const Value: TColor);
procedure SetColorDarkerText(const Value: TColor);
procedure SetColorDefaultBackground(const Value: TColor);
procedure SetColorDefaultForeground(const Value: TColor);
procedure SetColorDisabledText(const Value: TColor);
procedure SetColorEdge(const Value: TColor);
procedure SetColorErrorBackground(const Value: TColor);
procedure SetColorHotBackground(const Value: TColor);
procedure SetColorLinkText(const Value: TColor);
procedure SetColorPureBackground(const Value: TColor);
procedure SetColorSofterBackground(const Value: TColor);
procedure SetColorText(const Value: TColor);
{ Private declarations }
protected
procedure DoClose(var Action: TCloseAction); override;
function DarkMode: boolean;
procedure ChangeColorMode(Sender: TObject); virtual;
public
{ Public declarations }
Npp: TNppPlugin;
Expand All @@ -43,7 +69,21 @@ TNppForm = class(TForm)
procedure MessageWarning(const ATitle, ACaption: nppString);
procedure MessageError(const ATitle,ACaption: nppString);
procedure MessageSimple(const ATitle,ACaption: nppString);
procedure OnAfterChangeDarkMode(Sender: TObject);
destructor Destroy; override;

property ColorDefaultBackground: TColor read FColorDefaultBackground write SetColorDefaultBackground;
property ColorDefaultForeground: TColor read FColorDefaultForeground write SetColorDefaultForeground;
property ColorBackground : TColor read FColorBackground write SetColorBackground;
property ColorSofterBackground : TColor read FColorSofterBackground write SetColorSofterBackground;
property ColorHotBackground : TColor read FColorHotBackground write SetColorHotBackground;
property ColorPureBackground : TColor read FColorPureBackground write SetColorPureBackground;
property ColorErrorBackground : TColor read FColorErrorBackground write SetColorErrorBackground;
property ColorText : TColor read FColorText write SetColorText;
property ColorDarkerText : TColor read FColorDarkerText write SetColorDarkerText;
property ColorDisabledText : TColor read FColorDisabledText write SetColorDisabledText;
property ColorLinkText : TColor read FColorLinkText write SetColorLinkText;
property ColorEdge : TColor read FColorEdge write SetColorEdge;
end;

var
Expand All @@ -63,6 +103,12 @@ constructor TNppForm.Create(NppParent: TNppPlugin);
// We figure right now this does more damage than good.
// So let the main transalte and dispatch do it's thing instead of isdialogmessage
Npp.RegisterAsDialog(Handle);
OnAfterChangeDarkMode(Self);
end;

procedure TNppForm.ChangeColorMode(Sender: TObject);
begin
{Íè÷åãî íå äåëàåì}
end;

function TNppForm.Confirmed(const ACaption, ATitle: nppString): boolean;
Expand All @@ -79,6 +125,12 @@ constructor TNppForm.Create(AOwner: TNppForm);
DefaultCloseAction := caNone;
inherited Create(AOwner);
Npp.RegisterAsDialog(Handle);
OnAfterChangeDarkMode(Self);
end;

function TNppForm.DarkMode: boolean;
begin
Result := Boolean(Npp.Npp_Send(NPPM_ISDARKMODEENABLED,0,0));
end;

destructor TNppForm.Destroy;
Expand Down Expand Up @@ -112,4 +164,110 @@ procedure TNppForm.MessageWarning(const ATitle, ACaption: nppString);
Application.MessageBox(nppPChar(ATitle),nppPChar(ACaption),MB_ICONWARNING + MB_OK);
end;

procedure TNppForm.OnAfterChangeDarkMode(Sender: TObject);
var
C: TNppDarkModeColors;
C_old: TNppDarkModeColors_ver8;
Size: Integer;
R: boolean;
begin
ColorDefaultForeground := TColor(Npp.Npp_Send(NPPM_GETEDITORDEFAULTFOREGROUNDCOLOR,0,0));
ColorDefaultBackground := TColor(Npp.Npp_Send(NPPM_GETEDITORDEFAULTBACKGROUNDCOLOR,0,0));

Size := SizeOf(TNppDarkModeColors_ver8);
R := Boolean(Npp.Npp_Send(NPPM_GETDARKMODECOLORS,Size, LPARAM(@C_old)));
if R then
begin
ColorBackground := TColor(C_old.background);
ColorSofterBackground := TColor(C_old.softerBackground);
ColorHotBackground := TColor(C_old.hotBackground);
ColorPureBackground := TColor(C_old.pureBackground);
ColorErrorBackground := TColor(C_old.errorBackground);
ColorText := TColor(C_old.text);
ColorDarkerText := TColor(C_old.darkerText);
ColorDisabledText := TColor(C_old.disabledText);
ColorLinkText := TColor(C_old.linkText);
ColorEdge := TColor(C_old.edge);
end
else
begin
Size := SizeOf(TNppDarkModeColors);
R := Boolean(Npp.Npp_Send(NPPM_GETDARKMODECOLORS,Size, LPARAM(@C)));
if R then
begin
ColorBackground := TColor(C.background);
ColorSofterBackground := TColor(C.softerBackground);
ColorHotBackground := TColor(C.hotBackground);
ColorPureBackground := TColor(C.pureBackground);
ColorErrorBackground := TColor(C.errorBackground);
ColorText := TColor(C.text);
ColorDarkerText := TColor(C.darkerText);
ColorDisabledText := TColor(C.disabledText);
ColorLinkText := TColor(C.linkText);
ColorEdge := TColor(C.edge);
end;
end;
ChangeColorMode(Sender);
end;

procedure TNppForm.SetColorBackground(const Value: TColor);
begin
FColorBackground := Value;
end;

procedure TNppForm.SetColorDarkerText(const Value: TColor);
begin
FColorDarkerText := Value;
end;

procedure TNppForm.SetColorDefaultBackground(const Value: TColor);
begin
FColorDefaultBackground := Value;
end;

procedure TNppForm.SetColorDefaultForeground(const Value: TColor);
begin
FColorDefaultForeground := Value;
end;

procedure TNppForm.SetColorDisabledText(const Value: TColor);
begin
FColorDisabledText := Value;
end;

procedure TNppForm.SetColorEdge(const Value: TColor);
begin
FColorEdge := Value;
end;

procedure TNppForm.SetColorErrorBackground(const Value: TColor);
begin
FColorErrorBackground := Value;
end;

procedure TNppForm.SetColorHotBackground(const Value: TColor);
begin
FColorHotBackground := Value;
end;

procedure TNppForm.SetColorLinkText(const Value: TColor);
begin
FColorLinkText := Value;
end;

procedure TNppForm.SetColorPureBackground(const Value: TColor);
begin
FColorPureBackground := Value;
end;

procedure TNppForm.SetColorSofterBackground(const Value: TColor);
begin
FColorSofterBackground := Value;
end;

procedure TNppForm.SetColorText(const Value: TColor);
begin
FColorText := Value;
end;

end.
8 changes: 6 additions & 2 deletions lib/SciSupport.pas
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ TSCNotification = record
end;

TCharacterRange = Record
cpMin : Integer;
cpMax : Integer;
cpMin : NativeInt;
cpMax : NativeInt;
end;
PTextRange = ^TTextRange;
TTextRange = Record
Expand All @@ -61,6 +61,9 @@ TSCNotification = record
const
//++Const -- start of section automatically generated from Scintilla.iface
INVALID_POSITION = -1;

SCI_GETTECHNOLOGY = 2631;

SCI_START = 2000;
SCI_OPTIONAL_START = 3000;
SCI_LEXER_START = 4000;
Expand Down Expand Up @@ -329,6 +332,7 @@ TSCNotification = record
SCI_SETSEL = 2160;
SCI_GETSELTEXT = 2161;
SCI_GETTEXTRANGE = 2162;
SCI_GETTEXTRANGEFULL = 2039;
SCI_HIDESELECTION = 2163;
SCI_POINTXFROMPOSITION = 2164;
SCI_POINTYFROMPOSITION = 2165;
Expand Down
Loading

0 comments on commit edaf5cb

Please sign in to comment.