1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102
|
------------------------------------------------------------------------------
-- G P S --
-- --
-- Copyright (C) 2003-2015, AdaCore --
-- --
-- This library is free software; you can redistribute it and/or modify it --
-- under terms of the GNU General Public License as published by the Free --
-- Software Foundation; either version 3, or (at your option) any later --
-- version. This library is distributed in the hope that it will be useful, --
-- but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN- --
-- TABILITY or FITNESS FOR A PARTICULAR PURPOSE. --
-- --
-- --
-- --
-- --
-- --
-- You should have received a copy of the GNU General Public License and --
-- a copy of the GCC Runtime Library Exception along with this program; --
-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
-- <http://www.gnu.org/licenses/>. --
-- --
------------------------------------------------------------------------------
-- This package provides an example of a graphical textual window that
-- can be used as a console for a programming language
with Gtk.Handlers;
with Gtk.Scrolled_Window;
with Gtk.Text_Mark;
with Gtk.Text_View;
with Gtk.Widget;
with GNATCOLL.Scripts; use GNATCOLL.Scripts;
package GtkConsole is
type Gtk_Console_Record is new Virtual_Console_Record with private;
type Gtk_Console is access all Gtk_Console_Record'Class;
overriding procedure Ref (Console : access Gtk_Console_Record);
overriding procedure Unref (Console : access Gtk_Console_Record);
overriding procedure Insert_Text
(Console : access Gtk_Console_Record; Txt : String);
overriding procedure Insert_Log
(Console : access Gtk_Console_Record; Txt : String);
overriding procedure Insert_Prompt
(Console : access Gtk_Console_Record; Txt : String);
overriding procedure Insert_Error
(Console : access Gtk_Console_Record; Txt : String);
overriding procedure Grab_Events
(Console : access Gtk_Console_Record; Grab : Boolean);
overriding procedure Set_As_Default_Console
(Console : access Gtk_Console_Record;
Script : GNATCOLL.Scripts.Scripting_Language);
overriding procedure Set_Data_Primitive
(Instance : Class_Instance;
Console : access Gtk_Console_Record);
overriding function Get_Instance
(Script : access Scripting_Language_Record'Class;
Console : access Gtk_Console_Record)
return Class_Instance;
overriding procedure Process_Pending_Events_Primitive
(Console : access Gtk_Console_Record);
overriding function Read
(Console : access Gtk_Console_Record;
Size : Integer;
Whole_Line : Boolean) return String;
-- See inherited subprograms
function Create
(Wraps : access Gtk.Text_View.Gtk_Text_View_Record'Class)
return Gtk_Console;
-- Wraps a text_view into a gtk_console. It is recommended that the text
-- view be put inside a scrolled window.
-- Pressing <return> in the text view will execute the corresponding
-- command.
function Get
(Console : access Gtk_Console_Record) return Gtk.Text_View.Gtk_Text_View;
-- Return the widget encapsulated in the console
private
type Gtk_Console_Record is new Virtual_Console_Record with record
View : Gtk.Text_View.Gtk_Text_View;
Script : GNATCOLL.Scripts.Scripting_Language;
Prompt_Mark : Gtk.Text_Mark.Gtk_Text_Mark;
-- The position after which the user can insert text.
Insert_Mark : Gtk.Text_Mark.Gtk_Text_Mark;
-- The insert position.
Took_Grab : Boolean := False;
Waiting_For_Input : Integer := 0;
Waiting_For_Newline : Boolean := False;
-- When the console is blocked in a call to read() or readline(),
-- the first variable indicates the maximal number of characters to wait
-- for. The second is true if a newline character should stop the block.
Destroy_Id : Gtk.Handlers.Handler_Id;
end record;
end GtkConsole;
|