Skip to content

Commit

Permalink
Remove support to .txt file
Browse files Browse the repository at this point in the history
  • Loading branch information
MarkChenYutian committed Aug 8, 2023
1 parent e2d010b commit 71a1e4c
Show file tree
Hide file tree
Showing 7 changed files with 6 additions and 90 deletions.
2 changes: 1 addition & 1 deletion src/application.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export default class C0VMApplication extends React.Component<
BC0SourceCode: "",
BC0BreakPoints: new Set(),

C0Editors: [{ title: "Untitled_0.c0", key: 0, content: "", breakpoints: [], noCompile: false }],
C0Editors: [{ title: "Untitled_0.c0", key: 0, content: "", breakpoints: [] }],
ActiveEditor: 0,

PrintoutValue: "",
Expand Down
4 changes: 1 addition & 3 deletions src/components/code-editor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ export default class CodeEditor extends React.Component
key: this.state.C0_nextKey,
content: "",
breakpoints: [],
noCompile: false,
});
this.props.set_app_state({C0Editors: new_editors, ActiveEditor: this.state.C0_nextKey});
this.setState({C0_nextKey: this.state.C0_nextKey + 1});
Expand Down Expand Up @@ -101,7 +100,6 @@ export default class CodeEditor extends React.Component
key: -1,
content: res,
breakpoints: [],
noCompile: F.name.endsWith(".txt")
})
};
reader.readAsText(F, "utf-8");
Expand All @@ -121,7 +119,7 @@ export default class CodeEditor extends React.Component
update_content(key: number, s: string) {
let ns: C0EditorTab[] = [...this.props.app_state.C0Editors];
ns = ns.map((tab) => tab.key === key ? {
key: tab.key, title: tab.title, content: s, breakpoints: tab.breakpoints, noCompile: tab.noCompile
key: tab.key, title: tab.title, content: s, breakpoints: tab.breakpoints
} : tab);
this.props.set_app_state({C0Editors: ns, contentChanged: true});
}
Expand Down
15 changes: 2 additions & 13 deletions src/components/code_editor/c0-editor-group.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import DraggableTabs from "./draggable_tabs";
import EditableTab from "./editable_tabs";

import type { RcFile } from 'antd/lib/upload';
import TextEditor from "./text-editor";

const { TabPane } = Tabs;
const regex_valid_file_name = /^[0-9a-zA-Z_-]+\.(c(0|1)|txt)$/;
Expand Down Expand Up @@ -65,8 +64,6 @@ export default class C0EditorGroup extends React.Component <C0EditorGroupProps>
for (let i = 0; i < new_tabs.length; i ++) {
if (new_tabs[i].key === key) {
new_tabs[i].title = name;
if (name.endsWith(".txt")) new_tabs[i].noCompile = true;
else new_tabs[i].noCompile = false;
}
}
return { C0Editors: new_tabs };
Expand Down Expand Up @@ -151,15 +148,7 @@ export default class C0EditorGroup extends React.Component <C0EditorGroupProps>
closable = {this.props.appState.C0Editors.length !== 1}
closeIcon={<FontAwesomeIcon icon={faXmark}/>}
>
{
editor.title.endsWith(".txt")
? <TextEditor
editorValue = {editor.content}
updateContent = {(s) => this.props.updateContent(editor.key, s)}
updateCompileLine = {fileArr => console.log(fileArr)}
updateName = {(name) => this.set_tab_name(editor.key, name)}
/>
: <C0Editor
<C0Editor
execLine = {lineNumber}
editorValue = {editor.content}
breakPoints = {editor.breakpoints}
Expand All @@ -168,7 +157,7 @@ export default class C0EditorGroup extends React.Component <C0EditorGroupProps>
setBreakPts = {(bps) => this.set_brkpt_for_editor(editor.key, bps)}
editable = {this.props.currLine === undefined}
handle_import_folder = {(F: RcFile, FList: RcFile[]) => this.props.handle_import_folder(F, FList)}
/>}
/>
</TabPane>;
}
)
Expand Down

This file was deleted.

37 changes: 0 additions & 37 deletions src/components/code_editor/text-editor.tsx

This file was deleted.

5 changes: 2 additions & 3 deletions src/network/remote_compile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ export default function remote_compile(
/** Update since v1.0.4 - print out the compile command when user hit compile button */
let compile_command = "$ cc0 ";
for (let tab of app_state.C0Editors) {
if (tab.noCompile) continue;
compile_command += " " + tab.title;
}
compile_command += app_state.CompilerFlags["d"] ? " -d" : "";
Expand All @@ -36,8 +35,8 @@ export default function remote_compile(
"Access-Control-Allow-Origin": "*",
},
body: JSON.stringify({
codes : app_state.C0Editors.filter(tab => !tab.noCompile).map(tab => tab.content),
filenames: app_state.C0Editors.filter(tab => !tab.noCompile).map(tab => tab.title),
codes : app_state.C0Editors.map(tab => tab.content),
filenames: app_state.C0Editors.map(tab => tab.title),
})
})
.then(
Expand Down
1 change: 0 additions & 1 deletion src/types/react-interface.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ type C0EditorTab = {
key : number, /* Key of editor tab */
content: string, /* Content (raw string) of that tab */
breakpoints: BreakPoint[], /* Breakpoints attatched to that tab */
noCompile: boolean /* true to ignore this file in compile process */
};

interface C0VMApplicationProps {
Expand Down

0 comments on commit 71a1e4c

Please sign in to comment.