Skip to content

Commit

Permalink
Update app to new compiler version
Browse files Browse the repository at this point in the history
  • Loading branch information
jxxcarlson committed Feb 19, 2023
1 parent 602ee73 commit 35e8df1
Show file tree
Hide file tree
Showing 5 changed files with 65 additions and 57 deletions.
27 changes: 27 additions & 0 deletions build-instructions.md
Original file line number Diff line number Diff line change
@@ -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
76 changes: 27 additions & 49 deletions src/Main.elm
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,8 @@ init flags =
, doSync = False
, editorData = { begin = 0, end = 0 }
, foundIdIndex = 0
, searchSourceText = ""
, oldSearchSourceText = "___@@@___"
, sourceTextFragment = ""
, oldSearchSourceFragment = "___@@@___"
, searchCount = 0
, selectedId = ""
, selectionHighLighted = Unselected
Expand Down Expand Up @@ -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 }
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand All @@ -655,26 +638,34 @@ 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)"
in
( { 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_
)
Expand All @@ -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_
)
4 changes: 2 additions & 2 deletions src/Model.elm
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
13 changes: 8 additions & 5 deletions src/Text.elm
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -72,7 +72,8 @@ Visit \\link{scripta.io https://scripta.io} for the web version of this app.
"""


microLaTeXDemo = """
microLaTeXDemo =
"""
\\title{MicroLaTeX Guide}
Expand Down Expand Up @@ -337,8 +338,9 @@ buttons in the toolbar on the right.
"""

l0Demo =
"""

l0Demo =
"""
| title
About L0
Expand Down Expand Up @@ -435,6 +437,7 @@ begins with `||`.
"""


l0DemoOLD =
"""
| title
Expand Down
2 changes: 1 addition & 1 deletion src/View/Button.elm
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ syncLR =
, tooltipPlacement = below
, attributes = [ Font.color white, Background.color gray, width (px buttonWidth) ]
, msg = StartSync
, label = "->"
, label = "Sync Left > Right"
}


Expand Down

0 comments on commit 35e8df1

Please sign in to comment.