Skip to content
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

Keyboard shorcuts #4

Open
sojusnik opened this issue Nov 2, 2018 · 30 comments
Open

Keyboard shorcuts #4

sojusnik opened this issue Nov 2, 2018 · 30 comments
Labels
enhancement New feature or request

Comments

@sojusnik
Copy link

sojusnik commented Nov 2, 2018

Thanks for creating this useful plugin! Seems to be stable and fully functional on Ubuntu 18.10.

Although you mention libwebkit2gtk-4.0-dev as a dependency, I only needed to install pandoc for the installation. libwebkit2gtk-4.0-37 was already present on my machine.

I'm wondering why your great plugin isn't mentioned on the official Gedit site in plugins or markdown? Even a Google search doesn't find it, at least with gedit markdown plugin. Only by searching on GitHub I was lucky to discover it!

Do you actually plan to release it as a packaged plugin, so that people can easily find and install it through the OS' repository? When searching with apt (apt search gedit-plugin*) you get a lot of Gedit plugins, but your isn't there.

Oh, and one more thing: It's obvious that you are an avid markdown user. Thus, you use the bold, italic and header formats a lot. While specialized markdown editors allow to use keyboard shortcuts for formatting, Gedit is missing this functionality. However, somebody created a plugin for that, but it's unmaintained and not working with the latest version of Gedit. Since I'm code illiterate, maybe you could have a look on it? I'm sure that keyboard shortcuts for formatting would drastically improve the usability!

Actually only a handful would suffice for the beginning:
Ctrl+1-5 for headers
Ctrl+b for bold
Ctrl+i for italic

Would be great to hear you opinion!

@maoschanz
Copy link
Owner

I'm wondering why your great plugin isn't mentioned on the official Gedit site in plugins or markdown? Even a Google search doesn't find it, at least with gedit markdown plugin. Only by searching on GitHub I was lucky to discover it!

It's a plugin i did mainly for my personal use, the code really looks like shit (i shouldn't have used pandoc it was a horrible idea) and i broke a few things with the menu recently when i experimented some GTK+ technologies i didn't know about, Gedit maintainers would laugh if they see it 😅

Also, my plugins are only around 8 months old, it's not surprising they're not well referenced yet. I guess i should tell Gedit devs about these plugins if i want the wiki to be up-to-date

Do you actually plan to release it as a packaged plugin

Maybe when it will be more seriously designed (not using pandoc for the preview, showing an "export" dialog with options, etc. also i want some support for reveal.js)

use keyboard shortcuts for formatting

I wasn't sure about doing this because of potential conflicts with other plugins, for example Ctrl+M seems to be the standard shortcut for monospace formatting, which is the hardest markdown tag to write manually imo, but it's also the shortcut of the plugin to comment code

@sojusnik
Copy link
Author

sojusnik commented Nov 3, 2018

It's a plugin i did mainly for my personal use, the code really looks like shit (i shouldn't have used pandoc it was a horrible idea) and i broke a few things with the menu recently when i experimented some GTK+ technologies i didn't know about, Gedit maintainers would laugh if they see it sweat_smile

But it works, the other markdown plugins do not! This is what counts :)

I wasn't sure about doing this because of potential conflicts with other plugins, for example Ctrl+M seems to be the standard shortcut for monospace formatting, which is the hardest markdown tag to write manually imo, but it's also the shortcut of the plugin to comment code

That lies in the nature of keyboard shortcuts. ctrl+m isn't a default shortcut, but comes from gedit-plugin-code-comment. Even my suggested ctrl+i for italic is already conflicting with the default jump to line shortcut. Therefore the gedit plugin for markdown formatting with keyboard shortcuts should have adjustable shortcuts with sane default presets, namely:

ctrl+1-5 for headers
ctrl+b for bold
ctrl+e for italic (e for emphasis = italic)
ctrl+y for quotes (Y is similar to >)
ctrl+m for code (normally formatted as monospace) or ctrl+u (because it's an upside down half m 😄 )
ctr+l for strike (because both the L and the strikethrough text have a horizontal line)
ctrl+k for links (default in a lot of apps)

Do you think that this is easily doable?

With keyboard shortcuts and your plugin, gedit would be finally a solid alternative to other markdown editors, since it already has a bunch of useful features for manipulating text.

@maoschanz
Copy link
Owner

It's probably easy, but i'll do it later, i'm renaming the issue so i'll not forget about it

@maoschanz maoschanz changed the title Thank you! Keyboard shorcuts Nov 3, 2018
@sojusnik
Copy link
Author

sojusnik commented Nov 3, 2018

Merci beaucoup!
Can you give a rough estimate when it'll be done?

@maoschanz
Copy link
Owner

mid december i guess

@maoschanz
Copy link
Owner

maoschanz commented Nov 5, 2018

  • menu items:
    • remove all tags
    • title
    • bold
    • italic
    • underline not supported ?
    • monospace
    • stroke not supported by python3-markdown
    • quote
    • unordered list
    • ordered list
    • insert link
    • insert image
    • insert table
  • actions:
    • remove all tags
    • title
    • bold
    • italic
    • underline not supported ?
    • monospace
    • stroke not supported by python3-markdown
    • quote
    • unordered list
    • ordered list
    • insert link
    • insert image
    • insert table
  • shortcut:
    • remove all tags
    • title
    • bold
    • italic
    • underline not supported ?
    • monospace
    • stroke not supported by python3-markdown
    • quote
    • unordered list
    • ordered list
    • insert link
    • insert image
    • insert table

maoschanz referenced this issue Nov 5, 2018
everything is broken but at least there is a cool menu
@sojusnik
Copy link
Author

sojusnik commented Nov 5, 2018

Wohoo!

While trying to enable the updated version from the master branch in the plugins menu, gedit shows this:

$ gedit
(gedit:12176): libpeas-WARNING **: 18:32:20.662: Error importing plugin 'markdown_preview':
Traceback (most recent call last):
  File "/usr/lib/python3.6/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 994, in _gcd_import
  File "<frozen importlib._bootstrap>", line 971, in _find_and_load
  File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 678, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/home/sojusnik/.local/share/gedit/plugins/markdown_preview/__init__.py", line 1, in <module>
    import subprocess, gi, os, markdown
ModuleNotFoundError: No module named 'markdown'
(gedit:12176): libpeas-WARNING **: 18:32:20.662: Error loading plugin 'markdown_preview'

Before that I've deleted the old files from

~/.local/share/gedit/plugins/markdown_preview
~/.local/share/gedit/plugins/markdown_preview.plugin

@maoschanz
Copy link
Owner

as i wrote in the commit message, that's a work in progress and it's broken.

but here your error is just because of #5, do sudo apt install python3-markdown and it should be fine (it will still be broken on other aspects however)

maoschanz added a commit that referenced this issue Nov 6, 2018
i began an export dialog, empty for now
i tried a few things for editing-related actions
@sojusnik
Copy link
Author

sojusnik commented Nov 6, 2018

as i wrote in the commit message, that's a work in progress and it's broken.

Ok. Thanks for keeping us up-to-date!

maoschanz added a commit that referenced this issue Nov 12, 2018
Keyboard shortcuts don't work (why?) and the behavior regarding blocks can be improved (new line when beginning a list ? '```' tags if several lines of monospace ? etc.)
@sojusnik
Copy link
Author

I couldn't resist the temptation to use your plugin productively and want to share with you some observations:

  1. At the moment a Markdown tag can only be applied when a word is highlighted. From a usability point of view this should be improved to the degree that it would be enough to have the text cursor either at the beginning of a word (before the first letter) or at the end (after the last letter) and also between the letters of a word to apply formatting. This would save a lot of clicks and make formatting with keyboard shortcuts comfortable.

  2. The same principle should be applied to header, quotes and list formats. It should be enough to have the cursor somewhere within the sentence to apply formatting, obviously at the beginning of the sentence.

  3. To keep things simple and clean, the closing # in headers could be removed, since the original Markdown specification prefers # only at the beginning of a sentence.

  4. Normal URLs like https://github.com/maoschanz/gedit-plugin-markdown_preview/ are not clickable at the moment in the preview pane, only links like this are. Would be very helpful, if normal links would be autoconverted to clickable links.

Can't wait to have configurable shortcuts for formatting. Keep up the good work!

@sojusnik
Copy link
Author

Just wanted to mention that I still use your great plugin and hope that you'll find time to improve it. Thanks!

@maoschanz
Copy link
Owner

To be honest i'm quite stuck concerning shortcuts, because for example ctrl+shift+b works fine and add tags for bold, but anything with a number fails (sad for the titles), and i've no idea why.

also, I found the perfect gtk widget for configurable shortcuts but it's a really weird one to use and i couldn't make it work like i want for now

I didn't give up, don't worry, it will eventually be implemented 😊

@sojusnik
Copy link
Author

Hope dies last :)

@sojusnik
Copy link
Author

How are things going?

@maoschanz
Copy link
Owner

I haven't retry yet

@sojusnik
Copy link
Author

Ok. Is it possible that you change the default shortcuts to the following in the meantime?

ctrl+b for bold
ctrl+e for italic (e for emphasis = italic)
ctrl+y for quotes (Y is similar to >)
ctrl+m for code (normally formatted as monospace) or ctrl+u (because it's an upside down half m)

@sojusnik
Copy link
Author

To be honest i'm quite stuck concerning shortcuts, because for example ctrl+shift+b works fine and add tags for bold, but anything with a number fails (sad for the titles), and i've no idea why.

also, I found the perfect gtk widget for configurable shortcuts but it's a really weird one to use and i couldn't make it work like i want for now

Since you still seem to be stuck with those two issues, I have some suggestions to simplify things:

The keyboard shortcut functionality could be released as a separate plugin, as it already was done before. By doing so, you wouldn't have to struggle with the gtk widget, you've mentioned earlier, because, imho, it would be sufficient to agree upon default shortcuts, that don't conflict with the Gedit ones. If a user desires to tweak those shortcuts, he could do it in the source code, presupposed the code is commented accordingly and is easily understandable by coding illiterate users.

I propose the following:

ctrl+1-5 for headers
ctrl+b for bold
ctrl+e for italic (e for emphasis = italic; ctrl+i is already taken for jump to line)
ctrl+y for quotes (Y is similar to >)
ctrl+m for code (normally formatted as monospace; ctrl+m isn't a default shortcut, but comes from gedit-plugin-code-comment)
ctrl+u for clear all formatting tags from selected text
ctr+l for strike (because both the L and the strikethrough text have a horizontal line)
ctrl+k for links (default in a lot of apps)

This extension allows using strike with python-markdown.

The most important thing is, however, how those shortcuts should be applied:

At the moment a Markdown tag can only be applied when a word is selected. From a usability point of view this should be improved to the degree that it would be enough to have the text cursor either at the beginning of a word (before the first letter) or at the end (after the last letter) and also between the letters of a word to apply formatting, without the necessity to select the whole word! This would save a lot of clicks and make formatting with keyboard shortcuts comfortable and fast.

The same principle should be applied to headers and quotes — it should be enough to have the cursor somewhere within the sentence to apply formatting.

To remove formatting, either clear all could be used or when the same formatting is applied to an already formatted word/text — if a word is already bold and you apply ctrl+b on it, then the formatting should be removed.

This formatting behaviour is very well implemented in Zim. Since it's also written in Python, it could serve as an inspiration.

What do you think?

maoschanz added a commit that referenced this issue May 8, 2019
@maoschanz maoschanz added the enhancement New feature or request label May 10, 2019
@johnblommers
Copy link

I'm late to the party, wanted a Markdown preview plugin for Gedit and landed here. This plugin installs easily enough on Ubuntu 19.10 and my system already had all of the dependencies installed. If I may, let me make the following comments:

  1. Pandoc is a great Markdown rendering tool so please don't set it aside lightly. If you do remove it as a rendering option to clean up the project that would not break the heart. We can always use Pandoc on the command line to generate our published products. Indeed we probably should, leaving editing to gedit and this Markdown preview plugin.
  2. I love the ability to step through the preview by H2 heading. Smashing!
  3. Keep up your efforts. This project is valuable to those of us that write in Markdown and want a stable editor like gedit.

@maoschanz
Copy link
Owner

maoschanz commented Feb 13, 2020

The keyboard shortcut functionality could be released as a separate plugin, as it already was done before. By doing so, you wouldn't have to struggle with the gtk widget, you've mentioned earlier

I didn't tell it here but the widget now kinda works, the real issue is that any shortcut with a number fails.

I propose the following:

ctrl+1-5 for headers

so that would be hard

ctrl+m for code (normally formatted as monospace; ctrl+m isn't a default shortcut, but comes from gedit-plugin-code-comment)

I use gedit-plugin-code-comment far more than my own plugins, and the shortcut for monospace is the only one i would actually use

ctrl+u for clear all formatting tags from selected text
ctrl+l for strike

These ones are the default shortcuts for case conversion

This extension allows using strike with python-markdown.

Yes it's listed in my readme since 3rd party extensions are now supported

The most important thing is, however, how those shortcuts should be applied [...] What do you think?

I think it's important to get something working first, and think about the UX only then

@maoschanz
Copy link
Owner

Pandoc is a great Markdown rendering tool so please don't set it aside lightly.

I don't, python3-markdown is here as an alternative because i sometimes need its extensions, but it can't export files as PDF and it can't do revealjs

If you do remove it as a rendering option to clean up the project that would not break the heart.

I'm actually adding the possibility to configure the command line it uses, during the modifications the CSS is broken but it'll be back along with a working GUI for revealjs rendering options

This project is valuable to those of us that write in Markdown and want a stable editor like gedit.

Well the editor is stable but not the plugin lol

@01tot10
Copy link

01tot10 commented Dec 23, 2021

Yello!

Just installed this plugin with hopes to add quick markdown editing options to gedit, for cases when I don't want to open a more fully-featured editor. I tried to look for the editing options, but somehow couldn't find any, nor did any keyboard shortcuts that I tried work. Looking through this thread it seems like, at least once upon time, there were keyboard shortcuts implemented to some extent.

What is the status of these keyboard shortcuts at the moment?
I'm mainly looking for ways to make text bold or italic quickly, possibly with "ctrl+b" and "ctrl+i".

@maoschanz
Copy link
Owner

it's still not finished (issue still opened) so it's not in the installable releases

Capture d’écran de 2021-12-23 13-46-24

@01tot10
Copy link

01tot10 commented Dec 26, 2021

@maoschanz
Ah, right! I guess I could have derived that from the status. But seeing that some people were already using the features, I thought maybe I'm overlooking something.

Thanks for clearing things out! I'll be using manual styling, as I have until now :).

maoschanz added a commit that referenced this issue Dec 31, 2021
related to #4

the contextual menu has been restructured too, to include more actions
@maoschanz
Copy link
Owner

i think i'll release a version where the actions currently working will be listed in the contextual menu, so at least the main feature will be available

i mean, even without the shortcuts, inserting a 5-columns-wide table is easier with just 2 clicks than by typing the ASCII characters lol

and then the shortcuts themselves could be released later when i'll take a little time to figure out the problems with them

@johnblommers
Copy link

This sounds very reasonable. Release new features incrementally. Release as often as you like.

@ghost
Copy link

ghost commented Jan 9, 2023

Are the shortcuts available? Or is this a work in progress?

If this is already possible, could someone tell me how to make them work?

@maoschanz
Copy link
Owner

in the plugin preferences you can set shortcuts

Capture d’écran du 2023-01-09 14-47-42

but the corresponding methods aren't all implemented, so some will work and some will not. Be careful to set shortcuts which aren't already set to something else

@ghost
Copy link

ghost commented Jan 9, 2023

@maoschanz I cannot. I see only "General options, Backend, Style" but I do not have the shortcuts part behind style.

@maoschanz
Copy link
Owner

oh sorry you're right i forgot i didn't release the version with this feature yet

then it's indeed not available

i lost my hard drive this summer so i don't have this project on my personal computer currently, and i lost my WIPs, but i'll give it a try again in a few weeks, after my more important projects

@ghost
Copy link

ghost commented Jan 9, 2023

ok, I' ll wait. And thanks for sharing this plugin!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

4 participants