lib/markdown_exec.rb in markdown_exec-1.3.3.4 vs lib/markdown_exec.rb in markdown_exec-1.3.3.5
- old
+ new
@@ -258,11 +258,10 @@
when name_default == false, shell_default == false
false
else
true
end.tap_inspect
- # binding.pry
rescue StandardError => err
warn("ERROR ** Filter::fcb_select?(); #{err.inspect}")
raise err
end
end # class Filter
@@ -356,11 +355,11 @@
def fcbs_per_options(opts = {})
options = opts.merge(block_name_hidden_match: nil)
selrows = @table.select do |fcb_title_groups|
Filter.fcb_select? options, fcb_title_groups
end
- # binding.pry
+
### hide rows correctly
if opts[:hide_blocks_by_name]
selrows.reject { |block| hide_menu_block_per_options opts, block }
else
@@ -661,14 +660,11 @@
selected[:name]
end
def cfile
-# puts @options.inspect
-# binding.pry
@cfile ||= CachedNestedFileReader.new(import_pattern: @options.fetch(:import_pattern))
- # @cfile ||= CachedNestedFileReader.new(import_pattern: /^ *#insert (.+)$/)
end
# :reek:DuplicateMethodCall
# :reek:UncommunicativeVariableName { exclude: [ e ] }
# :reek:LongYieldList
@@ -943,45 +939,42 @@
blocks = []
if opts[:menu_initial_divider].present?
blocks.push FCB.new({
# name: '',
chrome: true,
- text: format(
+ name: format(
opts[:menu_divider_format],
opts[:menu_initial_divider]
).send(opts[:menu_divider_color].to_sym),
disabled: '' # __LINE__.to_s
})
end
iter_blocks_in_file(opts) do |btype, fcb|
- # binding.pry
case btype
when :filter
## return type of blocks to select
#
%i[blocks line]
when :line
## convert line to block
#
- # binding.pry
if opts[:menu_divider_match].present? &&
(mbody = fcb.body[0].match opts[:menu_divider_match])
- # binding.pry
blocks.push FCB.new(
{ chrome: true,
disabled: '',
- text: format(opts[:menu_divider_format],
+ name: format(opts[:menu_divider_format],
mbody[:name]).send(opts[:menu_divider_color].to_sym) }
)
elsif opts[:menu_task_match].present? &&
(mbody = fcb.body[0].match opts[:menu_task_match])
blocks.push FCB.new(
{ chrome: true,
disabled: '',
- text: format(opts[:menu_task_format],
+ name: format(opts[:menu_task_format],
mbody[:name]).send(opts[:menu_task_color].to_sym) }
)
else
# line not added
end
@@ -994,11 +987,11 @@
if opts[:menu_divider_format].present? && opts[:menu_final_divider].present?
blocks.push FCB.new(
{ chrome: true,
disabled: '',
- text: format(opts[:menu_divider_format],
+ name: format(opts[:menu_divider_format],
opts[:menu_final_divider])
.send(opts[:menu_divider_color].to_sym) }
)
end
blocks.tap_inspect
@@ -1276,22 +1269,28 @@
execute_started_at: @execute_started_at,
execute_script_filespec: @execute_script_filespec
}
end
+ ## insert exit option at head or tail
+ #
+ def prompt_menu_add_exit(_prompt_text, items, exit_option, _opts = {})
+ if @options[:menu_exit_at_top]
+ (@options[:menu_with_exit] ? [exit_option] : []) + items
+ else
+ items + (@options[:menu_with_exit] ? [exit_option] : [])
+ end
+ end
+
## tty prompt to select
# insert exit option at head or tail
# return selected option or nil
#
def prompt_with_quit(prompt_text, items, opts = {})
exit_option = '* Exit'
- all_items = if @options[:menu_exit_at_top]
- (@options[:menu_with_exit] ? [exit_option] : []) + items
- else
- items + (@options[:menu_with_exit] ? [exit_option] : [])
- end
- sel = @prompt.select(prompt_text, all_items, opts.merge(filter: true))
+ sel = @prompt.select(prompt_text, prompt_menu_add_exit(prompt_text, items, exit_option, opts),
+ opts.merge(filter: true))
sel == exit_option ? nil : sel
end
# :reek:UtilityFunction ### temp
def read_configuration_file!(options, configuration_path)
@@ -1418,11 +1417,9 @@
)
fcb.to_h
end.compact
return nil if bm.count.zero?
-
- # binding.pry
sel = prompt_with_quit pt, bm,
per_page: opts[:select_page_height]
return nil if sel.nil?