Module: Diakonos

Defined in:
lib/diakonos/installation.rb,
lib/diakonos.rb,
lib/diakonos/mode.rb,
lib/diakonos/grep.rb,
lib/diakonos/ctag.rb,
lib/diakonos/list.rb,
lib/diakonos/help.rb,
lib/diakonos/mouse.rb,
lib/diakonos/hooks.rb,
lib/diakonos/about.rb,
lib/diakonos/keying.rb,
lib/diakonos/search.rb,
lib/diakonos/buffer.rb,
lib/diakonos/window.rb,
lib/diakonos/config.rb,
lib/diakonos/cursor.rb,
lib/diakonos/key-map.rb,
lib/diakonos/finding.rb,
lib/diakonos/logging.rb,
lib/diakonos/version.rb,
lib/diakonos/display.rb,
lib/diakonos/bookmark.rb,
lib/diakonos/sessions.rb,
lib/diakonos/readline.rb,
lib/diakonos/extension.rb,
lib/diakonos/functions.rb,
lib/diakonos/text-mark.rb,
lib/diakonos/clipboard.rb,
lib/diakonos/buffer/undo.rb,
lib/diakonos/interaction.rb,
lib/diakonos/buffer/file.rb,
lib/diakonos/extension-set.rb,
lib/diakonos/buffer/cursor.rb,
lib/diakonos/buffer/delete.rb,
lib/diakonos/functions/tags.rb,
lib/diakonos/display/format.rb,
lib/diakonos/buffer/display.rb,
lib/diakonos/functions/shell.rb,
lib/diakonos/clipboard-xclip.rb,
lib/diakonos/functions/search.rb,
lib/diakonos/functions/cursor.rb,
lib/diakonos/buffer/selection.rb,
lib/diakonos/buffer/searching.rb,
lib/diakonos/functions/basics.rb,
lib/diakonos/clipboard-klipper.rb,
lib/diakonos/functions/buffers.rb,
lib/diakonos/buffer-management.rb,
lib/diakonos/functions/sessions.rb,
lib/diakonos/buffer/bookmarking.rb,
lib/diakonos/functions/grepping.rb,
lib/diakonos/buffer/indentation.rb,
lib/diakonos/readline/functions.rb,
lib/diakonos/functions/readline.rb,
lib/diakonos/functions/selection.rb,
lib/diakonos/functions/clipboard.rb,
lib/diakonos/functions-deprecated.rb,
lib/diakonos/functions/bookmarking.rb,
lib/diakonos/functions/indentation.rb,
lib/diakonos/clipboard-klipper-dbus.rb,
lib/diakonos/functions/text-manipulation.rb

Overview

This file is completely overwritten by install.rb upon installation. This copy is here to permit the tests to execute.

Defined Under Namespace

Modules: Display, Functions, KeyMap, Keying Classes: Bookmark, Buffer, CTag, Clipboard, ClipboardKlipper, ClipboardKlipperDBus, ClipboardXClip, Diakonos, Extension, ExtensionSet, Finding, Mode, Readline, Session, TextMark, Window

Constant Summary

