Browse Source

refactor tips for <app-bang>

main
familyfriendlymikey 2 years ago
parent
commit
4f93a3d79f
  1. 129
      app/components/app-bang.imba

129
app/components/app-bang.imba

@ -5,78 +5,75 @@ tag app-bang
get tips get tips
let result = [] let result = []
let temp
temp = {
click_handler: api.handle_bang.bind(api)
hotkey_handler: api.handle_bang.bind(api)
hotkey: 'return'
hotkey_display_name: "Return"
}
if state.bang_selection_index > -1 if state.bang_selection_index > -1
result.push <> temp.content = "Use History Item"
<.tip
@click=api.handle_bang
@hotkey('return').force=api.handle_bang
>
<.tip-hotkey> "Return"
<.tip-content> "Use History Item"
else else
result.push <> temp.content = "Search"
<.tip result.push temp
@click=api.handle_bang
@hotkey('return').force=api.handle_bang temp = {
> click_handler: api.handle_add_link.bind(api)
<.tip-hotkey> "Return" hotkey_handler: api.handle_add_link.bind(api)
<.tip-content> "Search" hotkey: 'shift+return'
hotkey_display_name: 'Shift + Return'
result.push <> content: "Create Link \"{state.query.trim!}\""
<.tip.ellipsis }
@click=api.handle_add_link result.push temp
@hotkey('shift+return').force=api.handle_add_link
>
<.tip-hotkey> "Shift + Return"
<.tip-content.ellipsis>
<span[ws:pre]> "Create Link "
let sq = state.query.trim!.split /\s+/
if sq.length >= 2
let url = sq.pop!
<span> '"'
<span> sq.join " "
<span[c:blue3 ws:pre]> " {url}"
<span> '"'
else
<span> "\"{sq.join " "}\""
if state.bang_selection_index > -1 if state.bang_selection_index > -1
result.push <> temp = {
<.tip click_handler: api.delete_bang_history_item.bind(api)
@click=api.delete_bang_history_item hotkey_handler: api.delete_bang_history_item.bind(api)
@hotkey('shift+backspace').force=api.delete_bang_history_item hotkey: 'shift+backspace'
> hotkey_display_name: "Shift + Backspace"
<.tip-hotkey> "Shift + Backspace" content: "Delete History Item"
<.tip-content> "Delete History Item" }
result.push temp
if state.active_bang if state.active_bang
result.push <> temp = {
<.tip click_handler: api.unset_active_bang.bind(api)
@click=api.unset_active_bang hotkey_handler: api.unset_active_bang.bind(api)
@hotkey('esc').force=api.unset_active_bang hotkey: 'esc'
> hotkey_display_name: "Esc"
<.tip-hotkey> "Esc" content: "Back"
<.tip-content> "Back" }
result.push temp
result.push <>
<.tip@click=(api.delete_bang_history! and $tips.show_more = no)> def handle_delete_bang_history
<.tip-hotkey> "Click" api.delete_bang_history!
<.tip-content> "Delete Bang History" $tips.show_more = no
temp = {
result.push <> click_handler: handle_delete_bang_history
<.tip @click=api.handle_cut> hotkey_display_name: "Click"
if api.math_result content: "Delete Bang History"
<.tip-hotkey> "Cut (Math, If No Selection)" }
<.tip-content> "Cut Math Result" result.push temp
else
<.tip-hotkey> "Cut (If No Selection)" temp = {
<.tip-content> "Cut All Text" click_handler: api.handle_cut.bind(api)
}
result.push <> if api.math_result
<.tip.noclick> temp.hotkey_display_name = "Cut (If No Selection)"
<.tip-hotkey> "Paste (If Input Empty)" temp.content = "Cut All Text"
<.tip-content> "Instant Search" else
temp.hotkey_display_name = "Cut (Math, If No Selection)"
temp.content = "Cut Math Result"
result.push temp
temp = {
hotkey_display_name: "Paste (If Input Empty)"
content: "Instant Search"
}
result.push temp
result result

Loading…
Cancel
Save