_id
stringlengths
2
6
title
stringlengths
9
130
partition
stringclasses
3 values
text
stringlengths
66
10.5k
language
stringclasses
1 value
meta_information
dict
q23800
Canis.Table.model_row
train
def model_row index array = @list[index] array.each_with_index { |c,i| # if columns added later we could be overwriting the width ch = get_column(i) ch.width = c.to_s.length + 2 } # maintains index in current pointer and gives next or prev @column_pointer = Circular...
ruby
{ "resource": "" }
q23801
Canis.Table.save_as
train
def save_as outfile _t = "(all rows)" if @selected_indices.size > 0 _t = "(selected rows)" end unless outfile outfile = get_string "Enter file name to save #{_t} as " return unless outfile end # if there is a selection, then write only selected rows l =...
ruby
{ "resource": "" }
q23802
Canis.Table.delete_at
train
def delete_at ix return unless @list raise ArgumentError, "Argument must be within 0 and #{@list.length}" if ix < 0 or ix >= @list.length fire_dimension_changed #@list.delete_at(ix + @_header_adjustment) @list.delete_at(ix) end
ruby
{ "resource": "" }
q23803
Canis.Table.set_value_at
train
def set_value_at row,col,val actrow = row + @_header_adjustment @list[actrow , col] = val fire_row_changed actrow self end
ruby
{ "resource": "" }
q23804
Canis.Table.move_column
train
def move_column ix, newix acol = @chash.delete_at ix @chash.insert newix, acol _invalidate_width_cache #tmce = TableColumnModelEvent.new(ix, newix, self, :MOVE) #fire_handler :TABLE_COLUMN_MODEL_EVENT, tmce end
ruby
{ "resource": "" }
q23805
Canis.Table.fire_action_event
train
def fire_action_event if header_row? if @table_row_sorter x = _convert_curpos_to_column c = @chash[x] # convert to index in data model since sorter only has data_model index = c.index @table_row_sorter.toggle_sort_order index @table_row_sorter.so...
ruby
{ "resource": "" }
q23806
Canis.Table.matching_indices
train
def matching_indices raise "block required for matching_indices" unless block_given? @indices = [] ## content can be string or Chunkline, so we had to write <tt>index</tt> for this. @list.each_with_index do |fields, ix| flag = yield ix, fields if flag @indices << ix ...
ruby
{ "resource": "" }
q23807
Canis.Table.render_all
train
def render_all if @indices && @indices.count > 0 @indices.each_with_index do |ix, jx| render @pad, jx, @list[ix] end else @list.each_with_index { |line, ix| # FFI::NCurses.mvwaddstr(@pad,ix, 0, @list[ix].to_s) render @pad, ix, line } end ...
ruby
{ "resource": "" }
q23808
Enceladus::Configuration.Image.reset!
train
def reset! self.base_url = nil self.secure_base_url = nil self.backdrop_sizes = [] self.logo_sizes = [] self.logo_sizes = [] self.poster_sizes = [] self.profile_sizes = [] self.still_sizes = [] self.include_image_language = "en" self end
ruby
{ "resource": "" }
q23809
Enceladus::Configuration.Image.valid?
train
def valid? !base_url.nil? && !secure_base_url.nil? && backdrop_sizes.any? && logo_sizes.any? && poster_sizes.any? && profile_sizes.any? && still_sizes.any? end
ruby
{ "resource": "" }
q23810
Danger.DangerPronto.lint
train
def lint(commit = nil) files = pronto(commit) return if files.empty? markdown offenses_message(files) end
ruby
{ "resource": "" }
q23811
Cork.Board.path
train
def path(pathname, relative_to = Pathname.pwd) if pathname path = Pathname(pathname).relative_path_from(relative_to) "`#{path}`" else '' end end
ruby
{ "resource": "" }
q23812
Cork.Board.labeled
train
def labeled(label, value, justification = 12) if value title = "- #{label}:" if value.is_a?(Enumerable) lines = [wrap_string(title, indentation_level)] lines += value.map do |v| wrap_string("- #{v}", indentation_level + 2) end puts lines.join("\n...
ruby
{ "resource": "" }
q23813
Cork.Board.info
train
def info(message) indentation = verbose? ? @indentation_level : 0 indented = wrap_string(message, indentation) puts(indented) if block_given? @indentation_level += 2 @treat_titles_as_messages = true yield @treat_titles_as_messages = false @indentation_lev...
ruby
{ "resource": "" }
q23814
Cork.Board.title
train
def title(title, verbose_prefix = '', relative_indentation = 2) if @treat_titles_as_messages message(title, verbose_prefix) else puts_title(title, verbose_prefix) end if block_given? @indentation_level += relative_indentation @title_level += 1 yield ...
ruby
{ "resource": "" }
q23815
Cork.Board.message
train
def message(message, verbose_prefix = '', relative_indentation = 2) message = verbose_prefix + message if verbose? puts_indented message if verbose? @indentation_level += relative_indentation yield if block_given? @indentation_level -= relative_indentation end
ruby
{ "resource": "" }
q23816
Canis.Container.correct_component
train
def correct_component c raise "Form is still not set in Container" unless @form attach_form(c) unless c.form @last_row ||= @row + 1 inset = 2 # 2011-10-20 current default behaviour is to stack if @positioning == :stack c.row = @last_row c.col = @col + inset #...
ruby
{ "resource": "" }
q23817
RTanque.Runner.start
train
def start(gui = true) if gui require 'rtanque/gui' window = RTanque::Gui::Window.new(self.match) trap(:INT) { window.close } window.show else trap(:INT) { self.match.stop } self.match.start end end
ruby
{ "resource": "" }
q23818
Canis.App.loop
train
def loop &block @form.repaint @window.wrefresh Ncurses::Panel.update_panels @break_key = ?\C-q.getbyte(0) # added this extra loop since from some places we exit using throw :close # amd that was in a much higher place, and was getting us right out, with # no chance of user canc...
ruby
{ "resource": "" }
q23819
Canis.App.safe_loop
train
def safe_loop &block begin loop &block rescue => ex $log.debug( "APP.rb rescue reached ") $log.debug( ex) if ex $log.debug(ex.backtrace.join("\n")) if ex ensure close # putting it here allows it to be printed on screen, otherwise it was not showing at al...
ruby
{ "resource": "" }
q23820
Canis.App.field_help_text
train
def field_help_text f = @form.get_current_field if f.respond_to?('help_text') h = f.help_text h = "No help text defined for this field.\nTry F1, or press '?' for key-bindings." unless h textdialog "#{h}", :title => "Widget Help Text" else alert "Could not get field #{f}...
ruby
{ "resource": "" }
q23821
Canis.App.longest_in_list
train
def longest_in_list list #:nodoc: longest = list.inject(0) do |memo,word| memo >= word.length ? memo : word.length end longest end
ruby
{ "resource": "" }
q23822
Canis.App._resolve_command
train
def _resolve_command opts, cmd return cmd if opts.include? cmd matches = opts.grep Regexp.new("^#{cmd}") end
ruby
{ "resource": "" }
q23823
Canis.App.run
train
def run &block begin # check if user has passed window coord in config, else root window @window = Canis::Window.root_window awin = @window catch(:close) do @form = Form.new @window #@form.bind_key(KEY_F1, 'help'){ display_app_help } # NOT REQUIRED NOW 2012-01-...
ruby
{ "resource": "" }
q23824
Canis.App._process_args
train
def _process_args args, config, block_event, events #:nodoc: raise "FIXME seems uncalled _process_args, remove it this does not come up within a month 2014-08-19 " args.each do |arg| case arg when Array # please don't use this, keep it simple and use hash NOTE # we can ...
ruby
{ "resource": "" }
q23825
Canis.ListFooter.print
train
def print comp config = @config row = comp.row + comp.height - 1 col = comp.col + 2 len = comp.width - col g = comp.form.window # we check just in case user nullifies it deliberately, since he may have changed config values @color_pair ||= get_color($datacolor, config[:color],...
ruby
{ "resource": "" }
q23826
Canis.Window.set_layout
train
def set_layout(layout) case layout when Array $log.error "NIL in window constructor" if layout.include? nil raise ArgumentError, "Nil in window constructor" if layout.include? nil # NOTE this is just setting, and not replacing zero with max values @height, @width, @top, @lef...
ruby
{ "resource": "" }
q23827
Canis.Window.destroy
train
def destroy # typically the ensure block should have this #$log.debug "win destroy start" $global_windows.delete self Ncurses::Panel.del_panel(@panel.pointer) if @panel delwin() if @window Ncurses::Panel.update_panels # added so below window does not need to do this 2011-10-1 ...
ruby
{ "resource": "" }
q23828
Canis.Window.get_pad
train
def get_pad content_rows, content_cols pad = FFI::NCurses.newpad(content_rows, content_cols) @pads ||= [] @pads << pad ## added 2013-03-05 - 19:21 without next line how was pad being returned return pad end
ruby
{ "resource": "" }
q23829
Canis.Window.print_border_mb
train
def print_border_mb row, col, height, width, color, attr # the next is for xterm-256 att = get_attrib attr len = width len = Ncurses.COLS-0 if len == 0 # print a bar across the screen #attron(Ncurses.COLOR_PAIR(color) | att) # this works for newmessagebox but not for old one....
ruby
{ "resource": "" }
q23830
Canis.Window.print_border
train
def print_border row, col, height, width, color, att=Ncurses::A_NORMAL raise "height needs to be supplied." if height.nil? raise "width needs to be supplied." if width.nil? att ||= Ncurses::A_NORMAL #$log.debug " inside window print_border r #{row} c #{col} h #{height} w #{width} " # 200...
ruby
{ "resource": "" }
q23831
Canis.Window.print_border_only
train
def print_border_only row, col, height, width, color, att=Ncurses::A_NORMAL if att.nil? att = Ncurses::A_NORMAL else att = get_attrib att end wattron(Ncurses.COLOR_PAIR(color) | att) mvwaddch row, col, Ncurses::ACS_ULCORNER mvwhline( row, col+1, Ncurses::ACS_HLINE, ...
ruby
{ "resource": "" }
q23832
Canis.TabbedPane.goto_last_item
train
def goto_last_item bc = @buttons.count f = nil @components[bc..-1].each { |c| if c.focusable f = c end } if f leave_current_component @current_component = f set_form_row end end
ruby
{ "resource": "" }
q23833
Canis.TabbedPane.goto_next_component
train
def goto_next_component if @current_component != nil leave_current_component if on_last_component? @_entered = false return :UNHANDLED end @current_index = @components.index(@current_component) index = @current_index + 1 index.upto(@components.l...
ruby
{ "resource": "" }
q23834
Canis.TabbedPane.goto_prev_component
train
def goto_prev_component if @current_component != nil leave_current_component if on_first_component? @_entered = false return :UNHANDLED end @current_index = @components.index(@current_component) index = @current_index -= 1 index.downto(0) do |i|...
ruby
{ "resource": "" }
q23835
Canis.TabbedPane.make_buttons
train
def make_buttons names @action_buttons = [] $log.debug "XXX: came to NTP make buttons FORM= #{@form.name} names #{names} " total = names.inject(0) {|total, item| total + item.length + 4} bcol = center_column total # this craps out when height is zero brow = @row + @height-2 b...
ruby
{ "resource": "" }
q23836
Canis.ComboBox.handle_key
train
def handle_key(ch) @current_index ||= 0 # added 2009-01-18 22:44 no point moving horiz or passing up to Field if not edit if !@editable if ch == KEY_LEFT or ch == KEY_RIGHT return :UNHANDLED end end case @arrow_key_policy when :ignore if ch == KEY_D...
ruby
{ "resource": "" }
q23837
Canis.ComboBox.putc
train
def putc c if c >= 0 and c <= 127 ret = putch c.chr if ret == 0 addcol 1 if @editable set_modified end end return -1 # always ??? XXX end
ruby
{ "resource": "" }
q23838
Canis.ComboBox.putch
train
def putch char @current_index ||= 0 if @editable raise "how is it editable here in combo" super return 0 else match = next_match(char) text match unless match.nil? fire_handler :ENTER_ROW, self end @modified = true fire_handler :CHANGE...
ruby
{ "resource": "" }
q23839
Canis.ComboBox.next_match
train
def next_match char start = @current_index start.upto(@list.length-1) do |ix| if @list[ix][0,1].casecmp(char) == 0 return @list[ix] unless @list[ix] == @buffer end @current_index += 1 end ## could not find, start from zero @current_index = 0 start = ...
ruby
{ "resource": "" }
q23840
Canis.Devel.choose_file_and_view
train
def choose_file_and_view glob=nil, startdir="." glob ||= "**/*.rb" str = choose_file glob, :title => "Select a file", :directory => startdir, :help_text => "Enter pattern, use UP DOWN to traverse, Backspace to delete, ENTER to select. Esc-Esc to quit" if str and str != "" code_browse str...
ruby
{ "resource": "" }
q23841
Canis.Devel.view_properties_as_tree
train
def view_properties_as_tree field=@form.get_current_field alert "Nil field" unless field return unless field text = [] tree = {} #iv = field.instance_variables.map do |v| v.to_s; end field.instance_variables.each do |v| val = field.instance_variable_get(v) klass = val.class if ...
ruby
{ "resource": "" }
q23842
Canis.MenuSeparator.repaint
train
def repaint acolor = get_color($reversecolor, @color, @bgcolor) #@parent.window.printstring( @row, 0, "|%s|" % ("-"*@width), acolor) @parent.window.mvwhline( @row, 1, Ncurses::ACS_HLINE, @width) # these 2 are probably overwritten by the borders @parent.window.mvaddch( @row, 0, Ncurses::ACS...
ruby
{ "resource": "" }
q23843
Canis.Menu.select_item
train
def select_item ix0 return if @items.nil? or @items.empty? #$log.debug "insdie select item : #{ix0} active: #{@active_index}" if !@active_index.nil? @items[@active_index].on_leave end previtem = @active_index @active_index = ix0 if @items[ix0].enabled @item...
ruby
{ "resource": "" }
q23844
Canis.Menu.array_width
train
def array_width a longest = a.max {|a,b| a.to_s.length <=> b.to_s.length } #$log.debug "array width #{longest}" longest.to_s.length end
ruby
{ "resource": "" }
q23845
Canis.Menu.handle_key
train
def handle_key ch if !@current_menu.empty? cmenu = @current_menu.last else cmenu = self end if !@@menus.empty? cmenu = @@menus.last else cmenu = self end case ch when KEY_DOWN cmenu.select_next_item #return cmenu.fire # XXX ...
ruby
{ "resource": "" }
q23846
Canis.MenuBar.set_menu
train
def set_menu index #$log.debug "set meu: #{@active_index} #{index}" # first leave the existing window menu = @items[@active_index] menu.on_leave # hide its window, if open # now move to given menu @active_index = index menu = @items[@active_index] menu.on_enter #display ...
ruby
{ "resource": "" }
q23847
Canis.MenuBar.handle_keys
train
def handle_keys @selected = false @repaint_required = true # added 2011-12-12 otherwise keeps repainting and you see a flicker @toggle_key ||= 27 # default switch off with ESC, if nothing else defined set_menu 0 begin catch(:menubarclose) do while((ch = @window.getchar()) != @t...
ruby
{ "resource": "" }
q23848
Canis.KeyLabelPrinter.update_application_key_label
train
def update_application_key_label(display_code, new_display_code, text) @repaint_required = true labels = key_labels() raise "labels are nil !!!" unless labels labels.each_index do |ix| lab = labels[ix] next if lab.nil? if lab[0] == display_code labels[ix] = [new...
ruby
{ "resource": "" }
q23849
RubyCurses.StackFlow.handle_key
train
def handle_key ch $log.debug " STACKFLOW handle_key #{ch} " return if @components.empty? _multiplier = ($multiplier == 0 ? 1 : $multiplier ) # should this go here 2011-10-19 unless @_entered $log.warn "XXX WARN: calling ON_ENTER since in this situation it was not called" ...
ruby
{ "resource": "" }
q23850
RubyCurses.StackFlow.leave_current_component
train
def leave_current_component begin @current_component.on_leave rescue FieldValidationException => fve alert fve.to_s end # NOTE this is required, since repaint will just not happen otherwise # Some components are erroneously repainting all, after setting this to true so it i...
ruby
{ "resource": "" }
q23851
Canis.NewListSelectable.add_to_selection
train
def add_to_selection crow=@current_index-@_header_adjustment @last_clicked ||= crow min = [@last_clicked, crow].min max = [@last_clicked, crow].max case @selection_mode when :multiple @widget_scrolled = true # FIXME we need a better name if @selected_indices.include? crow ...
ruby
{ "resource": "" }
q23852
Canis.NewListSelectable.list_bindings
train
def list_bindings # what about users wanting 32 and ENTER to also go to next row automatically # should make that optional, TODO bind_key($row_selector || 32, 'toggle selection') { toggle_row_selection } # 2013-03-24 - 14:46 added condition so single select does not get these if @selection...
ruby
{ "resource": "" }
q23853
Canis.DefaultTreeModel.add
train
def add nodechild, allows_children=true, &block # calling TreeNode.add $log.debug " XXX def add of DTM #{nodechild} to root " node = @root.add nodechild, allows_children, &block if @handler # only if someone is listening, won't fire when being prepared tme = TreeModelEvent.new(row, row,:...
ruby
{ "resource": "" }
q23854
Canis.DefaultTreeModel.undo
train
def undo where raise "not yet used" return unless @delete_buffer case @delete_buffer[0] when Array @delete_buffer.each do |r| insert where, r end else insert where, @delete_buffer end end
ruby
{ "resource": "" }
q23855
Canis.DefaultTreeModel.data=
train
def data=(data) raise "not yet used" raise "Data nil or invalid" if data.nil? or data.size == 0 delete_all @data = data tme = TreeModelEvent.new(0, @data.length-1,:ALL_COLUMNS, self, :INSERT) fire_handler :TREE_MODEL_EVENT, tme end
ruby
{ "resource": "" }
q23856
Canis.TreeNode.add
train
def add node, allows_children=true, &block raise IllegalStateException, "Cannot add a child to this node" unless @allows_children $log.debug " XXX def add of TreeNode #{node} parent #{self} " case node when Array node.each do |e| add e, allows_children, &block end ...
ruby
{ "resource": "" }
q23857
Canis.TreeNode.user_object_path
train
def user_object_path arr = [] arr << self.user_object.to_s traverse_up do |e| arr << e.user_object.to_s end arr.reverse! end
ruby
{ "resource": "" }
q23858
Canis.Bottomline.say
train
def say statement, config={} @window ||= _create_footer_window #@window.show #unless @window.visible? $log.debug "XXX: inside say win #{@window} !" case statement when Question if config.has_key? :color_pair $log.debug "INSIDE QUESTION 2 " if $log.debug? else ...
ruby
{ "resource": "" }
q23859
Canis.Bottomline.say_with_pause
train
def say_with_pause statement, config={} @window ||= _create_footer_window #@window.show #unless @window.visible? # 2011-10-14 23:52:52 say statement, config @window.wrefresh Ncurses::Panel.update_panels ch=@window.getchar() hide_bottomline ## return char so we can use for...
ruby
{ "resource": "" }
q23860
Canis.Bottomline.say_with_wait
train
def say_with_wait statement, config={} @window ||= _create_footer_window #@window.show #unless @window.visible? # 2011-10-14 23:52:59 say statement, config @window.wrefresh Ncurses::Panel.update_panels sleep 0.5 hide_bottomline end
ruby
{ "resource": "" }
q23861
Canis.Bottomline.explain_error
train
def explain_error( error ) say_with_pause(@question.responses[error]) unless error.nil? if @question.responses[:ask_on_error] == :question say(@question) elsif @question.responses[:ask_on_error] say(@question.responses[:ask_on_error]) end end
ruby
{ "resource": "" }
q23862
Canis.Bottomline.print_str
train
def print_str(text, config={}) win = config.fetch(:window, @window) # assuming its in App x = config.fetch :x, 0 # @message_row # Ncurses.LINES-1, 0 since one line window 2011-10-8 y = config.fetch :y, 0 $log.debug "XXX: print_str #{win} with text : #{text} at #{x} #{y} " color = config[...
ruby
{ "resource": "" }
q23863
Canis.Bottomline.display_text_interactive
train
def display_text_interactive text, config={} require 'canis/core/util/rcommandwindow' ht = config[:height] || 15 layout = { :height => ht, :width => Ncurses.COLS-1, :top => Ncurses.LINES-ht+1, :left => 0 } rc = CommandWindow.new nil, :layout => layout, :box => true, :title => config[:title] ...
ruby
{ "resource": "" }
q23864
Canis.Bottomline.list
train
def list( items, mode = :rows, option = nil ) items = items.to_ary.map do |item| ERB.new(item, nil, "%").result(binding) end case mode when :inline option = " or " if option.nil? case items.size when 0 "" when 1 items.first when 2 "...
ruby
{ "resource": "" }
q23865
DelSolr.Document.construct_field_tag
train
def construct_field_tag(name, value, options={}) options[:name] = name.to_s use_cdata = options.delete(:cdata) return "<field#{options.to_xml_attribute_string}>#{use_cdata ? cdata(value) : value}</field>\n" end
ruby
{ "resource": "" }
q23866
Canis.DefaultListSelectionModel.goto_next_selection
train
def goto_next_selection return if selected_rows().length == 0 row = selected_rows().sort.find { |i| i > @obj.current_index } row ||= @obj.current_index #@obj.current_index = row @obj.goto_line row end
ruby
{ "resource": "" }
q23867
Canis.DefaultListSelectionModel.goto_prev_selection
train
def goto_prev_selection return if selected_rows().length == 0 row = selected_rows().sort{|a,b| b <=> a}.find { |i| i < @obj.current_index } row ||= @obj.current_index #@obj.current_index = row @obj.goto_line row end
ruby
{ "resource": "" }
q23868
Canis.DefaultListSelectionModel.remove_row_selection_interval
train
def remove_row_selection_interval ix0, ix1 @anchor_selection_index = ix0 @lead_selection_index = ix1 arr = @selected_indices.dup # to un highlight @selected_indices.delete_if {|x| x >= ix0 and x <= ix1 } arr.each {|i| @obj.fire_row_changed(i) } lse = ListSelectionEvent.new(ix0, ix1, ...
ruby
{ "resource": "" }
q23869
Canis.DefaultListSelectionModel.ask_select
train
def ask_select prompt="Enter selection pattern: " ret = get_string prompt return if ret.nil? || ret == "" indices = get_matching_indices ret #$log.debug "listselectionmodel: ask_select got matches#{@indices} " return if indices.nil? || indices.empty? indices.each { |e| # wil...
ruby
{ "resource": "" }
q23870
Canis.DefaultListSelectionModel.ask_unselect
train
def ask_unselect prompt="Enter selection pattern: " ret = get_string prompt return if ret.nil? || ret == "" indices = get_matching_indices ret return if indices.nil? || indices.empty? indices.each { |e| # will not work if single select !! FIXME remove_row_selection_interva...
ruby
{ "resource": "" }
q23871
Canis.DefaultListSelectionModel.list_bindings
train
def list_bindings # freeing space for paging, now trying out 'v' as selector. 2014-04-14 - 18:57 @obj.bind_key($row_selector || 'v'.ord, 'toggle selection') { toggle_row_selection } # the mode may be set to single after the constructor, so this would have taken effect. if @obj.selection_...
ruby
{ "resource": "" }
q23872
RubyCurses.ModStack.item_for
train
def item_for widget each do |e| if e.is_a? Item if e.widget == widget return e end end end return nil end
ruby
{ "resource": "" }
q23873
Canis.ApplicationHeader.print_center
train
def print_center(htext, r = 0, c = 0) win = @window len = win.getmaxx len = Ncurses.COLS-0 if len == 0 || len > Ncurses.COLS # win.printstring r, ((len-htext.length)/2).floor, htext, @color_pair, @attr end
ruby
{ "resource": "" }
q23874
Canis.ApplicationHeader.print_top_right
train
def print_top_right(htext) hlen = htext.length len = @window.getmaxx # width was not changing when resize happens len = Ncurses.COLS-0 if len == 0 || len > Ncurses.COLS #$log.debug " def print_top_right(#{htext}) #{len} #{Ncurses.COLS} " @form.window.printstring 0, len-hlen, htext, @color_...
ruby
{ "resource": "" }
q23875
Cream::Helper.Role.owner?
train
def owner? obj, relation=nil if relation return true if user_relation?(obj, relation) end [:user, :owner, :author].each do |relation| return true if user_relation?(obj, relation) end false end
ruby
{ "resource": "" }
q23876
DelSolr.Client.prepare_update_xml
train
def prepare_update_xml(options = {}) r = ["<add#{options.to_xml_attribute_string}>\n"] # copy and clear pending docs working_docs, @pending_documents = @pending_documents, nil working_docs.each { |doc| r << doc.xml } r << "\n</add>\n" r.join # not sure, but I think Array#join is fast...
ruby
{ "resource": "" }
q23877
Canis.Utils.suspend
train
def suspend _suspend(false) do system("tput cup 26 0") system("tput ed") system("echo Enter C-d to return to application") system (ENV['PS1']='\s-\v\$ ') if ENV['SHELL']== '/bin/bash' system(ENV['SHELL']); end end
ruby
{ "resource": "" }
q23878
Canis.Utils.shell_output
train
def shell_output $shell_history ||= [] cmd = get_string("Enter shell command:", :maxlen => 50) do |f| require 'canis/core/include/rhistory' f.extend(FieldHistory) f.history($shell_history) end if cmd && !cmd.empty? run_command cmd $shell_history.push(cmd) ...
ruby
{ "resource": "" }
q23879
Canis.PrefixCommand.define_key
train
def define_key _keycode, *args, &blk _symbol = @symbol h = $rb_prefix_map[_symbol] raise ArgumentError, "No such keymap #{_symbol} defined. Use define_prefix_command." unless h _keycode = _keycode[0].getbyte(0) if _keycode[0].class == String arg = args.shift if arg.is_a? String ...
ruby
{ "resource": "" }
q23880
Canis.Tabular.column_width
train
def column_width colindex, width @cw[colindex] ||= width if @chash[colindex].nil? @chash[colindex] = ColumnInfo.new("", width) else @chash[colindex].w = width end @chash end
ruby
{ "resource": "" }
q23881
Canis.Tabular.render
train
def render buffer = [] _guess_col_widths rows = @list.size.to_s.length @rows = rows _prepare_format str = "" if @numbering str = " "*(rows+1)+@y end str << @fmstr % @columns buffer << str #puts "-" * str.length buffer << separator ...
ruby
{ "resource": "" }
q23882
Abn.Client.search_by_acn
train
def search_by_acn(acn) self.errors << "No ACN provided." && return if acn.nil? self.errors << "No GUID provided. Please obtain one at - http://www.abr.business.gov.au/Webservices.aspx" && return if self.guid.nil? begin client = Savon.client(self.client_options) response = client.call(...
ruby
{ "resource": "" }
q23883
Canis.ViEditable.vieditable_init_listbox
train
def vieditable_init_listbox $log.debug " inside vieditable_init_listbox " @editable = true bind_key( ?C, :edit_line) bind_key( ?o) { insert_line(@current_index+1) } bind_key( ?O) { insert_line(@current_index) } bind_key( [?d, ?d] , :delete_line ) bind_key( ?\C-_ ) { @undo_ha...
ruby
{ "resource": "" }
q23884
Canis.ViEditable.vieditable_init_tabular
train
def vieditable_init_tabular $log.debug " inside vieditable_init tabular" @editable = true #bind_key( ?C, :edit_line) #bind_key( ?o, :insert_line) #bind_key( ?O) { insert_line(@current_index-1) } #bind_key( ?o) { insert_line(@current_index+1) } #bind_key( ?O) { insert_line(@cu...
ruby
{ "resource": "" }
q23885
Canis.ViEditable.edit_line
train
def edit_line lineno=@current_index line = self[lineno] prompt = "Edit: " maxlen = 80 config={}; oldline = line.dup config[:default] = line ret, str = rb_getstr(@form.window, $error_message_row, $error_message_col, prompt, maxlen, config) $log.debug " rb_getstr returned...
ruby
{ "resource": "" }
q23886
Canis.ViEditable.edit_string
train
def edit_string string, prompt="Edit: ", maxlen=80 config={}; config[:default] = string ret, str = rb_getstr(@form.window, $error_message_row, $error_message_col, prompt, maxlen, config) #return str if ret == 0 #return "" end
ruby
{ "resource": "" }
q23887
Canis.ViEditable.input_string
train
def input_string prompt="Insert: ", maxlen=80 #ret, str = rb_getstr(@form.window, $error_message_row, $error_message_col, prompt, maxlen, config) ret, str = rb_getstr(@form.window, $error_message_row, $error_message_col, prompt, maxlen, config) #return str if ret == 0 #return "" end
ruby
{ "resource": "" }
q23888
Canis.TextPad.fire_row_changed
train
def fire_row_changed ix return if ix >= @list.length clear_row @pad, ix # allow documents to reparse that line fire_handler :ROW_CHANGED, ix _arr = _getarray render @pad, ix, _arr[ix] end
ruby
{ "resource": "" }
q23889
Canis.TextPad.forward_regex
train
def forward_regex regex if regex.is_a? Symbol regex = @text_patterns[regex] raise "Pattern specified #{regex} does not exist in text_patterns " unless regex end $multiplier = 1 if !$multiplier || $multiplier == 0 line = @current_index _arr = _getarray buff = _arr[line...
ruby
{ "resource": "" }
q23890
Canis.TextPad._handle_key
train
def _handle_key ch begin ret = process_key ch, self $multiplier = 0 bounds_check rescue => err $log.error " TEXTPAD ERROR _handle_key #{err} " $log.debug(err.backtrace.join("\n")) alert "#{err}" #textdialog ["Error in TextPad: #{err} ", *err.backtrace]...
ruby
{ "resource": "" }
q23891
Canis.TextPad.on_enter_row
train
def on_enter_row arow return nil if @list.nil? || @list.size == 0 @repaint_footer_required = true ## can this be done once and stored, and one instance used since a lot of traversal will be done require 'canis/core/include/ractionevent' aev = TextActionEvent.new self, :ENTER_ROW, current...
ruby
{ "resource": "" }
q23892
Canis.TextPad.next_regex
train
def next_regex regex if regex.is_a? Symbol regex = @text_patterns[regex] raise "Pattern specified #{regex} does not exist in text_patterns " unless regex end @last_regex = regex find_more end
ruby
{ "resource": "" }
q23893
Canis.AbstractTextPadRenderer.pre_render
train
def pre_render @attr = @source.attr cp = get_color($datacolor, @source.color(), @source.bgcolor()) @color_pair = @source.color_pair || cp @cp = FFI::NCurses.COLOR_PAIR(cp) end
ruby
{ "resource": "" }
q23894
Canis.AbstractTextPadRenderer.render_all
train
def render_all pad, arr pre_render @content_cols = @source.pad_cols @clearstring = " " * @content_cols @list = arr att = @attr || NORMAL FFI::NCurses.wattron(pad, @cp | att) arr.each_with_index { |line, ix| render pad, ix, line } FFI::NCurses.wattroff(pad,...
ruby
{ "resource": "" }
q23895
Canis.DefaultRenderer.render
train
def render pad, lineno, text if text.is_a? AbstractChunkLine text.print pad, lineno, 0, @content_cols, color_pair, attr return end ## messabox does have a method to paint the whole window in bg color its in rwidget.rb att = NORMAL FFI::NCurses.wattron(pad, @cp | att) ...
ruby
{ "resource": "" }
q23896
Canis.FieldHistory.history
train
def history arr return @history unless arr if arr.is_a? Array @history = arr else @history << arr unless @history.include? arr end end
ruby
{ "resource": "" }
q23897
Canis.MultiBuffers.add_content
train
def add_content text, config={} unless @_buffers bind_key(?\M-n, :buffer_next) bind_key(?\M-p, :buffer_prev) bind_key(KEY_BACKSPACE, :buffer_prev) # backspace, already hardcoded in textview ! bind_key(?:, :buffer_menu) end @_buffers ||= [] @_buffers_conf ||= [] ...
ruby
{ "resource": "" }
q23898
Canis.MultiBuffers.add_files
train
def add_files filearray, config={} filearray.each do |e| add_content(e, config.dup); end end
ruby
{ "resource": "" }
q23899
Canis.MultiBuffers.buffer_next
train
def buffer_next buffer_update_info @_buffer_ctr += 1 x = @_buffer_ctr l = @_buffers[x] if l populate_buffer_from_filename x else @_buffer_ctr = 0 end set_content @_buffers[@_buffer_ctr], @_buffers_conf[@_buffer_ctr] buffer_update_position end
ruby
{ "resource": "" }