update
This commit is contained in:
@@ -3,14 +3,25 @@ import { ref } from "vue"
|
|||||||
export const insertText = ref("")
|
export const insertText = ref("")
|
||||||
|
|
||||||
export const cTexts = [
|
export const cTexts = [
|
||||||
",",
|
|
||||||
";",
|
";",
|
||||||
|
",",
|
||||||
|
"&",
|
||||||
|
"{}",
|
||||||
|
" = ",
|
||||||
|
" == ",
|
||||||
|
" > ",
|
||||||
|
" < ",
|
||||||
|
" != ",
|
||||||
|
" || ",
|
||||||
|
" && ",
|
||||||
|
"()",
|
||||||
'printf("");',
|
'printf("");',
|
||||||
'scanf("");',
|
'scanf("");',
|
||||||
"{\n}",
|
"int ",
|
||||||
"int",
|
"float ",
|
||||||
"%d",
|
"%d",
|
||||||
"if () ",
|
"%.2f",
|
||||||
|
"if () {}",
|
||||||
" else ",
|
" else ",
|
||||||
]
|
]
|
||||||
|
|
||||||
@@ -24,13 +35,14 @@ export const pythonTexts = [
|
|||||||
" != ",
|
" != ",
|
||||||
"print()",
|
"print()",
|
||||||
"input()",
|
"input()",
|
||||||
"if ",
|
"if :",
|
||||||
"else:",
|
"else:",
|
||||||
"elif ",
|
"elif :",
|
||||||
"for ",
|
"for ",
|
||||||
" in ",
|
" in ",
|
||||||
"range():",
|
"range():",
|
||||||
"while",
|
"while",
|
||||||
"[]",
|
"[]",
|
||||||
"{}",
|
"{}",
|
||||||
|
'"%.2f" % ',
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -46,10 +46,13 @@ whenever(insertText, (text: string) => {
|
|||||||
if (['"', "]", ")"].includes(text[len - 1])) delta = 1
|
if (['"', "]", ")"].includes(text[len - 1])) delta = 1
|
||||||
// {}
|
// {}
|
||||||
if (text === "{}") delta = 1
|
if (text === "{}") delta = 1
|
||||||
|
// if : elif :
|
||||||
|
if (text.slice(len - 2) === " :") delta = 1
|
||||||
// range():
|
// range():
|
||||||
if (text.slice(len - 2) === "):") delta = 2
|
if (text.slice(len - 2) === "):") delta = 2
|
||||||
// printf(""); scanf("");
|
// printf(""); scanf("");
|
||||||
if (text.slice(len - 3) === '");') delta = 3
|
if (text.slice(len - 3) === '");') delta = 3
|
||||||
|
if (text === "if () {}") delta = 4
|
||||||
if (delta > 0) {
|
if (delta > 0) {
|
||||||
const pos = codeEditor.state.selection.main.head - delta
|
const pos = codeEditor.state.selection.main.head - delta
|
||||||
codeEditor.dispatch({
|
codeEditor.dispatch({
|
||||||
|
|||||||
Reference in New Issue
Block a user