DONT_ADJUST_ROW =
false
ADJUST_ROW =
true
PROMPT_OVERWRITE =
true
DONT_PROMPT_OVERWRITE =
false
QUIET =
true
NOISY =
false
AFTER_CHAR =
true
ON_CHAR =
false
INCLUSIVE =
true
NOT_INCLUSIVE =
false
DEFAULT_TAB_SIZE =
8
FORCE_REVERT =
true
ASK_REVERT =
false
ASK_REPLACEMENT =
true
NO_REPLACEMENT =
nil
CASE_SENSITIVE =
true
CASE_INSENSITIVE =
false
LANG_TEXT =
'text'
BOL_ZERO =
0
BOL_FIRST_CHAR =
1
BOL_ALT_ZERO =
2
BOL_ALT_FIRST_CHAR =
3
EOL_END =
0
EOL_LAST_CHAR =
1
EOL_ALT_END =
2
EOL_ALT_LAST_CHAR =
3
VERSION =
'0.9.4'
LAST_MODIFIED =
'September 20, 2014'
DO_REDRAW =
true
DONT_REDRAW =
false
TAB =
9
ENTER =
13
ESCAPE =
27
BACKSPACE =
127
CTRL_C =
3
CTRL_D =
4
CTRL_K =
11
CTRL_Q =
17
CTRL_H =
263
CTRL_W =
23
RESIZE2 =
4294967295
DO_COMPLETE =
true
DONT_COMPLETE =
false
CHOICE_NO =
0
CHOICE_YES =
1
CHOICE_ALL =
2
CHOICE_CANCEL =
3
CHOICE_YES_TO_ALL =
4
CHOICE_NO_TO_ALL =
5
CHOICE_YES_AND_STOP =
6
CHOICE_DELETE =
7
CHOICE_WITHIN_SELECTION =
8
CHOICE_KEYS =
[
  ["n".ord, "N".ord],
  ["y".ord, "Y".ord],
  ["a".ord, "A".ord],
  ["c".ord, "C".ord, ESCAPE, CTRL_C, CTRL_D, CTRL_Q],
  ["e".ord],
  ["o".ord],
  ["s".ord],
  ["d".ord],
  ["w".ord],
]
CHOICE_STRINGS =
[
  '(n)o',
  '(y)es',
  '(a)ll',
  '(c)ancel',
  'y(e)s to all',
  'n(o) to all',
  'yes and (s)top',
  '(d)elete',
  'all (w)ithin selection',
]
INSTALL_SETTINGS =
{
  :prefix   => '.',
  :bin_dir  => 'bin',
  :doc_dir  => '.',
  :help_dir => 'help',
  :conf_dir => '.',
  :lib_dir  => 'lib',
  :installed => {
    :files => [],
    :dirs => [],
  },
}
CLEAR_STACK_POINTER =
true
DONT_CLEAR_STACK_POINTER =
false
DIFFERENT_FILE =
true
NOT_DIFFERENT_FILE =
false

Class Method Summary (collapse)

Class Method Details

+ (Object) check_ruby_version



11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/diakonos/version.rb', line 11

def self.check_ruby_version
  ruby_version = parse_version( RUBY_VERSION )
  if ruby_version < [ 2, 0 ]
    $stderr.puts "This version of Diakonos (#{Diakonos::VERSION}) requires Ruby 2.0."
    if ruby_version >= [ 1, 9 ]
      $stderr.puts "Version 0.9.2 is the last version of Diakonos which can run under Ruby 1.9."
    elsif ruby_version >= [ 1, 8 ]
      $stderr.puts "Version 0.8.9 is the last version of Diakonos which can run under Ruby 1.8."
    end
    exit 1
  end
end

+ (Object) grep_array(regexp, array, lines_of_context, prefix, filepath)



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
# File 'lib/diakonos/grep.rb', line 2

def self.grep_array( regexp, array, lines_of_context, prefix, filepath )
  num_lines = array.size
  line_numbers = []
  array.each_with_index do |line,index|
    next if line !~ regexp
    start_index = [ 0, index - lines_of_context ].max
    end_index = [ index + lines_of_context, num_lines-1 ].min
    (start_index..end_index).each do |i|
      line_numbers << i
    end
  end

  line_numbers.uniq!
  results = []
  last_i = line_numbers[ 0 ]
  one_result = []
  line_numbers.each do |i|
    if i - last_i > 1
      results << one_result.join( "\n" )
      one_result = []
    end
    one_result << ( "#{prefix}#{i+1}: " << ( "%-300s | #{filepath}:#{i+1}" % array[ i ] ) )
    last_i = i
  end
  if ! one_result.empty?
    results << one_result.join( "\n" )
  end

  results
end

+ (Array) parse_filename_and_line_number(s)



127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
# File 'lib/diakonos.rb', line 127

def self.parse_filename_and_line_number( s )
  if(
    # Ruby
    s =~ /from (.+):(\d+)/ ||
    # Python
    s =~ /File "(.+)", line (\d+)/ ||
    # Perl
    s =~ /at (.+) line (\d+)/ ||
    # generic
    s =~ /^(.+):(\d+)/
  )
    [ $1, ( $2.to_i - 1 ) ]
  else
    [ s, nil ]
  end
end

+ (Object) parse_version(s)



5
6
7
8
9
# File 'lib/diakonos/version.rb', line 5

def self.parse_version( s )
  if s
    s.split( '.' ).map { |part| part.to_i }.extend( Comparable )
  end
end