@@ -91,9 +91,7 @@ package body DAP.Clients is
9191 New_Request : in out DAP.Requests.DAP_Request_Access);
9292
9393 -- Evaluate_Request --
94- type Evaluate_Kind is
95- (Show_Lang, Set_Lang, Restore_Lang, List_Adainit,
96- Info_Line, Info_First_Line, Hover, Variable_Address, Endian);
94+
9795 type Evaluate_Request is
9896 new DAP.Requests.Evaluate.Evaluate_DAP_Request
9997 with record
@@ -1454,20 +1452,47 @@ package body DAP.Clients is
14541452 Trace (Me, E);
14551453 end Process_Event ;
14561454
1455+ -- ------------------------
1456+ -- Process_User_Command --
1457+ -- ------------------------
1458+
1459+ procedure Process_User_Command
1460+ (Self : in out DAP_Client;
1461+ Cmd : String;
1462+ Output_Command : Boolean := False)
1463+ is
1464+ Request : DAP.Requests.DAP_Request_Access;
1465+ begin
1466+ if Output_Command then
1467+ Self.Display_In_Debugger_Console (Cmd, Is_Command => True);
1468+ end if ;
1469+
1470+ Request := Self.Create_Evaluate_Command
1471+ (Command, VSS.Strings.Conversions.To_Virtual_String (Cmd));
1472+
1473+ Self.Enqueue (Request);
1474+ end Process_User_Command ;
1475+
14571476 -- -------------------------------
14581477 -- Display_In_Debugger_Console --
14591478 -- -------------------------------
14601479
14611480 procedure Display_In_Debugger_Console
1462- (Self : in out DAP_Client;
1463- Msg : String)
1481+ (Self : in out DAP_Client;
1482+ Msg : String;
1483+ Is_Command : Boolean := False)
14641484 is
14651485 Console : constant access Interactive_Console_Record'Class :=
14661486 DAP.Views.Consoles.Get_Debugger_Interactive_Console (Self);
14671487
14681488 begin
14691489 if Console /= null then
1470- Console.Insert (Msg, Add_LF => True);
1490+ if Is_Command then
1491+ Console.Insert
1492+ (Msg, Add_LF => True, Highlight => True, Add_To_History => True);
1493+ else
1494+ Console.Insert (Msg, Add_LF => True);
1495+ end if ;
14711496 end if ;
14721497 end Display_In_Debugger_Console ;
14731498
@@ -1823,6 +1848,32 @@ package body DAP.Clients is
18231848 Self.Enqueue (DAP.Requests.DAP_Request_Access (Req));
18241849 end Value_Of ;
18251850
1851+ -- ---------------------------
1852+ -- Create_Evaluate_Command --
1853+ -- ---------------------------
1854+
1855+ function Create_Evaluate_Command
1856+ (Self : DAP_Client;
1857+ Kind : Evaluate_Kind;
1858+ Cmd : Virtual_String)
1859+ return DAP.Requests.DAP_Request_Access
1860+ is
1861+ Req : constant Evaluate_Request_Access :=
1862+ new Evaluate_Request (Self.Kernel);
1863+ Frame : constant Integer := Self.Get_Selected_Frame;
1864+ begin
1865+ Req.Kind := Kind;
1866+ Req.Client := Self.This;
1867+ Req.Parameters.arguments.expression := Cmd;
1868+ if Frame /= 0 then
1869+ Req.Parameters.arguments.frameId :=
1870+ (Is_Set => True, Value => Frame);
1871+ end if ;
1872+ Req.Parameters.arguments.context :=
1873+ (Is_Set => True, Value => DAP.Tools.Enum.repl);
1874+ return DAP.Requests.DAP_Request_Access (Req);
1875+ end Create_Evaluate_Command ;
1876+
18261877 -- ---------------------
18271878 -- On_Result_Message --
18281879 -- ---------------------
@@ -1832,33 +1883,11 @@ package body DAP.Clients is
18321883 Result : in out DAP.Tools.EvaluateResponse;
18331884 New_Request : in out DAP.Requests.DAP_Request_Access)
18341885 is
1835- procedure Command (Kind : Evaluate_Kind; Cmd : Virtual_String);
18361886 procedure Show_File
18371887 (File : Virtual_String;
18381888 Line : Natural;
18391889 Addr : Address_Type);
18401890
1841- -- -----------
1842- -- Command --
1843- -- -----------
1844-
1845- procedure Command (Kind : Evaluate_Kind; Cmd : Virtual_String) is
1846- Req : constant Evaluate_Request_Access :=
1847- new Evaluate_Request (Self.Kernel);
1848- Frame : constant Integer := Self.Client.Get_Selected_Frame;
1849- begin
1850- Req.Kind := Kind;
1851- Req.Client := Self.Client;
1852- Req.Parameters.arguments.expression := Cmd;
1853- if Frame /= 0 then
1854- Req.Parameters.arguments.frameId :=
1855- (Is_Set => True, Value => Frame);
1856- end if ;
1857- Req.Parameters.arguments.context :=
1858- (Is_Set => True, Value => DAP.Tools.Enum.repl);
1859- New_Request := DAP.Requests.DAP_Request_Access (Req);
1860- end Command ;
1861-
18621891 -- -------------
18631892 -- Show_File --
18641893 -- -------------
@@ -1898,7 +1927,8 @@ package body DAP.Clients is
18981927 then Match.Captured (1 )
18991928 else " auto" );
19001929 end ;
1901- Command (Endian, " show endian" );
1930+ New_Request := Self.Client.Create_Evaluate_Command
1931+ (Endian, " show endian" );
19021932
19031933 when Endian =>
19041934 declare
@@ -1911,17 +1941,21 @@ package body DAP.Clients is
19111941 Match := Endian_Pattern.Match (Result.a_body.result);
19121942 end ;
19131943
1914- Command (Set_Lang, " set lang c" );
1944+ New_Request := Self.Client.Create_Evaluate_Command
1945+ (Set_Lang, " set lang c" );
19151946
19161947 when Set_Lang =>
1917- Command (List_Adainit, " list adainit" );
1948+ New_Request := Self.Client.Create_Evaluate_Command
1949+ (List_Adainit, " list adainit" );
19181950
19191951 when List_Adainit =>
1920- Command (Restore_Lang, " set lang " & Self.Client.Stored_Lang);
1952+ New_Request := Self.Client.Create_Evaluate_Command
1953+ (Restore_Lang, " set lang " & Self.Client.Stored_Lang);
19211954
19221955 when Restore_Lang =>
19231956 if DAP.Modules.Preferences.Open_Main_Unit.Get_Pref then
1924- Command (Info_Line, " info line" );
1957+ New_Request := Self.Client.Create_Evaluate_Command
1958+ (Info_Line, " info line" );
19251959 else
19261960 Self.Client.On_Ready;
19271961 end if ;
@@ -1948,7 +1982,7 @@ package body DAP.Clients is
19481982 if Match.Has_Match
19491983 and then Match.Has_Capture (1 )
19501984 then
1951- Command
1985+ New_Request := Self.Client.Create_Evaluate_Command
19521986 (Info_First_Line, " info line "
19531987 & Match.Captured (1 ) & " :1" );
19541988 else
@@ -1993,6 +2027,9 @@ package body DAP.Clients is
19932027 (Self.Kernel, " 0" & S (Index .. S'Last));
19942028 end if ;
19952029 end ;
2030+
2031+ when Command =>
2032+ null ;
19962033 end case ;
19972034 end On_Result_Message ;
19982035
0 commit comments