-
Notifications
You must be signed in to change notification settings - Fork 270
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
[Addons Plugin] - Keybinding that inserts divider separator lines #1384
Comments
@Skif_off Would Lua in this case be able to know the language/file type of the currently opened document, in order to know which divider to use? I / the user would just need a small “template” for how to type in the file type / desired divider. If something like this could actually be achieved with Lua/GeanyLua plugin, I imagine they would be "if" statements if "txt" if "xml" if "lua" Then user would just assign a single keybinding to the Lua script and it would generate a divider based on the file type template/list from the Lua script. If interested let me know. |
@advice2020, you misspelled my nickname :) I didn't receive the notification, I saw it by accident. Maybe something like this (but I didn't check it) local aTypes = {
{"Lua", ".lua", "--#####################################"},
{"", ".txt", "######################################"},
{"XML", ".xml", "<!--#################################-->"}
}
local aFI = geany.fileinfo()
local sExt, sStr
for i = 1, #aTypes do
if aTypes[i][1] == aFI.type then
sStr = aTypes[i][3]
break
end
end
if sStr == nil then
sExt = string.lower(aFI.ext)
for i = 1, #aTypes do
if aTypes[i][2] == sExt then
sStr = aTypes[i][3]
break
end
end
end
if sStr == nil then
geany.status("Warning: Unknown file type!")
return
end
local iEOL = geany.scintilla("SCI_GETEOLMODE")
local sLE
if iEOL == 0 then
sLE = "\r\n"
elseif iEOL == 1 then
sLE = "\r"
elseif iEOL == 2 then
sLE = "\n"
else
sLE = "\n"
end
local iCurPos = geany.caret()
local iL, iC = geany.rowcol(iCurPos)
iCurPos = geany.scintilla("SCI_POSITIONFROMLINE", iL - 1)
geany.select(iCurPos)
geany.selection(sStr .. sLE)
where "file extension" with dot, "file type" - see |
@Skif-off No problem, as mentioned you never have to check it, just the fact that you are willing to provide anything means so much, I have no problem testing things out. Thank you so much for this! I will use this one a great deal, really appreciate it. P.S. |
For any users in the future, just couple things I came across that might be helpful. Sometimes .txt files in Linux do not contain an extension in the filename, the following line will allow you to use this script with those files (remember to add coma at the end of this line if in the middle of your template list). The original script adds separator to the above line where the cursor is located. Anyways, hopefully this will be helpful to someone someday. |
Not sure what to do with this thread now? |
@advice2020, I just use the program and see the repositories from time to time.
The script moves the cursor to the beginning of the line and inserts the text and the corresponding line ending character(s). The line ending character is appended to the divider separator line before being inserted into the document. iCurPos = geany.scintilla("SCI_POSITIONFROMLINE", iL - 1)
|
@Skif-off I think I see what you mean, I just did not describe it properly when I mentioned to other users that it "adds the separator above the line". The way you created the script is how I plan on using it, but as mentioned I always like to have little tweaks that can change little behaviors in scripts likes this. Thank You again P.S. EDIT: |
I was wondering if anyone would be interested in creating / adding on to an existing plugin.
I see there is an existing plugin called “Addons” which is for various small features added to Geany, maybe it can be added to this plugin if anyone is interested.
This plugin would allow user to setup a keybinding that would create divider/separator lines when the keybinding is applied.
User would be able to setup how they want the divider/separator lines to display visually and because each language has a different "comment" symbol, there would have to be a way for user to be able to set this up per language/file type.
EXAMPLES
(plain regular text file which does not require a comment symbol)
(not sure if any other users would find this useful, but ability to use this in plain text files for me would be very helpful)
txt
######################################
xml
<!--#################################-->
lua
--#####################################
Thank You
The text was updated successfully, but these errors were encountered: