mirror of
https://git.srhtnin.garden/sarah/SaraView.git
synced 2026-10-14 18:38:11 +02:00
Client: variables resolved in the live editor and reading view
Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
1 parent
eec8fd4b79
commit
ee904540c6
7 files changed
+169
-16
No files matched your search
+8
-3
@@ -3,7 +3,8 @@ EditorView/ImageView idea, with SaraView's View/Edit/Save toolbar).
|
||||
|
||||
- Markdown is rendered in View; the other text types are shown as
|
||||
highlighted code. On a server, ```mermaid blocks show as diagrams (Diagrams.py),
|
||||
and the properties block at the top as its panel (Properties.py).
|
||||
the properties block at the top as its panel (Properties.py), and
|
||||
variables (portals, loops) as what they resolve to (Variables.py).
|
||||
Checkboxes (tasks, true/false properties) tick from View and save at once,
|
||||
like the web view; in Live they leave the note unsaved, like typing. Edit is a plain monospace field with an explicit Save
|
||||
(Ctrl+S). On a server, saving records line blame for you, like the web view.
|
||||
@@ -25,6 +26,7 @@ from App import App
|
||||
from Core import ChipButton, CodeStyleSheet, HumanSize, MarkdownCodeTheme, MarkdownSheet, Palette
|
||||
from Diagrams import MaybeDiagram, WithDiagrams
|
||||
from Properties import ParseProperties, PropertiesView, ToggleLine, WithCheckboxes
|
||||
from Variables import FindSpans, Substitute
|
||||
from LiveMarkdown import LiveMarkdown
|
||||
from Sources import Entry, SourceError, TextFileTypes
|
||||
|
||||
@@ -127,7 +129,8 @@ class FileView(ft.Container):
|
||||
if self.IsLive:
|
||||
self.Live = LiveMarkdown(self.Content, self.TheApp.Config.FontSize, self._OnTextChanged,
|
||||
self.OnFocusChange, self._OnTapLink,
|
||||
MakeDiagram=lambda Text, Size: MaybeDiagram(self.TheApp, Text, Size))
|
||||
MakeDiagram=lambda Text, Size: MaybeDiagram(self.TheApp, Text, Size),
|
||||
GetSpans=lambda Document: FindSpans(self.TheApp, self.Root, self.RelativePath, Document))
|
||||
return self.Live
|
||||
return self._RenderedView()
|
||||
if self.FileType == "image":
|
||||
@@ -145,6 +148,7 @@ class FileView(ft.Container):
|
||||
Toggle = self._ToggleAndSave if self.TheApp.Source.CanWrite else None
|
||||
Found = ParseProperties(Text)
|
||||
BodyStart = Found.EndOffset if Found else 0
|
||||
Spans = FindSpans(self.TheApp, self.Root, self.RelativePath, Text)
|
||||
|
||||
def MakeMarkdown(Part: str) -> ft.Control:
|
||||
return ft.Markdown(
|
||||
@@ -159,7 +163,8 @@ class FileView(ft.Container):
|
||||
|
||||
def MakeWithCheckboxes(Part: str, Start: int) -> ft.Control:
|
||||
FirstLine = Text[:BodyStart + Start].count("\n")
|
||||
Parts = WithCheckboxes(Part, FirstLine, MakeMarkdown, Toggle, FontSize)
|
||||
Shown, LineMap = Substitute(Part, BodyStart + Start, Spans) # variables as their results
|
||||
Parts = WithCheckboxes(Shown, FirstLine, MakeMarkdown, Toggle, FontSize, LineMap)
|
||||
return Parts[0] if len(Parts) == 1 else ft.Column(Parts, spacing=0, tight=True)
|
||||
|
||||
Views = WithDiagrams(self.TheApp, Text[BodyStart:], FontSize, MakeWithCheckboxes)
|
||||
|
||||
Reference in new issue
Block a user