UDL 2.0 in Notepad 7 release
-
What’s the difference betweeen the double-
(())
and single-()
grouping operators? The UDL 2.1 documentation at http://ivan-radic.github.io/udl-documentation/delimiters/ describes the double-(())
version, but not the single-()
version. Is it documented someplace else? -
the truth you want the truth, well - no idea.
I didn’t check the source code yet - found it by trail and error and
still don’t understand when and how it is working but from the examples
(sourceforge thread) provided I see that this might be a solution.Cheers
Claudia -
if you haven’t already installed the python script plugin, then please
install it from here instead of using
the plugin manager.The script looks like this
WIN_EOL = 45001 # command id edit->eol conversion->windows UNIX_EOL = 45002 # command id edit->eol conversion->unix MAC_EOL = 45003 # command id edit->eol conversion->mac TEXT_INSERT = 1 # editor constants TEXT_DELETE = 2 # editor constants IS_ADA_FILE = False # variable to identify ada file format_dict={FORMATTYPE.WIN:WIN_EOL, FORMATTYPE.UNIX:UNIX_EOL, FORMATTYPE.MAC:MAC_EOL,} # map fromattype to command id buffer_dict={} # used to save original format or different source files def this_is_a_ada_file(_filename): # if file ends with either .a or .ada it is return True if _filename.endswith(('.a', '.ada')) else False # considered to be an ada file def callback_BUFFERACTIVATED(args): # gets called when new file is opened global IS_ADA_FILE # or tab has been changed global ORIGINAL_FROMAT_TYPE # bufferid = args['bufferID'] filename = notepad.getBufferFilename(bufferid) # get the filename from bufferid and if this_is_a_ada_file(filename): # check if it is an ada file if IS_ADA_FILE = True # yes, set file identifier and if buffer_dict.get(bufferid, None) is None: # if it hasn't already saved buffer_dict[bufferid] = notepad.getFormatType() # save eol format of current doc else: # otherwise IS_ADA_FILE = False # set file identifier to false def callback_FILEBEFORESAVE(args): # gets called before file gets saved if IS_ADA_FILE: # if it is a ada file saved_format = buffer_dict.get(args['bufferID'],None) # try to get a saved format if saved_format is not None: # if one was found notepad.menuCommand(format_dict.get(saved_format)) # set the original format def callback_MODIFIED(args): # gets called whenever something changes (text, style...) if IS_ADA_FILE and (notepad.getFormatType() != FORMATTYPE.WIN): # if it is an ada file and eol is not windows then mod_type = args['modificationType'] # get type of modification if (mod_type & TEXT_INSERT or mod_type & TEXT_DELETE) and args['text'] != '\r': # if it is an insert but not a \r or a delete then notepad.menuCommand(WIN_EOL) # set the windows eol else ignore it editor.clearCallbacks() # sanity check - just to be sure no callback have notepad.clearCallbacks() # registered yet notepad.callback(callback_FILEBEFORESAVE, [NOTIFICATION.FILEBEFORESAVE]) # register before save callback notepad.callback(callback_BUFFERACTIVATED, [NOTIFICATION.BUFFERACTIVATED ]) # register buffer activated callback editor.callback(callback_MODIFIED,[SCINTILLANOTIFICATION.MODIFIED]) # register modify callback
I hope the comments are clear, basically, every time you open a new file or you switch
a tab it get’s checkd if the file is an ada file by checking it extensions (see code).
If it is and you start modifying the code it checks if windows eol is used and if not
script sets it. If you save the file, it gets checked what the original eol was and then it
resets the eol.If you create a new script with name startup.py and put the content into it
and you change the python script configuration from LAZY to ATSTARTUP, then
the script gets automatically executed every time you start npp.If you create a new script with a different name, you need to execute it manually once
every time you start npp.Let me know if something is unclear.
Cheers
Claudia -
Peter, now I know why it worked because type and subtype is also configured
as keywords. So my workaround seems to be non-working, just another
coloring rule is active.Cheers
Claudia -
I have added today the python script and seems that is not solving the problem :(
I have upload a video example of the real problem… the bug u can see in the video is totally random… in any sentence suddenly tha open/close folding mark just is in a wrong place… and just creating new lines it auto fix it… and when you remove those new lines again the mark keeps in the correct place… so strange…
Video url --> https://youtu.be/xZZxKMRjU0w
Many thanks !!!
-
the script itself doesn’t do any folding operations it just modifies the eols.
So the bug seems not to be solved by using windows eol therefore
the script isn’t helping either.Unfortunately there is no way python script can interact with lexers in
a safely manner.Cheers
Claudia -
So is there any news about “udl 2.0” or anyway to fix this ??
-
See https://ivan-radic.github.io/udl-documentation/ for the current docu and https://github.com/notepad-plus-plus/notepad-plus-plus/issues/2713 regarding status of UDL 3
-
About UDL3 status is there any ETA ?? Will be any UDL3 Beta ?
Many Thanks for the doc and info !!
-
No status as far as I know and no timeschedule. Maybe in your case it makes sense to checkout https://sourceforge.net/p/scintilla/code/ci/fba1e8c31818fc1b38fc1b1ba3a200f40ef568f9/log/?path=/lexers/LexAda.cxx and checkout for an update there as scintilla is the basis for n++, but the update cycle of scintilla for n++ is quite slow.
-
There are no code folding / function list support at all in scintilla or notepad++ that’s why I am trying to do it by myself using the “user custom lang definition” and udl but udl is useless with ADA :(.
Would be nice if udl3 fix this kind of problems… But I am not sure after these years if udl3 will be realease any day…
Thanks for the info.
-
ADA is not the only reason for UDL3. Generally UDL’s generally don’t work well with different themes and UDL3 is said to help with that, too: https://sourceforge.net/p/notepad-plus/discussion/331754/thread/bd2bc405/#757b