Class: Roebe::GUI::UniversalWidgets::Shell

Inherits:
Base show all
Includes:
UniversalWidgets::BaseModule
Defined in:
lib/roebe/gui/universal_widgets/shell/shell.rb

Overview

Roebe::GUI::UniversalWidgets::Shell

Constant Summary collapse

N =
#

N

#
"\n"
TITLE =
#

TITLE

This constant sets the main title for this widget. It currently

includes a

to indicate the namespace within module Roebe.

#
'Shell'
WIDTH =
#

WIDTH

#
'42% or minimum 1480px'
HEIGHT =
#

HEIGHT

#
'30% or minimum 300px'
USE_THIS_FONT =
#

USE_THIS_FONT

#
:hack_23
LARGER_FONT =
#

LARGER_FONT

#
:hack_25
SMALLER_FONT =
#

SMALLER_FONT

#
:hack_20
EMPTY_STRING =
#

EMPTY_STRING

#
''
INPUT_WAS_NOT_FOUND =
#

INPUT_WAS_NOT_FOUND

#
'Input was not found.'
PADDING_TO_USE_FOR_THE_USER_INPUT =
#

PADDING_TO_USE_FOR_THE_USER_INPUT

#
12
HASH_DESIGNATED_KEY_COMBINATIONS =
#

HASH_DESIGNATED_KEY_COMBINATIONS

If we need more key-combinations to work quickly, we can simply add them here. As of May 2021, only the first four are in use.

#
{
  'Alt+w' => 'report_return_date',
  'Alt+e' => 'show_path_in_use',
  'Alt+r' => 'cd_one_down',
  'Alt+t' => 'll',
  'Alt+z' => 'NOT_YET_DEFINED',
  'Alt+u' => 'NOT_YET_DEFINED',
  'Alt+i' => 'NOT_YET_DEFINED',
  'Alt+o' => 'NOT_YET_DEFINED',
  'Alt+p' => 'NOT_YET_DEFINED',
  'Alt+ü' => 'NOT_YET_DEFINED',
}

Constants inherited from Base

Base::COLOURS, Base::HOME_DIRECTORY_OF_USER_X, Base::NAMESPACE

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#actions, #append_this_onto_that_file, #append_what_into, #be_silent, #be_verbose?, #beautiful_url, #burlywood, #call_next, #chdir, #cheerful_guy, #cliner, #complex_esystem, #convert_global_env, #copy_directory, #copy_file, #cornflowerblue, #create_directory, #crimson, #current_month?, #current_time?, #current_year?, #cyan, #darkcyan, #darkgreen, #darkkhaki, #darkslateblue, #deeppink, #delete_symlink, #do_not_use_the_base_colours, #do_use_the_base_colours, #e, #ecomment, #editor_to_use?, #efancy, #eimp, #emphasis, #ensure_main_encoding, #ensure_utf_encoding, #eparse, #erev, #esteelblue, #etomato, #ewarn, #exit_program, #firebrick, #get_current_day, #get_current_month, #get_files_and_directories, #get_files_from, #get_german_name_for_this_weekday, #gold, #green, #grey, #hh_mm_ss, #hh_mm_ss_day_month_year, #home_dir?, #home_directory_of_user_x?, #infer_the_namespace, #internal_hash?, #is_a_directory?, #is_a_file?, #is_a_jpg_file?, #is_an_image_file?, #is_archive?, #is_audio_file?, #is_in_studium_dir?, #is_multimedia_file?, #is_on_roebe?, #is_on_windows?, #is_studium_available?, #is_symlink?, #is_this_a_ruby_file?, #is_video_file?, #iso_encoding?, #le, #left_colour, #lightblue, #lightgreen, #lightseagreen, #lightsteelblue, #lime, #limegreen, #localhost_to_data, #log_directory?, #main_encoding?, #mediumorchid, #mediumpurple, #mediumseagreen, #mediumslateblue, #mediumspringgreen, #mediumturquoise, #mkdir_p, #mv, #n_days_in_this_month, #n_pages_in_this_pdf_file?, #namespace?, #no_file_exists_at, #ogrey, #olive, #olivedrab, #open_in_browser, #opne, #opnesystem, #opnn, #orange, #orchid, #orev, #palegoldenrod, #palevioletred, #pink, #powderblue, #programs_dir?, #project_base_dir?, #random_html_colour, #rds, #read_file_in_iso_encoding, #read_file_via_the_default_encoding, #read_lines_via_iso_encoding, #readlines_with_main_encoding, #red, #register_sigint, #remove, #remove_directory, #remove_file, #rename_kde_konsole_tab, #replace_localhost_with_data, #report_pwd, #require_rescue, #reset_the_internal_hash, #return_all_directories_from_this_directory, #return_all_files_from_this_directory, #return_current_directory, #return_dd_mm_yyyy, #return_file_or_directory_of, #return_files_from_pwd, #return_last_part_of_the_current_directory, #return_utc, #rev, #right_arrow?, #right_colour, #roebe_log_directory?, #rosybrown, #royalblue, #ruby_base_directory?, #run_in_background, #run_rcfiles_then_run_ata_via_qdbus, #sandybrown, #sdir, #seagreen, #set_be_verbose, #set_xorg_buffer, #sfancy, #sfile, #show_help, #silent_redirection?, #simp, #simple_esystem, #skyblue, #slateblue, #slategray, #springgreen, #steelblue, #string_italic, #swarn, #symlink, #teal, #temp_dir?, #to_camelcase, #to_counted_hash, #tomato, #touch, #try_to_require_the_beautiful_url_gem, #try_to_require_the_html_template, #try_to_require_the_open_gem, #try_to_require_the_program_information_gem, #try_to_require_the_xorg_buffer, #use_colours?, #verbose_truth, #weekday?, #word_wrap, #write_what_into, #yellow

