Named Bookmarks - a few remarks

cchris
2013-04-02
2013-04-23
  • cchris

    cchris - 2013-04-02

    I just installed Named Bookmarks. As mentioned, this looked like basic functionality N++ had to have.

    Now a few remarks:
    1/ While the comment is probably the cheapest way to add the bookmark, it won't play nice with SCMs like SVN, which will record a source change whenever bookmarks change. Remembering them in some property file will avoid the isue, as well as 3/ below. But then comes the tricky issue of tracking the position of the bookmark as text changes.
    2/ I just tried to define two bookmarks using the same number of cyrilic characters. They look fine in the creation dialog box, but booth come out as /@??????/, even though the default text font can display cyrillic script normally. Also, more annoyingly, there was only one bookmark reported in the Go to named bookmark dialog listbox.
    3/ I tried inserting bookmarks in a PHP file, and this would use the same C stream comment marks. Problem is, these C comment marks are not comments in every manguage around, and could be invalid text. Writing the bookmark name and then sending a line comment or stream comment message would remove the issue - keep the C marks when there is no coment marks at all for current highlighter, and use line comments if stream commenting is not available.

    Keep on the good work...

    CChris

     
  • David Bailey

    David Bailey - 2013-04-08

    Chris,

    Thanks for responding - I have been very busy with other things just recently and missed your response for several days.

    I guess I consider that adding a bookmark is adding a change to the source - just as adding a comment is making a change to the source. The alternative, as you say, is to store the bookmarks elsewhere, and I didn't feel comfortable that this would ever be robust. I imagine this issue is exactly why a feature of this sort is not already part of Notepad++! Do you see it is a reason not to proceed with this plugin?

    Regarding cyrilics, I will look at this, but I can't guarantee an easy solution, because the plugin uses a DLL that supplies a simple windows interface mechanism, and I don't know how it will handle UTF8 characters etc. Collectively, we own this DLL, so it might be possible to change it - it belonged to Salford Software, as part of their FTN77 and FTN95 compilers (on which I worked for many years), and at one point Silverfrost took ownership of the whole project - so in theory it could be altered, but the code is mostly 10+ years old....

    I guess the third point was just laziness - I will restrict the application to files with .CPP, .C, and .JAVA suffices.

    Personally, I think structured comments could represent a way to add lots of really useful features to NPP - for example, a structured comment (or maybe just a named bookmark) could display as a heading. Source code with large, readable headings would be a wonderful feature IMHO! Of course, this would need a switch to ignore this syntax to enable these things to be edited.

    Thanks for your interest.

    David

     
    Last edit: David Bailey 2013-04-08
  • cchris

    cchris - 2013-04-09

    There is no reason not to proced with the plugin, this is a functionality many people have asked for - see IdeaTorrent , Bookmarks category.

    About the Windows interface: unless your dll is very old, I asume it takes UTF16-LE encoded characters. Worst case could be that it takes local codepage ASCII. You may need to check the documentation for this dll, check what comes in and tranlate what gets out - in case user enters something the format of the document won't allow.

    I just tried a bookmark name using my own language (French), which has accented letters present in ISO-8859-1 character set. The é shows in document as 0xE9, which indicates your plugin receives UTF16, probably LE - 0xE9 is the Unicode for é (é, or e with acute accent). While I can understand the first version of the plugin can't have it all, please consider this usability issue for people likely to use characters outside Ascii range.

    Same point about the language-dependant comment marks. I have some large HTML files where named bookmarks would be handy, but /.../ won't play nice there. Again, I understand this could come in a future version without a timetable.

    CChris

     
    • David Bailey

      David Bailey - 2013-04-09

      Chris,

      Thanks for your encouragement. I will look into the issue of handling UTF-8 and produce another beta version for everyone to test. I think I will also generalise the plugin a bit to:

      a) Include HTML in some scheme that can be easily extended further to cover other languages, as necessary (but not by the user).

      b) Add a few more recognition characters after the /* to make structured comments more generally useful for other purposes. Perhaps

      /*@NPPBookmark........*/

      David

       
      Last edit: David Bailey 2013-04-09
  • François-R Boyer

    To recognize comments in several languages, one way is to rely on language lexers already in Scintilla. Once you ensure the document is styled, you can get the style of the characters to know if it is in comment (I have not looked at your code, or tried this case, but if you simply look for /*, it could find it in a string instead of a comment). You can search for COMMENT in SciLexer.h, to know what are the define names for comment styles in all languages.

     
    • David Bailey

      David Bailey - 2013-04-09

      My plugin as is could indeed be fooled by a string that contains a string that has the right format - but that hardly matters in practice. More importantly, when I want to add a comment, I move to the LHS of the line - so I am not inside a token - and then insert the bookmark comment as a line on its own.

      I am a bit reluctant to grow version 1 of this plugin until it gets pushed down my stack by other activities!

      David

       
  • David Bailey

    David Bailey - 2013-04-12

    I have now updated the beta version of the named bookmark plugin to work with utf-8 characters within the bookmarks, and also to restrict its operation to C,C++,C#,Java, or HTML files (so I now support two comment styles - more might follow).

    http://www.dbaileyconsultancy.co.uk/npp_plugins/namedbookmarks.zip

    If you downloaded the older version, please note that both DLL's have changed.

    I look forward to reactions.

    David

     
  • cchris

    cchris - 2013-04-13

    I just tried the newe version, and it works great! Thanks again for the nice work.

    One small glitch : when the active file is not highlighted with a supported highlighter, a clearer message than "Unknown exception" would be nice. But supporting more languages is clearly more useful.

    When hitting such a situation, your plugin could do the following:
    - Write the NppBookmark string on the new comment line
    - Comment it sending the proper WM_COMMAND message to N++
    - read the line again and store a tag like
    <language name="Euphoria" commentStart="--" commentEnd=""/> in some comment.xml configuration file.
    -- Alternately you could read and parse langs.xml, but this won't help with UDL/externally supported languages.
    - Now build actuaal string and replace previous bootstrap comment.
    - On request for bookmarks on a file with unsupported language, read the (cached) ccomment.xml to find out how the stuff was commented in, and then build the proper search term.

    This way users might use the plugin on supported language, albeit with a small performance penalty on first use on an unsupported type.

    CChris

     
    • David Bailey

      David Bailey - 2013-04-13

      "One small glitch : when the active file is not highlighted with a supported highlighter, a clearer message than "Unknown exception" would be nice."

      I guess you must be referring to the case when the language isn't recognised - yes I will sort that out and get a version into the plugin manager. I I'd rather not get into the complexities of making the comment mechanism work for all languages for the first version.

      The problem with writing bookmarks into an external file, is of course that they probably won't stay instep with the source - particularly when some sort of source control is in operation - so if I understand your proposal correctly, it would rather defeat the object of named bookmarks.

      I propose to just pop up a dialog to explain the problem, and get version 1.2 live!

      David

       
      Last edit: David Bailey 2013-04-13
  • David Bailey

    David Bailey - 2013-04-14

    OK I have just uploaded version 1.2.0.0 with the glitch fixed. I want to make this the first public release of the code.
    http://www.dbaileyconsultancy.co.uk/npp_plugins/namedbookmarks.zip

    Interfacing with the plugin manager seems a bit tricky - at least for the first time.

    1) Am I right that the installing XML should be supplied separately - not in the ZIP file?

    2) When I install the test plugin manager, does that replace the standard plugin manager, or will they operate side by side?

    David

     
    • Dave Brotherstone

      On 14 Apr 2013 23:22, "David Bailey" david-bailey@users.sf.net wrote:

      Interfacing with the plugin manager seems a bit tricky - at least for the
      first time.

      1) Am I right that the installing XML should be supplied separately -
      not in the ZIP file?

      There's no XML needed. There's a web interface to define the steps - see
      www.brotherstone.co.uk/npp/pm#submitting

      You might find the info on www.Brotherstone.co.uk useful too.

      2) When I install the test plugin manager, does that replace the
      standard plugin manager, or will they operate side by side?

      It replaces it. I use a second copy of n++ with a dolocalconf.XML file for
      testing.

      Dave

       
  • David Bailey

    David Bailey - 2013-04-15

    Thanks for that Dave,

    I know I contacted you a little while ago about this, but I somehow got the impression that both the web interface, and the hand written XML were required!

    Do I go through the web interface and then then use the test plugin - which presumably accesses new plugins that are not yet visible to the normal manager?

    Does the test plugin manager continue to function as a normal plugin manager - can I just leave it in place if I don't mind seeing plugins that are still under test?

    The XML (which I will not now be using) would seem to leave the layout of the files in the ZIP entirely up to the author of the plugin (for example, I don't need to put the plugin inside a unicode sub directory), does that remain the same for the web interface?

    Sorry for all the confusion - I am nearly there!

    David

     
  • David Bailey

    David Bailey - 2013-04-15

    I am on the web form for submitting plugins here:

    http://www.brotherstone.co.uk/npp/pm/admin/plugins/add

    I am sorry but I am still stuck!

    By "Homepage URL", do you mean the address of the ZIP containing the DLL's - because there doesn't seem to be anywhere else to put this information!

    Also, I find nowhere to add details of the additional dll, and where to place it. This seemed easy with the XML technique.

    The XML contains a field for the MD5 hash code, but this form does not - unless some more interrogation happens after I press "Add new Plugin".

    I also have buttons that say "Copy", "Download", "Delete", and "Run"!

    Sorry, I really am completely lost!

    David

     
    • Dave Brotherstone

      Homepage is your URL for your plugin - if its got a website or project
      page. The installation steps are added with those "download, copy, run
      delete" buttons. You'll add a download step, then enter the URL (http only,
      no HTTPS support yet), and the it will ask you if you want to it to
      download the file and check the md5, click yes. It will download the zip
      and show the files in the zip on the right hand side.

      Add a copy step for each file or file spec (e.g. *.txt) that you want to
      copy. Check the "validate" checkbox for each executable file (I.e. DLLs,
      exe etc), and on the right hand side click "add hash" next to those files
      that you've clicked validate on. By all means compare these md5sums with
      your local copy.

      That's it. I need to write this up properly. I'll get round to it.:-)

      Dave

       
  • David Bailey

    David Bailey - 2013-04-15

    I don't know - the file seemed to vanish when I pressed the download button - but that doesn't make sense - I have just put it back!

    David

     
  • David Bailey

    David Bailey - 2013-04-21

    Thanks to Dave Brotherstone version 1.2 of the NamedBookmarks plugin is uploaded awaiting incorporation in the plugin list (it is obviously still available directly from my website).

    I will not be extending this plugin until I get some reactions from people, I thought it might be interesting to discuss a few possible extensions based on the same idea - that comments can contain information for the editor.

    Someone contacted me about making bookmarks operate across several files at once. My feeling is that it might be interesting to think of bookmarks as being a little bit analogous to HTML targets, and maybe what is needed is a new structure (also embedded in comments) that acts as a set of hyperlinks that would contain both the file name (relative or absolute paths) and the bookmark within the file.

    I also have a vision (OK too grand a word!) of a source file containing headings and maybe colour variations - again controlled by stylised comments.

    Any thoughts?

    David

     
  • cchris

    cchris - 2013-04-23

    The idea of using some custom markers to differentiate sections of code, resulting in style variations or some extra tools being available has bee on IdeaTorrent for a while. Voting for old ideas requires some motivation if one is not aware of http://sourceforge.net/apps/mediawiki/notepad-plus/index.php?title=IdeaTorrent_Summary . Implementing this means the plugin always knows in what section the currently visible area is so as to talk Scintilla into doing the right thing, without a performance penalty. This will be great! Also you may run out of styles unless you increase the number of bits Scintilla uses to represent styles.

    Cross file bookmarks is good to have as well, but I'd avoid absolute paths, so that moving a project to a different drive won't break all the links at once.

     
  • David Bailey

    David Bailey - 2013-04-23

    "Cross file bookmarks is good to have as well, but I'd avoid absolute paths, so that moving a project to a different drive won't break all the links at once."

    I was thinking of something analogous to HTML, where links can be relative or absolute.

    I was hoping to use a mark style to pick out headings, but for some reason, the style configurator won't let me alter the font size/properties for these styles. This would seem the obvious way to implement headings identified by custom markers.

    David

     

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

JavaScript is required for this form.





No, thanks