All find commands and seek command now use Symbols for the direction, even in conf files.

This commit is contained in:
Pistos 2011-07-22 13:59:08 -04:00
parent 73b2946bcf
commit 67e7eff004
6 changed files with 49 additions and 69 deletions

View file

@ -249,16 +249,16 @@ key keycode517 seek /\w(\W|$)|(?:^|\W)(\w)/
key keycode518 seek /\w(\W|$)|(?:^|\W)(\w)/
key keycode553 seek /\w(\W|$)|(?:^|\W)(\w)/
key keycode555 seek /\w(\W|$)|(?:^|\W)(\w)/
key esc left seek /\w(\W|$)|(?:^|\W)(\w)/, "up"
key esc O d seek /\w(\W|$)|(?:^|\W)(\w)/, "up"
key esc [ D seek /(?:^|\W)(\w)|\w(\W|$)/, "up"
key esc [ 1 ; 3 D seek /\w(\W|$)|(?:^|\W)(\w)/, "up"
key esc [ 1 ; 5 D seek /\w(\W|$)|(?:^|\W)(\w)/, "up"
key esc [ 1 ; ; D seek /\w(\W|$)|(?:^|\W)(\w)/, "up"
key keycode515 seek /\w(\W|$)|(?:^|\W)(\w)/, "up"
key keycode516 seek /\w(\W|$)|(?:^|\W)(\w)/, "up"
key keycode538 seek /\w(\W|$)|(?:^|\W)(\w)/, "up"
key keycode540 seek /\w(\W|$)|(?:^|\W)(\w)/, "up"
key esc left seek /\w(\W|$)|(?:^|\W)(\w)/, :up
key esc O d seek /\w(\W|$)|(?:^|\W)(\w)/, :up
key esc [ D seek /(?:^|\W)(\w)|\w(\W|$)/, :up
key esc [ 1 ; 3 D seek /\w(\W|$)|(?:^|\W)(\w)/, :up
key esc [ 1 ; 5 D seek /\w(\W|$)|(?:^|\W)(\w)/, :up
key esc [ 1 ; ; D seek /\w(\W|$)|(?:^|\W)(\w)/, :up
key keycode515 seek /\w(\W|$)|(?:^|\W)(\w)/, :up
key keycode516 seek /\w(\W|$)|(?:^|\W)(\w)/, :up
key keycode538 seek /\w(\W|$)|(?:^|\W)(\w)/, :up
key keycode540 seek /\w(\W|$)|(?:^|\W)(\w)/, :up
key esc [ 5 ; 5 ~ go_block_previous
key esc [ 6 ; 5 ~ go_block_next
key esc [ 5 ; 3 ~ go_block_outer
@ -444,15 +444,15 @@ key alt+f find nil, case_sensitive: true
#key alt+f findExact
key ctrl+alt+f find nil, word_only: true
key esc F find_clip
#key ctrl+alt+f find nil, direction: "up", case_sensitive: true
key f3 find_again "down"
key esc [ [ C find_again "down"
key esc O R find_again "down"
key esc [ 1 3 ~ find_again "down"
key f15 find_again "up"
key esc [ 2 8 ~ find_again "up"
key esc O 2 R find_again "up"
key esc [ 2 5 ~ find_again "up"
#key ctrl+alt+f find nil, direction: :up, case_sensitive: true
key f3 find_again :down
key esc [ [ C find_again :down
key esc O R find_again :down
key esc [ 1 3 ~ find_again :down
key f15 find_again :up
key esc [ 2 8 ~ find_again :up
key esc O 2 R find_again :up
key esc [ 2 5 ~ find_again :up
key ctrl+r searchAndReplace
key alt+r searchAndReplace CASE_SENSITIVE
key ctrl+alt+u clearMatches
@ -561,13 +561,13 @@ mkey input esc [ [ E readline_grep_context_decrease
mkey input f6 readline_grep_context_increase
mkey input esc [ 1 7 ~ readline_grep_context_increase
mkey input f3 find_again "down"
mkey input esc [ [ C find_again "down"
mkey input esc O R find_again "down"
mkey input esc [ 1 3 ~ find_again "down"
mkey input f15 find_again "up"
mkey input esc [ 2 8 ~ find_again "up"
mkey input esc O 2 R find_again "up"
mkey input f3 find_again :down
mkey input esc [ [ C find_again :down
mkey input esc O R find_again :down
mkey input esc [ 1 3 ~ find_again :down
mkey input f15 find_again :up
mkey input esc [ 2 8 ~ find_again :up
mkey input esc O 2 R find_again :up
# ---------------------------------------------------------------------
# Language Definitions

View file

@ -59,7 +59,7 @@ After the startup scripts are require-d, Diakonos evaluates any Ruby code given
with the -e command line argument. Here is an example of using the -e argument
to initiate a search on startup:
diakonos -e 'find "down", CASE_SENSITIVE, "search expression"' filename
diakonos -e 'find "search expression", case_sensitive: true' filename
See also the documentation on extensions.

View file

@ -241,7 +241,7 @@ module Diakonos
files = `egrep -rl '#{regexp}' *`.split( /\n/ )
if files.any?
@files.concat( files.map { |f| session_file_hash_for f } )
script = "\nfind 'down', CASE_SENSITIVE, '#{regexp}'"
script = "\nfind '#{regexp}', case_sensitive: true"
@post_load_script << script
end
when '-ro'
@ -533,23 +533,6 @@ module Diakonos
temp
end
def direction_of( str, default = :down )
case str
when "up"
:up
when /other/
:opposite
when "down"
:down
when "forward"
:forward
when "backward"
:backward
else
default
end
end
# @return [Array] the filename and line number parsed
def parse_filename_and_line_number( s )
if(

View file

@ -336,7 +336,7 @@ module Diakonos
files.each do |f|
open_file f
end
find regexp, direction: 'down', case_sensitive: true
find regexp, direction: :down, case_sensitive: true
end
end

View file

@ -49,12 +49,12 @@ module Diakonos
orig_ptr = @cursor_stack_pointer
case direction
when :backward, 'backward'
when :backward
@cursor_stack_pointer = ( @cursor_stack_pointer || @cursor_stack.length ) - 1 - delta
while different_file && @cursor_stack[ @cursor_stack_pointer ] && @cursor_stack[ @cursor_stack_pointer ][ :buffer ] == buffer_current
@cursor_stack_pointer -= 1
end
when :forward, 'forward'
when :forward
@cursor_stack_pointer = ( @cursor_stack_pointer || 0 ) + 1
while different_file && @cursor_stack[ @cursor_stack_pointer ] && @cursor_stack[ @cursor_stack_pointer ][ :buffer ] == buffer_current
@cursor_stack_pointer += 1
@ -252,4 +252,4 @@ module Diakonos
end
end
end
end

View file

@ -6,8 +6,8 @@ module Diakonos
# The regular expression to search for.
# @param [Hash] options
# Options that alter how the search is performed
# @option options [String] :direction ('down')
# The direction to search; 'down' or 'up'.
# @option options [Symbol] :direction (:down)
# The direction to search; :down or :up.
# @option options [Boolean] :case_sensitive (false)
# Whether or not the search should be case_sensitive.
# @option options [String] replacement
@ -18,7 +18,7 @@ module Diakonos
# @see #find_again
# @see #find_clip
def find( regexp_source_ = nil, options = {} )
direction = direction_of( options[:direction] )
direction = options[:direction] || :down
case_sensitive = options[:case_sensitive]
replacement = options[:replacement]
word_only = options[:word_only]
@ -85,23 +85,22 @@ module Diakonos
# Searches for matches of the latest clipboard item in the current buffer.
# Note that the clipboard item is interpreted as a regular expression.
# Only the last line of multi-line clipboard items is used.
# @param [String] dir_str
# The direction to search; 'down' (default) or 'up'.
# @param [String] direction
# The direction to search. :down (default) or :up.
# @param [Boolean] case_sensitive
# Whether or not the search should be case_sensitive. Default is insensitive.
# @see #find
def find_clip( dir_str = "down", case_sensitive = CASE_INSENSITIVE )
find @clipboard.clip[-1], direction: dir_str, case_sensitive: case_sensitive
def find_clip( direction = :down, case_sensitive = CASE_INSENSITIVE )
find @clipboard.clip[-1], direction: direction, case_sensitive: case_sensitive
end
# Search again for the most recently sought search term.
# @param [String] dir_str
# The direction to search; 'up' or 'down'.
# @param [String] direction
# The direction to search; :down or :up.
# @see #find
# @see #find_exact
def find_again( dir_str = nil )
if dir_str
direction = direction_of( dir_str )
def find_again( direction = :down )
if direction
buffer_current.find_again( @last_search_regexps, direction )
else
buffer_current.find_again( @last_search_regexps )
@ -110,13 +109,13 @@ module Diakonos
end
# Search for an exact string (not a regular expression).
# @param [String] dir_str
# The direction to search; 'down' (default) or 'up'.
# @param [Symbol] direction
# The direction to search; :down (default) or :up.
# @param [String] search_term_
# The thing to search for.
# @see #find
# @see #find_again
def find_exact( dir_str = "down", search_term_ = nil )
def find_exact( direction = :down, search_term_ = nil )
buffer_current.search_area = nil
if search_term_.nil?
if buffer_current.changing_selection
@ -131,7 +130,6 @@ module Diakonos
search_term = search_term_
end
if search_term
direction = direction_of( dir_str )
regexp = [ Regexp.new( Regexp.escape( search_term ) ) ]
buffer_current.find( regexp, :direction => direction )
@last_search_regexps = regexp
@ -154,11 +152,10 @@ module Diakonos
# The user is not prompted for any value.
# @param [String] regexp_source
# The regular expression to search for.
# @param [String] dir_str
# The direction to search; 'down' (default) or 'up'.
def seek( regexp_source, dir_str = "down" )
# @param [Symbol] direction
# The direction to search; :down (default) or :up.
def seek( regexp_source, direction = :down )
if regexp_source
direction = direction_of( dir_str )
regexp = Regexp.new( regexp_source )
buffer_current.seek( regexp, direction )
end