/[freeride]/freeride/plugins/rubyide_fox_gui/editpane.rb
ViewVC logotype

Diff of /freeride/plugins/rubyide_fox_gui/editpane.rb

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.8 by ljulliar, Tue May 13 18:12:54 2003 UTC revision 1.9 by ljulliar, Thu May 15 21:38:19 2003 UTC
# Line 14  Line 14 
14  # Copyright (c) 2001 Curt Hibbs. All rights reserved.  # Copyright (c) 2001 Curt Hibbs. All rights reserved.
15  #  #
16    
17    require 'fox'
18    
19  module FreeRIDE  module FreeRIDE
20    module FoxRenderer    module FoxRenderer
21            
22        include Fox
23    
24      ##      ##
25      # This is the module that renders ediutpanes using      # This is the module that renders ediutpanes using
26      # FXScintilla.      # FXScintilla.
# Line 29  module FreeRIDE Line 33  module FreeRIDE
33                
34        def EditPane.start(plugin)        def EditPane.start(plugin)
35          edit_book_slot = plugin["/system/ui/fox/editBook"]          edit_book_slot = plugin["/system/ui/fox/editBook"]
36    
37            # Subscribe to the editpane slot to render any newly created edit pane
38          plugin["/system/ui/components/EditPane"].subscribe do |event, slot|          plugin["/system/ui/components/EditPane"].subscribe do |event, slot|
39            if (event == :notify_slot_add && slot.parent.name == 'EditPane')            if (event == :notify_slot_add && slot.parent.name == 'EditPane')
40              if (edit_book_slot.data == nil)              if (edit_book_slot.data == nil)
# Line 47  module FreeRIDE Line 53  module FreeRIDE
53              Renderer.new(plugin, slot)              Renderer.new(plugin, slot)
54            end            end
55          end          end
56            
57          # Start processing icons          # If a new icon is invoked through its slot then autoload the icon
58          plugin[ICON_PATH].subscribe do |event, slot|          plugin[ICON_PATH].subscribe do |event, slot|
59            if event == :notify_slot_add            if event == :notify_slot_add
60              app = slot['/system/ui/fox/FXApp'].data              app = slot['/system/ui/fox/FXApp'].data
# Line 60  module FreeRIDE Line 66  module FreeRIDE
66            end            end
67          end          end
68    
69            # create the Goto Line EditPane Service Dialog box
70            cmd_mgr = plugin["/system/ui/commands"].manager
71            cmd = cmd_mgr.add("EditPane/GotoLine", "Line...") do |cmd_slot|
72              GotoLineDialog.new(plugin)
73            end
74            plugin["/system/ui/keys"].manager.bind("EditPane/GotoLine", :ctrl, :G)
75    
76            cmd.availability=false
77            cmd.manage_availability do |command|
78              plugin['/system/ui/current'].subscribe do |event, slot|
79                if slot.name=="EditPane"
80                  case event
81                  when :notify_slot_link
82                    command.availability=true
83                  when :notify_slot_unlink
84                    command.availability=false
85                  end
86                end
87              end
88            end
89    
90            # Insert the "line..." menu item in the Goto menu
91            gotomenu = plugin["/system/ui/components/MenuPane/Goto_menu"].manager
92            gotomenu.add_command("EditPane/GotoLine")
93    
94          # Restore files          # Restore files
         cmd_mgr = plugin['/system/ui/commands'].manager  
95          cmd_mgr.command('/EditPane/RestoreFiles').invoke()          cmd_mgr.command('/EditPane/RestoreFiles').invoke()
96    
97          # Now only is this plugin running          # Now only is this plugin running
# Line 287  module FreeRIDE Line 317  module FreeRIDE
317                    
318        end  # class Renderer        end  # class Renderer
319                
320      end  
321          class GotoLineDialog < FXDialogBox
322    
323            include Fox
324            
325            def initialize(plugin)
326              @plugin = plugin
327              owner = plugin["/system/ui/fox/FXMainWindow"].data
328              
329              # Invoke base class initialize function first
330              super(owner, "Goto Line", DECOR_TITLE|DECOR_BORDER|DECOR_CLOSE)
331              h_frm = FXHorizontalFrame.new(self, LAYOUT_FILL_X)
332              FXLabel.new(h_frm, "Line: ", nil, JUSTIFY_LEFT|LAYOUT_CENTER_Y)
333              line_tf = FXTextField.new(h_frm, 12, nil, 0, (FRAME_SUNKEN|
334                LAYOUT_FILL_X|LAYOUT_CENTER_Y|LAYOUT_FILL_COLUMN))
335              line_tf.connect(SEL_COMMAND, method(:onCmdFetchLine))
336              line_tf.setFocus
337              self.connect(SEL_CLOSE) { self.destroy }
338              self.create
339              self.show
340            end
341            
342            def onCmdFetchLine(sender, sel, ptr)
343              line = sender.text.to_i
344              ep_slot = @plugin['/system/ui/current/EditPane']
345              ep_slot['actions/set_cursor_line'].invoke(line-1) if line > 0
346              # return focus to the edit pane when the dialog box closes
347              ep_slot['actions/make_current'].invoke()
348              self.destroy
349            end
350            
351          end # class GotoLineDialog
352    
353        end # class EditPane
354    
355    end    end
356  end  end

Legend:
Removed from v.1.8  
changed lines
  Added in v.1.9

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26