SlickEdit Community

SlickEdit Product Discussion => SlickEdit® => SlickEdit User Macros => Topic started by: jporkkahtc on June 26, 2015, 06:57:42 am

Title: SymHighlights GUI
Post by: jporkkahtc on June 26, 2015, 06:57:42 am
I've enhanced SymHighlight to include a UI that displays the set of highlighted words.
Each line has 2 check boxes: Enable and WordOnly.
WordOnly lets you set for each highlight if it should match a word exactly, or any match.


SymHighlight.e is heavily modified from the original by marksun.




I don't really know how to distribute this easily.
I've included a zip with several *.e files.




HighlightsDlgDef.e: This is the dialog definition. Normally it would be in your "vusrobjs.e" file.




To install:
Extract all the files to your slick config directory.
From the slick command line, run "HighlightsDlgDef.e" to install the dialog definition.
Then use Macro->Load Module on each of:
Then bind the commands
to keys as you would with SymHighlight.e


To open the dialog, run the command
  run_highlights
Title: Re: SymHighlights GUI
Post by: at5dapa1 on July 08, 2016, 10:35:57 am
Thank you for this beautiful macro.
In case you have not updated in the meantime I have few tips for:
Code: [Select]
static int dummyIndex = 0;
void ctl_new_button.lbutton_up()
{
    WordInfo wordSymDummy;
    // 139 is the nr of s_symColour elements from SymHighlightJOE.e
    wordSymDummy.m_Color = dummyIndex % 139;
    wordSymDummy.m_Enabled = true;
    wordSymDummy.m_WordMatch = true;
    wordSymDummy.m_Word = "text" :+ dummyIndex++;
    AddHighlightWord(wordSymDummy);
}

    - The dummyIndex can be re-zeroed in a separate DoClearDialog() method called from ClearAllSymHighlight().
Code: [Select]
// set shorcut keys in SlickEdit
_command void quick_SymHighlightsSetSEKeys() name_info(','VSARG2_EDITORCTL|VSARG2_MACRO)
{
  gui_bind_to_key("quick-SymHighlights-");
}
Title: Re: SymHighlights GUI
Post by: Clark on July 24, 2016, 01:41:02 pm
I don't really know how to distribute this easily.
I've included a zip with several *.e files.
There isn't a great way to package macros right now. The current plan is to support macro plugins for v22 (not v21 which is the next major release).
Title: Re: SymHighlights GUI
Post by: hs2 on July 24, 2016, 03:05:09 pm
As workaround a hotfix package could be used. HS2
Title: Re: SymHighlights GUI
Post by: jporkkahtc on July 28, 2016, 06:31:20 pm
Thanks for the tips.
I've not worked on this for awhile, but I have plans to, so I will try to incorporate these changes.
I was motivated to write this while I needed to work with some horrible log files for debugging  - something I've not been doing much of lately.



Title: Re: SymHighlights GUI
Post by: eee on November 23, 2016, 12:58:22 pm
SE : SlickEdit Pro 2016 (v21.0.0.12 64-bit)
with  hotfix_se2100_9_cumulative.zip

When loading HighlightDialog.e
get the following error in the status line: Identifier 'sc' not declared
and the attached dialog
Title: Re: SymHighlights GUI
Post by: eee on November 23, 2016, 03:29:13 pm
It would also be nice to be able to set specific colors to specific words.
I managed to get the functions to receive a string (default '') in addition to using the selection or cur_word, but setting a specific color is a bit obscure, so I need help here.

Use-case: analyzing log files. Having constant colors for debug/info/warning/error would be an enormous enhancement.
Title: Re: SymHighlights GUI
Post by: jporkkahtc on November 23, 2016, 05:15:42 pm
WRT "sc", at the top of the file change import to require
#require "sc/lang/IToString.e"
#require "sc/lang/IHashable.e"

I'm not sure what the difference is.

I want to develop this further, but I don't have a pressing need for it - so its just in my spare time right now.

I intended for the UI to allow you to pick a specific color for each word, but I've not written that part yet.
Probably not with a color picker, but something simpler like cycling the colors each time you click on the word in the UI.

Title: Re: SymHighlights GUI
Post by: eee on November 23, 2016, 05:32:09 pm
OK.
But when you get to it, keep in mind the possibility to determine strings and bound colors via a macro call.
This will allow persistence.
e.g.
    SetSymHighlight("ERROR", 1);
    SetSymHighlight("WARNING", 2);
    SetSymHighlight("INFO", 3);
