jmigpin/editor

AutoReload Row

jsonfarmer opened this issue · 6 comments

Hello! Thank you so much for this excellent text editor program. It is really wonderful to use.

For my usecase I have began sketching out a plugin that displays a list of all the active row's symbols, taken from the LSP. For this to work I would prefer the ability to auto-reload the row display the symbol list so it always matches the active row. I was wondering if anyone had any ideas for accomplishing this? I couldn't not find anything in the readme and am still wrapping my head around the codebase so sorry if this is a silly question.

Would also prefer to move this to the irc channel if there is one we can use, because this is more of a discussion question than a codebase issue.

Thank you in advance!

After thinking on this some more, I realized I could use the terminal clear command to potentially update a row textarea. Unfortunately I can't seem to get a basic terminal clear example working with the built in execution buffer.
Here's what I'm trying which isn't working:

package main
  
import "fmt"
  
// Main function
func main() {
    fmt.Println("!... Hello World ...!")
    fmt.Print("\033c")
}

The documentation briefly mentions allowing terminal clear characters so maybe there is a way to get this idea working?

It is always nice to see people finding the editor useful!

Regarding clearing the terminal, try "\033[2J".
The terminal filter needs a review to use the scanner code that has been updated. Hopefully that will be done soon.

About your plugin idea if you're still considering it: there seems to be an event that could help which is RowStateChangeEEventId. Here you can probably check if the row is active and perhaps re-run the symbol list on save.

image

Is this the current expected behavior?

Another (perhaps more unix-y) approach to implementing this would be to write the symbol list to some dedicated file path, lets say <editor path>/symbols and edit this file whenever a rowstatechange occurs.
This still needs a way to automatically Reload the row which has this file open, but might be a better approach than some standalone terminal program.

In the lower row, try having " | $terminal=f | go run test.go" and run the cmd.

Perhaps when running a cmd from a row editing a file, that cmd should be present in the newly created row, but thats another issue.

About the symbols: you can run a terminal program continously that detects changes in a filepath and then updates the output (making that screen clear). That should be possible without changing anything in the editor itself. Nor creating a specific symbols path should be necessary.

In the lower row, try having " | $terminal=f | go run test.go" and run the cmd.

Worked thank you :)

About the symbols: you can run a terminal program continously that detects changes in a filepath and then updates the output (making that screen clear). That should be possible without changing anything in the editor itself. Nor creating a specific symbols path should be necessary.

Yes now that I know how to include the terminal flag to make the clear escape character work, this approach should work great! Cheers.