<p><a class="user-mention" data-hovercard-user-id="617017" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://github.com/eht16">@eht16</a>  <a class="user-mention" data-hovercard-user-id="181177" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://github.com/codebrainz">@codebrainz</a><br>
I have defined 2 very simple python scripts for <strong>to lower / upper</strong> command separately, based on <a class="user-mention" data-hovercard-user-id="617017" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://github.com/eht16">@eht16</a> 's script, and assigned shortcut <code>CTRL + L</code> and <code>CTRL + U</code> to them respectively, it works on my Linux machine now.</p>
<h2>The scripts</h2>
<p><strong>geanyLowerCase.py:</strong></p>
<pre><code>#!/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()
</code></pre>
<p><strong>geanyUpperCase.py:</strong></p>
<pre><code>#!/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()
</code></pre>
<h2>Additional steps to make it work</h2>
<ul>
<li>Link these 2 scripts under <code>$PATH</code>.</li>
<li>Link script as command in geany.
<ul>
<li>in geany,</li>
<li>edit -> format -> send selection to -> set custom commands,</li>
<li>add the script, and label it,</li>
<li>remember its order in the commands,</li>
</ul>
</li>
<li>Define shortcut for new commands.
<ul>
<li>edit -> preference -> keybindings -> format,</li>
<li>change key for "send to custom command x",<br>
where <code>x</code> is the order of you new command when define it,</li>
</ul>
</li>
<li>Test it.</li>
<li>Done.</li>
</ul>
<h2>Possible improvements needed</h2>
<ul>
<li>After format via shortcut, the select text are not selected any more.<br>
Maybe it's better to still select those text after the action.</li>
<li>This is tested on Linux, not on windows yet,.<br>
Might need to modify the script a bit to make it work, e.g the <code>shebang</code> part.</li>
</ul>
<h2>More scripts?</h2>
<ul>
<li>to Capital case.<br>
e.g <code>aBc</code> -> <code>Abc</code></li>
</ul>

<p style="font-size:small;-webkit-text-size-adjust:none;color:#666;">—<br />You are receiving this because you are subscribed to this thread.<br />Reply to this email directly, <a href="https://github.com/geany/geany/issues/1929#issuecomment-416435848">view it on GitHub</a>, or <a href="https://github.com/notifications/unsubscribe-auth/ABDrJ2cw8lc4ZHh1IEQYurejEJ94_rTbks5uVLN_gaJpZM4WI7ay">mute the thread</a>.<img src="https://github.com/notifications/beacon/ABDrJyTjQV0KHpE2vUDCwtBDHOVMwPGcks5uVLN_gaJpZM4WI7ay.gif" height="1" width="1" alt="" /></p>
<script type="application/json" data-scope="inboxmarkup">{"api_version":"1.0","publisher":{"api_key":"05dde50f1d1a384dd78767c55493e4bb","name":"GitHub"},"entity":{"external_key":"github/geany/geany","title":"geany/geany","subtitle":"GitHub repository","main_image_url":"https://assets-cdn.github.com/images/email/message_cards/header.png","avatar_image_url":"https://assets-cdn.github.com/images/email/message_cards/avatar.png","action":{"name":"Open in GitHub","url":"https://github.com/geany/geany"}},"updates":{"snippets":[{"icon":"PERSON","message":"@kuchaguangjie in #1929: @eht16  @codebrainz \r\nI 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.\r\n\r\n## The scripts\r\n\r\n**geanyLowerCase.py:**\r\n\r\n    #!/usr/bin/env python\r\n    # -*- coding: utf-8 -*-\r\n\r\n    # geany - customized formatting - to lower case,\r\n    import sys\r\n\r\n    def lower_case(string):\r\n        return string.lower()\r\n\r\n    def main():\r\n        data = sys.stdin.read()\r\n        sys.stdout.write(lower_case(data))\r\n\r\n    if __name__ == '__main__':\r\n        main()\r\n\r\n**geanyUpperCase.py:**\r\n\r\n    #!/usr/bin/env python\r\n    # -*- coding: utf-8 -*-\r\n\r\n    # geany - customized formatting - to upper case,\r\n    import sys\r\n\r\n    def upper_case(string):\r\n        return string.upper()\r\n\r\n    def main():\r\n        data = sys.stdin.read()\r\n        sys.stdout.write(upper_case(data))\r\n\r\n    if __name__ == '__main__':\r\n        main()\r\n\r\n\r\n## Additional steps to make it work\r\n\r\n* Link these 2 scripts under `$PATH`.\r\n* Link script as command in geany.\r\n  * in geany,\r\n  * edit -\u003e format -\u003e send selection to -\u003e set custom commands,\r\n  * add the script, and label it,\r\n  * remember its order in the commands,\r\n* Define shortcut for new commands.\r\n  * edit -\u003e preference -\u003e keybindings -\u003e format,\r\n  * change key for \"send to custom command x\",\r\n\twhere `x` is the order of you new command when define it,\r\n* Test it.\r\n* Done.\r\n\r\n## Possible improvements needed\r\n\r\n* After format via shortcut, the select text are not selected any more.\r\n  Maybe it's better to still select those text after the action.\r\n* This is tested on Linux, not on windows yet,.\r\n  Might need to modify the script a bit to make it work, e.g the `shebang` part.\r\n\r\n## More scripts?\r\n* to Capital case.\r\n  e.g `aBc` -\u003e `Abc`"}],"action":{"name":"View Issue","url":"https://github.com/geany/geany/issues/1929#issuecomment-416435848"}}}</script>
<script type="application/ld+json">[
{
"@context": "http://schema.org",
"@type": "EmailMessage",
"potentialAction": {
"@type": "ViewAction",
"target": "https://github.com/geany/geany/issues/1929#issuecomment-416435848",
"url": "https://github.com/geany/geany/issues/1929#issuecomment-416435848",
"name": "View Issue"
},
"description": "View this Issue on GitHub",
"publisher": {
"@type": "Organization",
"name": "GitHub",
"url": "https://github.com"
}
},
{
"@type": "MessageCard",
"@context": "http://schema.org/extensions",
"hideOriginalBody": "false",
"originator": "AF6C5A86-E920-430C-9C59-A73278B5EFEB",
"title": "Re: [geany/geany] Shortcut suggestions (#1929)",
"sections": [
{
"text": "",
"activityTitle": "**kuchaguangjie**",
"activityImage": "https://assets-cdn.github.com/images/email/message_cards/avatar.png",
"activitySubtitle": "@kuchaguangjie",
"facts": [

]
}
],
"potentialAction": [
{
"name": "Add a comment",
"@type": "ActionCard",
"inputs": [
{
"isMultiLine": true,
"@type": "TextInput",
"id": "IssueComment",
"isRequired": false
}
],
"actions": [
{
"name": "Comment",
"@type": "HttpPOST",
"target": "https://api.github.com",
"body": "{\n\"commandName\": \"IssueComment\",\n\"repositoryFullName\": \"geany/geany\",\n\"issueId\": 1929,\n\"IssueComment\": \"{{IssueComment.value}}\"\n}"
}
]
},
{
"targets": [
{
"os": "default",
"uri": "https://github.com/geany/geany/issues/1929#issuecomment-416435848"
}
],
"@type": "OpenUri",
"name": "View on GitHub"
},
{
"name": "Unsubscribe",
"@type": "HttpPOST",
"target": "https://api.github.com",
"body": "{\n\"commandName\": \"MuteNotification\",\n\"threadId\": 371439282\n}"
}
],
"themeColor": "26292E"
}
]</script>