The numbers denote a color index.

Title: Re: SymHighlights GUI
Post by: jporkkahtc on January 18, 2017, 10:09:19 pm
I've incorporated these suggestions into the new version - not quite ready yet.

WRT SetSymHighlight() - I have this now, but what I'd like to do is have save/load functions to take the current set of highlights and save to a file, and later restore them.

I'm considering supporting a regex as a match string, but this has some interesting effects and would be difficult to make it robust given an arbitrary user written regex.
Title: Re: SymHighlights GUI
Post by: jporkkahtc on January 31, 2017, 07:00:16 pm
OK, here is the new version.
Loading it should be easier this time.
Be sure to unload the current one first.
Unpack the zip and put the files where Slick can find them - in your slick path, or in your config directory directly.

Then from the Slick command line run
symtagload

This should load all the modules in the right order to make it work.
To unload, run
symtagunload.

For key binding, run
symtagBindKeys.


This release it mostly about cleaning up the code and making it work more reliably.
I haven't tested it extensively yet, but seems to work.


In the dialog there are some shortcuts.
"c" - cycle color
"Shift+c" - cycle color backwards.
"e" - toggle enable/disable
"w" - toggle word mode on/off.
"F2" - edit the highlight word.


(Updated the zip file to include the correct dlg defintion that includes esc key support).
Title: Re: SymHighlights GUI
Post by: eee on February 01, 2017, 12:47:27 pm
Must fix the following in load
- colorDistance.e is with a lower case c (not Color), fix also in unload
- The absolute path to gRootPath should be replaced with"gRootPath = _ConfigPath();" as the 1st line of defmain(), or something similar.

Just installed it and assigned keys, did not try to really work with it.
Basically seems to work.
Title: Re: SymHighlights GUI
Post by: stsimmer on October 30, 2017, 10:02:28 am
cant load this macro... can you provide more exactly how to ...
step by step.... if ti possible...
Title: Re: SymHighlights GUI
Post by: jporkkahtc on October 30, 2017, 06:12:26 pm
I added HighlightsDlg_V22.zip to the original post.
I also updated the git repo:  https://github.com/jporkka/slickMacros.git
Title: Re: SymHighlights GUI
Post by: Clark on October 30, 2017, 06:21:13 pm
We noticed a problem with classes turning on too many pedantic options and causing the issue with the boolean keyword even if pedantic is off. Removing pedantic should have worked but currently doesn't. We will get that fixed.

Not sure what you did but I added the following to the top of a couple files. Not great but it works and is backward compatible.
#if __VERSION__>=22
    #define boolean bool
#endif
Title: Re: SymHighlights GUI
Post by: stsimmer on November 01, 2017, 10:35:10 am
Thank you very much, what about installation instruction?
Title: Re: SymHighlights GUI
Post by: jporkkahtc on November 01, 2017, 07:45:09 pm
In the readme.txt
The readme tells you to put these macro files in your CONFIG directory.
The CONFIG dir is something like C:\Users\joe\Documents\Slickedit\22.0.0.0\

I like to put my macros in a different location.
In CONFIG\user.cfg.xml I have added:
Code: [Select]
<misc.environment n="misc.environment" version="1" configs="win">
<p n="VSLICKMACROS" v="%VSLICKMACROS%;%SLICKEDITCONFIG%macros;%VSLICKPATH%;%SLICKEDITCONFIG%macros\Highlight"/>
<p n="VSLICKPATH" v="%VSLICKPATH%;%SLICKEDITCONFIG%macros;%SLICKEDITCONFIG%macros\Highlight"/>
</misc.environment>

This lets me put my macros into these two folders as well:
Code: [Select]
C:\Users\joe\Documents\Slickedit\macros
C:\Users\joe\Documents\Slickedit\macros\Highlight


There doesn't seem to be a UI in Slickedit to create this entry in user.cfg.xml, but it does preserve once it is there. (Restart slick after adding it).

Anyways, once you unpack the macros into CONFIG or Highlight as above, from the slick command line just run
Code: [Select]
symtagload

To be extra clear, when you have done it properly you will have either

