Replies: 1 comment 1 reply
-
In cases like these I personally use a single run command with a function that pops up a dropdown dialogbox where I select what I want to do, and the function returns the command string. For example:
textadept.run.run_commands.adoc = function()
local commands = {
html = 'asciidoctor -a icons=font -a source-highlighter=pygments %f',
pdf = 'asciidoctor-pdf -a icons=font -a source-highlighter=pygments -a pdf-page-size=letter %f',
view = 'firefox %e.html'
}
local button, cmd = ui.dialogs.dropdown{title = 'Run', items = {'html', 'pdf', 'view'}, string_output = true}
return button == _L['OK'] and commands[cmd] or nil
end
Over time I memorize what's in the list so I can hit the arrow down key to quickly run the command I want. You can use a filteredlist dialog if you want to visualize all options. I would not use a menu item(s).
Hopefully this helps.
|
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
This is kind of a how-to question. I know with the flexibility of Lua, almost anything is possible, but depending on whether there is a simple way to do this or not without writing a bunch of Lua, it may be a feature request.
I have used Geany for years, but I'm giving Textadept a try, because I really like the multiple cursors. Geany supports custom build commands (I know Textadept does too, but Geany does them a little bit differently):
These are custom build commands I set up for Asciidoc files:
asciidoctor -a icons=font -a source-highlighter=pygments %f
asciidoctor-pdf -a icons=font -a source-highlighter=pygments -a pdf-page-size=letter %f
firefox %e.html
Asciidoc files have a .adoc file extension, so in Textadept I could:
Here are the differences: (1) Geany allows custom labels for the build commands, so I can have Compile HTML and Compile PDF. With Textadept, I have to remember that I assigned HTML to Run and PDF to Compile. (2) Geany allows up to three custom commands (more if you use the independent and execute slots). I've already used Run and Compile, so I don't have a command left for Preview.
I know I could add custom menu entries to the Tools menu:
But how do I make these menu items only appear when the file extension is .adoc? I've seen example init.lua files that have things like
if buffer:get_lexer() == 'lua'
, but Asciidoc doesn't have a lexer (and I don't really need syntax highlighting for Asciidoc, so I wasn't going to try and writer a lexer for it myself). Would I need to use a regex on buffer.filename to get the file extension?My hope is that it would be as simple as something like the existing textadept.run.run_commands and textadept.run_compile_commands that still have access to %f, %e, %d, %p for convenience and the ability to set custom labels, something like (totally hypothetical code):
Beta Was this translation helpful? Give feedback.
All reactions