Skip to content

Commit 956af3b

Browse files
committed
wip hack rm dock
1 parent d5c2517 commit 956af3b

File tree

1 file changed

+64
-45
lines changed

1 file changed

+64
-45
lines changed

js/widget.js

+64-45
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ export default{
4444
.forced-indent {width: 4em;}\
4545
.CodeMirror {border: 1px solid #aaa; height: auto;}\
4646
widget-code-input-signature {border-bottom: 0px solid #aaa;}\
47-
widget-code-input-docstring {border-top: 0px solid #aaa;}\
47+
//widget-code-input-docstring {border-top: 0px solid #aaa;}\
4848
.widget-code-input-body { border-top: 1px solid #aaa;}\
4949
</style>';
5050

@@ -59,9 +59,9 @@ export default{
5959
'<textarea id="' +
6060
theTextareaId +
6161
'-signature" class="CodeMirror.widget-code-input-signature"></textarea>' +
62-
'<textarea id="' +
63-
theTextareaId +
64-
'-docstring" class="CodeMirror.widget-code-input-docstring"></textarea>' +
62+
//'<textarea id="' +
63+
//theTextareaId +
64+
//'-docstring" class="CodeMirror.widget-code-input-docstring"></textarea>' +
6565
'<textarea id="' +
6666
theTextareaId +
6767
'-body" class="CodeMirror.widget-code-input-body"></textarea>';
@@ -83,7 +83,7 @@ export default{
8383
var guttercomp = new Compartment; // allow dynamic changing of line numbers
8484

8585
var theme_compartment_sig = new Compartment;
86-
var theme_compartment_doc = new Compartment;
86+
//var theme_compartment_doc = new Compartment;
8787
var theme_compartment_body = new Compartment;
8888

8989

@@ -116,30 +116,39 @@ export default{
116116

117117
mySignatureCodeMirror.dom.classList.add("widget-code-input-signature")
118118

119-
var myDocstringCodeMirror = editorFromTextArea(document.getElementById(theTextareaId + '-docstring'), [lineNumbers(), EditorState.readOnly.of(true), EditorView.editorAttributes.of({class:"widget-code-input-docstring"}), gutter({class:"forced-indent"}), guttercomp.of(lineNumbers()),
120-
121-
history(),
122-
drawSelection(),
123-
dropCursor(),
124-
EditorState.allowMultipleSelections.of(true),
125-
syntaxHighlighting(defaultHighlightStyle, { fallback: true }),
126-
bracketMatching(),
127-
closeBrackets(),
128-
autocompletion(),
129-
rectangularSelection(),
130-
crosshairCursor(),
131-
keymap.of([
132-
...closeBracketsKeymap,
133-
...defaultKeymap,
134-
...searchKeymap,
135-
...historyKeymap,
136-
...foldKeymap,
137-
...completionKeymap,
138-
...lintKeymap,
139-
]), python(), indentUnit.of(" "), theme_compartment_doc.of(basicLight)]);
140-
141-
142-
mySignatureCodeMirror.dom.classList.add("widget-code-input-signature"); // add css for border to docstring element
119+
//var myDocstringCodeMirror = editorFromTextArea(document.getElementById(theTextareaId + '-docstring'),
120+
// [lineNumbers(),
121+
// EditorState.readOnly.of(true),
122+
// EditorView.editorAttributes.of({class:"widget-code-input-docstring"}),
123+
// gutter({class:"forced-indent"}),
124+
// guttercomp.of(lineNumbers()),
125+
// history(),
126+
// drawSelection(),
127+
// dropCursor(),
128+
// EditorState.allowMultipleSelections.of(true),
129+
// syntaxHighlighting(defaultHighlightStyle, { fallback: true }),
130+
// bracketMatching(),
131+
// closeBrackets(),
132+
// autocompletion(),
133+
// rectangularSelection(),
134+
// crosshairCursor(),
135+
// keymap.of([
136+
// ...closeBracketsKeymap,
137+
// ...defaultKeymap,
138+
// ...searchKeymap,
139+
// ...historyKeymap,
140+
// ...foldKeymap,
141+
// ...completionKeymap,
142+
// ...lintKeymap,
143+
// ]),
144+
// python(),
145+
// indentUnit.of(" "),
146+
// theme_compartment_doc.of(basicLight)
147+
// ]
148+
//);
149+
150+
151+
//mySignatureCodeMirror.dom.classList.add("widget-code-input-signature"); // add css for border to docstring element
143152

144153
// event listener for changes to function body
145154

@@ -206,14 +215,24 @@ function signatureValueChanged() {
206215
function updateLineNumbers() {
207216
const linesSignature = mySignatureCodeMirror.state.doc.toString().split('\n').length;
208217

209-
const docstring = myDocstringCodeMirror.state.doc.toString();
210-
const linesDocstring = docstring == "" ? 0 : docstring.split('\n').length;
211-
212-
// increment line numbers in docstring text area by the number of lines in the signature
213-
myDocstringCodeMirror.dispatch({
214-
effects: guttercomp.reconfigure(
215-
lineNumbers({ formatNumber: n=> linesDocstring == 0 ? "" : linesSignature+n }))
216-
});
218+
const linesDocstring = 0;
219+
//const docstring = myDocstringCodeMirror.state.doc.toString();
220+
//const linesDocstring = docstring == "" ? 0 : docstring.split('\n').length;
221+
//// changing css style seems to not work
222+
////const fixedHeightEditor = EditorView.theme({
223+
//// "&": {height: "100px"},
224+
//// ".cm-scroller": {overflow: "auto"}
225+
////})
226+
////var theme = new Compartment;
227+
////myDocstringCodeMirror.dispatch({
228+
//// effects: theme.reconfigure(fixedHeightEditor)
229+
////});
230+
231+
//// increment line numbers in docstring text area by the number of lines in the signature
232+
//myDocstringCodeMirror.dispatch({
233+
// effects: guttercomp.reconfigure(
234+
// lineNumbers({ formatNumber: n=> linesDocstring == 0 ? "" : linesSignature+n }))
235+
//});
217236

218237
myBodyCodeMirror.dispatch({
219238
effects: guttercomp.reconfigure(
@@ -228,11 +247,11 @@ function signatureValueChanged() {
228247

229248
const newDocstring = model.get('docstring');
230249

231-
if (newDocstring !== myDocstringCodeMirror.state.doc.toString()) {
232-
myDocstringCodeMirror.dispatch({
233-
changes: {from: 0, to: myDocstringCodeMirror.state.doc.length, insert: newDocstring}
234-
})
235-
}
250+
//if (newDocstring !== myDocstringCodeMirror.state.doc.toString()) {
251+
// myDocstringCodeMirror.dispatch({
252+
// changes: {from: 0, to: myDocstringCodeMirror.state.doc.length, insert: newDocstring}
253+
// })
254+
//}
236255
updateLineNumbers();
237256
}
238257

@@ -270,9 +289,9 @@ function bodyValueChanged() {
270289
mySignatureCodeMirror.dispatch({
271290
effects: theme_compartment_sig.reconfigure(theme)
272291
})
273-
myDocstringCodeMirror.dispatch({
274-
effects: theme_compartment_doc.reconfigure(theme)
275-
})
292+
//myDocstringCodeMirror.dispatch({
293+
// effects: theme_compartment_doc.reconfigure(theme)
294+
//})
276295
myBodyCodeMirror.dispatch({
277296
effects: theme_compartment_body.reconfigure(theme)
278297
})

0 commit comments

Comments
 (0)