Methods included from Base::CommandlineArguments

#append_onto_the_commandline_arguments, #clear_commandline_arguments, #commandline_arguments?, #commandline_arguments_as_string?, #commandline_arguments_without_leading_hyphens?, #first_argument?, #first_argument_without_leading_hyphens?, #has_an_argument_been_passed?, #remove_hyphened_arguments_from_the_commandline_arguments, #return_commandline_arguments_with_leading_hyphens, #second_argument?, #set_commandline_arguments

Constructor Details

#initialize(commandline_arguments = nil, run_already = true) ⇒ Shell

#

initialize

#


119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
# File 'lib/roebe/gui/universal_widgets/shell/shell.rb', line 119

def initialize(
    commandline_arguments = nil,
    run_already           = true
  )
  super(:vertical) if use_gtk3?
  determine_the_GUI_to_be_used(commandline_arguments) # This must come first, even before reset().
  reset
  set_commandline_arguments(
    commandline_arguments
  )
  new_text = %Q(<span weight="ultrabold" size="large" foreground="darkblue"> #{TITLE} </span>)
  label.set_markup(new_text, use_underline: true)
  on_delete_event_quit_the_application
  run if run_already
end

Class Method Details

.[](i = ARGV) ⇒ Object

#

Roebe::GUI::UniversalWidgets::Shell[]

#


886
887
888
# File 'lib/roebe/gui/universal_widgets/shell/shell.rb', line 886

def self.[](i = ARGV)
  new(i)
end

.height?Boolean

#

Roebe::GUI::Gtk::Shell.height?

#

Returns:

  • (Boolean)


112
113
114
# File 'lib/roebe/gui/universal_widgets/shell/shell.rb', line 112

def self.height?
  HEIGHT
end

.run(i = ARGV) ⇒ Object

#

Roebe::GUI::Gtk::Shell.run

#


845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
# File 'lib/roebe/gui/universal_widgets/shell/shell.rb', line 845

def self.run(
    i = ARGV
  )
  require 'gtk_paradise/run'
  _ = ::Roebe::GUI::Gtk::Shell.new(i)
  r = ::Gtk.run
  r << _
  @accel_group = ::Gtk::AccelGroup.new
  # ======================================================================= #
  # === Alt+1
  #
  # Alt+1 will focus on the gtk-entry, the main user input.
  # ======================================================================= #
  use_this_key = Gdk::Keyval::KEY_1
  @accel_group.alt_key(use_this_key) {
    _.focus_on_the_user_input_gtk_entry
  }
  # ======================================================================= #
  # === Alt+2
  # ======================================================================= #
  use_this_key = Gdk::Keyval::KEY_2
  @accel_group.alt_key(use_this_key) {
    _.focus_on_the_bottom_widget
  }
  r.add_accel_group(@accel_group)
  _.set_parent_widget(r) # Must designate the parent-widget first.
  # ====================================================================== #
  # Enable additional key-combinations next:
  # ====================================================================== #
  _.enable_these_key_combinations(
    _.hash_designated_key_combinations?
  )
  r.automatic_size_then_automatic_title
  r.enable_quick_exit
  r.set_background :white
  r.top_left_then_run
end

.width?Boolean

#

Roebe::GUI::Gtk::Shell.width?

#

Returns:

  • (Boolean)


105
106
107
# File 'lib/roebe/gui/universal_widgets/shell/shell.rb', line 105

def self.width?
  WIDTH
end

Instance Method Details

#add_status_message(i) ⇒ Object

#

add_status_message

This method will simply add the status message to the statusbar.

#


574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
# File 'lib/roebe/gui/universal_widgets/shell/shell.rb', line 574

def add_status_message(i)
  case i
  # ======================================================================= #
  # === :clear
  #
  # This will simply empty the status-bar.
  # ======================================================================= #
  when :clear
    i = EMPTY_STRING
  # ======================================================================= #
  # === :found_nothing
  # ======================================================================= #
  when :found_nothing
    i = INPUT_WAS_NOT_FOUND
  end
  @statusbar.push(@statusbar_context_id, i)
  # @statusbar.modify_foreground :crimson
  # ^^^ this does not work, unfortunately. May have to revisit
  # this at a later time.
end

#border_size?Boolean

#

border_size?

#

Returns:

  • (Boolean)


462
463
464
# File 'lib/roebe/gui/universal_widgets/shell/shell.rb', line 462

def border_size?
  0
end

#connect_the_skeletonObject

#

connect_the_skeleton (connect tag)

#


690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
# File 'lib/roebe/gui/universal_widgets/shell/shell.rb', line 690

def connect_the_skeleton
  abort_on_exception

  outer_vbox = create_vbox

  outer_vbox = vbox
  outer_vbox.minimal(@top_bar)
  outer_vbox.minimal(@entry_user_input_for_the_shell, 4)
  # ======================================================================= #
  # Next add the draggable container for the scrolled-window on the
  # left hand side, and the mini-vbox containing the xorg-button
  # and the combo box on the right hand side.
  # ======================================================================= #
  tiny_vbox = return_the_content_of_the_vbox_on_the_right_side
  drag1 = drag_via_left_and_right_movement(
    @scrolled_window_containing_the_text_view,
    tiny_vbox
  )
  drag1.position = 1320

  # ======================================================================= #
  # Add the directory-content widget, below the bottom widget.
  # ======================================================================= #
  drag2 = drag_via_up_and_down_movement(
    drag1,
    @directory_content_widget
  )
  outer_vbox.minimal(drag2, 5)

  # ======================================================================= #
  # Next, add the entry that shows the current working directory.
  # ======================================================================= #
  super_tiny_hbox = hbox
  super_tiny_hbox.minimal(@eventbox_label_current_working_directory)
  super_tiny_hbox.maximal(@entry_showing_the_current_working_directory)
  @bottom_widget.minimal(super_tiny_hbox,                  5)
  @bottom_widget.minimal(create_then_return_the_statusbar, 5)
  # @bottom_widget.minimal(@vte, 1)
  outer_vbox.minimal(@bottom_widget)

  window = create_window_or_runner(nil, width?, height?, title?)
  window << outer_vbox

  properly_prepare_this_window(window,
    {
      title:       title?,
      font:        font?,
      width:       width?,
      height:      height?,
      padding:     padding?,
      border_size: border_size?
    }
  )
  window.show_all
  window.top_left
  fill_in_the_tabs_with_data
  deselect_and_select_relevant_widgets
  update_the_current_working_directory
  run_main
end

#create_the_bottom_widgetObject

#

create_the_bottom_widget

#


754
755
756
# File 'lib/roebe/gui/universal_widgets/shell/shell.rb', line 754

def create_the_bottom_widget
  @bottom_widget = create_vbox
end

#create_the_button_xorg_bufferObject

#

create_the_button_xorg_buffer

#


476
477
478
479
480
481
482
# File 'lib/roebe/gui/universal_widgets/shell/shell.rb', line 476

def create_the_button_xorg_buffer
  # ======================================================================= #
  # Create the assign-to-xorg button next:
  # ======================================================================= #
  @button_xorg_buffer = ::Gtk::ButtonXorgBuffer.new(@text_buffer) { :split }
  @button_xorg_buffer.set_font(:hack_18)
end

#create_the_buttonsObject

#

create_the_buttons

#


178
179
180
181
182
183
184
185
186
187
188
189
# File 'lib/roebe/gui/universal_widgets/shell/shell.rb', line 178

def create_the_buttons
  # ======================================================================= #
  # === @button_clear_textview_widget
  # ======================================================================= #
  @button_clear_textview_widget = themed_icon(
    'edit-clear-all-symbolic.symbolic'
  ) # 'edit-paste-symbolic.symbolic')
  @button_clear_textview_widget.hint = 'Click on this button '
  @button_clear_textview_widget.on_clicked {
    textview?.clear
  }
end

#create_the_combo_boxObject

#

create_the_combo_box (combo tag)

#


194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
# File 'lib/roebe/gui/universal_widgets/shell/shell.rb', line 194

def create_the_combo_box
  # ======================================================================= #
  # Create a combo-box next.
  # ======================================================================= #
  array = []
  begin
    require 'case_parser'
    _ = Roebe::Shell.file_menu
    array << CaseParser.parse(_)
    array.flatten!
    array.reject! {|entry| entry.to_s.empty? } # Get rid of emptry lines.
    array.map! {|entry|
      entry = entry.to_s
      entry.delete!('*')
      entry.delete!('"')
      entry
    }
  rescue LoadError
  end
  # ======================================================================= #
  # === @combo_box_containing_useful_commands_from_the_case_when_menu
  # ======================================================================= #
  @combo_box_containing_useful_commands_from_the_case_when_menu = return_combo_box_entry(array)
  @combo_box_containing_useful_commands_from_the_case_when_menu.set_font(:hack_16)
  @combo_box_containing_useful_commands_from_the_case_when_menu.focus_on_the_first_element
  @combo_box_containing_useful_commands_from_the_case_when_menu.on_changed {
    if @combo_box_containing_useful_commands_from_the_case_when_menu.active_iter
      entry_user_input?.set_text(
        @combo_box_containing_useful_commands_from_the_case_when_menu.active_text+' '
      )
    end
  }
end

#create_the_directory_content_widgetObject

#

create_the_directory_content_widget

#


827
828
829
830
831
832
833
# File 'lib/roebe/gui/universal_widgets/shell/shell.rb', line 827

def create_the_directory_content_widget
  # ======================================================================= #
  # The directory-content-widget comes next.
  # ======================================================================= #
  @directory_content_widget = directory_content_widget { :omit_the_bottom_widget }
  @directory_content_widget.bblack2
end

#create_the_entriesObject

#

create_the_entries (entries tag, entry tag)

#


310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
# File 'lib/roebe/gui/universal_widgets/shell/shell.rb', line 310

def create_the_entries
  # ======================================================================= #
  # === @entry_user_input_for_the_shell
  #
  # First we will create the entry that contains the user input.
  # ======================================================================= #
  @entry_user_input_for_the_shell = create_entry
  @entry_user_input_for_the_shell.bblack1
  # @entry_user_input_for_the_shell.BG_yellow
  @entry_user_input_for_the_shell.set_activates_default(true)
  @entry_user_input_for_the_shell.enable_events
  @entry_user_input_for_the_shell.do_focus
  @entry_user_input_for_the_shell.css_class('BG_gainsboro')
  @entry_user_input_for_the_shell.border(
    PADDING_TO_USE_FOR_THE_USER_INPUT,
    PADDING_TO_USE_FOR_THE_USER_INPUT,
    PADDING_TO_USE_FOR_THE_USER_INPUT,
    PADDING_TO_USE_FOR_THE_USER_INPUT
  ) if use_gtk3? # ^^^ A smallish "border" is visually nicer, in my opinion.
  @entry_user_input_for_the_shell.fancy_hint =
    "This entry can be used to input the shell "\
    "commands. Input your <b>commands</b>here.\n"
  @entry_user_input_for_the_shell.shadow_hint =
    'Input the shell-commands here ...'
  @entry_user_input_for_the_shell.on_enter_key {
    do_evaluate_the_shell_command
  }
  @entry_user_input_for_the_shell.signal_connect(:activate) { |widget|
    do_evaluate_the_main_entry
  }
  unless @commandline_arguments.empty?
    # ===================================================================== #
    # Assign the commandline arguments to the input-box next:
    # ===================================================================== #
    @entry_user_input_for_the_shell.set_text(
      @commandline_arguments.join(' ').strip
    )
    if is_on_roebe? and !@entry_user_input_for_the_shell.text?.empty?
      do_evaluate_the_shell_command
    end
  end
  # ======================================================================= #
  # === @entry_showing_the_current_working_directory
  #
  # Next comes the entry that will show the current working directory.
  # ======================================================================= #
  @entry_showing_the_current_working_directory = create_entry
  @entry_showing_the_current_working_directory.bblack1
  @entry_showing_the_current_working_directory.set_font(:hack_15)
  @entry_showing_the_current_working_directory.width_height(400, 30)
  @entry_showing_the_current_working_directory.very_light_yellowish_background
  @entry_showing_the_current_working_directory.on_key_press_event { |widget, event|
    # ===================================================================== #
    # Handle the "enter" key next, as well as the "return" key.
    # ===================================================================== #
    case Gdk::Keyval.to_name(event.keyval)
    when 'Return','KP_Enter'
      set_pwd(
        @entry_showing_the_current_working_directory.text?
      )
      update_the_current_working_directory
    # else
    #   pp _
    end
  }
end

#create_the_eventboxObject

#

create_the_eventbox

#


761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
# File 'lib/roebe/gui/universal_widgets/shell/shell.rb', line 761

def create_the_eventbox
  @eventbox_label_current_working_directory = eventbox(
    @label_current_working_directory
  )
  # ======================================================================= #
  # === Handle left-mouse-button click events
  #
  # Let the eventbox respond to left-mouse-click, and then update the
  # widget that displays the current working directory.
  #
  # We will, however had, add a 3 seconds delay after such a click
  # event.
  # ======================================================================= #
  @eventbox_label_current_working_directory.signal_connect(:event) { |widget, event|
    case event.event_type
    when Gdk::EventType::BUTTON_PRESS
      update_the_current_working_directory
    end
  }
end

#create_the_labelsObject

#

create_the_labels (labels tag)

#


678
679
680
681
682
683
684
685
# File 'lib/roebe/gui/universal_widgets/shell/shell.rb', line 678

def create_the_labels
  # ======================================================================= #
  # === @label_current_working_directory
  # ======================================================================= #
  @label_current_working_directory = label('Current working directory → ')
  @label_current_working_directory.set_font(:hack_15)
  @label_current_working_directory.make_bold
end

#create_the_scrolled_windowObject

#

create_the_scrolled_window

This is the buffer that contains all output from the roebe-shell.

#


543
544
545
546
547
# File 'lib/roebe/gui/universal_widgets/shell/shell.rb', line 543

def create_the_scrolled_window
  @scrolled_window_containing_the_text_view = scrolled_window(text_view?) { :always }
  @scrolled_window_containing_the_text_view.set_size_request(600, 500)
  @scrolled_window_containing_the_text_view.bblack1
end

#create_the_skeletonObject Also known as: create_skeleton

#

create_skeleton (create tag, skeleton tag)

#


231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
# File 'lib/roebe/gui/universal_widgets/shell/shell.rb', line 231

def create_the_skeleton
  create_the_labels                   # (1) defined in shell_module.rb
  create_the_buttons                  # (2)
  create_the_textview_widget          # (3)
  create_the_scrolled_window          # (4)
  create_the_entries                  # (5)
  create_the_directory_content_widget # (6)
  create_the_title_label
  create_the_top_bar
  create_the_button_xorg_buffer
  create_the_combo_box
  create_the_eventbox
  create_the_bottom_widget
  # instantiate_a_flexible_vte
end

#create_the_textview_widgetObject Also known as: create_the_text_buffer_and_the_text_view

#

create_the_textview_widget

#


427
428
429
430
431
432
433
434
435
436
437
438
439
# File 'lib/roebe/gui/universal_widgets/shell/shell.rb', line 427

def create_the_textview_widget
  @text_buffer = create_text_buffer
  # ======================================================================= #
  # === @textview_widget
  # ======================================================================= #
  @textview_widget = create_text_view(@text_buffer)
  @textview_widget.bblack1
  @textview_widget.pad8px
  @textview_widget.width_height(500, 200)
  @textview_widget.set_editable(true)
  @textview_widget.visible_cursor
  @textview_widget.set_font(:hack_16)
end

#create_the_title_labelObject

#

create_the_title_label

#


267
268
269
270
271
272
273
274
# File 'lib/roebe/gui/universal_widgets/shell/shell.rb', line 267

def create_the_title_label
  # ====================================================================== #
  # === @label_title
  # ====================================================================== #
  @label_title = return_title
  @label_title.set_name('header3')
  @label_title.make_selectable
end

#create_the_top_barObject Also known as: create_the_top_widget

#

create_the_top_bar (top tag)

#


797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
# File 'lib/roebe/gui/universal_widgets/shell/shell.rb', line 797

def create_the_top_bar
  # ======================================================================= #
  # === @top_bar
  # ======================================================================= #
  @top_bar = default_top_bar { :with_close_button }
  @top_bar.spacing = 12
  @top_bar.set_custom_title(@label_title)
  # ======================================================================= #
  # Add a small clock next. This one does not work, though. The other
  # clock works, however had.
  # ======================================================================= #
  # @top_bar.add_right(emoji(:clock))
  @top_bar.add_right(::Gtk.return_simple_clock_widget { :bold })
  @top_bar.add_left(@button_clear_textview_widget)
end

#create_then_return_the_statusbarObject

#

create_then_return_the_statusbar (status tag)

#


785
786
787
788
789
790
791
792
# File 'lib/roebe/gui/universal_widgets/shell/shell.rb', line 785

def create_then_return_the_statusbar
  @statusbar = create_statusbar
  if @statusbar.respond_to? :has_resize_grip= 
    @statusbar.has_resize_grip = true
  end
  @statusbar_context_id = @statusbar.get_context_id('statusbar_gtk_shell')
  return @statusbar
end

#deselect_and_select_relevant_widgetsObject

#

deselect_and_select_relevant_widgets

#


516
517
518
519
520
521
522
# File 'lib/roebe/gui/universal_widgets/shell/shell.rb', line 516

def deselect_and_select_relevant_widgets
  Thread.new {
    sleep 0.025
    @label_title.deselect
    entry_for_the_user_input?.do_focus
  }
end

#do_evaluate_the_shell_command(i = @entry_user_input_for_the_shell.text?) ⇒ Object Also known as: evaluate_this_input_via_the_shell, evaluate_this_command, evaluate_this_input, do_evaluate_the_main_entry, do_click_the_main_button

#

do_evaluate_the_shell_command

This method can be used to “send” input to the Roebe::Shell, without depending on the main loop {} that is normally used by Roebe::Shell.

It will also modify the textview-widget on the bottom.

#


652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
# File 'lib/roebe/gui/universal_widgets/shell/shell.rb', line 652

def do_evaluate_the_shell_command(
    i = @entry_user_input_for_the_shell.text?
  )
  begin
    shell?.suiadoa(i)
    set_content_for_the_textview_widget(last_result?)
    update_the_current_working_directory # Always update the current working directory as well.
    if gtk3?
      if shell?.menu_found_no_match?
        add_status_message(:found_nothing)
      else
        add_status_message(:clear)
      end
    end
  rescue Exception => error
    pp error
  end
end

#do_require_gtk3_specific_widgetsObject

#

do_require_gtk3_specific_widgets

#


161
162
163
164
165
166
# File 'lib/roebe/gui/universal_widgets/shell/shell.rb', line 161

def do_require_gtk3_specific_widgets
  require 'gtk_paradise/widgets/gtk3/debug_widget/debug_widget.rb'
  require 'gtk_paradise/widgets/gtk3/directory_content_widget/directory_content_widget.rb'
  require 'gtk_paradise/widgets/gtk3/mini_clock/mini_clock.rb'
  require 'gtk_paradise/widgets/gtk3/button_xorg_buffer/button_xorg_buffer.rb'
end

#do_require_the_roebe_shellObject

#

do_require_the_roebe_shell

#


598
599
600
# File 'lib/roebe/gui/universal_widgets/shell/shell.rb', line 598

def do_require_the_roebe_shell
  require 'roebe/requires/require_the_roebe_shell.rb'
end

#entry_showing_the_current_working_directory?Boolean Also known as: entry_on_the_bottom?

#

entry_showing_the_current_working_directory?

#

Returns:

  • (Boolean)


612
613
614
# File 'lib/roebe/gui/universal_widgets/shell/shell.rb', line 612

def entry_showing_the_current_working_directory?
  @entry_showing_the_current_working_directory
end

#entry_user_input_for_the_shell?Boolean Also known as: main_entry?, entry_for_user_input?, entry_for_the_user_input?, entry_user_input?, user_input?

#

entry_user_input_for_the_shell?

#

Returns:

  • (Boolean)


444
445
446
# File 'lib/roebe/gui/universal_widgets/shell/shell.rb', line 444

def entry_user_input_for_the_shell?
  @entry_user_input_for_the_shell
end

#evaluate_this_for_the_shell(i) ⇒ Object

#

evaluate_this_for_the_shell

#


387
388
389
# File 'lib/roebe/gui/universal_widgets/shell/shell.rb', line 387

def evaluate_this_for_the_shell(i)
  @shell.evaluate_this_input(i)
end

#evaluate_this_user_input_before_assigning_this_as_the_new_text(i) ⇒ Object

#

evaluate_this_user_input_before_assigning_this_as_the_new_text

#


412
413
414
415
# File 'lib/roebe/gui/universal_widgets/shell/shell.rb', line 412

def evaluate_this_user_input_before_assigning_this_as_the_new_text(i)
  evaluate_this_input(i)
  @entry_user_input_for_the_shell.set_text(i)
end

#focus_on_the_bottom_widgetObject

#

focus_on_the_bottom_widget

#


469
470
471
# File 'lib/roebe/gui/universal_widgets/shell/shell.rb', line 469

def focus_on_the_bottom_widget
  text_view?.do_focus
end

#focus_on_the_user_input_gtk_entryObject

#

focus_on_the_user_input_gtk_entry

#


527
528
529
# File 'lib/roebe/gui/universal_widgets/shell/shell.rb', line 527

def focus_on_the_user_input_gtk_entry
  entry_for_user_input?.do_focus
end

#hash_designated_key_combinations?Boolean

#

hash_designated_key_combinations?

#

Returns:

  • (Boolean)


605
606
607
# File 'lib/roebe/gui/universal_widgets/shell/shell.rb', line 605

def hash_designated_key_combinations?
  HASH_DESIGNATED_KEY_COMBINATIONS
end

#instantiate_a_flexible_vteObject

#

instantiate_a_flexible_vte

#


816
817
818
819
820
821
822
# File 'lib/roebe/gui/universal_widgets/shell/shell.rb', line 816

def instantiate_a_flexible_vte
  require 'gtk_paradise/widgets/gtk3/flexible_vte/flexible_vte.rb'
  # ====================================================================== #
  # === @vte
  # ====================================================================== #
  # @vte = ::Gtk::FlexibleVte.new {{ n_tabs: 3 }}
end

#instantiate_the_roebe_shellObject

#

instantiate_the_roebe_shell

This method will instantiate a new Roebe::Shell. Currently, Roebe::Shell embedded in ruby-gtk will not use readline nor colours.

#


254
255
256
257
258
259
260
261
262
# File 'lib/roebe/gui/universal_widgets/shell/shell.rb', line 254

def instantiate_the_roebe_shell
  do_require_the_roebe_shell
  # ====================================================================== #
  # === @shell
  # ====================================================================== #
  @shell = ::Roebe::Shell.new { :do_not_enter_the_main_loop }
  @shell.do_not_use_readline
  @shell.disable_colours { :be_quiet } # For now we will disable them.
end

#last_result?Boolean Also known as: shell_result?

#

last_result?

#

Returns:

  • (Boolean)


420
421
422
# File 'lib/roebe/gui/universal_widgets/shell/shell.rb', line 420

def last_result?
  @shell.last_result?
end

#padding?Boolean

#

padding?

#

Returns:

  • (Boolean)


455
456
457
# File 'lib/roebe/gui/universal_widgets/shell/shell.rb', line 455

def padding?
  0
end

#report_return_dateObject

#

report_return_date

This is triggered via “Alt+w”.

#


281
282
283
284
# File 'lib/roebe/gui/universal_widgets/shell/shell.rb', line 281

def report_return_date
  main_entry?.set_text(__method__.to_s)
  do_click_the_main_button
end

#resetObject

#

reset (reset tag)

#


138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
# File 'lib/roebe/gui/universal_widgets/shell/shell.rb', line 138

def reset
  super() if respond_to?(:super)
  reset_the_base_module
  reset_the_internal_variables
  infer_the_namespace
  # ======================================================================= #
  # === @configuration
  # ======================================================================= #
  @configuration = [true, __dir__, namespace?]
  # ======================================================================= #
  # === Set the title, width, height and the font in use.
  # ======================================================================= #
  title_width_height_font(TITLE, WIDTH, HEIGHT, USE_THIS_FONT)
  if use_gtk3?
    do_require_gtk3_specific_widgets
    use_gtk_paradise_project_css_file
  end
  infer_the_size_automatically
end

#reset_the_shared_moduleObject

#

reset_the_shared_module

#


394
395
396
397
398
399
400
401
402
403
404
405
406
407
# File 'lib/roebe/gui/universal_widgets/shell/shell.rb', line 394

def reset_the_shared_module
  instantiate_the_roebe_shell
  # ======================================================================= #
  # === @can_we_left_mouse_button_click
  # ======================================================================= #
  @can_we_left_mouse_button_click = true
  # ======================================================================= #
  # === :last_result
  # ======================================================================= #
  if @internal_hash.nil?
    reset_the_internal_hash
  end
  @internal_hash[:last_result] = nil
end

#return_the_bottom_widget_finallyObject

#

return_the_bottom_widget_finally

#


565
566
567
# File 'lib/roebe/gui/universal_widgets/shell/shell.rb', line 565

def return_the_bottom_widget_finally
  return @bottom_widget
end

#return_the_content_of_the_vbox_on_the_right_sideObject

#

return_the_content_of_the_vbox_on_the_right_side

#


552
553
554
555
556
557
558
559
560
# File 'lib/roebe/gui/universal_widgets/shell/shell.rb', line 552

def return_the_content_of_the_vbox_on_the_right_side
  # ======================================================================= #
  # The tiny-vbox is on the right side.
  # ======================================================================= #
  tiny_vbox = create_vbox
  tiny_vbox.minimal(@button_xorg_buffer, 1)
  tiny_vbox.minimal(@combo_box_containing_useful_commands_from_the_case_when_menu, 1)
  return tiny_vbox
end

#return_titleObject

#

return_title

This main header will also make use of “header1”.

#


489
490
491
# File 'lib/roebe/gui/universal_widgets/shell/shell.rb', line 489

def return_title
  return label("☘️ #{TITLE} ☘️") # The old symbol was the fruit-emoji, aka '🌹'.
end

#runObject

#

run (run tag)

#


838
839
840
# File 'lib/roebe/gui/universal_widgets/shell/shell.rb', line 838

def run
  run_super
end

#set_content_for_the_textview_widget(i = last_result? ) ⇒ Object Also known as: update_the_textview_widget_with_this_content

#

set_content_for_the_textview_widget

#


496
497
498
499
500
501
502
503
504
# File 'lib/roebe/gui/universal_widgets/shell/shell.rb', line 496

def set_content_for_the_textview_widget(
    i = last_result?
  )
  if i.is_a? Array
    i = i.join
  end
  i = ::Colours.remove_escape_sequences(i.dup).to_s
  @textview_widget.set_text(i)
end

#set_pwd(i = @entry_showing_the_current_working_directory.text) ⇒ Object

#

set_pwd

#


634
635
636
637
638
639
640
641
# File 'lib/roebe/gui/universal_widgets/shell/shell.rb', line 634

def set_pwd(
    i = @entry_showing_the_current_working_directory.text
  )
  evaluate_this_input_via_the_shell(i)
  _ = roebe_shell?.return_pwd.to_s # Must come after the ^^^ above.
  @entry_showing_the_current_working_directory.set_text(_)
  update_the_textview_widget_with_this_content(_)
end

#set_text_in_the_main_entry_then_click_the_main_button(i) ⇒ Object

#

set_text_in_the_main_entry_then_click_the_main_button

#


626
627
628
629
# File 'lib/roebe/gui/universal_widgets/shell/shell.rb', line 626

def set_text_in_the_main_entry_then_click_the_main_button(i)
  main_entry?.set_text(i.to_s)
  do_click_the_main_button
end

#shell?Boolean Also known as: roebe_shell?

#

shell?

#

Returns:

  • (Boolean)


380
381
382
# File 'lib/roebe/gui/universal_widgets/shell/shell.rb', line 380

def shell?
  @shell
end

#show_path_in_useObject

#

show_path_in_use

#


619
620
621
# File 'lib/roebe/gui/universal_widgets/shell/shell.rb', line 619

def show_path_in_use
  set_text_in_the_main_entry_then_click_the_main_button(__method__.to_s)
end

#smaller_font?Boolean

#

smaller_font?

#

Returns:

  • (Boolean)


171
172
173
# File 'lib/roebe/gui/universal_widgets/shell/shell.rb', line 171

def smaller_font?
  SMALLER_FONT
end

#textview?Boolean

#

textview?

#

Returns:

  • (Boolean)


289
290
291
# File 'lib/roebe/gui/universal_widgets/shell/shell.rb', line 289

def textview?
  @textview_widget
end

#textview_widget?Boolean Also known as: text_view?

#

textview_widget?

#

Returns:

  • (Boolean)


509
510
511
# File 'lib/roebe/gui/universal_widgets/shell/shell.rb', line 509

def textview_widget?
  @textview_widget
end

#top_bar?Boolean Also known as: top_widget?

#

top_bar?

#

Returns:

  • (Boolean)


534
535
536
# File 'lib/roebe/gui/universal_widgets/shell/shell.rb', line 534

def top_bar?
  @top_bar
end

#update_the_current_working_directory(use_this_directory = return_pwd) ⇒ Object

#

update_the_current_working_directory

This method will merely modify the working-directory Gtk::Entry.

#


298
299
300
301
302
303
304
305
# File 'lib/roebe/gui/universal_widgets/shell/shell.rb', line 298

def update_the_current_working_directory(
    use_this_directory = return_pwd
  )
  @entry_showing_the_current_working_directory.set_text(
    use_this_directory
  )
  @directory_content_widget.set_pwd(use_this_directory) if gtk3?
end