[Github-comments] [geany/geany] Shortcut suggestions (#1929)
kuchaguangjie
notifications at xxxxx
Tue Aug 28 03:05:35 UTC 2018
@eht16 @codebrainz
I have defined 2 very simple python scripts for **to lower / upper** command separately, based on @eht16 's script, and assigned shortcut `CTRL + L` and `CTRL + U` to them respectively, it works on my Linux machine now.
## The scripts
**geanyLowerCase.py:**
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# geany - customized formatting - to lower case,
import sys
def lower_case(string):
return string.lower()
def main():
data = sys.stdin.read()
sys.stdout.write(lower_case(data))
if __name__ == '__main__':
main()
**geanyUpperCase.py:**
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# geany - customized formatting - to upper case,
import sys
def upper_case(string):
return string.upper()
def main():
data = sys.stdin.read()
sys.stdout.write(upper_case(data))
if __name__ == '__main__':
main()
## Additional steps to make it work
* Link these 2 scripts under `$PATH`.
* Link script as command in geany.
* in geany,
* edit -> format -> send selection to -> set custom commands,
* add the script, and label it,
* remember its order in the commands,
* Define shortcut for new commands.
* edit -> preference -> keybindings -> format,
* change key for "send to custom command x",
where `x` is the order of you new command when define it,
* Test it.
* Done.
## Possible improvements needed
* After format via shortcut, the select text are not selected any more.
Maybe it's better to still select those text after the action.
* This is tested on Linux, not on windows yet,.
Might need to modify the script a bit to make it work, e.g the `shebang` part.
## More scripts?
* to Capital case.
e.g `aBc` -> `Abc`
--
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/geany/geany/issues/1929#issuecomment-416435848
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.geany.org/pipermail/github-comments/attachments/20180827/e3a64a32/attachment-0001.html>
More information about the Github-comments
mailing list