Skip to content

Commit 0107265

Browse files
committed
converted most textareas to divs
1 parent 1c9e9c5 commit 0107265

File tree

3 files changed

+46
-23
lines changed

3 files changed

+46
-23
lines changed

media/regexworkbench.css

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,25 +66,48 @@ button.selected.vscode-high-contrast {
6666

6767
#regex {
6868
height: 16px;
69+
padding: 4px;
6970
}
7071

7172
#search {
73+
padding: 4px;
7274
height: 100px;
75+
overflow: auto;
76+
font-family: var(--vscode-editor-font-family);
77+
font-size: 11px;
78+
background-color: var(--vscode-editor-background);
79+
color: var(--vscode-editor-foreground);
80+
border: 1px solid var(--vscode-button-foreground);
7381
}
7482

7583
#replacement {
84+
padding: 4px;
7685
height: 100px;
86+
overflow: auto;
87+
font-family: var(--vscode-editor-font-family);
88+
font-size: 11px;
89+
background-color: var(--vscode-editor-background);
90+
color: var(--vscode-editor-foreground);
91+
border: 1px solid var(--vscode-button-foreground);
7792
}
7893

7994
#replaced {
95+
padding: 4px;
8096
height: 100px;
97+
overflow: auto;
98+
font-family: var(--vscode-editor-font-family);
99+
font-size: 11px;
100+
background-color: var(--vscode-editor-background);
101+
color: var(--vscode-editor-foreground);
102+
border: 1px solid var(--vscode-button-foreground);
81103
}
82104

83105
#splitresults {
84106
height: 150px;
85107
}
86108

87109
#results {
110+
padding: 4px;
88111
height: 150px;
89112
font-family: var(--vscode-editor-font-family);
90113
outline: 1px solid var(--vscode-checkbox-foreground);

media/regexworkbench.js

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,8 @@ function execute() {
5454
}
5555
} catch (e) {
5656
console.log(e);
57-
$('#results').val('Invalid regular expression');
58-
$('#splitresults').val('Invalid regular expression');
57+
$('#results').html('Invalid regular expression');
58+
$('#splitresults').html('Invalid regular expression');
5959
}
6060

6161
updateStateInHost();
@@ -96,22 +96,22 @@ function buildResultsTable(results, parent) {
9696

9797
function match() {
9898
const regex = new MultiRegExp2(new RegExp($('#regex').val(), "g" + getSwitches()));
99-
const search = $('#search').val();
99+
const search = $('#search').html();
100+
let results = [];
100101

101102
const execResults = regex.execForAllGroups(search, true);
102-
if (execResults == null) {
103-
return;
103+
if (execResults != null) {
104+
const match = execResults.shift();
105+
match.groups = execResults;
106+
results.push(match);
104107
}
105108

106-
const match = execResults.shift();
107-
match.groups = execResults;
108-
109-
buildResultsTable([match], $('#results'));
109+
buildResultsTable(results, $('#results'));
110110
};
111111

112112
function matchAll() {
113113
const regex = new MultiRegExp2(new RegExp($('#regex').val(), "g" + getSwitches()));
114-
const search = $('#search').val();
114+
const search = $('#search').html();
115115

116116
let results = [];
117117
let iteration;
@@ -127,7 +127,7 @@ function matchAll() {
127127

128128
function split() {
129129
const regex = new RegExp($('#regex').val(), "g" + getSwitches());
130-
const search = $('#search').val();
130+
const search = $('#search').html();
131131

132132
const items = search.split(regex).map(s => s.replace(/[\r\n]/g, " "));
133133
const results = items.map(item => `<span class="nl">${item}</span>`).join('');
@@ -138,19 +138,19 @@ function split() {
138138
function replace() {
139139
match();
140140
const regex = new RegExp($('#regex').val(), getSwitches());
141-
const search = $('#search').val();
142-
const replacement = $('#replacement').val();
141+
const search = $('#search').html();
142+
const replacement = $('#replacement').html();
143143

144144
$('#replaced').val(search.replace(regex, replacement));
145145
};
146146

147147
function replaceAll() {
148148
matchAll();
149149
const regex = new RegExp($('#regex').val(), "g" + getSwitches());
150-
const search = $('#search').val();
151-
const replacement = $('#replacement').val();
150+
const search = $('#search').html();
151+
const replacement = $('#replacement').html();
152152

153-
$('#replaced').val(search.replace(regex, replacement));
153+
$('#replaced').html(search.replace(regex, replacement));
154154
};
155155

156156
function processResults(r) {
@@ -206,8 +206,8 @@ function onReplacementChange(_) {
206206
function updateStateInHost() {
207207
const state = {
208208
regex: $('#regex').val(),
209-
search: $('#search').val(),
210-
replacement: $('#replacement').val(),
209+
search: $('#search').html(),
210+
replacement: $('#replacement').html(),
211211
mode: $('.mode-btn.selected')[0].id.replace("-btn", ""),
212212
switches: {
213213
i: $('#i-switch.selected').length > 0,
@@ -249,8 +249,8 @@ function infoWindow(msg) {
249249

250250
function setUiState(state) {
251251
$('#regex').val(state.regex);
252-
$('#search').val(state.search);
253-
$('#replacement').val(state.replacement);
252+
$('#search').html(state.search);
253+
$('#replacement').html(state.replacement);
254254

255255
const buttonId = `#${state.mode}-btn`;
256256
$(buttonId).click();

src/extension.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -253,17 +253,17 @@ class RegexWorkbenchPanel {
253253
254254
<div id="replacement-section" class="section">
255255
<span class="section-header">Replacement</span>
256-
<textarea id="replacement" class="ta"></textarea>
256+
<div id="replacement" class="ta" contenteditable="true"></div>
257257
</div>
258258
259259
<div id="search-section" class="section">
260260
<span class="section-header">Search Text</span>
261-
<textarea id="search" class="ta"></textarea>
261+
<div id="search" class="ta" contenteditable="true"></div>
262262
</div>
263263
264264
<div id="replaced-section" class="section">
265265
<span class="section-header">Replaced Text</span>
266-
<textarea id="replaced" class="ro ta"></textarea>
266+
<div id="replaced" class="ta"></div>
267267
</div>
268268
269269
<div id="results-section" class="section">

0 commit comments

Comments
 (0)