Lazarus

Using the Lazarus IDE => Debugger => Topic started by: Tango600 on June 13, 2022, 09:44:39 am

Title: Visual Studio keymap (for debugger and compiller)
Post by: Tango600 on June 13, 2022, 09:44:39 am
If I create Visual Studio keymap, how I publish this&
Title: Re: Visual Studio keymap (for debugger and compiller)
Post by: MarkMLl on June 13, 2022, 09:59:10 am
Are you saying that you've produced a keymap for Lazarus? If so I'd suggest discussing it here with a particular focus on what OSes etc. you've tested it with. Then submit is as a bug report (see link in left-hand column).

If OTOH you're discussing a keymap for Visual Studio it's not relevant to this forum.

MarkMLl
Title: Re: Visual Studio keymap (for debugger and compiller)
Post by: marcov on June 13, 2022, 10:06:02 am
If OTOH you're discussing a keymap for Visual Studio it's not relevant to this forum.

If it is to put FPC under an other IDE like VS/VSCode, it is relevant, but should be moved to FPC subforums (not lazarus subforum).

The short answer is probably: put it on github/gitlab or any other form of free hosting.   
Title: Re: Visual Studio keymap (for debugger and compiller)
Post by: MarkMLl on June 13, 2022, 12:28:15 pm
If it is to put FPC under an other IDE like VS/VSCode, it is relevant, but should be moved to FPC subforums (not lazarus subforum).

Yes, true.

At this point however I'd note that the Lazarus IDE stands comparison with VSCode, and is superior (in my opinion) to Eclipse. It's a pity that it doesn't support more languages, possibly via something like the Language Server Protocol (noting e.g. the thread at https://www.mail-archive.com/fpc-pascal@lists.freepascal.org/msg52619.html).

MarkMLl
Title: Re: Visual Studio keymap (for debugger and compiller)
Post by: Martin_fr on June 13, 2022, 01:35:32 pm
If I create Visual Studio keymap, how I publish this&

You mean you went to menu: Tools > Options > Editor > Keymap?

Unfortunately the IDE does not have an Export or Import function for those settings.

You can find the changes you made in the "EditorOptions.xml" file, in your "primary config path".
The "primary config path" can be found in menu View > Ide Internals > About IDE.
It defaults to: C:\Users\<YOUR_USERNAME>\AppData\Local\lazarus or on Linux to ~/.lazarus

The XML in that file has a "<KeyMapping>" section.



So to make your changes available:
- you open that file, and copy that section. Then publish that XML.
- Users who want to use it can (while the IDE is closed) edit their "EditorOptions.xml".


However, your changes will be based on one of the default schemes. Either:
- Lazarus Default
- Classic
- MacOs Apple style
- MacOs Lazarus style

The Mac schemes will have different mappings for the modifier keys.
E.g. "Ctrl-c" will be "Command-C"  (IIRC).

Your changes are relative to your selected scheme. (only the diff is saved).
So it may (at least partly) work with other schemes. But likely will need some work for them.

Of course - if for example you are NOT a Mac user - then everyone importing your scheme, if they too are not Mac users, can use the same base-scheme.
But not all Mac-Users wont be happy using a non-Mac base scheme.
Still they can adapt it....



It would be nice, if someone could contribute Export/Import of keymaps....
Title: Re: Visual Studio keymap (for debugger and compiller)
Post by: Tango600 on June 13, 2022, 07:47:56 pm
... should be moved to FPC subforums (not lazarus subforum).

