-
Notifications
You must be signed in to change notification settings - Fork 20
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
label coloring for jumps #35
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is some weird design in RARS about coloring, we should discuss it further.
private void findLabelKeywords() { | ||
labelKeywords = new KeywordMap(false); | ||
if (Globals.getGui().getMainPane().getEditPane() != null) { | ||
char[] array = Globals.getGui().getMainPane().getEditPane().getSource().toCharArray(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The way you get the source code seems to break a lot of isolation and separation of concern.
for (char c : array) { | ||
if (c == '\n') | ||
lastNewLine = currentIndex; | ||
if (c == ':') { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are already 2 tokenizers (rars.assembler.Tokenizer
and rars.venus.editors.jeditsyntax.tokenmarker
) ; there should be a way to reuse one of them or generalize it instead of parsing the label definition a 3rd way.
Ideally, there should be only one tokenizers, but that's another battle :)
@@ -73,6 +73,7 @@ public static String[] getRISCVTokenExamples() { | |||
|
|||
|
|||
public byte markTokensImpl(byte token, Segment line, int lineIndex) { | |||
findLabelKeywords(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
markTokensImpl seems to be called a lot. I'm not sure what is its job.
This is an alternative implementation of #35 Instead of rescaning the document on each markTokensImpl, a special update method is called on each document modification. The KeywordMap class is also extended to handle the clearing of all keywords.
Superseded by #51 |
This is an enhancement for the edit pane: adding color to labels.
We are here adding coloring to labels when they appear in the file without the ':'. If the label has already been placed with ':' somewhere in the file, we color the corresponding label every time it is used (in a branching situation for example). It will be colored as soon as the label is placed with ':', and uncolored if that part gets erased.
This is a way to see typos immediately when coding : if there is a typo in the label, it will not be colored. With this, you don't have to wait until you assemble to see that you have typos in your labels. The enhancement also allows better visibility of labels, which are not just plain text.