Author Topic: Communication between plugins (abbreviations, codecompletion)  (Read 14802 times)

Offline p2rkw

  • Almost regular
  • **
  • Posts: 142
Communication between plugins (abbreviations, codecompletion)
« on: August 20, 2012, 10:31:03 pm »
Hi,
How plug-ins can communicate (exchange data) with each other? Is it possible?

Last time I found out that  most of my abbreviations keywords are c++ keywords too (class, for, switch, etc.). So when I typing one of them and codecompletion's SmartSense occurs I pressed"enter", and next keyboard shortcut for autocomplete.

Unfortunately I can only remember small part of my abbreviation's keywords. But, wait, why other abbreviations can't be listed in call tip too?
So, I want to import keywords from abbreviations plugin to codecompletion's SmartSense. If abbreviation keyword will be selected it macro will be automatically expanded.
What you think about this idea?

How can I import abbreviation's keywords to codecompletion? I read about Codeblocks events but it seems that only main app can send them.

« Last Edit: August 27, 2012, 12:46:47 pm by p2rkw »

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9694
Re: Communication between plugins (abbreviations, codecompletion)
« Reply #1 on: August 21, 2012, 06:34:07 am »
How plug-ins can communicate (exchange data) with each other? Is it possible?
This should not be needed and would be bad design and therefore error prone.

If abbreviation keyword will be selected it macro will be automatically expanded.
This should therefore be a function of the abbreviations plugin and not code-completion. Thus, no plugin-plugin communication is needed. :)
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ

Offline p2rkw

  • Almost regular
  • **
  • Posts: 142
Re: Communication between plugins (abbreviations, codecompletion)
« Reply #2 on: August 22, 2012, 02:40:38 am »
@MortenMacFly: my first idea was to import all abbreviations keywords into CC as normal keywords, so they could be avalible as well as normal keywords (one sorted list)  and after eventually selection of imported keyword call abbreviations plugin to expand macro. But I don't know enough source code architecture so I added auto completion to abbreviations.

I know that this patch should be divided into 2 parts, but again, I dont know how to create two patches on one working copy :)
Patch1:
- replace iteration over abbreviation's keywords map with find
- abbreviations now can be expandend even if cursor is inside keyword (not only at end)
Patch2:
- same as above +
- if keyword isn't complete abbreviation will display  auto complete tip with possible matches

edit: patch in first post
« Last Edit: August 22, 2012, 09:50:53 pm by p2rkw »

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9694
Re: Communication between plugins (abbreviations, codecompletion)
« Reply #3 on: August 22, 2012, 06:07:02 am »
Patch1:
Patch2:
Don't forget to put them on the patch tracker so they don't get lost and can be assigned to a dev.
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9694
Re: Communication between plugins (abbreviations, codecompletion)
« Reply #4 on: August 22, 2012, 06:51:54 am »
Patch1:
Patch2:
BTW: Applying patch 2 causes conflicts when having patch 1 applied first. Does patch 2 include/supersede patch 1? They don't seem to be incremental to me...
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ

Offline p2rkw

  • Almost regular
  • **
  • Posts: 142
Re: Communication between plugins (abbreviations, codecompletion)
« Reply #5 on: August 22, 2012, 02:08:55 pm »
Quote
Does patch 2 include/supersede patch 1?
Yes, I made patch2 after patch 1.

Today, I realized that I generate patch in wrong directory, so I'm attaching corrected second patch ( it seems that first one is unnecessary ).
I don't have perrmisions to upload patch, can you do that?
edit: patch removed form this post
« Last Edit: August 22, 2012, 09:50:03 pm by p2rkw »

Offline p2rkw

  • Almost regular
  • **
  • Posts: 142
Re: Communication between plugins (abbreviations, codecompletion)
« Reply #6 on: August 22, 2012, 03:34:23 pm »
I found serious bug :/ Dont apply those patches.

Offline daniloz

  • Regular
  • ***
  • Posts: 268
