Skip to content
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

Closed
wants to merge 1 commit into from
Closed

Conversation

Shin-703
Copy link

@Shin-703 Shin-703 commented Jul 3, 2024

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.

Copy link
Collaborator

@privat privat left a 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();
Copy link
Collaborator

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 == ':') {
Copy link
Collaborator

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();
Copy link
Collaborator

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.

@privat privat mentioned this pull request Jul 11, 2024
privat added a commit that referenced this pull request Jul 15, 2024

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.
@privat
Copy link
Collaborator

privat commented Jul 16, 2024

Superseded by #51

@privat privat closed this Jul 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants