IDE: SourceEditor, show selection mode indicator. Issue #40599

This commit is contained in:
Martin 2024-09-29 21:12:41 +02:00
parent 904136f96f
commit fcc0fe6d11
4 changed files with 40 additions and 7 deletions

View File

@ -608,6 +608,7 @@ type
FPendingFoldState: String; FPendingFoldState: String;
procedure DoTopViewChanged(Sender: TObject); procedure DoTopViewChanged(Sender: TObject);
function GetIsStickySelecting: Boolean;
procedure SetScrollOnEditLeftOptions(AValue: TSynScrollOnEditOptions); procedure SetScrollOnEditLeftOptions(AValue: TSynScrollOnEditOptions);
procedure SetScrollOnEditRightOptions(AValue: TSynScrollOnEditOptions); procedure SetScrollOnEditRightOptions(AValue: TSynScrollOnEditOptions);
procedure SetTabViewClass(AValue: TSynEditStringTabExpanderClass); procedure SetTabViewClass(AValue: TSynEditStringTabExpanderClass);
@ -1169,6 +1170,7 @@ type
// Selection // Selection
property DefaultSelectionMode: TSynSelectionMode read GetDefSelectionMode write SetDefSelectionMode default smNormal; property DefaultSelectionMode: TSynSelectionMode read GetDefSelectionMode write SetDefSelectionMode default smNormal;
property SelectionMode: TSynSelectionMode read GetSelectionMode write SetSelectionMode default smNormal; property SelectionMode: TSynSelectionMode read GetSelectionMode write SetSelectionMode default smNormal;
property IsStickySelecting: Boolean read GetIsStickySelecting;
// Cursor // Cursor
procedure UpdateCursorOverride; override; procedure UpdateCursorOverride; override;
@ -2173,6 +2175,11 @@ begin
FTextArea.TheLinesView := FTheLinesView; FTextArea.TheLinesView := FTheLinesView;
end; end;
function TCustomSynEdit.GetIsStickySelecting: Boolean;
begin
Result := FBlockSelection.StickyAutoExtend;
end;
procedure TCustomSynEdit.SetScrollOnEditLeftOptions( procedure TCustomSynEdit.SetScrollOnEditLeftOptions(
AValue: TSynScrollOnEditOptions); AValue: TSynScrollOnEditOptions);
begin begin

View File

@ -2917,6 +2917,9 @@ resourcestring
uepReadonly= 'Readonly'; uepReadonly= 'Readonly';
uepIns='INS'; uepIns='INS';
uepOvr='OVR'; uepOvr='OVR';
uepSelNorm='Def';
uepSelLine='Line';
uepSelCol ='Col';
lisUEFontWith = 'Font without UTF-8'; lisUEFontWith = 'Font without UTF-8';
lisUETheCurre = 'The current editor font does not support UTF-8 but your system seems to use it.' lisUETheCurre = 'The current editor font does not support UTF-8 but your system seems to use it.'
+'%sThat means non ASCII characters will probably be shown incorrectly.' +'%sThat means non ASCII characters will probably be shown incorrectly.'

View File

@ -7,9 +7,9 @@ object SourceNotebook: TSourceNotebook
Caption = 'SourceNotebook' Caption = 'SourceNotebook'
ClientHeight = 300 ClientHeight = 300
ClientWidth = 400 ClientWidth = 400
LCLVersion = '3.99.0.0'
OnMouseUp = FormMouseUp OnMouseUp = FormMouseUp
OnResize = FormResize OnResize = FormResize
LCLVersion = '2.3.0.0'
object StatusBar: TStatusBar object StatusBar: TStatusBar
Left = 0 Left = 0
Height = 23 Height = 23
@ -30,7 +30,9 @@ object SourceNotebook: TSourceNotebook
Width = 50 Width = 50
end end
item item
Text = 'INS' Width = 0
end
item
Width = 50 Width = 50
end> end>
SimpleText = 'This is a test' SimpleText = 'This is a test'

View File

