Author Topic: A few goodies for programmers and no-mouse-please hackers ;)  (Read 13704 times)

hs2

  • Senior Community Member
  • Posts: 2761
  • Hero Points: 292
Thought it's time to give s.th. back to the community b/c that's the idea of it, right ?
The attached module contains a couple of my daily use-macros.
Hope they are useful for some others too.

- 1st part provides simple pop-up listboxes with the operator hierarchy for those (like me) who cannot remember all of these rules.

- 2nd part is helps to 'quickly find the current word/selection w/o using the fully blown dialog' in current buffer, all buffers, project files and workspace files.
I also made a slight adoption of find_word_sel to find all TODOs accordingly - but it's not included. I share it if someone is interested in.
@SlickTeam: Would be nice a have an auto-updated toolbar for it (similar to 'Bookmarks') and with configurable TODO-patterns.

- 3rd part was inspired by running out of keyboard shortcuts - and my limited ability to remember all of them ;)
  In addition I just don't want to put my hands off the keyboard - find the mouse on the desk and do a right click ... only to get the (useful) context/config/version control menus.

Have fun - HS2
« Last Edit: July 24, 2006, 01:08:14 PM by hs2 »

Graeme

  • Senior Community Member
  • Posts: 2793
  • Hero Points: 347
Re: A few goodies for programmers and no-mouse-please hackers ;)
« Reply #1 on: July 24, 2006, 10:25:10 AM »

Thanks for posting the macros HS2. 

When I saw the C++ precedence table which you got from Stroustrup CPP book I remembered he had some minor errors in that table  - I think he's corrected them in an errata but I'm not sure which edition.  sizeof is a unary operator and groups right to left.  Post-inc and post-dec are postfix operators and belong with [] etc and group left to right. 

I don't think throw operator has an associativity because you can't chain them.  One book I have says throw has same precedence as assignment operators and groups right to left -  throw a = b; does the assignment before the throw  - but I guess this is the same as saying throw has lower precedence.

Graeme

hs2

  • Senior Community Member
  • Posts: 2761
  • Hero Points: 292
Re: A few goodies for programmers and no-mouse-please hackers ;)
« Reply #2 on: July 24, 2006, 01:13:47 PM »
Oh dear ... you are absolutely right ! I quickly double-checked the table against HIS special aka. 4th edition.
The attachment is updated and extended (just the cpp_hier []).

Thanks Grame !

hs2

  • Senior Community Member
  • Posts: 2761
  • Hero Points: 292
Re: A few goodies for programmers and no-mouse-please hackers ;)
« Reply #3 on: November 23, 2014, 07:39:07 PM »
k_context_menu.e now contains the commented an override of the stock macro mouse.e::context_menu() required by k_context_menu.
HS2

Edit: uploaded fixed version (commented 'context_menu' override)
Edit2: uploaded fix for toolwindow context menu with SEv19
« Last Edit: December 03, 2014, 09:35:10 PM by hs2 »

MindprisM

  • Senior Community Member
  • Posts: 127
  • Hero Points: 8
Re: A few goodies for programmers and no-mouse-please hackers ;)
« Reply #4 on: November 25, 2014, 12:17:54 PM »
One strategy I have adopted for managing macro invocation is to use a "linear menu" via letter_prompt:

The menu is triggered by a hot key, say alt-q, then letter_prompt gives a prompt like:

Goto_, Copy_, Add_, Interests, conTrols, Published, Notification, Hookevents, control Events, pUblish, intereSt, Receive, senDer, nOtification refresh, remoVe unused sections

Where the uppercase letter is the letter to press and the trailing underscore indicates a submenu

So if I press alt-q g

The prompt will look like

_.g:Goto... Internal_, Public_, pRotected_, priVate_, Constructor

The setup looks like:
Code: [Select]
top_menu('Goto_, Copy_, Add_, Interests, conTrols, Published, Notification, Hookevents, control Events, pUblish, intereSt, Receive, senDer, nOtification refresh, remoVe unused sections');
sub_menu('_', 'g', 'Internal_, Public_, pRotected_, priVate_, Constructor');

