parent
e3725817f0
commit
624c6427d2
|
|
@ -4,6 +4,7 @@ import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"github.com/atotto/clipboard"
|
||||||
"io"
|
"io"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
|
@ -184,13 +185,14 @@ func (l *Log) bindKeys() {
|
||||||
ui.Key4: ui.NewKeyAction("30m", l.sinceCmd(30*60), true),
|
ui.Key4: ui.NewKeyAction("30m", l.sinceCmd(30*60), true),
|
||||||
ui.Key5: ui.NewKeyAction("1h", l.sinceCmd(60*60), true),
|
ui.Key5: ui.NewKeyAction("1h", l.sinceCmd(60*60), true),
|
||||||
tcell.KeyEnter: ui.NewSharedKeyAction("Filter", l.filterCmd, false),
|
tcell.KeyEnter: ui.NewSharedKeyAction("Filter", l.filterCmd, false),
|
||||||
ui.KeyC: ui.NewKeyAction("Clear", l.clearCmd, true),
|
ui.KeyL: ui.NewKeyAction("Clear", l.clearCmd, true),
|
||||||
ui.KeyM: ui.NewKeyAction("Mark", l.markCmd, true),
|
ui.KeyM: ui.NewKeyAction("Mark", l.markCmd, true),
|
||||||
ui.KeyS: ui.NewKeyAction("Toggle AutoScroll", l.toggleAutoScrollCmd, true),
|
ui.KeyS: ui.NewKeyAction("Toggle AutoScroll", l.toggleAutoScrollCmd, true),
|
||||||
ui.KeyF: ui.NewKeyAction("Toggle FullScreen", l.toggleFullScreenCmd, true),
|
ui.KeyF: ui.NewKeyAction("Toggle FullScreen", l.toggleFullScreenCmd, true),
|
||||||
ui.KeyT: ui.NewKeyAction("Toggle Timestamp", l.toggleTimestampCmd, true),
|
ui.KeyT: ui.NewKeyAction("Toggle Timestamp", l.toggleTimestampCmd, true),
|
||||||
ui.KeyW: ui.NewKeyAction("Toggle Wrap", l.toggleTextWrapCmd, true),
|
ui.KeyW: ui.NewKeyAction("Toggle Wrap", l.toggleTextWrapCmd, true),
|
||||||
tcell.KeyCtrlS: ui.NewKeyAction("Save", l.SaveCmd, true),
|
tcell.KeyCtrlS: ui.NewKeyAction("Save", l.SaveCmd, true),
|
||||||
|
ui.KeyC: ui.NewKeyAction("Copy", l.cpCmd, true),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -288,6 +290,14 @@ func (l *Log) SaveCmd(evt *tcell.EventKey) *tcell.EventKey {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (l *Log) cpCmd(evt *tcell.EventKey) *tcell.EventKey {
|
||||||
|
l.app.Flash().Info("Content copied to clipboard...")
|
||||||
|
if err := clipboard.WriteAll(l.logs.GetText(true)); err != nil {
|
||||||
|
l.app.Flash().Err(err)
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
func sanitizeFilename(name string) string {
|
func sanitizeFilename(name string) string {
|
||||||
processedString := invalidPathCharsRX.ReplaceAllString(name, "-")
|
processedString := invalidPathCharsRX.ReplaceAllString(name, "-")
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,7 @@ func TestLogAutoScroll(t *testing.T) {
|
||||||
v.GetModel().Set(dao.LogItems{dao.NewLogItemFromString("blee"), dao.NewLogItemFromString("bozo")})
|
v.GetModel().Set(dao.LogItems{dao.NewLogItemFromString("blee"), dao.NewLogItemFromString("bozo")})
|
||||||
v.GetModel().Notify()
|
v.GetModel().Notify()
|
||||||
|
|
||||||
assert.Equal(t, 14, len(v.Hints()))
|
assert.Equal(t, 15, len(v.Hints()))
|
||||||
|
|
||||||
v.toggleAutoScrollCmd(nil)
|
v.toggleAutoScrollCmd(nil)
|
||||||
assert.Equal(t, "Autoscroll: Off FullScreen: Off Timestamps: Off Wrap: Off", v.Indicator().GetText(true))
|
assert.Equal(t, "Autoscroll: Off FullScreen: Off Timestamps: Off Wrap: Off", v.Indicator().GetText(true))
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue