-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Make blank space less apparent. #2501
Changes from 3 commits
9ed9f41
adea8b4
81f796c
4df81f0
65825ca
3c4b07f
be9bfa1
427892f
0d276cb
c2fb40f
95fcd87
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -414,6 +414,20 @@ def highlightBlock(self, text): | |
|
||
match = self.PROG.search(text, match.end()) | ||
|
||
# Make blank space less apparent by setting the foreground alpha. | ||
# This only has an effect when "Show blank space" is turned on. | ||
re_blank = re.compile("\s+") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This line should perhaps be a class variable (look on top for) # Syntax highlighting rules:
PROG = re.compile(make_python_patterns(), re.S)
IDPROG = re.compile(r"\s+(\w+)", re.S) This way the compilation is done only once when the class is instantiated, and the code would be more uniform, as you can see no regex is compiled within the highlighting method. |
||
match = re_blank.search(text, offset) | ||
while match: | ||
start, end = match.span() | ||
start = max([0, start+offset]) | ||
end = max([0, end+offset]) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In which cases There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
That code is copied from the loop earlier in the function. Interpreting the code (and some experimentation) taught me that |
||
format = self.format(start) | ||
color_foreground = format.foreground().color() | ||
color_foreground.setAlpha(80) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Perhaps since you are hard coding the alpha value, it would be better to have it in a more "accessible/set-able" place? @Nodd suggestions on this? maybe color_foreground = format.foreground().color()
color_foreground.setAlpha(self.SPACE_TAB_ALPHA) And |
||
self.setFormat(start, end-start, color_foreground) | ||
match = re_blank.search(text, match.end()) | ||
|
||
self.setCurrentBlockState(state) | ||
|
||
if oedata is not None: | ||
|
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.
All this should have an if statement tied to the option of showing spaces, no?
Also to make it work with other syntax highlighters it should be refactored as a separate method inside BaseSH