@ -4448,6 +4448,9 @@ begin
end; end;
end; end;
ecStickySelection, ecStickySelectionCol, ecStickySelectionLine:
FSourceNoteBook.UpdateStatusBar;
else else
begin begin
Handled:=false; Handled:=false;
@ -8713,6 +8716,7 @@ procedure TSourceNotebook.StatusBarDrawPanel(AStatusBar: TStatusBar; APanel: TSt
const ARect: TRect); const ARect: TRect);
var var
pnl: TSourceEditorStatusPanel; pnl: TSourceEditorStatusPanel;
cl: TColor;
begin begin
if APanel = StatusBar.Panels[1] then begin if APanel = StatusBar.Panels[1] then begin
IDEImages.Images_16.ResolutionForControl[16, AStatusBar] IDEImages.Images_16.ResolutionForControl[16, AStatusBar]
@ -8934,7 +8938,7 @@ end;
procedure TSourceNotebook.OpenFolderMenuItemClick(Sender: TObject); procedure TSourceNotebook.OpenFolderMenuItemClick(Sender: TObject);
begin begin
OpenDocument(ExtractFilePath(Statusbar.Panels[4].Text)); OpenDocument(ExtractFilePath(Statusbar.Panels[5].Text));
end; end;
procedure TSourceNotebook.ExecuteEditorItemClick(Sender: TObject); procedure TSourceNotebook.ExecuteEditorItemClick(Sender: TObject);
@ -8964,9 +8968,9 @@ begin
end; end;
W := 0; W := 0;
for i := 0 to StatusBar.Panels.Count - 1 do for i := 0 to StatusBar.Panels.Count - 1 do
if i <> 4 then if i <> 5 then
w := w + StatusBar.Panels[i].Width; w := w + StatusBar.Panels[i].Width;
StatusBar.Panels[4].Width := Max(150, StatusBar.Width - W); StatusBar.Panels[5].Width := Max(150, StatusBar.Width - W);
finally finally
StatusBar.EndUpdate; StatusBar.EndUpdate;
end; end;
@ -9146,7 +9150,7 @@ var
PanelFilename: String; PanelFilename: String;
PanelCharMode: string; PanelCharMode: string;
PanelXY: string; PanelXY: string;
PanelFileMode: string; PanelFileMode, PanelSelMode: string;
CurEditor: TSynEdit; CurEditor: TSynEdit;
begin begin
if FUpdateLock > 0 then begin if FUpdateLock > 0 then begin
@ -9219,6 +9223,18 @@ begin
PanelFileMode := PanelFileMode + ueLocked; PanelFileMode := PanelFileMode + ueLocked;
end; end;
PanelSelMode := '';
case CurEditor.SelectionMode of
smNormal: if CurEditor.IsStickySelecting or CurEditor.SelAvail then
PanelSelMode := uepSelNorm;
smLine: PanelSelMode := uepSelLine;
smColumn: PanelSelMode := uepSelCol;
end;
if (PanelSelMode<>'') and not CurEditor.SelAvail then
PanelSelMode := '('+PanelSelMode+')';
if CurEditor.IsStickySelecting then
PanelSelMode := '* '+PanelSelMode;
PanelXY := Format(' %6d:%4d', PanelXY := Format(' %6d:%4d',
[TempEditor.CurrentCursorYLine,TempEditor.CurrentCursorXLine]); [TempEditor.CurrentCursorYLine,TempEditor.CurrentCursorXLine]);
@ -9230,7 +9246,12 @@ begin
Statusbar.Panels[0].Text := PanelXY; Statusbar.Panels[0].Text := PanelXY;
StatusBar.Panels[2].Text := PanelFileMode; StatusBar.Panels[2].Text := PanelFileMode;
Statusbar.Panels[3].Text := PanelCharMode; Statusbar.Panels[3].Text := PanelCharMode;
Statusbar.Panels[4].Text := PanelFilename; Statusbar.Panels[4].Text := PanelSelMode;
if PanelSelMode = '' then
Statusbar.Panels[4].Width := 0
else
Statusbar.Panels[4].Width := 50;
Statusbar.Panels[5].Text := PanelFilename;
if(EditorMacroForRecording.IsRecording(CurEditor)) then if(EditorMacroForRecording.IsRecording(CurEditor)) then
Statusbar.Panels[1].Width := IDEImages.ScaledSize(20) Statusbar.Panels[1].Width := IDEImages.ScaledSize(20)
else else