Closed andrei-a-papou closed 5 months ago
Good idea; I don’t use another viewer than my editor, but I see how it can be useful.
Thanks a lot for contributing as much as you do, I’m really grateful!
No problem, happy to help!
I'm not sure yet how to do this, but have a look at this commit: it's possible to use the note
parameter in hooks.
Maybe there's a way here to (for example), have pter run in something like tmux and set up the on-select
hook to automatically open (reuse?) a note viewer in a split panel right next to pter. Maybe. I don't have the time to check how to do this in detail, but it should be possible.
Anyway, I'll still pull your changes in :grin:
Sounds like a good idea. I had some problems running pter
in tmux (I think some keys failed to work, but this may have been fixed by now.) I'll check it out!
Just in case, here's the same patch set, only against https://codeberg.org/vonshednob/pter/commit/0f1a4bcfd045f0123be2604d75e4714a396740a9:
96-view-note-1.diff.gz 96-view-note-2.diff.gz 96-view-note-3.diff.gz 96-view-note-4.diff.gz 96-view-note-5.diff.gz
After more testing, I've switched to viewer = nano --restricted --view --nohelp
instead of less
. I use nano
as the external editor, so this makes sense. And nano
is used as a fallback value for editor
anyway.
I've also discovered that when a pager like less
or batcat --pager always
is used, you can press Ctrl-C
to exit the viewer abnormally, which crashes pter. Perhaps Ctrl-C
can be trapped, I don't know, but I've set up nano
as both editor and viewer with a custom nanorc and this works great for me.
In any case, I would suggest defaulting to nano --view
as a fallback viewer.
less
works fine once Ctrl+C
is caught. So I used less
and more
as the fallbacks. Also -- it's in!
less
works fine now, yes!
I've added the ability to view notes in an external viewer. Rationale: I keep notes in Markdown files and sometimes I just need to view them without editing. I run pter in a minimal Docker container that is ill-suited for running GUI Markdown editors that can also preview things.
Hence this quick patch. The viewer function will look for
viewer =
under[General]
, falling back toless
if the config setting is unset. Parameters can be passed to the viewer binary, here's what I use for *.md files:viewer = batcat --paging always
96-view-note-1.diff.gz 96-view-note-2.diff.gz 96-view-note-3.diff.gz 96-view-note-4.diff.gz
These patches will apply against 3.15.2 -- albeit with some offsets (since I have other local patches applied before them). Things seem to work OK, please let me know if there are any problems.