Re: Communication between plugins (abbreviations, codecompletion)
« Reply #7 on: August 22, 2012, 03:39:19 pm »
I've tested the patch and like it (haven't been hit by the serious bugs yet). Just an icon is missing now...  ;)

If abbreviation keyword will be selected it macro will be automatically expanded.
This should therefore be a function of the abbreviations plugin and not code-completion. Thus, no plugin-plugin communication is needed. :)

I understand the idea of having no plugin-plugin communication. However, me too, I'd like to see the abbreviations in the same list as the code-completion suggestions, without having to remember a different shortcut for using the abbreviations.

Idea: do a framework to show completions and from this framework, we could have plugins providing the suggestions (words) with a callback to a function that "insert/execute" the suggestion.  ;D

Offline Alpha

  • Developer
  • Lives here!
  • *****
  • Posts: 1513
Re: Communication between plugins (abbreviations, codecompletion)
« Reply #8 on: August 22, 2012, 08:46:29 pm »
Word of caution: how do you plan resolve identifiers that are both keywords and abbreviations (ex. struct, class, and while)?

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9694
Re: Communication between plugins (abbreviations, codecompletion)
« Reply #9 on: August 22, 2012, 09:28:22 pm »
Word of caution: how do you plan resolve identifiers that are both keywords and abbreviations (ex. struct, class, and while)?
True. I still think it shouldn't be mixed. I am rather happy with having two shortcuts here - one for CC and one for abbrevs. Maybe thy should be bound more close together, like:
CTRL + SPACE for CC and
CTRL + SHIFT + SPACE for abbrevs or alike.
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ

Offline p2rkw

  • Almost regular
  • **
  • Posts: 142
Re: Communication between plugins (abbreviations, codecompletion)
« Reply #10 on: August 22, 2012, 09:49:16 pm »
I arleady fixed it ;) Check out patch from first post ( before apply revert changes )
« Last Edit: August 22, 2012, 09:53:31 pm by p2rkw »

Offline daniloz

  • Regular
  • ***
  • Posts: 268
Re: Communication between plugins (abbreviations, codecompletion)
« Reply #11 on: August 22, 2012, 09:54:17 pm »
Word of caution: how do you plan resolve identifiers that are both keywords and abbreviations (ex. struct, class, and while)?

Just show them twice, since both plugins will add them to the list, but each one with a different icon, so it will be easy to identify them in the list...

Offline p2rkw

  • Almost regular
  • **
  • Posts: 142
Re: Communication between plugins (abbreviations, codecompletion)
« Reply #12 on: August 27, 2012, 01:14:29 pm »
Quote
Idea: do a framework to show completions and from this framework, we could have plugins providing the suggestions (words) with a callback to a function that "insert/execute" the suggestion.  Grin
I agree with that, but I don't decide here :)
Other option is to toggle between auto-complete lists with one shortcut.
Anyway current patch only adds auto-complete list to abbreviations, but it's not very functional because it's necessary to use shortcut to see it.
I fixed bugs, and in current version patch doesn't break CC autocomplete.

BTW: I tried to handle wxEVT_SCI_AUTOCOMP_CANCELLED event, but it doesn't occur.

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9694
Re: Communication between plugins (abbreviations, codecompletion)
« Reply #13 on: August 27, 2012, 01:19:27 pm »
I fixed bugs, and in current version patch doesn't break CC autocomplete.
I don't see any patch anymore...
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ

Offline p2rkw

  • Almost regular
  • **
  • Posts: 142
Re: Communication between plugins (abbreviations, codecompletion)
« Reply #14 on: August 27, 2012, 01:46:03 pm »
I uploaded it to patch tracker: http://developer.berlios.de/patch/?func=detailpatch&patch_id=3323&group_id=5358

Edit: There's still one bug: when abbreviation was selected from auto-complete list macro is expanded correctly, but CC still tries to insert selected keyword, so if cursor(pipe) is inside word it will be replaced by empty string by CC plugin.
« Last Edit: August 31, 2012, 12:28:08 am by p2rkw »