Skip to content

Commit 7b0b991

Browse files
committed
Replace String by Virtual_String
1 parent 1f64be6 commit 7b0b991

14 files changed

+91
-42
lines changed

common/ui/src/histories.adb

+19-9
Original file line numberDiff line numberDiff line change
@@ -548,7 +548,7 @@ package body Histories is
548548
procedure Add_To_History
549549
(Hist : in out History_Record;
550550
Key : History_Key;
551-
New_Entry : String)
551+
New_Entry : VSS.Strings.Virtual_String)
552552
is
553553
procedure Unchecked_Free is new Ada.Unchecked_Deallocation
554554
(String_List, String_List_Access);
@@ -563,7 +563,9 @@ package body Histories is
563563
if Value.List /= null then
564564
if not Value.Allow_Duplicates then
565565
for V in Value.List'Range loop
566-
if Value.List (V).all = New_Entry then
566+
if Value.List (V).all
567+
= VSS.Strings.Conversions.To_UTF_8_String (New_Entry)
568+
then
567569
Tmp := Value.List (V);
568570
Value.List (Value.List'First + 1 .. V) :=
569571
Value.List (Value.List'First .. V - 1);
@@ -573,7 +575,8 @@ package body Histories is
573575
end loop;
574576

575577
elsif Value.Merge_First
576-
and then Value.List (Value.List'First).all = New_Entry
578+
and then Value.List (Value.List'First).all
579+
= VSS.Strings.Conversions.To_UTF_8_String (New_Entry)
577580
then
578581
return;
579582
end if;
@@ -589,13 +592,15 @@ package body Histories is
589592
Free (Value.List (Value.List'Last));
590593
Value.List (Value.List'First + 1 .. Value.List'Last) :=
591594
Value.List (Value.List'First .. Value.List'Last - 1);
592-
Value.List (Value.List'First) := new String'(New_Entry);
595+
Value.List (Value.List'First) :=
596+
new String'(VSS.Strings.Conversions.To_UTF_8_String (New_Entry));
593597
else
594598
-- Insert the element in the table
595599
Tmp2 := new String_List (1 .. Value.List'Length + 1);
596600
Tmp2 (2 .. Tmp2'Last) := Value.List.all;
597601
Unchecked_Free (Value.List);
598-
Tmp2 (Tmp2'First) := new String'(New_Entry);
602+
Tmp2 (Tmp2'First) :=
603+
new String'(VSS.Strings.Conversions.To_UTF_8_String (New_Entry));
599604
Value.List := Tmp2;
600605
end if;
601606

@@ -604,7 +609,10 @@ package body Histories is
604609
end if;
605610

606611
else
607-
Value.List := new String_List'(1 => new String'(New_Entry));
612+
Value.List :=
613+
new String_List'
614+
(1 => new String'
615+
(VSS.Strings.Conversions.To_UTF_8_String (New_Entry)));
608616
end if;
609617
end Add_To_History;
610618

@@ -810,10 +818,12 @@ package body Histories is
810818
procedure Save_Text
811819
(Self : access Gtk.GEntry.Gtk_Entry_Record'Class;
812820
Hist : access History_Record;
813-
Key : History_Key)
814-
is
821+
Key : History_Key) is
815822
begin
816-
Add_To_History (Hist.all, Key, Self.Get_Text);
823+
Add_To_History
824+
(Hist.all,
825+
Key,
826+
VSS.Strings.Conversions.To_Virtual_String (Self.Get_Text));
817827
end Save_Text;
818828

819829
end Histories;

common/ui/src/histories.ads

+1-1
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ package Histories is
143143
procedure Add_To_History
144144
(Hist : in out History_Record;
145145
Key : History_Key;
146-
New_Entry : String);
146+
New_Entry : VSS.Strings.Virtual_String);
147147
-- Store a new history string.
148148
-- If too many strings are stored, the oldest one is removed.
149149
-- If New_Entry is already in the history, it is not added a second time,

kernel/src/filter_panels.adb

+5-4
Original file line numberDiff line numberDiff line change
@@ -663,10 +663,11 @@ package body Filter_Panels is
663663
(Hist => Panel.Kernel.Get_History.all,
664664
Key => Key,
665665
New_Entry =>
666-
Prefix
667-
& (if Add.Get_Negate then '-' else '+')
668-
& (if Add.Get_Whole_Word then 'w' else ' ')
669-
& Add.Get_Text);
666+
VSS.Strings.Conversions.To_Virtual_String
667+
(Prefix
668+
& (if Add.Get_Negate then '-' else '+')
669+
& (if Add.Get_Whole_Word then 'w' else ' ')
670+
& Add.Get_Text));
670671
end if;
671672

672673
if Panel.Pattern_Config_Menu = null then

kernel/src/generic_views.adb

+2-2
Original file line numberDiff line numberDiff line change
@@ -535,10 +535,10 @@ package body Generic_Views is
535535

536536
Add_To_History
537537
(Get_History (View.Kernel).all, Window_X_Hist_Key,
538-
Gint'Image (X));
538+
VSS.Strings.To_Virtual_String (Gint'Wide_Wide_Image (X)));
539539
Add_To_History
540540
(Get_History (View.Kernel).all, Window_Y_Hist_Key,
541-
Gint'Image (Y));
541+
VSS.Strings.To_Virtual_String (Gint'Wide_Wide_Image (Y)));
542542
end Store_Position;
543543

544544
-----------------------------

kernel/src/gps-dialogs.adb

+9-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
------------------------------------------------------------------------------
22
-- GNAT Studio --
33
-- --
4-
-- Copyright (C) 2000-2024, AdaCore --
4+
-- Copyright (C) 2000-2025, AdaCore --
55
-- --
66
-- This is free software; you can redistribute it and/or modify it under --
77
-- terms of the GNU General Public License as published by the Free Soft- --
@@ -17,6 +17,9 @@
1717

1818
with Ada.Unchecked_Deallocation;
1919
with Ada.Strings.Unbounded; use Ada.Strings.Unbounded;
20+
21+
with VSS.Strings.Conversions;
22+
2023
with GNATCOLL.VFS; use GNATCOLL.VFS;
2124
with Gdk.Event; use Gdk.Event;
2225
with Glib.Object; use Glib.Object;
@@ -30,7 +33,6 @@ with Gtkada.Stock_Labels; use Gtkada.Stock_Labels;
3033

3134
with GPS.Kernel.MDI; use GPS.Kernel.MDI;
3235
with GPS.Main_Window; use GPS.Main_Window;
33-
with VSS.Strings.Conversions;
3436

3537
package body GPS.Dialogs is
3638

@@ -466,7 +468,11 @@ package body GPS.Dialogs is
466468
is
467469
S : constant String := Self.Get_Active_Text;
468470
begin
469-
Add_To_History (Self.Kernel.Get_History.all, Self.Key.all, S);
471+
Add_To_History
472+
(Self.Kernel.Get_History.all,
473+
Self.Key.all,
474+
VSS.Strings.Conversions.To_Virtual_String (S));
475+
470476
return S;
471477
end Get_Text;
472478

kernel/src/gps-kernel-scripts.adb

+3-2
Original file line numberDiff line numberDiff line change
@@ -1210,8 +1210,9 @@ package body GPS.Kernel.Scripts is
12101210
and then PyString_Check (Item)
12111211
then
12121212
Add_To_History
1213-
(Get_Kernel (Data).Get_History.all, Key,
1214-
Nth_Arg (Data, 2));
1213+
(Get_Kernel (Data).Get_History.all,
1214+
Key,
1215+
GNATCOLL.Scripts.VSS_Utils.Nth_Arg (Data, 2));
12151216
else
12161217
Set_History
12171218
(Get_Kernel (Data).Get_History.all, Key,

kernel/src/gps-kernel.adb

+4-1
Original file line numberDiff line numberDiff line change
@@ -1153,7 +1153,10 @@ package body GPS.Kernel is
11531153
Key : Histories.History_Key;
11541154
New_Entry : String) is
11551155
begin
1156-
Add_To_History (Handle.History.all, Key, New_Entry);
1156+
Add_To_History
1157+
(Handle.History.all,
1158+
Key,
1159+
VSS.Strings.Conversions.To_Virtual_String (New_Entry));
11571160
end Add_To_History;
11581161

11591162
-------------------

kernel/src/gps-search-gui.adb

+4-2
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ with GNATCOLL.Utils; use GNATCOLL.Utils;
2525
with System;
2626
with System.Address_Image;
2727

28+
with VSS.Strings.Conversions;
29+
2830
with Glib; use Glib;
2931
with Glib.Properties; use Glib.Properties;
3032
with Glib.Values; use Glib.Values;
@@ -707,7 +709,7 @@ package body GPS.Search.GUI is
707709
Add_To_History
708710
(Get_History (S.Get_Kernel).all,
709711
Module.Current_Command.History.all,
710-
S.Get_Text);
712+
VSS.Strings.Conversions.To_Virtual_String (S.Get_Text));
711713
end if;
712714
end On_Entry_Changed;
713715

@@ -722,7 +724,7 @@ package body GPS.Search.GUI is
722724
Add_To_History
723725
(Get_History (S.Get_Kernel).all,
724726
Module.Current_Command.History.all,
725-
S.Get_Text);
727+
VSS.Strings.Conversions.To_Virtual_String (S.Get_Text));
726728
end if;
727729

728730
Reset;

kernel/src/gtkada-entry_completion.adb

+8-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
------------------------------------------------------------------------------
22
-- GNAT Studio --
33
-- --
4-
-- Copyright (C) 2002-2023, AdaCore --
4+
-- Copyright (C) 2002-2025, AdaCore --
55
-- --
66
-- This is free software; you can redistribute it and/or modify it under --
77
-- terms of the GNU General Public License as published by the Free Soft- --
@@ -20,6 +20,8 @@ with Ada.Unchecked_Conversion;
2020
with Ada.Unchecked_Deallocation;
2121
with GNAT.Strings; use GNAT.Strings;
2222

23+
with VSS.Strings;
24+
2325
with Commands; use Commands;
2426
with Default_Preferences; use Default_Preferences;
2527
with Gdk.Event; use Gdk.Event;
@@ -1816,7 +1818,9 @@ package body Gtkada.Entry_Completion is
18161818
S.GEntry.Set_Width_Chars (Size);
18171819
S.GEntry.Queue_Resize;
18181820
Add_To_History
1819-
(Get_History (S.Kernel).all, S.Name.all & "-width", Size'Img);
1821+
(Get_History (S.Kernel).all,
1822+
S.Name.all & "-width",
1823+
VSS.Strings.To_Virtual_String (Gint'Wide_Wide_Image (Size)));
18201824

18211825
Show_Preview (S);
18221826
On_Entry_Changed (S);
@@ -1837,7 +1841,8 @@ package body Gtkada.Entry_Completion is
18371841
Add_To_History
18381842
(Get_History (Radio.Entry_View.Kernel).all,
18391843
Radio.Entry_View.Name.all & "-kind",
1840-
Search_Kind'Image (Radio.Kind));
1844+
VSS.Strings.To_Virtual_String
1845+
(Search_Kind'Wide_Wide_Image (Radio.Kind)));
18411846

18421847
Show_Preview (Radio.Entry_View);
18431848
On_Entry_Changed (Radio.Entry_View);

kernel/src/interactive_consoles.adb

+7-3
Original file line numberDiff line numberDiff line change
@@ -830,10 +830,13 @@ package body Interactive_Consoles is
830830
if UTF8 (UTF8'Last) = ASCII.LF then
831831
Histories.Add_To_History
832832
(Console.History.all, History_Key (Console.Key.all),
833-
UTF8 (UTF8'First .. UTF8'Last - 1));
833+
VSS.Strings.Conversions.To_Virtual_String
834+
(UTF8 (UTF8'First .. UTF8'Last - 1)));
834835
else
835836
Histories.Add_To_History
836-
(Console.History.all, History_Key (Console.Key.all), UTF8);
837+
(Console.History.all,
838+
History_Key (Console.Key.all),
839+
VSS.Strings.Conversions.To_Virtual_String (UTF8));
837840
end if;
838841
end if;
839842

@@ -2101,7 +2104,8 @@ package body Interactive_Consoles is
21012104
if Command /= "" and then Console.History /= null then
21022105
Add_To_History
21032106
(Console.History.all,
2104-
History_Key (Console.Key.all), Command);
2107+
History_Key (Console.Key.all),
2108+
VSS.Strings.Conversions.To_Virtual_String (Command));
21052109
Console.Current_Position := -1;
21062110
end if;
21072111

keymanager/src/keymanager_module.adb

+8-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
------------------------------------------------------------------------------
22
-- GNAT Studio --
33
-- --
4-
-- Copyright (C) 2003-2024, AdaCore --
4+
-- Copyright (C) 2003-2025, AdaCore --
55
-- --
66
-- This is free software; you can redistribute it and/or modify it under --
77
-- terms of the GNU General Public License as published by the Free Soft- --
@@ -18,6 +18,9 @@
1818
with Ada.Characters.Handling; use Ada.Characters.Handling;
1919
with Ada.Unchecked_Conversion;
2020
with GNAT.OS_Lib; use GNAT.OS_Lib;
21+
22+
with VSS.Strings.Conversions;
23+
2124
with GNATCOLL.Scripts.Python.Gtkada; use GNATCOLL.Scripts.Python.Gtkada;
2225
with GNATCOLL.Scripts; use GNATCOLL.Scripts;
2326
with GNATCOLL.Traces; use GNATCOLL.Traces;
@@ -1469,7 +1472,10 @@ package body KeyManager_Module is
14691472
Name : String)
14701473
is
14711474
begin
1472-
Add_To_History (Get_History (Kernel).all, Hist_Key_Theme, Name);
1475+
Add_To_History
1476+
(Get_History (Kernel).all,
1477+
Hist_Key_Theme,
1478+
VSS.Strings.Conversions.To_Virtual_String (Name));
14731479
end Set_Key_Theme;
14741480

14751481
--------------

vsearch/src/vsearch.adb

+10-4
Original file line numberDiff line numberDiff line change
@@ -961,7 +961,10 @@ package body Vsearch is
961961
& (if Case_Sensitive then '*' else ' ')
962962
& Character'Val (127);
963963
begin
964-
Add_To_History (Get_History (Vsearch.Kernel).all, Pattern_Hist_Key, V);
964+
Add_To_History
965+
(Get_History (Vsearch.Kernel).all,
966+
Pattern_Hist_Key,
967+
VSS.Strings.Conversions.To_Virtual_String (V));
965968

966969
if To_Combo then
967970
Add_History_To_Combo
@@ -1038,7 +1041,7 @@ package body Vsearch is
10381041
Add_To_History
10391042
(Get_History (Vsearch_Module_Id.Kernel).all,
10401043
Replace_Hist_Key,
1041-
VSS.Strings.Conversions.To_UTF_8_String (Replace_Text));
1044+
Replace_Text);
10421045

10431046
return Ctxt;
10441047
end Create_Context;
@@ -2155,7 +2158,10 @@ package body Vsearch is
21552158
To_Combo => False);
21562159

21572160
Add_To_History
2158-
(History, Replace_Hist_Key, Vsearch.Replace_Combo.Get_Active_Text);
2161+
(History,
2162+
Replace_Hist_Key,
2163+
VSS.Strings.Conversions.To_Virtual_String
2164+
(Vsearch.Replace_Combo.Get_Active_Text));
21592165

21602166
-- The widgets in Context_Specific have a longer lifecycle than the
21612167
-- dialog itself: make sure here that they are not destroyed when the
@@ -3562,7 +3568,7 @@ package body Vsearch is
35623568
Add_To_History
35633569
(Get_History (Handle).all,
35643570
Last_Search_Module_Key,
3565-
Module.Get_Label);
3571+
VSS.Strings.Conversions.To_Virtual_String (Module.Get_Label));
35663572
end Set_Last_Search_Module;
35673573

35683574
-----------------------------

widgets/src/build_configurations-gtkada.adb

+4-3
Original file line numberDiff line numberDiff line change
@@ -1542,7 +1542,7 @@ package body Build_Configurations.Gtkada is
15421542
Add_To_History
15431543
(History.all,
15441544
Target_To_Key (Target),
1545-
Get_Text (Ent));
1545+
VSS.Strings.Conversions.To_Virtual_String (Get_Text (Ent)));
15461546

15471547
Set_Persistent
15481548
(History.all,
@@ -1692,7 +1692,7 @@ package body Build_Configurations.Gtkada is
16921692
Add_To_History
16931693
(History.all,
16941694
Target_To_Key (UI.Target_UI.Target),
1695-
Default);
1695+
VSS.Strings.Conversions.To_Virtual_String (Default));
16961696
end if;
16971697
end;
16981698
end if;
@@ -1716,7 +1716,8 @@ package body Build_Configurations.Gtkada is
17161716
Add_To_History
17171717
(History.all,
17181718
Target_To_Key (UI.Target_UI.Target),
1719-
Get_Text (Get_Entry (UI.Target_UI.Editor)));
1719+
VSS.Strings.Conversions.To_Virtual_String
1720+
(Get_Text (Get_Entry (UI.Target_UI.Editor))));
17201721

17211722
Set_Persistent
17221723
(History.all,

0 commit comments

Comments
 (0)