Why, it is a Lazarus editor keymap.
Title: Re: Visual Studio keymap (for debugger and compiller)
Post by: Tango600 on June 13, 2022, 07:50:47 pm
note: Keymaps is hardcoded in "C:\lazarus\ide\keymapping.pp"
Title: Re: Visual Studio keymap (for debugger and compiller)
Post by: Tango600 on June 13, 2022, 07:58:06 pm
Note: Flashback note: I have installed many IDE on my PC. All IDEs have one keymap, except Lazarus.
Title: Re: Visual Studio keymap (for debugger and compiller)
Post by: skalogryz on June 13, 2022, 09:47:22 pm
It would be nice, if someone could contribute Export/Import of keymaps....
maybe, I could do that!
it has been my long time struggle xD
Title: Re: Visual Studio keymap (for debugger and compiller)
Post by: Martin_fr on June 13, 2022, 10:12:52 pm
It would be nice, if someone could contribute Export/Import of keymaps....
maybe, I could do that!
it has been my long time struggle xD

I'd be happy to assist if you have questions...

There is a similar feature for Colors and Advanced-Mouse-Config already.

The big question is, if an exported keymap should be
- a diff to one of the predefined sets. (That could over time cause issues, if the predefined set changes)
- a full export
- either of those - user can choose during export.
Title: Re: Visual Studio keymap (for debugger and compiller)
Post by: Martin_fr on June 13, 2022, 10:13:45 pm
note: Keymaps is hardcoded in "C:\lazarus\ide\keymapping.pp"

So you edited your copy of keymapping.pp ?
Title: Re: Visual Studio keymap (for debugger and compiller)
Post by: skalogryz on June 14, 2022, 07:36:02 pm
Here you go: https://github.com/skalogryz/Lazarus/commit/48eb5a1066438e93268d68486ec66bb9648b4eec

I don't really like the produced export file (which is based on the configuration).
It's not really human editable, but from IDE to IDE it should work just fine and it's future changes friendly already!

So maybe, the human-readable and editable format could be added alter.

todo: check if there're any "standards" in the keymapping world (similar to .editorconfig)

The big question is, if an exported keymap should be
- a diff to one of the predefined sets. (That could over time cause issues, if the predefined set changes)
- a full export
- either of those - user can choose during export.
What is "diff"? i think it's something that only IDE itself could use of, since it's aware of what is considered "default".
When brining the set of keys from one configuration to another, the "default" for source and destination systems can be different.
Thus the concept of "diff" makes no sense.

