Browse Source

add cutting and copying math result

main
familyfriendlymikey 2 years ago
parent
commit
4d1cd1eb86
  1. 26
      app/client.imba

26
app/client.imba

@ -384,7 +384,6 @@ tag app
get math_result get math_result
try try
let result = Number(eval_math state.query) let result = Number(eval_math state.query)
throw _ if result.toString! is state.query.trim!
throw _ if isNaN result throw _ if isNaN result
result result
catch catch
@ -444,6 +443,20 @@ tag app
get pretty_date get pretty_date
Date!.toString!.split(" ").slice(0, 4).join(" ") Date!.toString!.split(" ").slice(0, 4).join(" ")
def handle_click_copy s
try
await window.navigator.clipboard.writeText(s)
state.query = ''
sort_links!
def handle_cut e
return unless e.target.selectionStart == e.target.selectionEnd
let s = math_result
s ||= state.query
await window.navigator.clipboard.writeText(s)
state.query = ''
sort_links!
def render def render
css .disabled * css .disabled *
@ -635,9 +648,10 @@ tag app
css .side css .side
c:purple3/90 fs:15px c:purple3/90 fs:15px
d:flex ja:center w:30px d:flex ja:center w:30px
cursor:pointer
css .side svg css .side svg
w:15px cursor:pointer w:15px
css .left css .left
d:flex jc:left d:flex jc:left
@ -666,11 +680,15 @@ tag app
@input.if(!loading)=handle_input @input.if(!loading)=handle_input
@paste.if(!loading)=handle_paste @paste.if(!loading)=handle_paste
@blur=this.focus @blur=this.focus
@cut=handle_cut
disabled=loading disabled=loading
> >
if (let m = math_result) isnt no let m = math_result
<[c:blue3 pt:15px fs:20px ml:10px]> "= {m}" if m isnt no and m.toString! isnt state.query.trim!
<.side.right[c:blue3 fs:20px ml:10px w:unset]
@click=handle_click_copy(m)
> "= {m}"
else else
<.side.right @click.if(!loading)=toggle_settings> <.side.right @click.if(!loading)=toggle_settings>
<svg src="./assets/settings.svg"> <svg src="./assets/settings.svg">

Loading…
Cancel
Save