Skip to content

Commit

Permalink
feat: allow clipboard filter by numbers
Browse files Browse the repository at this point in the history
  • Loading branch information
ventsislav-georgiev committed Aug 27, 2022
1 parent 467f3c0 commit e3f0374
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 49 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ jobs:
if: steps.docker-cache.outputs.cache-hit != 'true'
run: |
mkdir -p ~/.cache/docker
cd ~/.cache/docker && wget -O fyne-cross-1.1-darwin.tar.gz ${{secrets.REMOTE_HOST}}/files/fyne-cross-1.1-darwin.tar.gz?token=${{secrets.SRV_TOKEN}}
cd ~/.cache/docker && wget -q -O fyne-cross-1.1-darwin.tar.gz ${{secrets.REMOTE_HOST}}/files/fyne-cross-1.1-darwin.tar.gz?token=${{secrets.SRV_TOKEN}}
cd ~/.cache/docker && docker load < fyne-cross-1.1-darwin.tar.gz
- name: load darwin image
Expand Down
55 changes: 7 additions & 48 deletions pkg/tools/cb/cb.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"context"
"fmt"
"image/color"
"strconv"
"strings"

"fyne.io/fyne/v2"
Expand Down Expand Up @@ -66,7 +65,7 @@ func Show() {
cell.TextStyle.Monospace = true
height := cell.MinSize().Height * linesPerClip
numbersSize = fyne.Size{Width: 0, Height: height}
clipSize = fyne.Size{Width: 400, Height: height}
clipSize = fyne.Size{Width: 450, Height: height}
}

var cbHistory clipHistory
Expand Down Expand Up @@ -99,25 +98,12 @@ func Show() {
}

onTypedKey := func(k *fyne.KeyEvent, i int) bool {
var err error

if k != nil {
if k.Name == fyne.KeyEscape {
go close()
return true
}

i, err = strconv.Atoi(string(k.Name))
if err != nil {
return false
}
if k == nil || k.Name != fyne.KeyEscape {
return false
}

i--
if i == -1 {
i = 9
}
return copyAndClose(i)
go close()
return true
}

w.Canvas().SetOnTypedKey(func(ke *fyne.KeyEvent) { onTypedKey(ke, 0) })
Expand Down Expand Up @@ -225,18 +211,6 @@ func Show() {
}

var (
indexStyle = widget.RichTextStyle{
ColorName: theme.ColorNamePlaceHolder,
Inline: false,
SizeName: theme.SizeNameCaptionText,
TextStyle: fyne.TextStyle{Italic: true, Monospace: true},
}
selectedIndexStyle = widget.RichTextStyle{
ColorName: theme.ColorNameForeground,
Inline: false,
SizeName: theme.SizeNameCaptionText,
TextStyle: fyne.TextStyle{Italic: true, Monospace: true},
}
clipStyle = widget.RichTextStyle{
ColorName: theme.ColorNamePlaceHolder,
Inline: false,
Expand Down Expand Up @@ -264,20 +238,11 @@ func populateList(history []string, list *fyne.Container, copyAndClose func(i in
var elementsOffset float32 = -9

for i, v := range history {
n := strconv.Itoa(i + 1)
if i == 9 {
n = "0"
}

istyle := indexStyle
cstyle := clipStyle
if i == selection {
istyle = selectedIndexStyle
cstyle = selectedClipStyle
}

indexContainer := container.New(fyneh.NewFixedLayout(numbersSize, elementsOffset, elementsOffset), newLabel(n, istyle))

var clip string
if v != "" {
lines := strings.Split(v, "\n")
Expand All @@ -287,21 +252,15 @@ func populateList(history []string, list *fyne.Container, copyAndClose func(i in
clip = strings.Join(lines, "↵")
}

clipContainer := fyneh.NewFixedContainer(newLabel(clip, cstyle), 5, elementsOffset)
clipContainer := fyneh.NewFixedContainer(newLabel(clip, cstyle), 0, elementsOffset)
clipContainer.SetMinSize(clipSize)
clipContainer.OnTapped = func(i int) func() {
return func() {
copyAndClose(i)
}
}(i)

item := container.NewBorder(nil, nil,
indexContainer,
nil,
clipContainer,
)

list.Add(item)
list.Add(clipContainer)
}
}

Expand Down

0 comments on commit e3f0374

Please sign in to comment.