diff --git a/net.certiv.tools.indentguide.feature/feature.xml b/net.certiv.tools.indentguide.feature/feature.xml index 1744c15..bc1cf8a 100644 --- a/net.certiv.tools.indentguide.feature/feature.xml +++ b/net.certiv.tools.indentguide.feature/feature.xml @@ -2,7 +2,7 @@ @@ -43,14 +43,14 @@ SOFTWARE. - - - - - - - - + + + + + + + + net.certiv net.certiv.tools.indentguide.parent - 2.1.0-SNAPSHOT + 2.2.0-SNAPSHOT net.certiv.tools.indentguide.feature diff --git a/net.certiv.tools.indentguide.plugin.test/pom.xml b/net.certiv.tools.indentguide.plugin.test/pom.xml index 221002d..9cafc34 100644 --- a/net.certiv.tools.indentguide.plugin.test/pom.xml +++ b/net.certiv.tools.indentguide.plugin.test/pom.xml @@ -8,7 +8,7 @@ net.certiv net.certiv.tools.indentguide.parent - 2.1.0-SNAPSHOT + 2.2.0-SNAPSHOT net.certiv.tools.indentguide.plugin.test diff --git a/net.certiv.tools.indentguide.plugin/META-INF/MANIFEST.MF b/net.certiv.tools.indentguide.plugin/META-INF/MANIFEST.MF index 897b83c..e5f864d 100644 --- a/net.certiv.tools.indentguide.plugin/META-INF/MANIFEST.MF +++ b/net.certiv.tools.indentguide.plugin/META-INF/MANIFEST.MF @@ -2,17 +2,17 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: IndentGuide Bundle-SymbolicName: net.certiv.tools.indentguide;singleton:=true -Bundle-Version: 2.1.0.qualifier +Bundle-Version: 2.2.0.qualifier Bundle-Activator: net.certiv.tools.indentguide.Activator Bundle-Vendor: Certiv Analytics -Require-Bundle: org.eclipse.core.runtime;bundle-version="[3.26.100,4.0.0)", - org.eclipse.e4.core.services;bundle-version="[2.3.400,3.0.0)", - org.eclipse.e4.ui.css.swt.theme;bundle-version="[0.13.200,1.0.0)", - org.eclipse.jface.text;bundle-version="[3.22.0,4.0.0)", - org.eclipse.osgi.services;bundle-version="[3.11.100,4.0.0)", - org.eclipse.ui;bundle-version="[3.201.200,4.0.0)", - org.eclipse.ui.forms;bundle-version="[3.11.500,4.0.0)", - org.eclipse.ui.workbench.texteditor;bundle-version="[3.16.600,4.0.0)" +Require-Bundle: org.eclipse.core.runtime;bundle-version="[3.24.100,4.0.0)", + org.eclipse.e4.core.services;bundle-version="[2.3.100,3.0.0)", + org.eclipse.e4.ui.css.swt.theme;bundle-version="[0.13.0,1.0.0)", + org.eclipse.jface.text;bundle-version="[3.20.0,4.0.0)", + org.eclipse.osgi.services;bundle-version="[3.10.200,4.0.0)", + org.eclipse.ui;bundle-version="[3.201.0,4.0.0)", + org.eclipse.ui.forms;bundle-version="[3.11.300,4.0.0)", + org.eclipse.ui.workbench.texteditor;bundle-version="[3.16.400,4.0.0)" Bundle-RequiredExecutionEnvironment: JavaSE-11 Automatic-Module-Name: net.certiv.tools.indentguide.singleton.true Bundle-ActivationPolicy: lazy diff --git a/net.certiv.tools.indentguide.plugin/pom.xml b/net.certiv.tools.indentguide.plugin/pom.xml index 65e9d1a..391fdf2 100644 --- a/net.certiv.tools.indentguide.plugin/pom.xml +++ b/net.certiv.tools.indentguide.plugin/pom.xml @@ -9,7 +9,7 @@ net.certiv net.certiv.tools.indentguide.parent - 2.1.0-SNAPSHOT + 2.2.0-SNAPSHOT net.certiv.tools.indentguide diff --git a/net.certiv.tools.indentguide.plugin/src/main/java/net/certiv/tools/indentguide/painter/GuidePainter.java b/net.certiv.tools.indentguide.plugin/src/main/java/net/certiv/tools/indentguide/painter/GuidePainter.java index bf6f265..6acbfdc 100644 --- a/net.certiv.tools.indentguide.plugin/src/main/java/net/certiv/tools/indentguide/painter/GuidePainter.java +++ b/net.certiv.tools.indentguide.plugin/src/main/java/net/certiv/tools/indentguide/painter/GuidePainter.java @@ -151,6 +151,8 @@ private void drawLineRange(GC gc, int begLine, int endLine, int x, int w) { StyledTextContent content = widget.getContent(); Line prevNb = null; // last non-blank line + Line prevLn = null; // immediately prior line + Line currLn = null; // current line Line nextNb = null; // next non-blank line for (int line = begLine; line <= endLine; line++) { @@ -159,37 +161,40 @@ private void drawLineRange(GC gc, int begLine, int endLine, int x, int w) { if (!Utils.isFolded(viewer, docLine)) { String text = widget.getLine(line); - Line ln = new Line(docLine, text, tabWidth); + prevLn = prevLine(docLine, tabWidth, currLn); + currLn = new Line(docLine, text, tabWidth); if (drawBlankLn) { - if (ln.blank) { + if (currLn.blank) { prevNb = prevNonblankLine(prevNb, docLine, tabWidth); nextNb = nextNonblankLine(nextNb, docLine, tabWidth); // log(ln.dir, prevNb, ln, nextNb); // change in dents: - <-> + - ln.delta = nextNb.tabs() - prevNb.tabs(); + currLn.delta = nextNb.tabs() - prevNb.tabs(); - ln.stops.clear(); - ln.stops.addAll(nextNb.stops); // default: same as next non-blank line - if (ln.delta > 0 && ln.tabs() > 1) ln.stops.removeLast(); // shift in + currLn.stops.clear(); + currLn.stops.addAll(nextNb.stops); // default: same as next non-blank line + if (currLn.delta > 0 && currLn.tabs() > 1) { + currLn.stops.removeLast(); // shift in + } } else { - prevNb = ln; + prevNb = currLn; } } - boolean nest = ln.tabs() > 1; - boolean only = ln.tabs(1); - boolean zero = ln.delta == 0; + boolean nest = currLn.tabs() > 1; + boolean only = currLn.tabs(1); + boolean zero = currLn.delta == 0; - for (Pos stop : ln.stops) { - boolean first = stop == ln.stops.peekFirst(); - boolean last = stop == ln.stops.peekLast(); + for (Pos stop : currLn.stops) { + boolean first = stop == currLn.stops.peekFirst(); + boolean last = stop == currLn.stops.peekLast(); - if (ln.comment) { + if (currLn.comment) { // skip first visible character - if (stop.col == ln.beg) continue; + if (stop.col == currLn.beg) continue; // skip first where only unless drawComment or drawLeadEdge if (only && !(drawComment || drawLeadEdge)) continue; @@ -200,7 +205,7 @@ private void drawLineRange(GC gc, int begLine, int endLine, int x, int w) { // skip last where !only unless drawComment if (last && !only && !drawComment) continue; - } else if (ln.blank) { + } else if (currLn.blank) { // skip first where only and zero if (first && only && zero) continue; @@ -215,19 +220,32 @@ private void drawLineRange(GC gc, int begLine, int endLine, int x, int w) { } else { // skip first visible character - if (stop.col == ln.beg) continue; + if (stop.col == currLn.beg) continue; // skip first unless drawLeadEdge if (first && !drawLeadEdge) continue; } - draw(gc, offset, stop.col, spcWidth); + boolean ascender = stop.col >= prevLn.endStop(); + + draw(gc, offset, stop.col, spcWidth, ascender); } } } } + private Line prevLine(int line, int tabWidth, Line currLn) { + if (currLn != null) return currLn; + + int prev = line - 1; + if (prev >= 0) { + String text = widget.getLine(prev); + return new Line(prev, text, tabWidth); + } + return new Line(-1, Utils.EMPTY + Utils.NL_MARK, tabWidth); + } + // get previous non-blank line private Line prevNonblankLine(Line prevNb, int line, int tabWidth) { if (prevNb != null && prevNb.num > -1 && prevNb.num < line) return prevNb; @@ -255,10 +273,18 @@ private Line nextNonblankLine(Line nextNb, int line, int tabWidth) { return new Line(end, Utils.EMPTY + Utils.NL_MARK, tabWidth); } - private void draw(GC gc, int offset, int col, int spcWidth) { + private void draw(GC gc, int offset, int col, int spcWidth, boolean ascender) { Point pos = widget.getLocationAtOffset(offset); pos.x += col * spcWidth + lineShift; - gc.drawLine(pos.x, pos.y, pos.x, pos.y + widget.getLineHeight(offset)); + + int sp = widget.getLineSpacing(); + int ht = widget.getLineHeight(offset); + + if (ascender) { + gc.drawLine(pos.x, pos.y - sp, pos.x, pos.y + ht + sp); + } else { + gc.drawLine(pos.x, pos.y, pos.x, pos.y + ht + sp); + } } public void loadPrefs() { diff --git a/net.certiv.tools.indentguide.site/pom.xml b/net.certiv.tools.indentguide.site/pom.xml index 55e510e..7bcce39 100644 --- a/net.certiv.tools.indentguide.site/pom.xml +++ b/net.certiv.tools.indentguide.site/pom.xml @@ -9,7 +9,7 @@ net.certiv net.certiv.tools.indentguide.parent - 2.1.0-SNAPSHOT + 2.2.0-SNAPSHOT net.certiv.tools.indentguide.site diff --git a/pom.xml b/pom.xml index 56ea968..8052018 100644 --- a/pom.xml +++ b/pom.xml @@ -8,7 +8,7 @@ net.certiv net.certiv.tools.indentguide.parent - 2.1.0-SNAPSHOT + 2.2.0-SNAPSHOT IndentGuide IndentGuide