Code: [Select]
C:\Users\joe\Documents\Slickedit\22.0.0.0\symtagload.e
or
Code: [Select]
C:\Users\joe\Documents\Slickedit\macros\Highlight\symtagload.e
Title: Re: SymHighlights GUI
Post by: stsimmer on November 02, 2017, 05:56:07 am
I am sorry about incorrect question…  I need "how to..." for linux and VS22…
Currently i put a files to the /opt/slickedit-pro2017/macros/HighlightsDlg/ … (default installation directory for slick edit 22)
(HighlightsDlg created by me, and all files from zip under this directory...)
After this, I am trying to load  macro from: Macro->load module..
and nothing...
Title: Re: SymHighlights GUI
Post by: jporkkahtc on November 02, 2017, 03:40:46 pm
Your config directory would be something like ~/.slickedit/22.0.0
User your user account, not the slickedit installation folder.

You should see a file named user.cfg.xml in the same directory.
Title: Re: SymHighlights GUI
Post by: at5dapa1 on February 16, 2018, 10:28:29 am
In CONFIG\user.cfg.xml I have added:
Code: [Select]
<misc.environment n="misc.environment" version="1" configs="win">
<p n="VSLICKMACROS" v="%VSLICKMACROS%;%SLICKEDITCONFIG%macros;%VSLICKPATH%;%SLICKEDITCONFIG%macros\Highlight"/>
<p n="VSLICKPATH" v="%VSLICKPATH%;%SLICKEDITCONFIG%macros;%SLICKEDITCONFIG%macros\Highlight"/>
</misc.environment>

Seems now (at least in Windows) we have to use SLICKEDITCONFIGVERSION instead of SLICKEDITCONFIG, so I have something like this:
Code: [Select]
<misc.environment n="misc.environment" version="1" configs="win">
<p n="VSLICK_MY_MACROS" v="%SLICKEDITCONFIGVERSION%_additional_macros_\;%SLICKEDITCONFIGVERSION%_additional_macros_\my_macros\;%SLICKEDITCONFIGVERSION%_additional_macros_\Symhighlight_V2\"/>
<p n="VSLICKMACROS" v="%VSLICKMACROS%;%VSLICK_MY_MACROS%"/>
<p n="VSLICKPATH" v="%VSLICKPATH%;%VSLICK_MY_MACROS%"/>
<p n="VSLICKINCLUDE" v="%VSLICKINCLUDE%;%VSLICK_MY_MACROS%"/>
</misc.environment>

echo %SLICKEDITCONFIGVERSION%
  =>  <My_Strange_Path>\config\22.0.2\
echo %SLICKEDITCONFIG%
  =>  <My_Strange_Path>\config\
Title: Re: SymHighlights GUI
Post by: at5dapa1 on February 16, 2018, 10:45:53 am
Not sure if it's on my config only, but in SymHighlightV2/HighlightDialog.e, in findItem(), had to replace s_list_ctrl._TreeGetNextIndex(0) with s_list_ctrl._TreeGetNextIndex(TREE_ROOT_INDEX), else I was getting "This property or method is not allowed on this object" on new SE22.0.2/Win7x64.
Title: Re: SymHighlights GUI
Post by: jporkkahtc on February 16, 2018, 03:35:02 pm
wrt SLICKEDITCONFIGVERSION:

Oops -- slickeditconfig is a system env var I set to tell Slick where to put the user configuration, instead of the default C:\users\<user>\documents\my slickedit config.

So you are right SLICKEDITCONFIGVERSION is the variable to use.
Title: Re: SymHighlights GUI
Post by: jporkkahtc on February 16, 2018, 03:37:03 pm
wrt TREE_ROOT_INDEX: That is defined as 0 in C:\Program Files\SlickEdit Pro 22.0.2\macros\slick.sh.

If you change it back to 0 does the problem still repro for you?

Can you share repro steps?
Title: Re: SymHighlights GUI
Post by: at5dapa1 on February 17, 2018, 11:45:21 am
Indeed I saw too that TREE_ROOT_INDEX is 0 and was a bit puzled why was complaining there and why TREE_ROOT_INDEX helped as it did work fine in 22.0.1. It appered sudenly in 22.0.2, maybe the macro reloading did help...
But now I put back to 0 and no more error! So maybe was something else, please ignore my comment for now. I'll come back if I hit again the issue.
Title: Re: SymHighlights GUI
Post by: rgloden on January 20, 2019, 09:34:50 pm
I would be elated to see SymHighlights (or equivalent) incorporated into the official SE release.  Loading 3rd party macros on lots of desktops in an enterprise environment doesn't work well.