men_item('_g','i', 'm', s1, 'goto_internal_members');
men_item('_gi','s', 'm', s1, 'goto_internal_static_members');
men_item('_gi','c', 'm', s1, 'goto_internal_const_members');
men_item('_gis','c', 'm', s1, 'goto_internal_static_const_members');
etc


Why is this better than a reqular menu? Its more stable (sticky) and precise (one key,one action). Plus it is easier to modify (no menu gui), and if you are hooking alt-keys the normal menu isn't easy to trigger.

I have code for it if interested.

hs2

  • Senior Community Member
  • Posts: 2761
  • Hero Points: 292
Re: A few goodies for programmers and no-mouse-please hackers ;)
« Reply #5 on: December 01, 2014, 10:58:57 PM »
See attached an updated version of misc_tools_hs2.e.
Please note that the 'k-context-menu' macro needs this compatible patch (snippet contained in the attached module):
Code: [Select]
#if 0 // HS2-NOT: k_context_menu needs this patch in mouse.e
// HS2-CHG: override stock macro mouse.e::context_menu() with this enhanced, but compatible version: x,y opt. args
_command void context_menu(int x = MAXINT, int y = MAXINT) name_info(','VSARG2_MARK|VSARG2_READ_ONLY|VSARG2_REQUIRES_EDITORCTL|VSARG2_ICON|VSARG2_NOEXIT_SCROLL)
{
   if (x == MAXINT) x = p_client_width  intdiv 2;
   if (y == MAXINT) y = p_client_height intdiv 2;
   _mou_mode_menu(x,y);
}
#endif

changes:
- minor code cleanup/commenting
- 'k-context-menu' works (again ?) with recent SE versions up to and including SEv19
- removed obsolete 'k-config-menu'

Regards, HS2

Edit: re-uploaded with fixes for SEv19 (toolwindow context menu was broken)
« Last Edit: December 02, 2014, 10:45:35 PM by hs2 »

hs2

  • Senior Community Member
  • Posts: 2761
  • Hero Points: 292
Re: A few goodies for programmers and no-mouse-please hackers ;)
« Reply #6 on: December 02, 2014, 10:55:06 PM »
Hi, I've fixed a compatibility issue related to extended/toolwindow context menus.
Thanks to flethuseo for testing and bug reporting.
misc_tools_hs2.e and also k_context_menu.e is now fully compatible with SE <= v19 - hopefully ;)
I've also added 'Defs' toolwindow support.
Please see the previous postings for the re-uploaded modules.

Regards, HS2
« Last Edit: December 02, 2014, 11:07:37 PM by hs2 »

flethuseo

  • Senior Community Member
  • Posts: 177
  • Hero Points: 2
Re: A few goodies for programmers and no-mouse-please hackers ;)
« Reply #7 on: December 03, 2014, 04:39:11 PM »
Thank you for fixing it! :)
All the stuff required to fix that up goes way over my head. I only know very simple macro programming.

flethuseo

  • Senior Community Member
  • Posts: 177
  • Hero Points: 2
Re: A few goodies for programmers and no-mouse-please hackers ;)
« Reply #8 on: December 04, 2014, 09:26:12 PM »
HS2,
How can I modify the macro to work for the buffers/project/workspace toolbars? I have tried the following, but it doesn't work (I'm referring to the toolbar that shows up when I issue command: activate-files

Code: [Select]
// @see somef...e
defeventtab _tbfilelist_form;
void _tbfilelist_form.K_CONTEXT_MENU_KEY()
{
   k_context_menu();
}


hs2

  • Senior Community Member
  • Posts: 2761
  • Hero Points: 292
Re: A few goodies for programmers and no-mouse-please hackers ;)
« Reply #9 on: December 05, 2014, 02:01:44 AM »
@flethuseo: Unfortunately it's not as easy as it seems :(
My private implementation worked with older SE versions but was broken with more recent SE versions due to change behaviour of the tree-lists.
And because I use the context menu of the files toolwindow very rarely it's didn't care - sorry.
HS2