Class: Editor

Inherits:
Ruiby_gtk show all
Defined in:
lib/ruiby_gtk/editor.rb

Overview

create a dialog which contain a little editor text is colorize for ruby lang

Constant Summary

Constants included from Ruiby_dsl

Ruiby_dsl::GTK2ICONNAME

Instance Method Summary collapse

Methods inherited from Ruiby_gtk

#chrome, #on_destroy, #on_resize, #rposition, #ruiby_exit, #set_window_icon

Methods included from Ruiby_threader

#after, #anim, #init_threader, #on_idle, #threader

Methods included from Ruiby_dsl

#_, #_accept?, #_cbox, #_check_append, #_create_log_window, #_dyn_check_button, #_dyn_entry, #_dyn_fslider, #_dyn_ientry, #_dyn_islider, #_dyn_label, #_dyn_progress, #_dyn_toggle_button, #_exe_posix, #_exe_windows, #_label, #_make_prop_line, #_nocodeeeeeeeeeee, #_pack, #_paned, #_radio_buttons, #_set_accepter, #_sub_image, #aaa_generalities, #accordion, #aitem, #alabel, #append_to, #apply_options, #attribs, #autoslot, #background, #backgroundi, #bourrage, #box, #button, #button_expand, #button_icon_text, #button_left_icon_text, #buttoni, #calendar, #canvas, #canvasOld, #cell, #cell_bottom, #cell_hspan, #cell_hspan_left, #cell_hspan_right, #cell_hvspan, #cell_left, #cell_pass, #cell_right, #cell_span, #cell_top, #cell_vspan, #cell_vspan_bottom, #cell_vspan_top, #center, #check_button, #clear, #clear_append_to, #clickable, #close_dialog, #color_choice, #color_conversion, #combo, #css_name, #current_layout, cv_color_html, #def_style, #delete, #dialog, #dialog_async, #entry, #exe, #fentry, #field, #fields, #flow, #flow_paned, #flowi, #force_update, #frame, #framei, #fslider, #get_config, #get_current_container, #get_icon, #get_image, #get_image_from, #get_pixbuf, #get_pixmap, #get_stockicon_pixbuf, #grid, #haccordion, #hide_app, #hradio_buttons, #html_color, html_color, #htoolbar, #htoolbar_with_icon_text, #ientry, #image, #install_composant, #islider, #label, #label_clickable, #labeli, #left, #levelbar, #list, #log, #log_as_widget, #menu, #menu_bar, #menu_button, #menu_checkbutton, #menu_separator, #next_row, #notebook, #on_canvas_button_motion, #on_canvas_button_press, #on_canvas_button_release, #on_canvas_draw, #on_canvas_key_press, #on_canvas_resize, #on_delete, #page, #panel, #panel_async, #panel_progress, #pclickable, #pclickablie, #plot, #popup, #popup_clear_append, #pp_item, #pp_separator, #progress, #progress_bar, #properties, #propertys, #razslot, #regular, #right, #row, #script, #scrolled, #sentence, #sentenci, #separator, #show_all_children, #show_app, #show_methods, #show_source, #slider, #slot, #slot_append_after, #slot_append_before, #sloti, #snapshot, #source_editor, #space, #spacei, #spacing, #stack, #stack_paned, #stacki, #syst_add_button, #syst_add_check, #syst_add_sepratator, #syst_icon, #syst_quit_button, #systray, #systray_setup, #table, #text_area, #text_area_dyn, #toggle_button, #toolbar_button, #toolbar_separator, #tooltip, #trace, #tree_grid, #update, #var_box, #var_boxi, #vbox_scrolled, #video, #vradio_buttons, #widget_properties, #window

Methods included from Ruiby_default_dialog

#_gooooooooooo, #_process_terminal_key, #alert, #ask, #ask_color, #ask_dir_to_read, #ask_dir_to_write, #ask_file_to_read, #ask_file_to_write, #dialog_chooser, #edit, #error, #message, #prompt, #promptSync, #terminal, #trace

Constructor Details

#initialize(w, filename, width = 350, &blk) ⇒ Editor

Returns a new instance of Editor


7
8
9
10
11
12
# File 'lib/ruiby_gtk/editor.rb', line 7

def initialize(w,filename,width=350,&blk)
  @filename=filename
  super("Edit #{filename[0..40]}",width,0)
  transient_for=w
  @blk=blk
end

Instance Method Details

#componentObject


13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/ruiby_gtk/editor.rb', line 13

def component()
  stack do
      if ed=source_editor()
        @edit=slot(ed).editor
        @edit.buffer.text=File.exists?(@filename) ? File.read(@filename) : @filename
      end
      sloti( button("Exit") { 
       if @blk 
         ok=@blk.call(@edit.buffer.text)
         destroy() if ok 
       else
         destroy()
       end           
      })
  end
end