CodeMirror 6 - back to development

Apparently the Autocomplete plugin can work with CodeMirror (earlier version) so perhaps this is the best route to autocomplete in code mirror?

  • I have not tested it yet but will later today

Hi @TW_Tones

I would also be eager to know if it works with CodeMirror 6 and if not what I can do to make it work :slight_smile:

Out of the box it does not work, this may be because code mirror is not using textarea

I admit I don’t know the details of how either work.

  • Including autocomplete inside input fields does not make it work.
  • Research to ensure the editor is wrapped such that the keystrokes can be monitored and the trigger can be activated, is possible the main step, and the first step at least.
  • I understand in a non-codemirror editor there is a way to trigger actions/popups inside the iframe used for the editor.

The autocomplete plugin seems to be only compatible with codemirror5 (I have not used this completion plugin). Codemirror6 has its own completion system and does not require an additional plugin.

As was raised earlier in the thread, We wanted to see if it could be adapted so the codemirror6 feature need not be developed.

1 Like

@BurningTreeC Just applied 0.5.1 – looking good!

Gotoline can provide one of the speediest ways to get back to the right location, especially after repeated saving when scrolling becomes tedious.

Ctrl+Alt+G is quite awkward.

Please make gotoline Ctrl+V.

(Ctrl+V is unused.)

Additionally the ESC key does not exit gotoline.

NOT as good:

Ctrl+G (previously suggested):

  • already used to cycle through find results.
  • already used by the browser for the same purpose

Alt+G

  • Alt keystokes are generally for app-level menus

Please don’t! Ctrl+V is system-wide clipboard Paste default shortcut in every OS and software I know.

Fred

4 Likes

I am sorry. Ctrl-V is obscenely stupid. I’m not even ashamed, because it’s so funny that my mind managed to detour that way.

Other options:

Ctrl+; / Ctrl+Shift+F / Ctrl+3 (#)

The problems with goto-line are…

  1. Remembering the line numbers :roll_eyes:
  2. They don’t work at all if line numbers are turned off. :roll_eyes: :roll_eyes:

“Bookmarks” are far more useful and easy. Basically, drop an anchor and a bookmark is created at that line. An icon appears in the gutter. F2 cycles through them all. Drop an anchor on the same line again and the bookmark is cleared.

Easy.

  1. You don’t need to remember anything. :brain:
  2. They work with and without line numbers. :100:

End of.

I have to disagree with that, but the two are by no means mutually exclusive anyway.

It’s just that Ctrl+Alt often requires two hands, or weird finger placement, depending on the keyboard.

This is clearly a highly subjective matter of use style. (I don’t know if you’re joking.)

Dropping anchors every 5 seconds sounds downright terrible to me.

I have never even heard of this. Is it a CodeMirror thing? How do you do it? I’m willing to try it, but it sounds like a lot more steps that may or may not be used.

By the way

  • How difficult/easy is it to personally customize these shortcuts? If there is any way to make this done in a Tiddler, then it would be beautiful, as we have demonstrated by our differences.

Hi @wattahay

I’ll investigate if keyboard shortcuts can be configured using tiddlers … maybe

1 Like

Meanwhile in Southtyrol …

@BurningTreeC has updated the plugin to v0.6.3

There are some bugfixes included and the updated library and (yes I know, it’s VERY opinionated) the styles for the editor toolbar buttons (I will think about those)


Now I’d like to address configurable keyboard shortcuts if possible

2 Likes

Hi all,

CodeMirror 6 v0.7.0 is online and includes a new Keyboard Shortcut system.
It allows changing the CodeMirror KeyMap by creating Tiddlers with the tag $:/tags/KeyboardShortcut/CodeMirror.
It’s based on the Tiddlywiki Core system but doesn’t use event.keyCode to get the key that’s being pressed - but uses event.key… this sadly ditches Internet Explorer support :cry:

But the upside is, that we can use the Keyboard Shortcuts easily for CodeMirror, too, without having to convert them from TiddlyWiki format to CodeMirror format in a complicated manner.

This Keyboard Shortcut system needs testing. KB shortcuts should still work the same way, KB shortcut names shouldn’t change. If they do, I need to update an internal conversion-table. Currently this table is short, I’m sure I need to add some entries. It looks like this:

var conversionKeys = {
	"ArrowLeft": "Left",
	"ArrowRight": "Right",
	"ArrowUp": "Up",
	"ArrowDown": "Down",
	",": "Comma",
	";": "Semicolon",
	".": "Period",
	":": "Colon"
};

I’m not experienced in which other characters need conversion, we’ll find out.

Please let me know if there are issues that arise from this change. It’s pretty experimental still.

Thank you,
Simon

1 Like

… aaand v0.7.2 is soon online which should fix the CodeMirror Keyboard Shortcuts not being recognized if they contain a “character” from the conversionKeys

:grin: no doesn’t work yet!

But now it works :muscle:

Version 0.7.4

Tested

Too bad that we cannot change keyboard shortcuts on-the-fly but need to close and open the Tiddler if we change one. Would be very cool otherwise

2 Likes

Version 0.7.5 is out!

  • reconfigurable keyboard shortcuts on the fly, without having to close the tiddler and reopening it
  • better handling of the escape key within the editor / closing panels … it’s still buggy

If you want to test, the plugin is online.
But beware, this might be in a very buggy state :grin:

1 Like

Yes, but manageable. :wink:

@discourse

image

I really, really don’t care. :triumph:

Version 0.7.7 fixes the escape-key-handling within the editor and fixes the broken editor-preview

Now that I’ve figured out how to change configurations on the fly I may implement more interesting features.

1 Like