aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authornkmathew <unknown>2015-09-26 10:12:42 +1000
committernkmathew <unknown>2015-09-26 10:12:42 +1000
commit3491002fbd32adbec743cf5ac4400fc463eab5f3 (patch)
treeba31af9776a66f69843ecfcf178e768aeaf0ae74 /src
parentcaf87bd4ad84b0570ea087dc34f32cee986bb43a (diff)
downloadscintilla-mirror-3491002fbd32adbec743cf5ac4400fc463eab5f3.tar.gz
Whitespace may be made visible just in indentation.
Diffstat (limited to 'src')
-rw-r--r--src/EditView.cxx16
-rw-r--r--src/ViewStyle.cxx6
-rw-r--r--src/ViewStyle.h4
3 files changed, 15 insertions, 11 deletions
diff --git a/src/EditView.cxx b/src/EditView.cxx
index 072a715f4..23fca07af 100644
--- a/src/EditView.cxx
+++ b/src/EditView.cxx
@@ -1301,8 +1301,7 @@ void EditView::DrawBackground(Surface *surface, const EditModel &model, const Vi
if (ts.representation) {
if (ll->chars[i] == '\t') {
// Tab display
- if (drawWhitespaceBackground &&
- (!inIndentation || vsDraw.viewWhitespace == wsVisibleAlways))
+ if (drawWhitespaceBackground && vsDraw.WhiteSpaceVisible(inIndentation))
textBack = vsDraw.whitespaceColours.back;
} else {
// Blob display
@@ -1316,8 +1315,7 @@ void EditView::DrawBackground(Surface *surface, const EditModel &model, const Vi
(inIndentation && vsDraw.viewIndentationGuides == ivReal)) {
for (int cpos = 0; cpos <= i - ts.start; cpos++) {
if (ll->chars[cpos + ts.start] == ' ') {
- if (drawWhitespaceBackground &&
- (!inIndentation || vsDraw.viewWhitespace == wsVisibleAlways)) {
+ if (drawWhitespaceBackground && vsDraw.WhiteSpaceVisible(inIndentation)) {
PRectangle rcSpace(
ll->positions[cpos + ts.start] + xStart - static_cast<XYPOSITION>(subLineStart),
rcSegment.top,
@@ -1503,8 +1501,7 @@ void EditView::DrawForeground(Surface *surface, const EditModel &model, const Vi
if (ll->chars[i] == '\t') {
// Tab display
if (phasesDraw == phasesOne) {
- if (drawWhitespaceBackground &&
- (!inIndentation || vsDraw.viewWhitespace == wsVisibleAlways))
+ if (drawWhitespaceBackground && vsDraw.WhiteSpaceVisible(inIndentation))
textBack = vsDraw.whitespaceColours.back;
surface->FillRectangle(rcSegment, textBack);
}
@@ -1520,7 +1517,7 @@ void EditView::DrawForeground(Surface *surface, const EditModel &model, const Vi
}
}
if (vsDraw.viewWhitespace != wsInvisible) {
- if (!inIndentation || vsDraw.viewWhitespace == wsVisibleAlways) {
+ if (vsDraw.WhiteSpaceVisible(inIndentation)) {
if (vsDraw.whitespaceColours.fore.isSet)
textFore = vsDraw.whitespaceColours.fore;
surface->PenColour(textFore);
@@ -1568,10 +1565,9 @@ void EditView::DrawForeground(Surface *surface, const EditModel &model, const Vi
if (vsDraw.viewWhitespace != wsInvisible) {
if (vsDraw.whitespaceColours.fore.isSet)
textFore = vsDraw.whitespaceColours.fore;
- if (!inIndentation || vsDraw.viewWhitespace == wsVisibleAlways) {
+ if (vsDraw.WhiteSpaceVisible(inIndentation)) {
XYPOSITION xmid = (ll->positions[cpos + ts.start] + ll->positions[cpos + ts.start + 1]) / 2;
- if ((phasesDraw == phasesOne) && drawWhitespaceBackground &&
- (!inIndentation || vsDraw.viewWhitespace == wsVisibleAlways)) {
+ if ((phasesDraw == phasesOne) && drawWhitespaceBackground) {
textBack = vsDraw.whitespaceColours.back;
PRectangle rcSpace(
ll->positions[cpos + ts.start] + xStart - static_cast<XYPOSITION>(subLineStart),
diff --git a/src/ViewStyle.cxx b/src/ViewStyle.cxx
index e8bf51363..9416ddcc6 100644
--- a/src/ViewStyle.cxx
+++ b/src/ViewStyle.cxx
@@ -512,6 +512,12 @@ bool ViewStyle::WhitespaceBackgroundDrawn() const {
return (viewWhitespace != wsInvisible) && (whitespaceColours.back.isSet);
}
+bool ViewStyle::WhiteSpaceVisible(bool inIndent) const {
+ return !inIndent && viewWhitespace == wsVisibleAfterIndent ||
+ inIndent && viewWhitespace == wsVisibleOnlyInIndent ||
+ viewWhitespace == wsVisibleAlways;
+}
+
ColourDesired ViewStyle::WrapColour() const {
if (whitespaceColours.fore.isSet)
return whitespaceColours.fore;
diff --git a/src/ViewStyle.h b/src/ViewStyle.h
index 242e7e38e..d5a9d5b71 100644
--- a/src/ViewStyle.h
+++ b/src/ViewStyle.h
@@ -52,7 +52,7 @@ public:
enum IndentView {ivNone, ivReal, ivLookForward, ivLookBoth};
-enum WhiteSpaceVisibility {wsInvisible=0, wsVisibleAlways=1, wsVisibleAfterIndent=2};
+enum WhiteSpaceVisibility {wsInvisible=0, wsVisibleAlways=1, wsVisibleAfterIndent=2, wsVisibleOnlyInIndent=3};
typedef std::map<FontSpecification, FontRealised *> FontMap;
@@ -185,6 +185,8 @@ public:
bool SetWrapVisualStartIndent(int wrapVisualStartIndent_);
bool SetWrapIndentMode(int wrapIndentMode_);
+ bool WhiteSpaceVisible(bool inIndent) const;
+
private:
void AllocStyles(size_t sizeNew);
void CreateAndAddFont(const FontSpecification &fs);