提交 9160f508 authored 作者: Noel Grandin's avatar Noel Grandin

Merge pull request #248 from agastald/auto_select

added 'auto-select' feature
......@@ -98,6 +98,9 @@ toolbar.autoComplete=Auto complete
toolbar.autoComplete.full=Full
toolbar.autoComplete.normal=Normal
toolbar.autoComplete.off=Off
toolbar.autoSelect=Auto select
toolbar.autoSelect.off=Off
toolbar.autoSelect.on=On
toolbar.cancelStatement=Cancel the current statement
toolbar.clear=Clear
toolbar.commit=Commit
......
......@@ -98,6 +98,9 @@ toolbar.autoComplete=Auto complete
toolbar.autoComplete.full=Total
toolbar.autoComplete.normal=Normal
toolbar.autoComplete.off=Desligado
toolbar.autoSelect=Auto seleção
toolbar.autoSelect.off=Desligado
toolbar.autoSelect.on=Ligado
toolbar.cancelStatement=Cancelar o comando que está em execução
toolbar.clear=Limpar
toolbar.commit=Commit
......
......@@ -128,6 +128,18 @@ Initial Developer: H2 Group
<option value="2">
${text.toolbar.autoComplete.full}
</option>
</select>&nbsp;
</td>
<td class="toolbar">
${text.toolbar.autoSelect}&nbsp;
<select name="autoSelect" size="1"
onchange="javascript:parent.h2query.setAutoSelect(this.value)">
<option value="0">
${text.toolbar.autoSelect.off}
</option>
<option selected="selected" value="1">
${text.toolbar.autoSelect.on}
</option>
</select>
</td>
<td class="toolbar">
......
......@@ -15,6 +15,7 @@ Initial Developer: H2 Group
var agent=navigator.userAgent.toLowerCase();
var is_opera = agent.indexOf("opera") >= 0;
var autoComplete = 0; // 0: off, 1: normal, 2: full
var autoSelect = 1; // 0: off, 1: on
var selectedRow = -1;
var lastList = '';
var lastQuery = null;
......@@ -294,6 +295,10 @@ function setAutoComplete(value) {
}
}
function setAutoSelect(value) {
autoSelect = value;
}
function manualAutoComplete() {
autoCompleteManual = true;
lastQuery = null;
......@@ -471,7 +476,13 @@ function submitSelected() {
var field = document.h2query.sql;
//alert('contents ' + field.selectionStart + ' ' + field.selectionEnd);
if (field.selectionStart == field.selectionEnd) {
return;
if (autoSelect == 0) {
return;
}
doAutoSelect();
if (field.selectionStart == field.selectionEnd) {
return;
}
}
var startPos = field.selectionStart;
var endPos = field.selectionEnd;
......@@ -480,6 +491,20 @@ function submitSelected() {
document.h2querysubmit.submit();
}
function doAutoSelect() {
var field = document.h2query.sql;
var position = field.selectionStart;
try {
var prevDoubleLine = field.value.lastIndexOf('\n\n',position - 1) + 2;
if (prevDoubleLine == 1) prevDoubleLine = 0;
var nextDoubleLine = field.value.indexOf('\n\n',position);
if (nextDoubleLine == -1) nextDoubleLine = field.value.length;
field.setSelectionRange(prevDoubleLine,nextDoubleLine);
} catch (e) {
field.selectionStart = field.selectionEnd = position;
}
}
//-->
</script>
</head>
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论