-
-
Notifications
You must be signed in to change notification settings - Fork 118
Expand file tree
/
Copy pathPrint.js
More file actions
68 lines (58 loc) · 1.97 KB
/
Print.js
File metadata and controls
68 lines (58 loc) · 1.97 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
/*
* Project Name : Visual Python
* Description : GUI-based Python code generator
* File Name : Print.js
* Author : Black Logic
* Note : Logic > print
* License : GNU GPLv3 with Visual Python special exception
* Date : 2021. 11. 18
* Change Date :
*/
//============================================================================
// [CLASS] Print
//============================================================================
define([
'vp_base/js/com/com_String',
'vp_base/js/com/component/PopupComponent'
], function(com_String, PopupComponent) {
/**
* Print
*/
class Print extends PopupComponent {
_init() {
super._init();
/** Write codes executed before rendering */
this.config.dataview = false;
this.config.codeview = false;
this.config.saveOnly = true;
this.state = {
code: 'print()',
...this.state
}
this._addCodemirror('code', this.wrapSelector('#code'));
}
templateForBody() {
/** Implement generating template */
var page = new com_String();
page.appendFormatLine('<textarea name="code" class="code vp-state" id="code">{0}</textarea>'
, this.state.code);
return page.toString();
}
open() {
super.open();
// if start with print(, set default cursor on codemirror
if (this.state.code.substr(0, 6) === 'print(') {
// set default cursor
let cmObj = this.getCodemirror('code');
if (cmObj && cmObj.cm) {
cmObj.cm.setCursor({ line: 0, ch: 6 });
cmObj.cm.focus();
}
}
}
generateCode() {
return this.state.code;
}
}
return Print;
});