|
837 | 837 | } else {
|
838 | 838 | this.f_display_editor('#editor .CodeMirror', false);
|
839 | 839 | }
|
| 840 | + |
| 841 | + this.setCompilationErrorsHandler(o_editor_monaco); |
840 | 842 | }
|
841 | 843 |
|
842 | 844 | o_script.onload = function() {
|
|
847 | 849 | var f_ChangePass_old = ShaderToy.prototype.ChangePass;
|
848 | 850 |
|
849 | 851 | ShaderToy.prototype.ChangePass = function(n_id) {
|
850 |
| - f_ChangePass_old.call(this, n_id) |
| 852 | + f_ChangePass_old.call(this, n_id); |
851 | 853 |
|
852 | 854 | var s_code = gShaderToy.mPass[gShaderToy.mActiveDoc].mDocs.getValue();
|
853 | 855 |
|
|
856 | 858 |
|
857 | 859 | var s_html_editor_choice = `
|
858 | 860 | <div id="editorManager" style="margin-bottom: 5px">
|
859 |
| - <div id="tab0" onclick="ToyPlug.editPage.f_display_editor('#editor .CodeMirror', false)" class="tab"><label>Orginal Shadertoy Editor</label></div> |
860 |
| - <div id="tab1" onclick="ToyPlug.editPage.f_display_editor('#editor .monaco-editor', true)" class="tab"><label>VScode (Monaco) Editor</label></div> |
| 861 | + <div onclick="ToyPlug.editPage.f_display_editor('#editor .CodeMirror', false)" class="tab"><label>Orginal Shadertoy Editor</label></div> |
| 862 | + <div onclick="ToyPlug.editPage.f_display_editor('#editor .monaco-editor', true)" class="tab"><label>VScode (Monaco) Editor</label></div> |
861 | 863 | </div>
|
862 | 864 | `;
|
863 | 865 |
|
|
890 | 892 | )
|
891 | 893 | )
|
892 | 894 | }
|
| 895 | + |
| 896 | + handleErrors(errors, isError, errorStr, fromScript, editor) { |
| 897 | + console.log("SetModelMarkers"); |
| 898 | + console.dir(errors) |
| 899 | + const monacoErrors = errors.map((shError) => ({ |
| 900 | + startLineNumber: shError.line.parent.lines.findIndex((p) => Array.isArray(p.widgets)) + 1, |
| 901 | + startColumn: 0, |
| 902 | + endLineNumber: shError.height, |
| 903 | + endColumn: shError.line.text.length + 1, |
| 904 | + message: errorStr, |
| 905 | + severity: 8 |
| 906 | + })); |
| 907 | + monaco.editor.setModelMarkers(editor.getModel(), "owner", monacoErrors); |
| 908 | + console.dir(monacoErrors) |
| 909 | + } |
| 910 | + |
| 911 | + setCompilationErrorsHandler(editor) { |
| 912 | + console.log("setCompilationErrorsHandler", editor) |
| 913 | + const t = this; |
| 914 | + const defaultHandler = ShaderToy.prototype.SetErrors; |
| 915 | + |
| 916 | + ShaderToy.prototype.SetErrors = function(isError, errorStr, fromScript) { |
| 917 | + defaultHandler.call(this, isError, errorStr, fromScript); |
| 918 | + |
| 919 | + if (isError) { |
| 920 | + t.handleErrors(this.mErrors, isError, errorStr, fromScript, editor); |
| 921 | + } else { |
| 922 | + monaco.editor.setModelMarkers(editor.getModel(), "owner", []); |
| 923 | + } |
| 924 | + } |
| 925 | + } |
893 | 926 | }
|
894 | 927 |
|
895 | 928 | /**
|
|
0 commit comments