Does the UDL miss the ablity to recognize methods and classes?
-
Thank you for your reply. Well, at least in Java classes are recognizable by their capital letter at the front, while identifiers (method names/variable names) usually start with a lower case letter. Does your proposed thread say anything about regular expressions and how to use them with Notepad++? I’m not sure. Maybe I should go over it once more.
-
if you are asking whether udl supports regex then the answer is no, not currently
but if the question is if the python script could be used with regex then yes, it can and
it is used in this exampleAs you see, only the keywords true and null have been defined, as well as
two delimiters, one using ( and ) and the other for strings using ’ and ’A script to accomplish this could look like this
from Npp import editor, notepad, NOTIFICATION, SCINTILLANOTIFICATION, INDICATORSTYLE # to use this for a different language, three steps need to be done # 1. replace the EnhancedUDLLexer string with a different but unique name, # Note, checkout the string_needs_to_be_replace_here marks try: # string_needs_to_be_replace_here EnhancedUDLLexer().main() except NameError: # string_needs_to_be_replace_here class SingletonEnhancedUDLLexer(type): _instances = {} def __call__(cls, *args, **kwargs): if cls not in cls._instances: # string_needs_to_be_replace_here cls._instances[cls] = super(SingletonEnhancedUDLLexer, cls).__call__(*args, **kwargs) return cls._instances[cls] # string_needs_to_be_replace_here class EnhancedUDLLexer(object): # string_needs_to_be_replace_here __metaclass__ = SingletonEnhancedUDLLexer @staticmethod def set_indicator_attributes(indicator_number, fore=(0,0,0)): editor.indicSetFore(indicator_number, fore) editor.indicSetStyle(indicator_number, INDICATORSTYLE.TEXTFORE) return indicator_number @staticmethod def paint_it(indicator, pos, length): editor.setIndicatorCurrent(indicator) editor.indicatorFillRange(pos,length) def do_regex(self, regex, indicator, start_position, end_position): editor.setIndicatorCurrent(indicator) editor.indicatorClearRange(start_position, end_position-start_position) editor.research(regex, lambda m: self.paint_it(indicator, m.span(0)[0], m.span(0)[1] - m.span(0)[0]), 0, start_position, end_position) def style(self): line_number = editor.getFirstVisibleLine() start_position = editor.positionFromLine(line_number) end_position = editor.getLineEndPosition(line_number + editor.linesOnScreen()) for indicator, regex in self.regex_dict.items(): self.do_regex(regex, indicator, start_position, end_position) def __init__(self): editor.callbackSync(self.on_updateui, [SCINTILLANOTIFICATION.UPDATEUI]) notepad.callback(self.on_langchanged, [NOTIFICATION.LANGCHANGED]) notepad.callback(self.on_bufferactivated, [NOTIFICATION.BUFFERACTIVATED]) self.__is_lexer_doc = False self.get_lexer_name = lambda: notepad.getLanguageName(notepad.getLangType()) def set_lexer_doc(self,bool_value): editor.setProperty(self.__class__.__name__, 1 if bool_value is True else -1) self.__is_lexer_doc = bool_value def on_bufferactivated(self,args): if self.get_lexer_name() == self.lexer_name and editor.getPropertyInt(self.__class__.__name__) != -1: self.__is_lexer_doc = True else: self.__is_lexer_doc = False def on_updateui(self,args): if self.__is_lexer_doc: self.style() def on_langchanged(self,args): self.set_lexer_doc(True if self.get_lexer_name() == self.lexer_name else False) def main(self): # 2. define the lexer language, normally like what is returned by notepad.getLanguageName self.lexer_name = 'udf - test' # 3. define needed indicator_ids, indicator_fore_colors and regexes self.regex_dict = { self.set_indicator_attributes(18, fore=(131,255,245)) : u'([A-Za-z][\w+]*)(?=\()', self.set_indicator_attributes(19, fore=(255,137,115)) : u'([A-Za-z][\w+]*)(?=\.)', } self.set_lexer_doc(True) self.style() # string_needs_to_be_replace_here EnhancedUDLLexer().main()
Note, focus was on portability not on performance and
you need to call it for each of the two views npp supports if you want
to have it automatically coloring udl docs in both views.Cheers
Claudia -
I’m looking forward to seeing steps 2 and 3! :-D
-
-
-
well sometimes you have to have changes in your life to keep it exciting :-)
Seems we are back to future again - I answered your question 1 minute before you
were asking it and you did it even 3 minutes before I was answering it :-DCheers
Claudia -
back to the future again
Yea, I’d much rather see
10-Aug-2018 7:47a
than2 minutes ago
orsix months ago
anyway, but geez, if they’re going to do it that way (relatively), can’t they at least get it right? This will be confusing to any future readers, so here is the progression of the last several posting timestamps, as ofRIGHT NOW
:It would be really cool to go to an absolute timestamp here, how can that be made to happen?
-
Now it is back on track - thx for your image otherwise future readers must think we are insane :-)
Cheers
Claudia -
There have been times that immediately after hitting SUBMIT, I see “PeterJones posted 7 minutes ago”…
I almost wonder if the timestamp issue here is similar to the one I described in the browser refresh thread: if there’s more than one server here, with different times – so that some people get one timestamp and some get the other.
The other possibility I can think of: NodeBB might assign the timestamp when you hit REPLY and get the compose window, rather than when you hit SUBMIT. So if you take longer to author and post your node, your post goes farther into the past. (Though if you’re replying to an existing node, I don’t see how that would explain your post showing with an earlier timestamp than the one you’re replying to. That goes back to my multiple-server-times hypothesis.)
update: appropriately, this one showed up as exactly “7 minutes ago” like I said above. :-)
-
what is strange is that if you hover over the timestamp then it does show the correct time.
Although I don’t know the server setup I would say that nowadays no server-ops should
have troubles to install “clustered” servers with time sync - most OSes which
support clustering do have it anyway and rely on it to work correctly.
It’s really strange …Cheers
ClaudiaUpdate: just said and proven to be incorrect. Just hovered, immediately after submitting the post,
over the timestamp and … it is wrong. -
I see - once the post passes the “lead time” it is correct again.
Cheers
Claudia -
*AUTO
DEMODISK = 0
ORG = $5400
TR ON
LST OFF***PRINCE OF PERSIA
***COPYRIGHT 1989 JORDAN MECHNERORG ORG
JMP AUTOCTRL
JMP CHECKSTRIKE
JMP CHECKSTAB
JMP AUTOPLAYBACK
JMP CUTCHECKJMP CUTGUARD
JMP ADDGUARD
JMP CUTADDAMOB LDX $0500 ;THIS IS A COMMENT, THE ABOVE LINE ISN’T ACTUALCODE
(LABEL MNEMONIC(LDX) OPERAND($0500) ;COMMENT)
CPX #MAXMOB
BEQ :RTSINX
STX NUMMOBJMP SAVEMOB
.
.
.
.This is a 6502 assembly source code made with the Merlin assembler for the Prince of Persia game (copyright to Jordan Mechner)
Somewhere in the middle of that code you will see the typical syntax of the assembler. It goes like --> a) LABEL b) MENMONIC c) OPERAND and d) COMMENTS
4 columns all the time, some of them are optional (LABELS and COMMENTS and rarely OPERANDS)
- Mnemonics are fixed keywords. I can highlight them. :)
- Operands are sometimes fixed and sometimes not, but I don’t want to highlight the non-fixed since I can highlight the fixed ones.
- Comments start with “;” or “*” and I can highlight them.
- Labels are not fixed keywords and I want to use a different color for them.
LABELS -always- start in the beginning of a new line. NO space precedes them.
Is it possible to color every word and ONLY THAT WORD who is the first ONE of each line of code???
Thanks in advance :)
-
Yes, can be done when you are willing to install python script plugin.
From my understanding of 6502 assembler and your description the label needs to be
followed by known mnemonic fields. Keeping this in mind and using a slightly
modified version of the script I posted above you would get something likeThe part of the script which needs to be modified is within the main function
def main(self): # 2. define the lexer language, normally like what is returned by notepad.getLanguageName self.lexer_name = 'Assembly' # 3. define needed indicator_ids, indicator_fore_colors and regexes self.regex_dict = { self.set_indicator_attributes(18, fore=(131,255,245)) : u'^\w+?(?= LDA| LDX| LDY)', } self.set_lexer_doc(True) self.style()
First you need to change the self.lexer_name with your udl name.
Run notepad.getLanguageName(notepad.getLangType()) in the python script console
after assigning your udl language to a document. I chose the assembly lexer for
demonstration purpose.Second you need to extend the list of know mnemonic words in the regex
u'^\w+?(?= LDA| LDX| LDY)',
Cheers
Claudia -
This post is deleted! -
I have uploaded a screenshot from the built-in editor of the Merlin Pro assembler (Applewin emulator, Enhanced Apple IIe system)
Can you see it?
-
Yes, I’m able to see your uploaded image.
What is your question or what did I miss?Cheers
Claudia