-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Calling clipboard.Write in lua crashes micro #3320
Comments
Right, it's not even exported to lua 🤦 I was assuming most of the things listed in https://pkg.go.dev/github.com/zyedidia/micro/v2/internal is accessible from lua since the documentation said what it listed is only a short list of the available functions. Could we expose the clipboard module? |
You could e.g. execute |
I use micro in both Windows and Linux so I think exposing the clipboard module would be beneficial for plugins. |
So you could use some cross-platform counterpart of
Writing text to clipboard or reading text from clipboard is not really a micro-specific functionality (like inserting text into micro's buffer, or opening a split pane in micro, and so on). It can be provided by any external tool or library. |
If there are Not to mention clipboard reading and writing is related to micro, since the clipboard interacts with micro (or the other way around). And there can be use cases for it as well, like a clipboard history or clipboard manager or maybe some sort of clipboard content processing. If we don't have the functions to export to lua, then yeah this might need a bit of work but this isn't the case. I don't see why we need to make plugin developers' lives difficult when we can just export the functions we are already using in micro. |
We could keep ad-hoc exporting things like unzip and http requests and everything but the kitchen sink, whenever someone ask for it, but that is not a very scalable approach, is it? Whereas the "use an external program" approach doesn't depend on adding changes to micro and provides maximum flexibility. Unix way, bro. That said, on second thought, you are right that micro's Now, we'd need to think how exactly should we expose it. (It's always easy to add a poorly thought out interface, it's hard to remove it afterwards.) There is no such thing as exposing an entire package to Lua, we only expose specific functions, global variables etc (those that make sense to expose). It seems in this case we'd need to expose:
We might also think whether it should also respect the |
Hi, Is there any movement with clipboard access? Many editors have functions Could these two functions be built-in actions to avoid exposing more in Lua? Kind Regards Gavin Holt |
Hi, Thank you for reminding of this previous discussion. From my point of view, actions affecting the clipboard should be precise and reflect the current selected text only. I have many shortcuts to aid text selection, including line selection (thanks to those who helped me write the Lua functions). Applying actions to unselected text is common in some editors, and I have adopted some of these for clearing (delete) actions e.g.
I have used Autohotkey, which allows me to use almost any shortcut and translate into something micro will accept. A full list of my current keyboard shortcuts is appended below for interest. Kind Regards Gavin Holt Universal Keyboard Shortcuts (UKS)IntroductionInstead of learning and re-learning keyboard shortcuts, I am only going to use editors that can be made to respond to the same keystrokes. From the list below those marked * do not work yet. Actions and WorkflowIn my trials of many editors, there are some editing actions and shortcuts I find useful, so I have adopted them. Moving - local to cursor
Selecting
Basic editing actions
Clipboard Actions
Searching
Navigating
NB. Micro also has bindable actions for; FirstTab, PreviousTab, PreviousSplit, NextSplit, NextTab, and LastTab. File commands
Dialog boxesThere are some instances where a clickable dialog box can be very useful.
Multicursors
FoldingTODO Micro won't fold yet! Scite will fold.
Splitting Screens
Mode Selection
LSP ActionsThe LSP is a method to offload some smart featrues:
FZF as an alternative interfaceFuzzy finder is a fantastic piece of software. There is enough power to replace almost all user interface widgets. I have attempted many functions with unmodified fzf.exe, with helpers such as bat.exe, findstr.exe and grep.exe. Command line shortcutsIt is helpful to use a different colour scheme for the fzf screens to aid in context switching. When fzf is active it has it's own keybindings, again I have moved away from the defaults:
Command line syntaxFzf has its own syntax to control filtering:
Note terms are separated by spaces. Use qotes for patterns with spaces. Not sure if braces work. Keybindings listA searchable list of keybindings, this is great method to increase discoverability:
Command listPowerful editors have command lines, this list includes annotations about the commands, merged with the command history:
Goto listThis allows plain text searching of the current file, and then navigates to the selected position. (You can search for a line number)
Goto previous listKeeping a log of editing locations during a session, allows easy backtracking.
Goto found listEntering a target string filters the current file, then additional plain text searching is done using FZF.
Goto buffer listSwitching between open buffers needs to be as painless as possible. This list includes open windows, recent files and favourites:
Open file listThis is one area where FZF shines. Using the current buffer path as proxy for the project domain, let the file finding begin:
Open backup listThis works best for locally stored versions sharing similar filenames. e.g.
Open help listI like to keep local copies of the runtime help files, add my own MarkDown files, and use cheatsheets:
Diff against old versionsThis works best for locally stored versions sharing similar filenames. e.g.
Insert file listInsert file/filename from project:
Insert unique word listSelect unique words from the current open buffer, can help avoid typos in variable names:
Insert line listA list of useful annotated one liners, by file type:
Insert reference listI have a script to extract citations from files, and insert as MarkDown footnotes.
Insert template listFrom a selection of template files.
Insert snippet listFrom a selection of snippets.
Shell command listThis list includes saved shell commands:
Textfilter command listThis lists saved textfilter commands:
Macro listThis list includes recent saved macros:
Lua commandsLua commands may be entered in a command line, or replaced in the text.
|
My question is simply: what exactly are you referring to as |
Hi
If selected, then end-of-line characters to be included. So highlighting with The default for Naming things is hard - the current
Kind Regards Gavin Holt |
Ok, got it. You want the equivalent of the current
Agree, the name is unfortunate, I think it would be good to rename it to And yep, we could also implement |
I've prepared a pull request with |
Description of the problem or steps to reproduce
When calling clipboard.Write with anything inside a lua script, it just crashes micro.
Example code:
Crash trace:
Specifications
Commit hash: e9bd1b3
OS: Linux
Terminal: WezTerm
The text was updated successfully, but these errors were encountered: