代码自动补全

develop
jialong.yu 3 years ago
parent e48147db7b
commit 1c93ae2793
  1. 21
      src/components/codemirror.vue

@ -6,7 +6,7 @@
:options="cmOption" :options="cmOption"
class="code-mirror" class="code-mirror"
@ready="ready" @ready="ready"
ref="myCmGenerate" ref="codemirror"
></codemirror> ></codemirror>
<div v-if="isSubmit" class="code-mask"></div> <div v-if="isSubmit" class="code-mask"></div>
<el-button <el-button
@ -49,6 +49,7 @@ import newmain from "../util/newMain";
import { codemirror } from "vue-codemirror"; import { codemirror } from "vue-codemirror";
import "codemirror/theme/ambiance.css"; // import "codemirror/theme/ambiance.css"; //
import "codemirror/mode/javascript/javascript.js"; import "codemirror/mode/javascript/javascript.js";
import "codemirror/mode/python/python.js";
import "codemirror/lib/codemirror.css"; import "codemirror/lib/codemirror.css";
// require active-line.js // require active-line.js
import "codemirror/addon/selection/active-line.js"; import "codemirror/addon/selection/active-line.js";
@ -119,12 +120,10 @@ export default {
foldGutter: true, // foldGutter: true, //
gutters: ["CodeMirror-linenumbers", "CodeMirror-foldgutter"], gutters: ["CodeMirror-linenumbers", "CodeMirror-foldgutter"],
highlightSelectionMatches: { showToken: /\w/, annotateScrollbar: true }, // highlightSelectionMatches: { showToken: /\w/, annotateScrollbar: true }, //
mode: { mode: 'python',
// , codemirror/mode
name: "javascript",
json: true
},
lineWrapping: true, // lineWrapping: true, //
autoCloseTags: true,//
autoCloseBrackets: true,//
// hint.js options // hint.js options
hintOptions: { hintOptions: {
// //
@ -134,8 +133,7 @@ export default {
keyMap: "sublime", keyMap: "sublime",
matchBrackets: true, matchBrackets: true,
showCursorWhenSelecting: true, showCursorWhenSelecting: true,
theme: "monokai", // theme: "monokai" //
extraKeys: { Ctrl: "autocomplete" } // keyMap
}, },
inputTextReg: /^((?!#).*?(,|\(|\[|\{|\s)+)?input(?!\w)\(['|"]([\s\S]+?)['|"]\)/m, // input() inputTextReg: /^((?!#).*?(,|\(|\[|\{|\s)+)?input(?!\w)\(['|"]([\s\S]+?)['|"]\)/m, // input()
requestList: [], // inputaxios requestList: [], // inputaxios
@ -162,7 +160,12 @@ export default {
methods: { methods: {
// //
ready() { ready() {
this.$refs.myCmGenerate.codemirror.setSize("auto", "calc(100vh - 167px)"); const code = this.$refs.codemirror.codemirror
code.setSize("auto", "calc(100vh - 167px)");
code.on('keypress', function() {
//
code.showHint()
});
}, },
/** /**
* python代码里如果有input函数的话是做了单独的处理的原理是先把所有input函数都替换成exit函数再在exit函数里加上特定标识再通过接口传给后端去执行 * python代码里如果有input函数的话是做了单独的处理的原理是先把所有input函数都替换成exit函数再在exit函数里加上特定标识再通过接口传给后端去执行

Loading…
Cancel
Save