Browse Source

add an option to display reply stub. Rendering blocked by cview

v0.6.0-dev
bacardi55 10 months ago
parent
commit
219f6bc81f
  1. 5
      CHANGELOG.md
  2. 7
      config/config.go
  3. 1
      core/structs.go
  4. 7
      docs/config.md
  5. 34
      ui/tuishortcuts.go

5
CHANGELOG.md

@ -16,6 +16,7 @@ CHANGELOG
* #36: Show the tinylog entry being replied to: When selecting an entry with J/K, if the entry is a response to another tinylog entry and in the RFC format for a response, it will show the original entry in a popup when using "T" (uppercase)?
* #35: parser v2: Improve parser to be compatible with proposition 15 of the RFC (https://codeberg.org/bacardi55/gemini-tinylog-rfc/issues/15) that allow multiple break line in posts. Also improve parsing in general.
* Implement a modal for entry details via alt+enter
* Implement `tui_show_stub` option to show the stub to copy instead (or additionally) of copying it to the clipboard. Can be useful if you run gtl without X and/or are using tools like tmux to copy texts. Idea is from @szczezuja.
## Smaller improvements:
* [TUI] Add optional limit to number of displayed entries: Allow to limit the number of entries displayed in the timeline. See `tui_max_entries` option in README.
@ -30,6 +31,10 @@ CHANGELOG
* Fix limit bug in cli mode
* Remove date format duplicate
## Known Issues:
* Text in modal is not nicely formatted (eg: Thread or reply stub). This is due to an issue in cview: https://code.rocketnine.space/tslocum/cview/issues/72
* Clicks in timeline don't select an entry. Indeed, this is on purpose to block an issue in cview when selecting a specific region: https://code.rocketnine.space/tslocum/cview/issues/73
Please read the README that has been updated accordingly.
## 0.5.2

7
config/config.go

@ -58,6 +58,13 @@ tui_max_entries = 0
# Copy a pre formatted text to clipboard when creating a new entry
# On linux, requires 'xclip' or 'xsel'
tui_copy_stub_clipboard = false
# If you are running gtl without X, the copy to clipboard feature
# will not work (Or if you don't have xclip or xsel).
# In this case, enabling this option will allow gtl to display
# the sub text in a modal for easy copy in tools like tmux
# At this stage, the rendering is ugly because of an issue in cview:
# https://code.rocketnine.space/tslocum/cview/issues/72#issuecomment-3968
tui_show_stub = false
`)
func Init(configArg string, Data *core.TlData) {

1
core/structs.go

@ -41,6 +41,7 @@ type TlConfig struct {
Post_edit_refresh bool
Tui_max_entries int
Tui_copy_stub_clipboard bool
Tui_show_stub bool
}
type TlFeed struct {

7
docs/config.md

@ -52,6 +52,13 @@ tui_max_entries = 0
# On linux, requires 'xclip' or 'xsel'
# Settings available since v0.6.0
tui_copy_stub_clipboard = false
# If you are running gtl without X, the copy to clipboard feature
# will not work (Or if you don't have `xclip` or `xsel`).
# In this case, enabling this option will allow gtl to display
# the sub text in a modal for easy copy in tools like tmux
# At this stage, the rendering is ugly because of an issue in cview:
# https://code.rocketnine.space/tslocum/cview/issues/72#issuecomment-3968
tui_show_stub = false
```
By default, gtl will look for ~/.config/gtl/gtl.toml . It will create it if needed.

34
ui/tuishortcuts.go

@ -272,9 +272,7 @@ func shiftEnterHandler(ev *tcell.EventKey) *tcell.EventKey {
// Manage editor related feature.
func openEditorHandler(ev *tcell.EventKey) *tcell.EventKey {
mainButtonName, buttonName, message, execFunc := "Cancel", "", "", func() {}
if TlTui.Clipboard.Enabled == true {
if TlTui.Clipboard.Enabled || TlTui.TlConfig.Tui_show_stub {
var text string
if ev.Rune() == 'R' {
if TlTui.SelectedEntry == -1 {
@ -291,11 +289,33 @@ func openEditorHandler(ev *tcell.EventKey) *tcell.EventKey {
} else if ev.Rune() == 'N' {
text = createNewEntryStub(TlTui.Clipboard.DateFormat)
}
if copyToClipboard(text) != nil {
log.Println("Couldn't copy Stub to clipboard")
if TlTui.Clipboard.Enabled {
if copyToClipboard(text) != nil {
log.Println("Couldn't copy Stub to clipboard")
}
}
if TlTui.TlConfig.Tui_show_stub {
TlTui.FormModal.GetForm().Clear(true)
// The format is ugly because an issue in cview:
// https://code.rocketnine.space/tslocum/cview/issues/72#issuecomment-3968
TlTui.FormModal.SetText(text)
TlTui.FormModal.SetTextAlign(cview.AlignLeft)
TlTui.FormModal.GetForm().AddButton("Reply", func() {
toggleFormModal()
launchEditor()
})
toggleFormModal()
return nil
}
}
launchEditor()
return nil
}
func launchEditor() {
mainButtonName, buttonName, message, execFunc := "Cancel", "", "", func() {}
if TlTui.App.Suspend(editTl) == true {
message = "Tinylog edited successfully"
@ -312,7 +332,7 @@ func openEditorHandler(ev *tcell.EventKey) *tcell.EventKey {
} else {
toggleFormModal()
if Tle.PostScriptRefresh == true {
refreshHandler(ev)
refreshHandler(nil)
}
}
}
@ -331,8 +351,6 @@ func openEditorHandler(ev *tcell.EventKey) *tcell.EventKey {
toggleFormModal()
}
TlTui.FocusManager.Focus(TlTui.ContentBox)
return nil
}
func linksHandler(ev *tcell.EventKey) *tcell.EventKey {

Loading…
Cancel
Save