提交 d99f5601 authored 作者: noelgrandin@gmail.com's avatar noelgrandin@gmail.com

Handle tabs like 4 spaces in web console, patch by Martin Grajcar

上级 0f49df20
...@@ -21,6 +21,7 @@ Change Log ...@@ -21,6 +21,7 @@ Change Log
(PageStore only; the MVStore already used 4096). (PageStore only; the MVStore already used 4096).
</li><li>Auto-scale MAX_MEMORY_ROWS and CACHE_SIZE settings by the amount of available RAM. Gives a better </li><li>Auto-scale MAX_MEMORY_ROWS and CACHE_SIZE settings by the amount of available RAM. Gives a better
out of box experience for people with more powerful machines. out of box experience for people with more powerful machines.
</li><li>Handle tabs like 4 spaces in web console, patch by Martin Grajcar
</li></ul> </li></ul>
<h2>Version 1.4.180 Beta (2014-07-13)</h2> <h2>Version 1.4.180 Beta (2014-07-13)</h2>
......
...@@ -16,6 +16,8 @@ import org.h2.util.New; ...@@ -16,6 +16,8 @@ import org.h2.util.New;
* This class is used by the H2 Console. * This class is used by the H2 Console.
*/ */
public class PageParser { public class PageParser {
private static final int TAB_WIDTH = 4;
private final String page; private final String page;
private int pos; private int pos;
private final Map<String, Object> settings; private final Map<String, Object> settings;
...@@ -245,12 +247,15 @@ public class PageParser { ...@@ -245,12 +247,15 @@ public class PageParser {
boolean convertSpace = true; boolean convertSpace = true;
for (int i = 0; i < s.length(); i++) { for (int i = 0; i < s.length(); i++) {
char c = s.charAt(i); char c = s.charAt(i);
if (c == ' ') { if (c == ' ' || c == '\t') {
if (convertSpace && convertBreakAndSpace) { // convert tabs into spaces
buff.append("&nbsp;"); for (int j = 0; j < (c == ' ' ? 1 : TAB_WIDTH); j++) {
} else { if (convertSpace && convertBreakAndSpace) {
buff.append(' '); buff.append("&nbsp;");
convertSpace = true; } else {
buff.append(' ');
convertSpace = true;
}
} }
continue; continue;
} }
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论