feat: configure command and search popup anchors
This commit is contained in:
@@ -75,6 +75,46 @@ module Vamp
|
||||
end
|
||||
end
|
||||
|
||||
# Collects anchor options for the independently positioned command and search popups.
|
||||
class PopupConfig
|
||||
# @return [Hash{String => String}]
|
||||
attr_reader :command, :search
|
||||
|
||||
# @return [void]
|
||||
def initialize
|
||||
@command = {}
|
||||
@search = {}
|
||||
end
|
||||
|
||||
# @param options [Hash{String, Symbol => String, Symbol}] anchor in the workspace's 3x3 grid
|
||||
# @return [Hash{String => String}]
|
||||
def command=(options)
|
||||
@command = options!(options)
|
||||
end
|
||||
|
||||
# @param options [Hash{String, Symbol => String, Symbol}] anchor in the workspace's 3x3 grid
|
||||
# @return [Hash{String => String}]
|
||||
def search=(options)
|
||||
@search = options!(options)
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
# @param options [Hash{String, Symbol => String, Symbol}]
|
||||
# @return [Hash{String => String}]
|
||||
def options!(options)
|
||||
Vamp.chrome_hash!(options).to_h do |option, value|
|
||||
raise ArgumentError, "unknown popup option: #{option}" unless option == "anchor"
|
||||
value = value.to_s if value.is_a?(Symbol)
|
||||
value = Vamp.string!(value, "popup anchor")
|
||||
unless %w[top_left top_center top_right center_left center center_right bottom_left bottom_center bottom_right].include?(value)
|
||||
raise ArgumentError, "unknown popup anchor: #{value}"
|
||||
end
|
||||
[option, value]
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# Collects and validates the Ruby startup configuration DSL.
|
||||
class Config
|
||||
# @return [Hash{String => Boolean, Hash{String, Symbol => Object}}] language presets/options
|
||||
@@ -83,6 +123,9 @@ module Vamp
|
||||
# @return [Vamp::BarConfig]
|
||||
attr_reader :bar
|
||||
|
||||
# @return [Vamp::PopupConfig]
|
||||
attr_reader :popup
|
||||
|
||||
# @return [void]
|
||||
def initialize
|
||||
@plugins = []
|
||||
@@ -94,6 +137,7 @@ module Vamp
|
||||
@file_explorer_view = "tree"
|
||||
@clipboard_mode = "system"
|
||||
@bar = BarConfig.new
|
||||
@popup = PopupConfig.new
|
||||
@labels = {}
|
||||
@diff_context_lines = 10
|
||||
@diff_expand_lines = 15
|
||||
@@ -193,6 +237,7 @@ module Vamp
|
||||
"leader" => @leader, "file_explorer_side" => @file_explorer_side, "file_picker_view" => @file_picker_view,
|
||||
"file_explorer_view" => @file_explorer_view, "clipboard_mode" => @clipboard_mode,
|
||||
"top_bar" => @bar.top, "bottom_bar" => @bar.bottom, "labels" => @labels,
|
||||
"popup" => { "command" => @popup.command, "search" => @popup.search },
|
||||
"diff_context_lines" => @diff_context_lines, "diff_expand_lines" => @diff_expand_lines }
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user