Just like any other application - the full export for the actual IDE version. (It's understood that commands could be added and removed between Lazarus versions).

upd
There is a similar feature for Colors and Advanced-Mouse-Config already.
For Colors I can only see "Export"... should there be an import too?

Looking through the Options frames, it appears to me that IDE needs some sort of guildelines on how to design those.

upd2
With the Import/Export in place, it should now be easier to get rid of hard-coded schemas and keep them external.
Title: Re: Visual Studio keymap (for debugger and compiller)
Post by: MarkMLl on June 14, 2022, 11:49:57 pm
todo: check if there're any "standards" in the keymapping world (similar to .editorconfig)

Not to the best of my knowledge. However if you've got access to a Linux system I'd point you at evtest and related info (which broadly speaking gives you a list of input devices- keyboard and other- and what they emit), and also at the mxk utility hence tangentially https://wiki.freepascal.org/Lazarus_IDE_with_Nostromo_Keypad_on_Linux for an example of what it can be used for.

Quote
What is "diff"? i think it's something that only IDE itself could use of, since it's aware of what is considered "default".
When brining the set of keys from one configuration to another, the "default" for source and destination systems can be different.
Thus the concept of "diff" makes no sense.

It makes a lot of sense, and is what Termcap etc. uses. Start off with some fairly standard mapping, and then have a brief list of how the current settings depart from it.

MarkMLl
Title: Re: Visual Studio keymap (for debugger and compiller)
Post by: skalogryz on June 15, 2022, 05:38:43 am
Start off with some fairly standard mapping, and then have a brief list of how the current settings depart from it.
and which mapping is standard for Larazus IDE?
is it standard for all operating systems Lazarus runs on?
Title: Re: Visual Studio keymap (for debugger and compiller)
Post by: MarkMLl on June 15, 2022, 08:52:07 am
Start off with some fairly standard mapping, and then have a brief list of how the current settings depart from it.
and which mapping is standard for Larazus IDE?
is it standard for all operating systems Lazarus runs on?

Not really relevant to the point that I think Martin's making. Start off with /something/ and give it a name, then publish modifications indicating what the named base is. The base could actually be a null mapping (i.e. the diff is actually a complete map), or a diff might be appropriate for multiple bases.

That would accommodate the case where e.g. I find I have to change just one mapping to avoid a clash with a KDE hotkey.

As I said, that's the way that termcap etc. have always worked on unix for output terminal control sequences, so there's precedent.

MarkMLl
Title: Re: Visual Studio keymap (for debugger and compiller)
Post by: Tango600 on June 17, 2022, 01:40:44 pm
So you edited your copy of keymapping.pp ?

I did it.

And I created issue.
https://gitlab.com/freepascal.org/lazarus/lazarus/-/issues/39798#note_994415230
Title: Re: Visual Studio keymap (for debugger and compiller)
Post by: skalogryz on June 18, 2022, 07:44:53 pm
for the discussion. Does it worth to modify loading XML process, thus it could understand characters, instead of integer codes for keys.

So instead of
Code: XML  [Select][+][-]
  1.     <Item9 Name="Build project/program">
  2.       <KeyA Default="False" Key1="117" Shift1="2"/>
  3.     </Item9>
  4.  
it would be possible to write:
Code: XML  [Select][+][-]
  1.     <Item9 Name="Build project/program">
  2.       <KeyA Default="False" Key1="F6" Shift1="Shift"/>
  3.     </Item9>
  4.  
(and if the actual number needs to be specified, it could be prefixed by some character)
Code: XML  [Select][+][-]
  1.     <Item9 Name="Build project/program">
  2.       <KeyA Default="False" Key1="*6" Shift1="Shift"/>
  3.     </Item9>
  4.  
(which would map to key "6")
Obviously, it's also possible to use a different attribute, i.e. Char1 (instead of Key1), BUT it also introduces a problem which one to use, if both are specified.

Purpose: to make the configuration of the key mapping files HUMAN friendly.

Btw, Visual Studio keyboard map XML is attached. It is based on Tango600's keyboard schema.
Title: Re: Visual Studio keymap (for debugger and compiller)
Post by: Martin_fr on June 18, 2022, 08:11:08 pm
for the discussion. Does it worth to modify loading XML process, thus it could understand characters, instead of integer codes for keys.

That is an interesting question... I think in most cases the actual key, is more important.

IIRC by default Ctrl+/  comments the current line/selection. Never mind which Keycode the "/" has on the users keyboard layout.

For example, I use "Dovrak UK Punctuation".
The IDE has
Code: Text  [Select][+][-]
  1.   ecToggleComment:       SetSingle(VK_OEM_2,[XCtrl]);
which did not work for me at all.
Having "ctrl" and "key=/" instead of a keycode, could help... or could mess it up.

On a German layout the "\" is only available via AltGr. Yet on an English layout the "\" has its own key.
Having something like ctrl-\  would then break, if a German user wants to load it.

Quote
(and if the actual number needs to be specified, it could be prefixed by some character)
Actually, in that case the XML could have a "KeyCode"
 <Item9 Name="Build project/program">
      <KeyA Default="False" KeyCode1="117" Key1="F6" Shift1="2"/>
    </Item9>

Quote
Btw, Visual Studio keyboard map XML is attached. It is based on Tango600's keyboard schema.

It will be a little time before I get to any of this. Quite busy right now.



I do think that the V.S. map is a great extension.
As for XML vs Build-in, I will wait what other devs have to say.
Title: Re: Visual Studio keymap (for debugger and compiller)
Post by: skalogryz on June 18, 2022, 10:31:24 pm
IIRC by default Ctrl+/  comments the current line/selection. Never mind which Keycode the "/" has on the users keyboard layout.
I see what you mean. Indeed layouts have different characters per same keycode.
Yet, if we define that characters are treated as US-layout characters and in the end are mapped to the corresponding key codes, this would be sufficient.
In the end, xml is to be human-friendly for the creator of such XML, not for the end-user.

For the end user the selection takes place through the UI only (and the contents of XML is not review).

Since you've brought that up.

How does this Key Edit dialog works:

There's a list of textual representation of keys (not just characters)
How does it map back to the key code? Does it respect the current layout, or is it fixed to a certain (US) layout?
Title: Re: Visual Studio keymap (for debugger and compiller)
Post by: Martin_fr on June 19, 2022, 11:23:14 am
I don't know what the dialog uses.

What we could use are the VK_### names: VK_A, VK_OEM.

Sadly, it seems we don't (yet? ;) ) have an IdentToInt for them.
See components\ideintf\idecommands.pas
  function IdentToIDECommand(const Ident: string; var Cmd: longint): boolean;
  function IDECommandToIdent(Cmd: longint; var Ident: string): boolean;

Title: Re: Visual Studio keymap (for debugger and compiller)
Post by: skalogryz on June 19, 2022, 09:24:07 pm
There are changes available: https://github.com/skalogryz/Lazarus/tree/keybordschemas

The branch introduces loading of the custom keyboard schemas.

I did put the description here: https://github.com/skalogryz/Lazarus/wiki/keybordschemas#Keyboard_Schema_Files

Now, it's possible to extend pre-defined schemas without changing the code and distribute them with Lazarus. (i didn't update any installers though)

