From 656ac86fd1cfc647190119e9c64982ac1bb6ae71 Mon Sep 17 00:00:00 2001 From: B-Dome <50382067+B-Dome@users.noreply.github.com> Date: Sun, 23 Jun 2024 15:17:20 +0200 Subject: [PATCH 01/11] added updated web-app code --- one-sided-web/spago.yaml | 2 + one-sided-web/src/Definitions.purs | 9 +- one-sided-web/src/EditorMod.js | 50 ++ one-sided-web/src/EditorMod.purs | 38 ++ one-sided-web/src/Events.purs | 28 +- one-sided-web/src/Layout.purs | 26 +- one-sided-web/src/Runner.purs | 5 +- one-sided-web/src/Types.purs | 761 +++++++++++++++++++++++++++++ 8 files changed, 895 insertions(+), 24 deletions(-) create mode 100644 one-sided-web/src/EditorMod.js create mode 100644 one-sided-web/src/EditorMod.purs create mode 100644 one-sided-web/src/Types.purs diff --git a/one-sided-web/spago.yaml b/one-sided-web/spago.yaml index 153549a..08b45d6 100644 --- a/one-sided-web/spago.yaml +++ b/one-sided-web/spago.yaml @@ -12,4 +12,6 @@ package: - effect - console - transformers + - record + - aff-promise diff --git a/one-sided-web/src/Definitions.purs b/one-sided-web/src/Definitions.purs index 7998d87..8016c9e 100644 --- a/one-sided-web/src/Definitions.purs +++ b/one-sided-web/src/Definitions.purs @@ -11,6 +11,7 @@ import Data.Either (Either(..)) import Data.Tuple (Tuple(..),snd) import Data.List (List,intercalate) import Data.Map (lookup,toUnfoldable) +import Data.Maybe (Maybe(..)) import Driver.Definition (DriverState(..),initialDriverState, runDriverM) import Driver.Driver (runStr) @@ -22,17 +23,19 @@ import Syntax.Kinded.Terms (getType,getPrdCns) import Syntax.Kinded.Program (Program(..),VarDecl(..),emptyProg) import Eval.Definition (EvalTrace(..)) import StandardLib (libMap) +import Types (Editor) -data Input = ProgramInput String | RunProg +data Input = ProgramInput String | RunProg | InitEditor data RunResult = ResErr {errMsg :: String, errDebug::String, errTypes::String} | ResSucc {succCmd::String, succTrace::String, succDebug::String, succTypes::String} -type State = {progSrc::String, runRes::RunResult} +type State = {progSrc::String, runRes::RunResult, monEditor:: Maybe Editor} initialState :: Input -> State initialState _ = { progSrc:intercalate "\n" (lookup (Modulename "Bool") libMap), - runRes:ResSucc {succCmd:"", succTrace:"", succDebug:"", succTypes:""} + runRes:ResSucc {succCmd:"", succTrace:"", succDebug:"", succTypes:""}, + monEditor: Nothing } runProg :: String -> RunResult diff --git a/one-sided-web/src/EditorMod.js b/one-sided-web/src/EditorMod.js new file mode 100644 index 0000000..d17229f --- /dev/null +++ b/one-sided-web/src/EditorMod.js @@ -0,0 +1,50 @@ +"use strict"; + + +//new options mapping function, based on what options looks like +var mapMaybes = function (options) { + var newObj = {}; + for (prop in options) { + var propKey = prop; + var propValue = options[prop]; + var newValue = undefined; + if (Object.keys(propValue).length != 0) { + newValue = propValue["value0"] + newObj[propKey] = newValue; + } + } + return newObj; +} + + +//here is the new implementation using getElementbyId +export const createImpl = function (options) { + return function (el) { + return function () { + return new Promise(function (resolve, reject) { + // make it happy for browser env + monacoRequire.config({ paths: { 'vs': 'monaco-editor/min/vs' } }); + + monacoRequire(['vs/editor/editor.main'], function () { + //console.log(options); + const mappedOpts = mapMaybes(options); + //console.log(mappedOpts); + //console.log(el); + window.editorVar = monaco.editor.create(document.getElementById(el), mappedOpts); + //console.log(editor); + resolve(window.editorVar); + }); + }); + }; + }; +}; + + +//2 new functions to import that get/set values for the editor +export const readEditorValue = function (){ + return window.editorVar.getValue() +} + +export const setEditorValue = function (strValue){ + window.editorVar.setValue(strValue) +} \ No newline at end of file diff --git a/one-sided-web/src/EditorMod.purs b/one-sided-web/src/EditorMod.purs new file mode 100644 index 0000000..bf81dc4 --- /dev/null +++ b/one-sided-web/src/EditorMod.purs @@ -0,0 +1,38 @@ +module EditorMod + ( create + , readEditorValue + , setEditorValue + ) + where + +import Prelude + +import Control.Promise (Promise, toAffE) +import Data.Maybe (Maybe(..)) +import Effect (Effect) +import Effect.Aff (Aff) +import Foreign (Foreign, unsafeToForeign) +import Types (Editor, defaultConstuctorOptions) + +foreign import createImpl + :: Foreign + -> String + -> Effect (Promise Editor) + +create + :: String + -> String + -> Aff Editor +create textValue elementIdString = do + let opts = defaultConstuctorOptions + { value = Just textValue + , language = Just "one-sided-sequent-calculus" + , theme = Just "vs-dark" + } + let effProm = createImpl (unsafeToForeign opts) elementIdString + toAffE effProm + +foreign import readEditorValue :: Effect String + +foreign import setEditorValue :: String -> Unit + diff --git a/one-sided-web/src/Events.purs b/one-sided-web/src/Events.purs index a5c615a..f0dc452 100644 --- a/one-sided-web/src/Events.purs +++ b/one-sided-web/src/Events.purs @@ -1,16 +1,19 @@ -module Events (runSrc, selectExample, getSrc, handleAction) where +module Events (runSrc, selectExample, getSrc, handleAction, createEditor) where import Definitions (Input(..),State, runProg) import StandardLib (libMap) import Common (Modulename(..)) -import Halogen (modify_) +import Halogen (modify_, liftAff) import Prelude (bind) import Data.Unit (Unit) import Data.Maybe (Maybe(..)) import Data.Map (lookup) import Control.Monad.State (class MonadState, gets) +import Effect.Aff.Class (class MonadAff) +import Effect.Unsafe (unsafePerformEffect) +import EditorMod (create, readEditorValue, setEditorValue) getSrc :: String -> Input getSrc newSrc = ProgramInput newSrc @@ -18,15 +21,28 @@ getSrc newSrc = ProgramInput newSrc runSrc::forall ev. ev->Input runSrc = \_ -> RunProg +createEditor::forall ev. ev->Input +createEditor = \_ -> InitEditor + selectExample :: String -> Input selectExample nm = case lookup (Modulename nm) libMap of Just src -> ProgramInput src Nothing -> ProgramInput "" -handleAction :: forall m. MonadState State m => Input -> m Unit +handleAction :: forall m. MonadAff m => MonadState State m => Input -> m Unit handleAction inp = case inp of - ProgramInput src -> modify_ (\st -> st {progSrc=src}) + ProgramInput src -> do + -- dont know how to call the setEditorValue function by itself (without using let or something) + -- setEditorValue has no return and only needs to be called for the editor value to change + let x = setEditorValue src + modify_ (\st -> st {progSrc=src}) RunProg -> do - src <- gets (\st -> st.progSrc) + -- instead of reading from progSrc, read directly from the editor and write it in the state after + let src = unsafePerformEffect readEditorValue let res = runProg src - modify_ (\st -> st {runRes=res}) + modify_ (\st -> st {runRes=res, progSrc=src}) + InitEditor -> do + src <- gets (\st -> st.progSrc) + let editorInst = create src "container" + x <- liftAff editorInst + modify_ (\st -> st {monEditor = Just x}) diff --git a/one-sided-web/src/Layout.purs b/one-sided-web/src/Layout.purs index 20149e6..b11960b 100644 --- a/one-sided-web/src/Layout.purs +++ b/one-sided-web/src/Layout.purs @@ -1,7 +1,7 @@ module Layout (render) where import Definitions (RunResult(..),Input, State) -import Events (runSrc, selectExample,getSrc) +import Events (runSrc, selectExample, createEditor) import StandardLib (libMap) import Prelude (($),(<>),(<$>),(+),show) @@ -21,16 +21,12 @@ getHTMLHeight str = let nlines = length (split (Pattern "\n") str) in "height: " <> show (nlines +3) <> "em;" render :: forall w. State -> HTML w Input -render {progSrc:src,runRes:res} = layout src res +render {runRes:res} = layout res -progDiv :: forall w. String -> HTML w Input -progDiv src = div - [ class_ $ ClassName "prog" ] - [ - textarea [id "progInput", value src, onValueChange getSrc, style $ getHTMLHeight src], - br_, - button [id "runButton", onClick runSrc] [text "Run"] - ] +progDiv :: forall w. HTML w Input +progDiv = div + [ id "container", class_ $ ClassName "prog"] + [] getArea :: forall w. String -> ClassName -> String -> HTML w Input @@ -73,11 +69,15 @@ exSelect = div_ [ br_ ] -layout :: forall w. String -> RunResult -> HTML w Input -layout src res = body [] +layout :: forall w. RunResult -> HTML w Input +layout res = body [] [ h1_ [text "One Sided Sequent Calculus"], + -- temporary Button to create Editor until i find a way to create the editor after loading + button [id "createEditor", onClick createEditor] [text "Create Editor"], exSelect, - progDiv src, + progDiv , + button [id "runButton", onClick runSrc] [text "Run"], resDiv res ] + diff --git a/one-sided-web/src/Runner.purs b/one-sided-web/src/Runner.purs index bbf93b9..621b8ea 100644 --- a/one-sided-web/src/Runner.purs +++ b/one-sided-web/src/Runner.purs @@ -9,15 +9,16 @@ import Halogen.Aff (awaitBody,runHalogenAff) import Halogen.VDom.Driver (runUI) import Halogen.Query.HalogenQ (HalogenQ) import Halogen.Query.HalogenM (HalogenM) +import Effect.Aff.Class (class MonadAff) import Definitions (Input(..),State, initialState) import Layout (render) import Events (handleAction) -component :: forall output m t. Component t Input output m +component :: forall output m t. MonadAff m => Component t Input output m component = mkComponent { initialState:initialState, render:render, eval:eval} -eval :: forall slots output m a t t2. HalogenQ t Input t2 a -> HalogenM State Input slots output m a +eval :: forall slots output m a t t2. MonadAff m => HalogenQ t Input t2 a -> HalogenM State Input slots output m a eval = mkEval defaultEval {handleAction=handleAction} uiRunner :: Effect Unit diff --git a/one-sided-web/src/Types.purs b/one-sided-web/src/Types.purs new file mode 100644 index 0000000..cf5db0c --- /dev/null +++ b/one-sided-web/src/Types.purs @@ -0,0 +1,761 @@ +module Types + ( AcceptSuggestion + , AccessibilitySupport + , Editor + , EditorConstructionOptions + , EditorFindOptions + , EditorMinimapOptions + , EditorOptionsMixin + , EditorScrollbarOptions + , FontWeight + , LineNumberFunction + , LineNumbers + , MONACO + , MultiCursorModifier + , RenderHighLight + , RenderWhiteSpace + , ScrollbarVisibility + , ShowFoldingControls + , ShowSlider + , SnippetSuggestion + , WordWrapState + , acceptSuggestionOff + , acceptSuggestionOn + , acceptSuggestionSmart + , accessibilitySupportAuto + , accessibilitySupportOff + , accessibilitySupportOn + , alt + , ctrlCmd + , defaultConstuctorOptions + , defaultEditorScrollbarOptions + , defaultMinimapOptions + , fontWeight100 + , fontWeight200 + , fontWeight300 + , fontWeight400 + , fontWeight500 + , fontWeight600 + , fontWeight700 + , fontWeight800 + , fontWeight900 + , fontWeightBold + , fontWeightBolder + , fontWeightInherit + , fontWeightInitial + , fontWeightLighter + , fontWeightNormal + , lineNumberFunction + , lineNumbersOff + , lineNumbersOn + , lineNumbersRelative + , renderHighLightAll + , renderHighLightGutter + , renderHighLightLine + , renderHighLightNone + , renderWhiteSpaceAll + , renderWhiteSpaceBoundary + , renderWhiteSpaceNone + , scrollbarVisibilityAuto + , scrollbarVisibilityHidden + , scrollbarVisibilityVisible + , showFoldingControlsAlways + , showFoldingControlsMouseOver + , showSliderAlways + , showSliderMouseOver + , snippetSuggestionBottom + , snippetSuggestionInline + , snippetSuggestionNone + , snippetSuggestionTop + , wordwrapBounded + , wordwrapColumn + , wordwrapOff + , wordwrapOn + ) + where + +import Data.Either (Either(..)) +import Data.Maybe (Maybe(..)) +import Record.Builder (build, merge) + +foreign import data Editor ∷ Type + +foreign import data MONACO :: Type + + +newtype FontWeight = FontWeight String + +fontWeightNormal :: FontWeight +fontWeightNormal = FontWeight "normal" + +fontWeightBold :: FontWeight +fontWeightBold = FontWeight "bold" + +fontWeightBolder :: FontWeight +fontWeightBolder = FontWeight "Bolder" + +fontWeightLighter :: FontWeight +fontWeightLighter = FontWeight "lighter" + +fontWeightInitial :: FontWeight +fontWeightInitial = FontWeight "initial" + +fontWeightInherit :: FontWeight +fontWeightInherit = FontWeight "inherit" + +fontWeight100 :: FontWeight +fontWeight100 = FontWeight "100" + +fontWeight200 :: FontWeight +fontWeight200 = FontWeight "200" + +fontWeight300 :: FontWeight +fontWeight300 = FontWeight "300" + +fontWeight400 :: FontWeight +fontWeight400 = FontWeight "400" + +fontWeight500 :: FontWeight +fontWeight500 = FontWeight "500" + +fontWeight600 :: FontWeight +fontWeight600 = FontWeight "600" + +fontWeight700 :: FontWeight +fontWeight700 = FontWeight "700" + +fontWeight800 :: FontWeight +fontWeight800 = FontWeight "800" + +fontWeight900 :: FontWeight +fontWeight900 = FontWeight "900" + +newtype WordWrapState = WordWrapState String +wordwrapOff :: WordWrapState +wordwrapOff = WordWrapState "off" + +wordwrapOn :: WordWrapState +wordwrapOn = WordWrapState "on" + +wordwrapColumn :: WordWrapState +wordwrapColumn = WordWrapState "wordWrapColumn" + +wordwrapBounded :: WordWrapState +wordwrapBounded = WordWrapState "bounded" + + +newtype MultiCursorModifier = MultiCursorModifier String +ctrlCmd :: MultiCursorModifier +ctrlCmd = MultiCursorModifier "ctrlCmd" + +alt :: MultiCursorModifier +alt = MultiCursorModifier "alt" + +newtype AccessibilitySupport = AccessibilitySupport String +accessibilitySupportOn :: AccessibilitySupport +accessibilitySupportOn = AccessibilitySupport "on" + +accessibilitySupportOff :: AccessibilitySupport +accessibilitySupportOff = AccessibilitySupport "off" + +accessibilitySupportAuto :: AccessibilitySupport +accessibilitySupportAuto = AccessibilitySupport "auto" + +newtype AcceptSuggestion = AcceptSuggestion String + +acceptSuggestionOn :: AcceptSuggestion +acceptSuggestionOn = AcceptSuggestion "on" + +acceptSuggestionOff :: AcceptSuggestion +acceptSuggestionOff = AcceptSuggestion "off" + +acceptSuggestionSmart :: AcceptSuggestion +acceptSuggestionSmart = AcceptSuggestion "smart" + +newtype SnippetSuggestion = SnippetSuggestion String + +snippetSuggestionTop :: SnippetSuggestion +snippetSuggestionTop = SnippetSuggestion "top" + +snippetSuggestionBottom :: SnippetSuggestion +snippetSuggestionBottom = SnippetSuggestion "bottom" + +snippetSuggestionInline :: SnippetSuggestion +snippetSuggestionInline = SnippetSuggestion "inline" + +snippetSuggestionNone :: SnippetSuggestion +snippetSuggestionNone = SnippetSuggestion "none" + +newtype ShowFoldingControls = ShowFoldingControls String + +showFoldingControlsAlways :: ShowFoldingControls +showFoldingControlsAlways = ShowFoldingControls "always" + +showFoldingControlsMouseOver :: ShowFoldingControls +showFoldingControlsMouseOver = ShowFoldingControls "mouseover" + +newtype RenderWhiteSpace = RenderWhiteSpace String + +renderWhiteSpaceNone :: RenderWhiteSpace +renderWhiteSpaceNone = RenderWhiteSpace "none" + +renderWhiteSpaceBoundary :: RenderWhiteSpace +renderWhiteSpaceBoundary = RenderWhiteSpace "boundary" + +renderWhiteSpaceAll :: RenderWhiteSpace +renderWhiteSpaceAll = RenderWhiteSpace "all" + +newtype RenderHighLight = RenderHighLight String + +renderHighLightNone :: RenderHighLight +renderHighLightNone = RenderHighLight "none" + +renderHighLightGutter :: RenderHighLight +renderHighLightGutter = RenderHighLight "gutter" + +renderHighLightLine :: RenderHighLight +renderHighLightLine = RenderHighLight "line" + +renderHighLightAll :: RenderHighLight +renderHighLightAll = RenderHighLight "all" + +type LineNumberFunction = Number -> String + +newtype LineNumbers = LineNumbers (Either String LineNumberFunction) +lineNumbersOn :: LineNumbers +lineNumbersOn = LineNumbers (Left "on") + +lineNumbersOff :: LineNumbers +lineNumbersOff = LineNumbers (Left "off") + +lineNumbersRelative:: LineNumbers +lineNumbersRelative = LineNumbers (Left "relative") + +lineNumberFunction :: LineNumberFunction -> LineNumbers +lineNumberFunction f = LineNumbers (Right f) + + +type EditorOptionsMixin a = { + -- | The aria label for the editor's textarea (when it is focused). + ariaLabel :: Maybe String, + + -- | Render vertical lines at the specified columns. + -- | Defaults to empty array. + rulers :: Maybe (Array Number), + + -- | A String containing the word separators used when doing word navigation. + -- | Defaults to `~!@#$%^&*()-=+[{]}\\|;:\'",.<>/? + wordSeparators :: Maybe String, + + -- | Enable Linux primary clipboard. + -- | Defaults to true. + selectionClipboard :: Maybe Boolean, + + -- | Control the rendering of line Numbers. + -- | If it is a function, it will be invoked when rendering a line Number and the return value will be rendered. + -- | Otherwise, if it is a truey, line Numbers will be rendered normally (equivalent of using an identity function). + -- | Otherwise, line Numbers will not be rendered. + -- | Defaults to true. + lineNumbers :: Maybe LineNumbers, + + -- | Should the corresponding line be selected when clicking on the line Number? + -- | Defaults to true. + selectOnLineNumbers :: Maybe Boolean, + + -- | Control the width of line Numbers, by reserving horizontal space for rendering at least an amount of digits. + -- | Defaults to 5. + lineNumbersMinChars :: Maybe Number, + + -- | Enable the rendering of the glyph margin. + -- | Defaults to true in vscode and to false in monaco-editor. + glyphMargin :: Maybe Boolean, + + -- | The width reserved for line decorations (in px). + -- | Line decorations are placed between line Numbers and the editor content. + -- | You can pass in a String in the format floating point followed by "ch". e.g. 1.3ch. + -- | Defaults to 10. + lineDecorationsWidth :: Maybe (Either Number String), + + -- | When revealing the cursor, a virtual padding (px) is added to the cursor, turning it into a rectangle. + -- | This virtual padding ensures that the cursor gets revealed before hitting the edge of the viewport. + -- | Defaults to 30 (px). + revealHorizontalRightPadding :: Maybe Number, + + -- | Render the editor selection with rounded borders. + -- | Defaults to true. + roundedSelection :: Maybe Boolean, + + -- | Class name to be added to the editor. + extraEditorClassName :: Maybe String, + + -- | Should the editor be read only. + -- | Defaults to false. + readOnly :: Maybe Boolean, + + -- | Control the behavior and rendering of the scrollbars. + scrollbar :: Maybe EditorScrollbarOptions, + + -- | Control the behavior and rendering of the minimap. + minimap :: Maybe EditorMinimapOptions, + + -- | Control the behavior of the find widget. + find :: Maybe EditorFindOptions, + + -- | Display overflow widgets as `fixed`. + -- | Defaults to `false`. + fixedOverflowWidgets :: Maybe Boolean, + + -- | The Number of vertical lanes the overview ruler should render. + -- | Defaults to 2. + overviewRulerLanes :: Maybe Number, + + -- | Controls if a border should be drawn around the overview ruler. + -- | Defaults to `true`. + overviewRulerBorder :: Maybe Boolean, + + -- | Control the cursor animation style, possible values are 'blink', 'smooth', 'phase', 'expand' and 'solid'. + -- | Defaults to 'blink'. + cursorBlinking :: Maybe String, + + -- | Zoom the font in the editor when using the mouse wheel in combination with holding Ctrl. + -- | Defaults to false. + mouseWheelZoom :: Maybe Boolean, + + -- | Control the cursor style, either 'block' or 'line'. + -- | Defaults to 'line'. + cursorStyle :: Maybe String, + + -- | Enable font ligatures. + -- | Defaults to false. + fontLigatures :: Maybe Boolean, + + -- | Disable the use of `will-change` for the editor margin and lines layers. + -- | The usage of `will-change` acts as a hint for browsers to create an extra layer. + -- | Defaults to false. + disableLayerHinting :: Maybe Boolean, + + -- | Disable the optimizations for monospace fonts. + -- | Defaults to false. + disableMonospaceOptimizations :: Maybe Boolean, + + -- | Should the cursor be hidden in the overview ruler. + -- | Defaults to false. + hideCursorInOverviewRuler :: Maybe Boolean, + + -- | Enable that scrolling can go one screen size after the last line. + -- | Defaults to true. + scrollBeyondLastLine :: Maybe Boolean, + + -- | Enable that the editor will install an interval to check if its container dom node size has changed. + -- | Enabling this might have a severe performance impact. + -- | Defaults to false. + automaticLayout :: Maybe Boolean, + + -- | Control the wrapping of the editor. + -- | When `wordWrap` = "off", the lines will never wrap. + -- | When `wordWrap` = "on", the lines will wrap at the viewport width. + -- | When `wordWrap` = "wordWrapColumn", the lines will wrap at `wordWrapColumn`. + -- | When `wordWrap` = "bounded", the lines will wrap at min(viewport width, wordWrapColumn). + -- | Defaults to "off". + wordWrap :: Maybe WordWrapState, + + -- | Control the wrapping of the editor. + -- | When `wordWrap` = "off", the lines will never wrap. + -- | When `wordWrap` = "on", the lines will wrap at the viewport width. + -- | When `wordWrap` = "wordWrapColumn", the lines will wrap at `wordWrapColumn`. + -- | When `wordWrap` = "bounded", the lines will wrap at min(viewport width, wordWrapColumn). + -- | Defaults to 80. + wordWrapColumn :: Maybe Number, + + -- | Force word wrapping when the text appears to be of a minified/generated file. + -- | Defaults to true. + wordWrapMinified :: Maybe Boolean, + + -- | Control indentation of wrapped lines. Can be: 'none', 'same' or 'indent'. + -- | Defaults to 'same' in vscode and to 'none' in monaco-editor. + wrappingIndent :: Maybe String, + + -- | Configure word wrapping characters. A break will be introduced before these characters. + -- | Defaults to '{([+'. + wordWrapBreakBeforeCharacters :: Maybe String, + + -- | Configure word wrapping characters. A break will be introduced after these characters. + -- | Defaults to ' \t})]?|&,;'. + wordWrapBreakAfterCharacters :: Maybe String, + + -- | Configure word wrapping characters. + -- | A break will be introduced after these characters only if + -- | no `wordWrapBreakBeforeCharacters` or `wordWrapBreakAfterCharacters` were found. + -- | Defaults to '.'. + wordWrapBreakObtrusiveCharacters :: Maybe String, + -- | Performance guard: Stop rendering a line after x characters. + -- | Defaults to 10000. + -- | Use -1 to never stop rendering + stopRenderingLineAfter :: Maybe Number, + + -- | Enable hover. + -- | Defaults to true. + hover :: Maybe Boolean, + + -- | Enable detecting links and making them clickable. + -- | Defaults to true. + links :: Maybe Boolean, + + -- | Enable custom contextmenu. + -- | Defaults to true. + contextmenu :: Maybe Boolean, + + -- | A multiplier to be used on the `deltaX` and `deltaY` of mouse wheel scroll events. + -- | Defaults to 1. + mouseWheelScrollSensitivity :: Maybe Number, + + -- | The modifier to be used to add multiple cursors with the mouse. + -- | Defaults to 'alt' + multiCursorModifier :: Maybe MultiCursorModifier, + + -- | Configure the editor's accessibility support. + -- | Defaults to 'auto'. It is best to leave this to 'auto'. + accessibilitySupport :: Maybe AccessibilitySupport, + + -- | Enable quick suggestions (shadow suggestions) + -- | Defaults to true. + quickSuggestions :: Maybe ( Either Boolean { + other :: Boolean, + comments :: Boolean, + strings :: Boolean + }), + + -- | Quick suggestions show delay (in ms) + -- | Defaults to 500 (ms) + quickSuggestionsDelay :: Maybe Number, + + -- | Enables parameter hints + parameterHints :: Maybe Boolean, + + -- | Render icons in suggestions box. + -- | Defaults to true. + iconsInSuggestions :: Maybe Boolean, + + -- | Enable auto closing brackets. + -- | Defaults to true. + autoClosingBrackets :: Maybe Boolean, + + -- | Enable auto indentation adjustment. + -- | Defaults to false. + autoIndent :: Maybe Boolean, + + -- | Enable format on type. + -- | Defaults to false. + formatOnType :: Maybe Boolean, + + -- | Enable format on paste. + -- | Defaults to false. + formatOnPaste :: Maybe Boolean, + + -- | Controls if the editor should allow to move selections via drag and drop. + -- | Defaults to false. + dragAndDrop :: Maybe Boolean, + + -- | Enable the suggestion box to pop-up on trigger characters. + -- | Defaults to true. + suggestOnTriggerCharacters :: Maybe Boolean, + + -- | Accept suggestions on ENTER. + -- | Defaults to 'on'. + acceptSuggestionOnEnter :: Maybe AcceptSuggestion, + + -- | Accept suggestions on provider defined characters. + -- | Defaults to true. + acceptSuggestionOnCommitCharacter :: Maybe Boolean, + + -- | Enable snippet suggestions. Default to 'true'. + snippetSuggestions :: Maybe SnippetSuggestion, + + -- | Copying without a selection copies the current line. + emptySelectionClipboard :: Maybe Boolean, + + -- | Enable word based suggestions. Defaults to 'true' + wordBasedSuggestions :: Maybe Boolean, + + -- | The font size for the suggest widget. + -- | Defaults to the editor font size. + suggestFontSize :: Maybe Number, + + -- | The line height for the suggest widget. + -- | Defaults to the editor line height. + suggestLineHeight :: Maybe Number, + + -- | Enable selection highlight. + -- | Defaults to true. + selectionHighlight :: Maybe Boolean, + + -- | Enable semantic occurrences highlight. + -- | Defaults to true. + occurrencesHighlight :: Maybe Boolean, + + -- | Show code lens + -- | Defaults to true. + codeLens :: Maybe Boolean, + + -- | Enable code folding + -- | Defaults to true in vscode and to false in monaco-editor. + folding :: Maybe Boolean, + + -- | Controls whether the fold actions in the gutter stay always visible or hide unless the mouse is over the gutter. + -- | Defaults to 'mouseover'. + showFoldingControls :: Maybe ShowFoldingControls, + + -- | Enable highlighting of matching brackets. + -- | Defaults to true. + matchBrackets :: Maybe Boolean, + + -- | Enable rendering of whitespace. + -- | Defaults to none. + renderWhitespace :: Maybe RenderWhiteSpace, + + -- | Enable rendering of control characters. + -- | Defaults to false. + renderControlCharacters :: Maybe Boolean, + + -- | Enable rendering of indent guides. + -- | Defaults to false. + renderIndentGuides :: Maybe Boolean, + + -- | Enable rendering of current line highlight. + -- | Defaults to all. + renderLineHighlight :: Maybe RenderHighLight, + + -- | Inserting and deleting whitespace follows tab stops. + useTabStops :: Maybe Boolean, + + -- | The font family + fontFamily :: Maybe String, + + -- | The font weight + fontWeight :: Maybe FontWeight, + + -- | The font size + fontSize :: Maybe Number, + + -- | The line height + lineHeight :: Maybe Number, + + -- | The letter spacing + letterSpacing :: Maybe Number + + | a +} + + +type EditorConstructionOptions = EditorOptionsMixin ( + value :: Maybe String, + language :: Maybe String, + theme :: Maybe String, + accessibilityHelpUrl :: Maybe String +) + +defaultConstuctorOptions :: EditorConstructionOptions +defaultConstuctorOptions = build (merge baseOpts) opts + where + baseOpts = defaultOptions + opts = { + value : Nothing, + language : Nothing, + theme : Nothing, + accessibilityHelpUrl: Nothing + } + +defaultOptions :: EditorOptionsMixin () +defaultOptions = + { ariaLabel: Nothing + , rulers: Nothing + , wordSeparators: Nothing + , selectionClipboard: Nothing + , lineNumbers: Nothing + , selectOnLineNumbers: Nothing + , lineNumbersMinChars: Nothing + , glyphMargin: Nothing + , lineDecorationsWidth: Nothing + , revealHorizontalRightPadding: Nothing + , roundedSelection: Nothing + , extraEditorClassName: Nothing + , readOnly: Nothing + , scrollbar: Nothing + , minimap : Nothing + , find : Nothing + , fixedOverflowWidgets: Nothing + , overviewRulerLanes: Nothing + , overviewRulerBorder: Nothing + , cursorBlinking: Nothing + , mouseWheelZoom: Nothing + , cursorStyle: Nothing + , fontLigatures: Nothing + , disableLayerHinting: Nothing + , disableMonospaceOptimizations: Nothing + , hideCursorInOverviewRuler: Nothing + , scrollBeyondLastLine: Nothing + , automaticLayout: Nothing + , wordWrap: Nothing + , wordWrapColumn: Nothing + , wordWrapMinified: Nothing + , wrappingIndent: Nothing + , wordWrapBreakBeforeCharacters: Nothing + , wordWrapBreakAfterCharacters: Nothing + , wordWrapBreakObtrusiveCharacters: Nothing + , stopRenderingLineAfter: Nothing + , hover: Nothing + , links: Nothing + , contextmenu: Nothing + , mouseWheelScrollSensitivity: Nothing + , multiCursorModifier: Nothing + , accessibilitySupport: Nothing + , quickSuggestions: Nothing + , quickSuggestionsDelay: Nothing + , parameterHints: Nothing + , iconsInSuggestions: Nothing + , autoClosingBrackets: Nothing + , autoIndent: Nothing + , formatOnType: Nothing + , formatOnPaste: Nothing + , dragAndDrop: Nothing + , suggestOnTriggerCharacters: Nothing + , acceptSuggestionOnEnter: Nothing + , acceptSuggestionOnCommitCharacter: Nothing + , snippetSuggestions: Nothing + , emptySelectionClipboard: Nothing + , wordBasedSuggestions: Nothing + , suggestFontSize: Nothing + , suggestLineHeight: Nothing + , selectionHighlight: Nothing + , occurrencesHighlight: Nothing + , codeLens: Nothing + , folding: Nothing + , showFoldingControls: Nothing + , matchBrackets: Nothing + , renderWhitespace: Nothing + , renderControlCharacters: Nothing + , renderIndentGuides: Nothing + , renderLineHighlight: Nothing + , useTabStops: Nothing + , fontFamily: Nothing + , fontWeight: Nothing + , fontSize: Nothing + , lineHeight: Nothing + , letterSpacing: Nothing + } + +newtype ScrollbarVisibility = ScrollbarVisibility String +scrollbarVisibilityAuto :: ScrollbarVisibility +scrollbarVisibilityAuto = ScrollbarVisibility "auto" + +scrollbarVisibilityVisible :: ScrollbarVisibility +scrollbarVisibilityVisible = ScrollbarVisibility "visible" + +scrollbarVisibilityHidden :: ScrollbarVisibility +scrollbarVisibilityHidden = ScrollbarVisibility "hidden" + +type EditorScrollbarOptions = { + -- | The size of arrows (if displayed). + -- | Defaults to 11. + arrowSize :: Maybe Number, + + -- | Render vertical scrollbar. + -- | Accepted values: 'auto', 'visible', 'hidden'. + -- | Defaults to 'auto'. + vertical :: Maybe ScrollbarVisibility, + + -- | Render horizontal scrollbar. + -- | Accepted values: 'auto', 'visible', 'hidden'. + -- | Defaults to 'auto'. + horizontal :: Maybe ScrollbarVisibility, + + -- | Cast horizontal and vertical shadows when the content is scrolled. + -- | Defaults to true. + useShadows :: Maybe Boolean, + + -- | Render arrows at the top and bottom of the vertical scrollbar. + -- | Defaults to false. + verticalHasArrows :: Maybe Boolean, + + -- | Render arrows at the left and right of the horizontal scrollbar. + -- | Defaults to false. + horizontalHasArrows :: Maybe Boolean, + + -- | Listen to mouse wheel events and react to them by scrolling. + -- | Defaults to true. + handleMouseWheel :: Maybe Boolean, + + -- | Height in pixels for the horizontal scrollbar. + -- | Defaults to 10 (px). + horizontalScrollbarSize :: Maybe Number, + + -- | Width in pixels for the vertical scrollbar. + -- | Defaults to 10 (px). + verticalScrollbarSize :: Maybe Number, + + -- | Width in pixels for the vertical slider. + -- | Defaults to `verticalScrollbarSize`. + verticalSliderSize :: Maybe Number, + + -- | Height in pixels for the horizontal slider. + -- | Defaults to `horizontalScrollbarSize`. + horizontalSliderSize :: Maybe Number +} + + +defaultEditorScrollbarOptions :: EditorScrollbarOptions +defaultEditorScrollbarOptions = { + arrowSize : Nothing, + vertical : Nothing, + horizontal : Nothing, + useShadows : Nothing, + verticalHasArrows : Nothing, + horizontalHasArrows : Nothing, + handleMouseWheel : Nothing, + horizontalScrollbarSize : Nothing, + verticalScrollbarSize : Nothing, + verticalSliderSize : Nothing, + horizontalSliderSize : Nothing +} + +newtype ShowSlider = ShowSlider String + +showSliderAlways :: ShowSlider +showSliderAlways = ShowSlider "always" + +showSliderMouseOver :: ShowSlider +showSliderMouseOver = ShowSlider "mouseover" + +type EditorMinimapOptions = { + -- | Enable the rendering of the minimap. + -- | Defaults to false. + enabled :: Maybe Boolean, + + -- | Control the rendering of the minimap slider. + -- | Defaults to 'mouseover'. + showSlider :: Maybe ShowSlider, + + -- | Render the actual text on a line (as opposed to color blocks). + -- | Defaults to true. + renderCharacters :: Maybe Boolean, + + -- | Limit the width of the minimap to render at most a certain number of columns. + -- | Defaults to 120. + maxColumn :: Maybe Int +} + +defaultMinimapOptions :: EditorMinimapOptions +defaultMinimapOptions = { + enabled : Nothing, + showSlider : Nothing, + renderCharacters: Nothing, + maxColumn: Nothing +} + +type EditorFindOptions = { + -- | Controls if we seed search string in the Find Widget with editor selection. + seedSearchStringFromSelection :: Maybe Boolean, + + -- | Controls if Find in Selection flag is turned on when multiple lines of text are selected in the editor. + autoFindInSelection :: Maybe Boolean +} From e6d8de429820ea04214042ccdf9cacb6b6f71227 Mon Sep 17 00:00:00 2001 From: B-Dome <50382067+B-Dome@users.noreply.github.com> Date: Sun, 23 Jun 2024 15:31:30 +0200 Subject: [PATCH 02/11] updated html and added editor files (removed some files from the monaco-editor folder that are not needed, so its a smaller upload) --- web-app/index.html | 10 +- web-app/index.js | 1914 +- web-app/languageDefinition.js | 50 + web-app/main.css | 4 + web-app/monaco-editor/CHANGELOG.md | 1612 + web-app/monaco-editor/LICENSE | 21 + web-app/monaco-editor/README.md | 122 + web-app/monaco-editor/ThirdPartyNotices.txt | 448 + .../browser/ui/codicons/codicon/codicon.ttf | Bin 0 -> 79844 bytes .../base/common/worker/simpleWorker.nls.de.js | 8 + .../base/common/worker/simpleWorker.nls.es.js | 8 + .../base/common/worker/simpleWorker.nls.fr.js | 8 + .../base/common/worker/simpleWorker.nls.it.js | 8 + .../base/common/worker/simpleWorker.nls.ja.js | 8 + .../vs/base/common/worker/simpleWorker.nls.js | 8 + .../base/common/worker/simpleWorker.nls.ko.js | 8 + .../base/common/worker/simpleWorker.nls.ru.js | 8 + .../common/worker/simpleWorker.nls.zh-cn.js | 8 + .../common/worker/simpleWorker.nls.zh-tw.js | 8 + .../min/vs/base/worker/workerMain.js | 28 + .../min/vs/basic-languages/cpp/cpp.js | 10 + .../min/vs/basic-languages/csharp/csharp.js | 10 + .../min/vs/basic-languages/csp/csp.js | 10 + .../min/vs/basic-languages/css/css.js | 12 + .../min/vs/basic-languages/html/html.js | 10 + .../min/vs/basic-languages/ini/ini.js | 10 + .../min/vs/basic-languages/java/java.js | 10 + .../basic-languages/javascript/javascript.js | 10 + .../min/vs/basic-languages/python/python.js | 10 + .../min/vs/basic-languages/ruby/ruby.js | 10 + .../min/vs/basic-languages/rust/rust.js | 10 + .../min/vs/basic-languages/sb/sb.js | 10 + .../min/vs/basic-languages/scala/scala.js | 10 + .../min/vs/basic-languages/scheme/scheme.js | 10 + .../basic-languages/typescript/typescript.js | 10 + .../min/vs/basic-languages/xml/xml.js | 10 + .../min/vs/basic-languages/yaml/yaml.js | 10 + .../min/vs/editor/editor.main.css | 8 + .../min/vs/editor/editor.main.js | 763 + .../min/vs/editor/editor.main.nls.de.js | 15 + .../min/vs/editor/editor.main.nls.es.js | 15 + .../min/vs/editor/editor.main.nls.fr.js | 13 + .../min/vs/editor/editor.main.nls.it.js | 13 + .../min/vs/editor/editor.main.nls.ja.js | 15 + .../min/vs/editor/editor.main.nls.js | 13 + .../min/vs/editor/editor.main.nls.ko.js | 13 + .../min/vs/editor/editor.main.nls.ru.js | 15 + .../min/vs/editor/editor.main.nls.zh-cn.js | 15 + .../min/vs/editor/editor.main.nls.zh-tw.js | 13 + .../min/vs/language/css/cssMode.js | 13 + .../min/vs/language/css/cssWorker.js | 78 + .../min/vs/language/html/htmlMode.js | 13 + .../min/vs/language/html/htmlWorker.js | 452 + .../min/vs/language/json/jsonMode.js | 15 + .../min/vs/language/json/jsonWorker.js | 36 + .../min/vs/language/typescript/tsMode.js | 20 + .../min/vs/language/typescript/tsWorker.js | 37016 ++++++++++++++++ web-app/monaco-editor/min/vs/loader.js | 11 + web-app/monaco-editor/monaco.d.ts | 9243 ++++ web-app/monaco-editor/package.json | 82 + 60 files changed, 51598 insertions(+), 753 deletions(-) create mode 100644 web-app/languageDefinition.js create mode 100644 web-app/monaco-editor/CHANGELOG.md create mode 100644 web-app/monaco-editor/LICENSE create mode 100644 web-app/monaco-editor/README.md create mode 100644 web-app/monaco-editor/ThirdPartyNotices.txt create mode 100644 web-app/monaco-editor/min/vs/base/browser/ui/codicons/codicon/codicon.ttf create mode 100644 web-app/monaco-editor/min/vs/base/common/worker/simpleWorker.nls.de.js create mode 100644 web-app/monaco-editor/min/vs/base/common/worker/simpleWorker.nls.es.js create mode 100644 web-app/monaco-editor/min/vs/base/common/worker/simpleWorker.nls.fr.js create mode 100644 web-app/monaco-editor/min/vs/base/common/worker/simpleWorker.nls.it.js create mode 100644 web-app/monaco-editor/min/vs/base/common/worker/simpleWorker.nls.ja.js create mode 100644 web-app/monaco-editor/min/vs/base/common/worker/simpleWorker.nls.js create mode 100644 web-app/monaco-editor/min/vs/base/common/worker/simpleWorker.nls.ko.js create mode 100644 web-app/monaco-editor/min/vs/base/common/worker/simpleWorker.nls.ru.js create mode 100644 web-app/monaco-editor/min/vs/base/common/worker/simpleWorker.nls.zh-cn.js create mode 100644 web-app/monaco-editor/min/vs/base/common/worker/simpleWorker.nls.zh-tw.js create mode 100644 web-app/monaco-editor/min/vs/base/worker/workerMain.js create mode 100644 web-app/monaco-editor/min/vs/basic-languages/cpp/cpp.js create mode 100644 web-app/monaco-editor/min/vs/basic-languages/csharp/csharp.js create mode 100644 web-app/monaco-editor/min/vs/basic-languages/csp/csp.js create mode 100644 web-app/monaco-editor/min/vs/basic-languages/css/css.js create mode 100644 web-app/monaco-editor/min/vs/basic-languages/html/html.js create mode 100644 web-app/monaco-editor/min/vs/basic-languages/ini/ini.js create mode 100644 web-app/monaco-editor/min/vs/basic-languages/java/java.js create mode 100644 web-app/monaco-editor/min/vs/basic-languages/javascript/javascript.js create mode 100644 web-app/monaco-editor/min/vs/basic-languages/python/python.js create mode 100644 web-app/monaco-editor/min/vs/basic-languages/ruby/ruby.js create mode 100644 web-app/monaco-editor/min/vs/basic-languages/rust/rust.js create mode 100644 web-app/monaco-editor/min/vs/basic-languages/sb/sb.js create mode 100644 web-app/monaco-editor/min/vs/basic-languages/scala/scala.js create mode 100644 web-app/monaco-editor/min/vs/basic-languages/scheme/scheme.js create mode 100644 web-app/monaco-editor/min/vs/basic-languages/typescript/typescript.js create mode 100644 web-app/monaco-editor/min/vs/basic-languages/xml/xml.js create mode 100644 web-app/monaco-editor/min/vs/basic-languages/yaml/yaml.js create mode 100644 web-app/monaco-editor/min/vs/editor/editor.main.css create mode 100644 web-app/monaco-editor/min/vs/editor/editor.main.js create mode 100644 web-app/monaco-editor/min/vs/editor/editor.main.nls.de.js create mode 100644 web-app/monaco-editor/min/vs/editor/editor.main.nls.es.js create mode 100644 web-app/monaco-editor/min/vs/editor/editor.main.nls.fr.js create mode 100644 web-app/monaco-editor/min/vs/editor/editor.main.nls.it.js create mode 100644 web-app/monaco-editor/min/vs/editor/editor.main.nls.ja.js create mode 100644 web-app/monaco-editor/min/vs/editor/editor.main.nls.js create mode 100644 web-app/monaco-editor/min/vs/editor/editor.main.nls.ko.js create mode 100644 web-app/monaco-editor/min/vs/editor/editor.main.nls.ru.js create mode 100644 web-app/monaco-editor/min/vs/editor/editor.main.nls.zh-cn.js create mode 100644 web-app/monaco-editor/min/vs/editor/editor.main.nls.zh-tw.js create mode 100644 web-app/monaco-editor/min/vs/language/css/cssMode.js create mode 100644 web-app/monaco-editor/min/vs/language/css/cssWorker.js create mode 100644 web-app/monaco-editor/min/vs/language/html/htmlMode.js create mode 100644 web-app/monaco-editor/min/vs/language/html/htmlWorker.js create mode 100644 web-app/monaco-editor/min/vs/language/json/jsonMode.js create mode 100644 web-app/monaco-editor/min/vs/language/json/jsonWorker.js create mode 100644 web-app/monaco-editor/min/vs/language/typescript/tsMode.js create mode 100644 web-app/monaco-editor/min/vs/language/typescript/tsWorker.js create mode 100644 web-app/monaco-editor/min/vs/loader.js create mode 100644 web-app/monaco-editor/monaco.d.ts create mode 100644 web-app/monaco-editor/package.json diff --git a/web-app/index.html b/web-app/index.html index 788f786..b1a99db 100644 --- a/web-app/index.html +++ b/web-app/index.html @@ -4,6 +4,12 @@