diff --git a/build-instructions.md b/build-instructions.md new file mode 100644 index 0000000..eaf1aa5 --- /dev/null +++ b/build-instructions.md @@ -0,0 +1,27 @@ +# The below are instructions for building +# Scripta Desktop for linux and windows, +# adapted from what I do for MacOS +# you should begin by dowloading the zip +# archive for the source code at +# https://github.com/jxxcarlson/scripta-tauri/releases + +# install rust, MacOS or Linux +curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh + +# instructions for Windows installation of Rust +https://forge.rust-lang.org/infra/other-installation-methods.html + +# install tauri +cargo install tauri-cli + +# build the app +cargo tauri build + +# make the zip file for Windows, +# similarly for Linux +# On MacOS, the is built and placed in +# /Applications -- let's call this +# directory APP, and let OS be +cp -r APP/scripta-desktop.app . +zip -r scripta-desktop-windows.zip scripta-desktop.app +rm -r scripta-desktop.app diff --git a/src/Main.elm b/src/Main.elm index 82a4501..af1fad5 100644 --- a/src/Main.elm +++ b/src/Main.elm @@ -120,8 +120,8 @@ init flags = , doSync = False , editorData = { begin = 0, end = 0 } , foundIdIndex = 0 - , searchSourceText = "" - , oldSearchSourceText = "___@@@___" + , sourceTextFragment = "" + , oldSearchSourceFragment = "___@@@___" , searchCount = 0 , selectedId = "" , selectionHighLighted = Unselected @@ -214,7 +214,7 @@ update msg model = SelectedText str -> -- store the text selected in the editor and sent to Elm in the model - firstSyncLR { model | searchSourceText = str |> Debug.log "SELECTED TEXT (0)" } + syncLR { model | sourceTextFragment = str } -- InputText { position, source } -> -- Frontend.Editor.inputText model { position = position, source = source } @@ -478,7 +478,7 @@ sync model msg_ = SendLineNumber editorData -> -- This is the code that highlights a line in the source text when rendered text is clicked. - ( { model | editorData = editorData |> Debug.log "EDITOR DATA" }, Cmd.none ) + ( { model | editorData = editorData }, Cmd.none ) SelectId id -> -- the element with this id will be highlighted @@ -629,23 +629,6 @@ updateKeys model keyMsg = ) - ---let --- pressedKeys = --- Keyboard.update keyMsg model.pressedKeys --- --- doSync = --- if List.member Keyboard.Control pressedKeys && List.member (Keyboard.Character "S") pressedKeys then --- not model.doSync --- --- else --- model.doSync ---in ---( { model | pressedKeys = pressedKeys, doSync = doSync } ---, Cmd.none ---) - - delayCmd : Float -> msg -> Cmd msg delayCmd delay msg = Task.perform (\_ -> msg) (Process.sleep delay) @@ -655,15 +638,24 @@ startSync : Model -> ( Model, Cmd Msg ) startSync model = -- Toggling doSync will cause the editor send the selected text -- to Elm where it will be processed by 'SelectedText str' - -- and then by firstSyncLR - ( { model | doSync = not model.doSync, foundIds = [] }, Cmd.none ) + -- and then by syncLR + ( { model | doSync = not model.doSync }, Cmd.none ) + + +syncLR : Model -> ( Model, Cmd Msg ) +syncLR model = + if model.sourceTextFragment /= model.oldSearchSourceFragment then + firstSyncLR model + + else + nextSyncLR model firstSyncLR : Model -> ( Model, Cmd Msg ) firstSyncLR model = let foundIds_ = - Scripta.API.matchingIdsInAST (model.searchSourceText |> Debug.log "SELECTED TEXT (1)") model.editRecord.tree |> Debug.log "FOUND IDS" + Scripta.API.matchingIdsInAST model.sourceTextFragment model.editRecord.tree id_ = List.head foundIds_ |> Maybe.withDefault "(nothing)" @@ -671,10 +663,9 @@ firstSyncLR model = ( { model | selectedId = id_ , foundIds = foundIds_ - , oldSearchSourceText = model.searchSourceText - , foundIdIndex = 1 + , oldSearchSourceFragment = model.sourceTextFragment + , foundIdIndex = 0 , searchCount = 0 - , message = id_ ++ ":: " ++ (foundIds_ |> String.join ", ") } , View.Utility.setViewportForElement Config.renderedTextViewportID id_ ) @@ -683,32 +674,19 @@ firstSyncLR model = nextSyncLR : Model -> ( Model, Cmd Msg ) nextSyncLR model = let - foundIds_ = - Scripta.API.matchingIdsInAST (model.searchSourceText |> Debug.log "SELECTED TEXT (1)") model.editRecord.tree |> Debug.log "FOUND IDS" + n = + List.length model.foundIds - id_ = - List.head foundIds_ |> Maybe.withDefault "(nothing)" + foundIndex = + model.foundIdIndex + 1 |> modBy n - data = - { foundIds = foundIds_ - , foundIdIndex = 1 - , cmd = View.Utility.setViewportForElement Config.renderedTextViewportID id_ - , selectedId = id_ - , searchCount = 0 - } + id_ = + List.Extra.getAt foundIndex model.foundIds + |> Maybe.withDefault "(no such index)" in ( { model | selectedId = id_ - , doSync = - if model.foundIdIndex == 0 then - not model.doSync - - else - model.doSync - , foundIds = foundIds_ - , foundIdIndex = 1 - , searchCount = 0 - , message = id_ ++ ":: " ++ (foundIds_ |> String.join ", ") + , foundIdIndex = foundIndex } - , data.cmd + , View.Utility.setViewportForElement Config.renderedTextViewportID id_ ) diff --git a/src/Model.elm b/src/Model.elm index 6611c07..ed2fcf1 100644 --- a/src/Model.elm +++ b/src/Model.elm @@ -22,8 +22,8 @@ type alias Model = , doSync : Bool , selectedText : String , foundIdIndex : Int - , searchSourceText : String - , oldSearchSourceText : String + , sourceTextFragment : String + , oldSearchSourceFragment : String , searchCount : Int , selectedId : String , selectionHighLighted : SelectionState diff --git a/src/Text.elm b/src/Text.elm index 21990ac..053f3de 100644 --- a/src/Text.elm +++ b/src/Text.elm @@ -37,8 +37,8 @@ Click on rendered text (right window). The corresponding source text will be highlighted. \\item -Select some source text, then type ctrl-S. The corresponding -rendered text will be highlighted. +Select some source text, then click on "Sync Left > Right" (lower left). The corresponding +rendered text will be highlighted. Push repeatedly if necessary. \\item The editor has lots of features: type ctrl-A to go to the beginning of the @@ -72,7 +72,8 @@ Visit \\link{scripta.io https://scripta.io} for the web version of this app. """ -microLaTeXDemo = """ +microLaTeXDemo = + """ \\title{MicroLaTeX Guide} @@ -337,8 +338,9 @@ buttons in the toolbar on the right. """ -l0Demo = - """ + +l0Demo = + """ | title About L0 @@ -435,6 +437,7 @@ begins with `||`. """ + l0DemoOLD = """ | title diff --git a/src/View/Button.elm b/src/View/Button.elm index 67f32e7..fa5a056 100644 --- a/src/View/Button.elm +++ b/src/View/Button.elm @@ -89,7 +89,7 @@ syncLR = , tooltipPlacement = below , attributes = [ Font.color white, Background.color gray, width (px buttonWidth) ] , msg = StartSync - , label = "->" + , label = "Sync Left > Right" }