Spaces:
Sleeping
Sleeping
updating
Browse files- code_editor.py +9 -2
code_editor.py
CHANGED
|
@@ -3,9 +3,16 @@ import streamlit as st
|
|
| 3 |
import streamlit_ace as st_ace
|
| 4 |
from utils import execute_code
|
| 5 |
|
| 6 |
-
def render_code_editor(selected_lang, ace_theme, editor_key
|
| 7 |
st.subheader("Editor")
|
| 8 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 9 |
code = st_ace.st_ace(
|
| 10 |
value=st.session_state.code,
|
| 11 |
placeholder=f"Start typing your {selected_lang} code…",
|
|
|
|
| 3 |
import streamlit_ace as st_ace
|
| 4 |
from utils import execute_code
|
| 5 |
|
| 6 |
+
def render_code_editor(selected_lang, ace_theme, editor_key):
|
| 7 |
st.subheader("Editor")
|
| 8 |
+
default_snippet = {
|
| 9 |
+
"Python": '''# default code\na = int(input())\nb = int(input())\nprint("Sum:", a + b)''',
|
| 10 |
+
"C": '''// default code\n#include <stdio.h>\nint main() {\n int a, b;\n scanf("%d %d", &a, &b);\n printf("Sum: %d\\n", a + b);\n return 0;\n}''',
|
| 11 |
+
"C++": '''// default code\n#include <iostream>\nusing namespace std;\nint main() {\n int a, b;\n cin >> a >> b;\n cout << "Sum: " << a + b << endl;\n return 0;\n}''',
|
| 12 |
+
"Java": '''// default code\nimport java.util.Scanner;\npublic class Program {\n public static void main(String[] args) {\n Scanner sc = new Scanner(System.in);\n int a = sc.nextInt();\n int b = sc.nextInt();\n System.out.println("Sum: " + (a + b));\n }\n}''',
|
| 13 |
+
"JavaScript": '''// default code\nconst readline = require('readline');\nconst rl = readline.createInterface({ input: process.stdin, output: process.stdout });\nlet inputs = [];\nrl.on('line', (line) => {\n inputs.push(parseInt(line));\n if (inputs.length === 2) {\n console.log("Sum:", inputs[0] + inputs[1]);\n rl.close();\n }\n});''',
|
| 14 |
+
"C#": '''// default code\nusing System;\npublic class Program {\n public static void Main(string[] args) {\n int a = Convert.ToInt32(Console.ReadLine());\n int b = Convert.ToInt32(Console.ReadLine());\n Console.WriteLine("Sum: " + (a + b));\n }\n}'''
|
| 15 |
+
}
|
| 16 |
code = st_ace.st_ace(
|
| 17 |
value=st.session_state.code,
|
| 18 |
placeholder=f"Start typing your {selected_lang} code…",
|