Author Topic: SymHighlights GUI  (Read 35056 times)

jporkkahtc

  • Senior Community Member
  • Posts: 2620
  • Hero Points: 210
  • Text
SymHighlights GUI
« 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:
  • [size=78%]SymHighlightJOE.e[/size]
  • [size=78%]colorDistance.e[/size]
  • [size=78%]HighlightDialog.e[/size]
Then bind the commands
  • [size=78%]CycleSymHighlight[/size]
  • [size=78%]ToggleSymHighlight[/size]
  • [size=78%]ClearAllSymHighlight[/size]
to keys as you would with SymHighlight.e


To open the dialog, run the command
  run_highlights
« Last Edit: October 30, 2017, 06:11:29 PM by jporkkahtc »

at5dapa1

  • Senior Community Member
  • Posts: 282
  • Hero Points: 24
Re: SymHighlights GUI
« Reply #1 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:
  • for "TODO: Add new item" in ctl_new_button.lbutton_up():
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().
  • add a dummy Close button in the dialog with p_cancel=true; so that it can be dismissed via Esc key.
    • add an alternate name to your exported commands, e.g. quick_SymHighlights_Toggle, quick_SymHighlights_Cycle, quick_SymHighlights_ClearAll, quick_SymHighlights_ShowDlg, so that it's easier to access them via command line.
      Then also a code like below can help the user to quickly set some shortcuts to them:
    Code: [Select]
    // set shorcut keys in SlickEdit
    _command void quick_SymHighlightsSetSEKeys() name_info(','VSARG2_EDITORCTL|VSARG2_MACRO)
    {
      gui_bind_to_key("quick-SymHighlights-");
    }

      Clark

      • SlickEdit Team Member
      • Senior Community Member
      • *
      • Posts: 6826
      • Hero Points: 526
      Re: SymHighlights GUI
      « Reply #2 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).

      hs2

      • Senior Community Member
      • Posts: 2761
      • Hero Points: 292
      Re: SymHighlights GUI
      « Reply #3 on: July 24, 2016, 03:05:09 PM »
      As workaround a hotfix package could be used. HS2

      jporkkahtc

      • Senior Community Member
      • Posts: 2620
      • Hero Points: 210
      • Text
      Re: SymHighlights GUI
      « Reply #4 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.




      eee

      • Community Member
      • Posts: 36
      • Hero Points: 3
      Re: SymHighlights GUI
      « Reply #5 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
      « Last Edit: November 23, 2016, 01:00:14 PM by eee »

      eee

      • Community Member
      • Posts: 36
      • Hero Points: 3
      Re: SymHighlights GUI
      « Reply #6 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.

      jporkkahtc

      • Senior Community Member
      • Posts: 2620
      • Hero Points: 210
      • Text
      Re: SymHighlights GUI
      « Reply #7 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.


      eee

      • Community Member
      • Posts: 36
      • Hero Points: 3
      Re: SymHighlights GUI
      « Reply #8 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.


      jporkkahtc

      • Senior Community Member
      • Posts: 2620
      • Hero Points: 210
      • Text
      Re: SymHighlights GUI
      « Reply #9 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.

      jporkkahtc

      • Senior Community Member
      • Posts: 2620
      • Hero Points: 210
      • Text
      Re: SymHighlights GUI
      « Reply #10 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).
      « Last Edit: January 31, 2017, 09:53:27 PM by jporkkahtc »

      eee

      • Community Member
      • Posts: 36
      • Hero Points: 3
      Re: SymHighlights GUI
      « Reply #11 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.

      stsimmer

      • Community Member
      • Posts: 16
      • Hero Points: 0
      Re: SymHighlights GUI
      « Reply #12 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...

      jporkkahtc

      • Senior Community Member
      • Posts: 2620
      • Hero Points: 210
      • Text
      Re: SymHighlights GUI
      « Reply #13 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

      Clark

      • SlickEdit Team Member
      • Senior Community Member
      • *
      • Posts: 6826
      • Hero Points: 526
      Re: SymHighlights GUI
      « Reply #14 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