File tree Expand file tree Collapse file tree 1 file changed +15
-9
lines changed
Tools/wasm/emscripten/web_example Expand file tree Collapse file tree 1 file changed +15
-9
lines changed Original file line number Diff line number Diff line change 1919 max-width : 800px ;
2020 margin : 0 auto;
2121 }
22- # code {
22+ # editor {
23+ padding : 5px ;
24+ border : 1px solid black;
2325 width : 100% ;
24- height : 180 px ;
26+ height : 300 px ;
2527 }
2628 # info {
2729 padding-top : 20px ;
4244 crossorigin
4345 integrity ="sha384-yYdNmem1ioP5Onm7RpXutin5A8TimLheLNQ6tnMi01/ZpxXdAwIm2t4fJMx1Djs+ "
4446 > </ script >
47+ < script
48+ src ="https://cdnjs.cloudflare.com/ajax/libs/ace/1.43.1/ace.js "
49+ crossorigin
50+ integrity ="sha512-kmA5vhcxOkZI0ReiKJMGNb8/KKbgbExIlnt6aXuPtl86AgHBEi6OHHOz2wsTazBDGZKxe7fmiE+pIuZJQks4+A== "
51+ > </ script >
4552 < script type ="module ">
4653 class WorkerManager {
4754 constructor (
498505 const stopButton = document . getElementById ( "stop" ) ;
499506 const clearButton = document . getElementById ( "clear" ) ;
500507
501- const codeBox = document . getElementById ( "codebox" ) ;
502-
503508 window . onload = ( ) => {
504509 const terminal = new WasmTerminal ( ) ;
505510 terminal . open ( document . getElementById ( "terminal" ) ) ;
535540 terminal . clear ( ) ;
536541 terminal . reset ( ) ; // reset the history
537542 programRunning ( true ) ;
538- const code = codeBox . value ;
543+ const code = editor . getValue ( ) ;
539544 pythonWorkerManager . run ( {
540545 args : [ "main.py" ] ,
541546 files : { "main.py" : code } ,
578583 finishedCallback ,
579584 ) ;
580585 } ;
586+ document . addEventListener ( 'DOMContentLoaded' , ( ) => {
587+ editor = ace . edit ( "editor" ) ;
588+ editor . session . setMode ( "ace/mode/python" ) ;
589+ } ) ;
581590 </ script >
582591 </ head >
583592 < body >
584593 < h1 > Simple REPL for Python WASM</ h1 >
585- < textarea id ="codebox " cols ="108 " rows ="16 ">
586- print('Welcome to WASM!')
587- </ textarea
588- >
594+ < div id ="editor "> print('Welcome to WASM!')</ div >
589595 < div class ="button-container ">
590596 < button id ="run " disabled > Run</ button >
591597 < button id ="repl " disabled > Start REPL</ button >
You can’t perform that action at this time.
0 commit comments