mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-15 21:39:12 +02:00
IDE: Allow sorting the unicode ranges in Character Map Dialog. Issue #31500, patch from FTurtle.
git-svn-id: trunk@54387 -
This commit is contained in:
parent
c6261efd55
commit
a501e7f99d
@ -1,7 +1,7 @@
|
|||||||
object CharacterMapDialog: TCharacterMapDialog
|
object CharacterMapDialog: TCharacterMapDialog
|
||||||
Left = 370
|
Left = 242
|
||||||
Height = 477
|
Height = 477
|
||||||
Top = 128
|
Top = 126
|
||||||
Width = 590
|
Width = 590
|
||||||
BorderStyle = bsSizeToolWin
|
BorderStyle = bsSizeToolWin
|
||||||
Caption = 'CharacterMapDialog'
|
Caption = 'CharacterMapDialog'
|
||||||
@ -90,11 +90,11 @@ object CharacterMapDialog: TCharacterMapDialog
|
|||||||
OnSelectCell = UnicodeGridSelectCell
|
OnSelectCell = UnicodeGridSelectCell
|
||||||
end
|
end
|
||||||
object cbUniRange: TComboBox
|
object cbUniRange: TComboBox
|
||||||
AnchorSideRight.Control = pgUnicode
|
AnchorSideTop.Control = UnicodeGrid
|
||||||
AnchorSideRight.Side = asrBottom
|
AnchorSideRight.Control = SortUniRangeListButton
|
||||||
AnchorSideBottom.Control = pgUnicode
|
AnchorSideBottom.Control = pgUnicode
|
||||||
AnchorSideBottom.Side = asrBottom
|
AnchorSideBottom.Side = asrBottom
|
||||||
Left = 273
|
Left = 242
|
||||||
Height = 21
|
Height = 21
|
||||||
Top = 380
|
Top = 380
|
||||||
Width = 291
|
Width = 291
|
||||||
@ -110,7 +110,7 @@ object CharacterMapDialog: TCharacterMapDialog
|
|||||||
AnchorSideTop.Control = cbUniRange
|
AnchorSideTop.Control = cbUniRange
|
||||||
AnchorSideTop.Side = asrCenter
|
AnchorSideTop.Side = asrCenter
|
||||||
AnchorSideRight.Control = cbUniRange
|
AnchorSideRight.Control = cbUniRange
|
||||||
Left = 236
|
Left = 205
|
||||||
Height = 13
|
Height = 13
|
||||||
Top = 384
|
Top = 384
|
||||||
Width = 31
|
Width = 31
|
||||||
@ -118,6 +118,24 @@ object CharacterMapDialog: TCharacterMapDialog
|
|||||||
Caption = 'Range'
|
Caption = 'Range'
|
||||||
ParentColor = False
|
ParentColor = False
|
||||||
end
|
end
|
||||||
|
object SortUniRangeListButton: TSpeedButton
|
||||||
|
AnchorSideTop.Control = cbUniRange
|
||||||
|
AnchorSideTop.Side = asrCenter
|
||||||
|
AnchorSideRight.Control = pgUnicode
|
||||||
|
AnchorSideRight.Side = asrBottom
|
||||||
|
AnchorSideBottom.Control = pgUnicode
|
||||||
|
Left = 539
|
||||||
|
Height = 25
|
||||||
|
Top = 378
|
||||||
|
Width = 25
|
||||||
|
AllowAllUp = True
|
||||||
|
Anchors = [akTop, akRight]
|
||||||
|
BorderSpacing.Around = 6
|
||||||
|
GroupIndex = 1
|
||||||
|
OnClick = SortUniRangeListButtonClick
|
||||||
|
ShowHint = True
|
||||||
|
ParentShowHint = False
|
||||||
|
end
|
||||||
end
|
end
|
||||||
object pgAnsi: TTabSheet
|
object pgAnsi: TTabSheet
|
||||||
Caption = 'ANSI'
|
Caption = 'ANSI'
|
||||||
@ -196,7 +214,7 @@ object CharacterMapDialog: TCharacterMapDialog
|
|||||||
'cp949 - Korean'
|
'cp949 - Korean'
|
||||||
'cp950 - Traditional Chinese'
|
'cp950 - Traditional Chinese'
|
||||||
'macintosh - MAC Roman (Western Europe)'
|
'macintosh - MAC Roman (Western Europe)'
|
||||||
'koi8 - Ukrainean, Cyrillic'
|
'koi8 - Ukrainian, Cyrillic'
|
||||||
'iso88591 - ISO Latin-1 (Western Europe)'
|
'iso88591 - ISO Latin-1 (Western Europe)'
|
||||||
'iso88592 - ISO Latin-2 (Central and Eastern Europe)'
|
'iso88592 - ISO Latin-2 (Central and Eastern Europe)'
|
||||||
'iso885915 - ISO Latin-9 (Western Europe)'
|
'iso885915 - ISO Latin-9 (Western Europe)'
|
||||||
|
@ -53,6 +53,7 @@ type
|
|||||||
cbCodePage: TComboBox;
|
cbCodePage: TComboBox;
|
||||||
AnsiCharInfoLabel: TLabel;
|
AnsiCharInfoLabel: TLabel;
|
||||||
cbUniRange: TComboBox;
|
cbUniRange: TComboBox;
|
||||||
|
SortUniRangeListButton: TSpeedButton;
|
||||||
CodePageLabel: TLabel;
|
CodePageLabel: TLabel;
|
||||||
RangeLabel: TLabel;
|
RangeLabel: TLabel;
|
||||||
UnicodeCharInfoLabel: TLabel;
|
UnicodeCharInfoLabel: TLabel;
|
||||||
@ -67,6 +68,7 @@ type
|
|||||||
procedure HelpButtonClick(Sender: TObject);
|
procedure HelpButtonClick(Sender: TObject);
|
||||||
procedure FormCreate(Sender: TObject);
|
procedure FormCreate(Sender: TObject);
|
||||||
procedure FormShow(Sender: TObject);
|
procedure FormShow(Sender: TObject);
|
||||||
|
procedure SortUniRangeListButtonClick(Sender: TObject);
|
||||||
procedure AnsiGridSelectCell(Sender: TObject; aCol, aRow: Integer;
|
procedure AnsiGridSelectCell(Sender: TObject; aCol, aRow: Integer;
|
||||||
var {%H-}CanSelect: Boolean);
|
var {%H-}CanSelect: Boolean);
|
||||||
procedure UnicodeGridSelectCell(Sender: TObject; aCol, aRow: Integer;
|
procedure UnicodeGridSelectCell(Sender: TObject; aCol, aRow: Integer;
|
||||||
@ -80,9 +82,14 @@ type
|
|||||||
Y: Integer);
|
Y: Integer);
|
||||||
private
|
private
|
||||||
FOnInsertCharacter: TOnInsertCharacterEvent;
|
FOnInsertCharacter: TOnInsertCharacterEvent;
|
||||||
|
FUnicodeBlockIndex: Integer;
|
||||||
procedure DoStatusAnsiGrid(ACol, ARow: integer);
|
procedure DoStatusAnsiGrid(ACol, ARow: integer);
|
||||||
procedure DoStatusUnicodeGrid(ACol, ARow: integer);
|
procedure DoStatusUnicodeGrid(ACol, ARow: integer);
|
||||||
procedure FillAnsiGrid;
|
procedure FillAnsiGrid;
|
||||||
|
procedure FillUnicodeGrid;
|
||||||
|
procedure FillUniRangeList(ASorted: Boolean);
|
||||||
|
function UnicodeBlockIndexByName(AName: String): Integer;
|
||||||
|
function UnicodeBlockSelected: Boolean;
|
||||||
procedure SelectSystemCP;
|
procedure SelectSystemCP;
|
||||||
public
|
public
|
||||||
property OnInsertCharacter: TOnInsertCharacterEvent read FOnInsertCharacter
|
property OnInsertCharacter: TOnInsertCharacterEvent read FOnInsertCharacter
|
||||||
@ -98,6 +105,9 @@ implementation
|
|||||||
|
|
||||||
{$R *.lfm}
|
{$R *.lfm}
|
||||||
|
|
||||||
|
const
|
||||||
|
NOT_SELECTED=Low(UnicodeBlocks)-1;
|
||||||
|
|
||||||
procedure ShowCharacterMap(AOnInsertChar: TOnInsertCharacterEvent);
|
procedure ShowCharacterMap(AOnInsertChar: TOnInsertCharacterEvent);
|
||||||
begin
|
begin
|
||||||
if CharacterMapDialog = nil then
|
if CharacterMapDialog = nil then
|
||||||
@ -113,6 +123,9 @@ procedure TCharacterMapDialog.FormCreate(Sender: TObject);
|
|||||||
begin
|
begin
|
||||||
Caption := lisCharacterMap;
|
Caption := lisCharacterMap;
|
||||||
RangeLabel.Caption := lisRange;
|
RangeLabel.Caption := lisRange;
|
||||||
|
SortUniRangeListButton.Flat:=True;
|
||||||
|
SortUniRangeListButton.Hint:=lisSortUnicodeRangeListAlphabetically;
|
||||||
|
SortUniRangeListButton.LoadGlyphFromResourceName(HInstance, 'pkg_sortalphabetically');
|
||||||
ButtonPanel.HelpButton.Caption:=lisMenuHelp;
|
ButtonPanel.HelpButton.Caption:=lisMenuHelp;
|
||||||
ButtonPanel.CloseButton.Caption:=lisBtnClose;
|
ButtonPanel.CloseButton.Caption:=lisBtnClose;
|
||||||
|
|
||||||
@ -175,24 +188,9 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TCharacterMapDialog.cbUniRangeSelect(Sender: TObject);
|
procedure TCharacterMapDialog.cbUniRangeSelect(Sender: TObject);
|
||||||
var
|
|
||||||
cnt, x, y: integer;
|
|
||||||
S, E: integer;
|
|
||||||
begin
|
begin
|
||||||
S:=UnicodeBlocks[cbUniRange.ItemIndex].S;
|
FUnicodeBlockIndex:=UnicodeBlockIndexByName(cbUniRange.Text);
|
||||||
E:=UnicodeBlocks[cbUniRange.ItemIndex].E;
|
FillUnicodeGrid;
|
||||||
UnicodeGrid.Clear;
|
|
||||||
UnicodeGrid.ColCount:=16;
|
|
||||||
UnicodeGrid.RowCount:=RoundUp(E-S,16);
|
|
||||||
cnt:=0;
|
|
||||||
for y:=0 to UnicodeGrid.RowCount-1 do
|
|
||||||
for x:=0 to UnicodeGrid.ColCount-1 do
|
|
||||||
begin
|
|
||||||
if S+Cnt<=E then
|
|
||||||
UnicodeGrid.Cells[x,y]:=UnicodeToUTF8(S+Cnt);
|
|
||||||
inc(cnt);
|
|
||||||
end;
|
|
||||||
UnicodeGrid.AutoSizeColumns;
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TCharacterMapDialog.FormKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
|
procedure TCharacterMapDialog.FormKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
|
||||||
@ -215,11 +213,14 @@ begin
|
|||||||
|
|
||||||
AnsiGrid.AutoSizeColumns;
|
AnsiGrid.AutoSizeColumns;
|
||||||
|
|
||||||
cbUniRange.Items.Clear;
|
FUnicodeBlockIndex:=NOT_SELECTED;
|
||||||
for i:=0 to MaxUnicodeBlocks do
|
FillUniRangeList(SortUniRangeListButton.Down);
|
||||||
cbUniRange.Items.Add(UnicodeBlocks[i].PG);
|
FillUnicodeGrid;
|
||||||
cbUniRange.ItemIndex:=0;
|
end;
|
||||||
cbUniRangeSelect(nil);
|
|
||||||
|
procedure TCharacterMapDialog.SortUniRangeListButtonClick(Sender: TObject);
|
||||||
|
begin
|
||||||
|
FillUniRangeList(SortUniRangeListButton.Down);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TCharacterMapDialog.AnsiGridSelectCell(Sender: TObject; aCol,
|
procedure TCharacterMapDialog.AnsiGridSelectCell(Sender: TObject; aCol,
|
||||||
@ -293,8 +294,8 @@ var
|
|||||||
tmp, tmp2: String;
|
tmp, tmp2: String;
|
||||||
i: Integer;
|
i: Integer;
|
||||||
begin
|
begin
|
||||||
if cbUniRange.ItemIndex<0 then exit;
|
if not UnicodeBlockSelected then Exit;
|
||||||
S:=UnicodeBlocks[cbUniRange.ItemIndex].S+(ACol)+(ARow*16);
|
S:=UnicodeBlocks[FUnicodeBlockIndex].S+(ACol)+(ARow*16);
|
||||||
tmp:=UnicodeToUTF8(S);
|
tmp:=UnicodeToUTF8(S);
|
||||||
tmp2:='';
|
tmp2:='';
|
||||||
for i:=1 to Length(tmp) do
|
for i:=1 to Length(tmp) do
|
||||||
@ -337,5 +338,58 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TCharacterMapDialog.FillUnicodeGrid;
|
||||||
|
var
|
||||||
|
cnt, x, y: integer;
|
||||||
|
S, E: integer;
|
||||||
|
begin
|
||||||
|
UnicodeGrid.Clear;
|
||||||
|
if not UnicodeBlockSelected then
|
||||||
|
Exit;
|
||||||
|
S:=UnicodeBlocks[FUnicodeBlockIndex].S;
|
||||||
|
E:=UnicodeBlocks[FUnicodeBlockIndex].E;
|
||||||
|
UnicodeGrid.ColCount:=16;
|
||||||
|
UnicodeGrid.RowCount:=RoundUp(E-S,16);
|
||||||
|
cnt:=0;
|
||||||
|
for y:=0 to UnicodeGrid.RowCount-1 do
|
||||||
|
for x:=0 to UnicodeGrid.ColCount-1 do
|
||||||
|
begin
|
||||||
|
if S+Cnt<=E then
|
||||||
|
UnicodeGrid.Cells[x,y]:=UnicodeToUTF8(S+Cnt);
|
||||||
|
inc(cnt);
|
||||||
|
end;
|
||||||
|
UnicodeGrid.AutoSizeColumns;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TCharacterMapDialog.FillUniRangeList(ASorted: Boolean);
|
||||||
|
var
|
||||||
|
BlockIdx: Integer;
|
||||||
|
begin
|
||||||
|
cbUniRange.Items.Clear;
|
||||||
|
cbUniRange.Sorted:=ASorted;
|
||||||
|
|
||||||
|
for BlockIdx:=Low(UnicodeBlocks) to High(UnicodeBlocks) do
|
||||||
|
cbUniRange.Items.Append(UnicodeBlocks[BlockIdx].PG);
|
||||||
|
|
||||||
|
if not UnicodeBlockSelected then
|
||||||
|
FUnicodeBlockIndex:=Low(UnicodeBlocks);
|
||||||
|
cbUniRange.Text:=UnicodeBlocks[FUnicodeBlockIndex].PG;
|
||||||
|
end;
|
||||||
|
|
||||||
|
function TCharacterMapDialog.UnicodeBlockIndexByName(AName: String): Integer;
|
||||||
|
var
|
||||||
|
BlockIdx: Integer;
|
||||||
|
begin
|
||||||
|
for BlockIdx:=Low(UnicodeBlocks) to High(UnicodeBlocks) do
|
||||||
|
if UnicodeBlocks[BlockIdx].PG=AName then
|
||||||
|
Exit(BlockIdx);
|
||||||
|
Result:=NOT_SELECTED;
|
||||||
|
end;
|
||||||
|
|
||||||
|
function TCharacterMapDialog.UnicodeBlockSelected: Boolean;
|
||||||
|
begin
|
||||||
|
Result:=(FUnicodeBlockIndex>=Low(UnicodeBlocks)) and (FUnicodeBlockIndex<=High(UnicodeBlocks));
|
||||||
|
end;
|
||||||
|
|
||||||
end.
|
end.
|
||||||
|
|
||||||
|
@ -4936,6 +4936,7 @@ resourcestring
|
|||||||
// character map
|
// character map
|
||||||
lisCharacterMap = 'Character Map';
|
lisCharacterMap = 'Character Map';
|
||||||
lisRange = 'Range';
|
lisRange = 'Range';
|
||||||
|
lisSortUnicodeRangeListAlphabetically = 'Sort Unicode range list alphabetically';
|
||||||
|
|
||||||
// codetools defines value dialog
|
// codetools defines value dialog
|
||||||
lisCTDefChooseDirectory = 'Choose Directory';
|
lisCTDefChooseDirectory = 'Choose Directory';
|
||||||
|
Loading…
Reference in New Issue
Block a user