Comments (10)
Agreed, that would be nice.
from glow.
Another thing that, imho, would be important is to maintain the scrolling position. When you're editing a really long document you don't want to scroll back to the position of the last change every time.
Totally agreed. in pager.go
, you can update the current document by editing the contents of m.currentDocument.Body
. Then you run renderWithGlamour(m, m.currentDocument.Body)
to re-render/update the view. And it keeps the current position :) As an example, you could drop this into pager.go
beneath switch msg.String() {
and just above case "q", "esc":
case "1":
m.currentDocument.Body = m.currentDocument.Body + "\n\nhere's a new line."
cmd = renderWithGlamour(m, m.currentDocument.Body)
cmds = append(cmds, cmd)
Then launch glow, open a file, and type "1" repeatedly. It'll keep appending lines to the end of the document, but as the file changes, the scroll position remains the same.
from glow.
I would love to see this feature too! I tried to fiddle with watch
and some quick and dirty helper scripts but an actual "live preview" would be great.
from glow.
This would close #135 as well.
from glow.
I would love to see that feature as well.
@mschloesser can you share your script until the feature is implemented? Because I didn't get it to work with watch.
from glow.
I feel like this shouldn't be too hard.
https://medium.com/@skdomino/watch-this-file-watching-in-go-5b5a247cf71f
Code would go in pager.go. First, you check to see if the document is stashed or not. If it's not, then using fsnotify, you could create a file watcher to detect any edits to m.currentDocument.localPath
. Any time there's an edit, re-read the the contents of m.currentDocument.localPath
and update m.currentDocument.Body
. Re-render the doc, and you're good.
No promises that I won't get distracted or otherwise not get around to it, but I'll probably look at this over the weekend.
from glow.
So we've got 3 parts to this:
- Initialize a watcher (should only happen once after you launch glow)
- Add a new filepath to the watcher (should happen each time you view a local file)
- Remove a filepath from the watcher (should happen each time you stop viewing a local file / return to file list)
Do you guys have any suggestions where each step should live? I'm thinking first add the watcher as an attribute of pagerModel. setContent()
gets run every time we both open a new file and when we re-render the document (e.g. after detecting a file change). I don't think there presently exists a single method that runs only when we first open a file, so perhaps add another attribute to pager like isViewingFile bool
, and then add a block to setContent()
such as:
if !isViewingFile:
isViewingFile = true
if isLocalFile:
addWatcher(currentFilePath)
and then toggle isViewingFile
to false and remove the watcher whenever you call unload()
. Does that seem reasonable? Or would there be a better way to implement this? Since I'm still not super familiar with the code, I wanted to ask before implementing it :P
from glow.
I would love to see that feature as well.
@mschloesser can you share your script until the feature is implemented? Because I didn't get it to work with watch.
@Lisiadito Unfortunately, I deleted the scripts since it didn't really work well.
Another thing that, imho, would be important is to maintain the scrolling position. When you're editing a really long document you don't want to scroll back to the position of the last change every time.
from glow.
Temporary (or maybe not) solution for those who needed this feature to integrate glow
it with a terminal editor such as vim: there is this nice plugin https://github.com/npxbr/glow.nvim
from glow.
Closing a few tickets describing the same feature. Let's track this in #135, which was the first ticket suggesting it.
from glow.
Related Issues (20)
- Escape character is rendered HOT 2
- Question: Width of tables?
- Install release package on alpine linux
- No path completion on zsh 5.9
- Render <table /> HOT 1
- Using TUI mode when file name is provided HOT 1
- Tab path completion doesn't work when I use glow to open a file in another directory HOT 2
- Cant Edit Markdown HOT 2
- Full path shows in TUI when using symlink folders HOT 1
- layout independend keyboard hotkeys
- [feature] picture show
- Colorize text inside a table HOT 1
- Table formatting breaks if output is piped HOT 1
- Tab completion f/glow
- Open Editors at Current Line Number in Pager HOT 2
- make glow work with 'less --no-init'
- Glow doesn't see markdown files. `.gitignore` HOT 3
- glow shuffles lines randomly after scrolling using u/d buttons or mouse HOT 3
- Cases when backslash should not be shown
- Unable to locate package glow HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from glow.