I don't know what the dialog uses.
it's based of KeyAndShiftStateToKeyString (at LCLProc) (KeyCodeStrings array)
and there's a corresponding TextToShortCut() function to convert text to a code

and it's obviously fixed to a certain keyboard layout.
Title: Re: Visual Studio keymap (for debugger and compiller)
Post by: AlexTP on June 20, 2022, 10:41:47 am
Quote
I did put the description here: https://github.com/skalogryz/Lazarus/wiki/keybordschemas#Keyboard_Schema_Files
It should be put to Lazarus Wiki.
Should I do it?
Title: Re: Visual Studio keymap (for debugger and compiller)
Post by: PascalDragon on June 20, 2022, 01:32:49 pm
Quote
I did put the description here: https://github.com/skalogryz/Lazarus/wiki/keybordschemas#Keyboard_Schema_Files
It should be put to Lazarus Wiki.
Should I do it?

Why would you want to add this if the corresponding isn't yet part of Lazarus' main?
Title: Re: Visual Studio keymap (for debugger and compiller)
Post by: skalogryz on July 06, 2022, 08:59:52 pm
a couple of commits:
https://github.com/skalogryz/Lazarus/commit/c5f80390b08a47fce8af7b6ebb39757167e3c5ed (human readable export)

https://github.com/skalogryz/Lazarus/commit/99f54ec041414ae3050938ecc2d79193bc14c18e (file dialog filters)

The major change is;
- export is now generates human-readable file
- import supports human-readable values, yet the original "decimals" values are supported (backwards compatible)
- the entire list of shortcuts is exported (for "Export" feature), no matter if the key has an assigned  value or not

As a result, this should make the list of shortcuts be easily readable and editable.
Code: XML  [Select][+][-]
  1.     <Item30 Name="Close">
  2.       <KeyA Key1="F4" Shift1="Ctrl" Key2="" Shift2=""/>
  3.       <KeyB Key1="W" Shift1="Ctrl" Key2="" Shift2=""/>
  4.     </Item30>
Title: Re: Visual Studio keymap (for debugger and compiller)
Post by: skalogryz on July 11, 2022, 03:36:18 pm
conflict resolving commit
https://github.com/fpc/Lazarus/commit/5f05ba32d10d75dce044a9fb30a2203e62f7d05e
TinyPortal © 2005-2018