From c71ed224069e0eea261d81dce8d271fffa8e8087 Mon Sep 17 00:00:00 2001 From: Hyeonung Baek Date: Sun, 15 May 2022 15:51:45 +0900 Subject: [PATCH 1/2] Add pseudocode --- tools/template/architecture.md | 137 +++++++++++++++++++++++++-------- 1 file changed, 104 insertions(+), 33 deletions(-) diff --git a/tools/template/architecture.md b/tools/template/architecture.md index 9268f3d..eef63af 100644 --- a/tools/template/architecture.md +++ b/tools/template/architecture.md @@ -339,61 +339,69 @@ fn apply(this, mutator, updatedAt, seq){ ### 다른 작업들 -``` -global doc - -searchWord(word) { - words(doc) - |> filter((w, _) => w = word) - |> map((_, i) => i) -} - -searchWordPrompt() { - word = prompt() - wordPositions = searchWord(word) - highlight(wordPositions, length(word)) -} - -when Ctrl-F is pressed { searchWordPrompt() } -``` - ``` module chunk { type mode = Read | Write - + struct Chunk { id: string content: string type: string } - + newChunk() { { id = uuid() ; content = "" ; type = "" } } - - chunkViewer(chunk : Chunk, deleteThis : () => void) : Component { + + chunkViewer(chunk : Chunk, focusedChunk : State, deleteThis : () => void) : Component { var mode = Read - + var c = new Component( content { value = chunk.content } settypebutton editbutton deletebutton ) - + when mode becomes Read { chunk.content = content } - + when mode becomes Write { focusedChunk = chunk.id } + when focusedChunk is changed { mode = Read } + when editbutton is clicked { mode = (mode = Read) ? Write : Read } when deletebutton is clicked { deleteThis() } when settypebutton is clicked { chunk.type = prompt() } - + return c } } +``` +``` +module search { + searchWord(chunks, word) { + return doc.chunks.concat_map((s) => s.matchAll(word)) + } + + searchWordPrompt(chunks: Chunk.chunk list) { + var word = prompt() + var results = searchWord(chunks, word) + + var c = new Component(results) + + when result in results is selected { + moveto(result.location) + close() + } + } + + when Ctrl-F is pressed { searchWordPrompt() } +} +``` + +``` module document { struct Document { title: string @@ -401,25 +409,88 @@ module document { tags: string set chunks: chunk.Chunk array } - + documentViewer(doc: document) : Component { var focusedChunk = null - + var c = new Component( taglist { value: tags } chunklist ) - + delete(id) { i = doc.chunks.find((c) => c.id = id) doc.chunks.remove(i) } - + chunklist = doc.chunks.concat_map((c, i) => - [ divider(i), chuknViewer(c, () => delete(c.id)) ]) - + [ divider(i), chuknViewer(c, focusedChunk, () => delete(c.id)) ]) + when divider(i) clicked { doc.chunks.insert(i, c) } when chunkViewer(c) is dropped on divider(i) { doc.chunks.move(c, i) } + + return c } } -``` \ No newline at end of file +``` + +``` +module filelist { + fileList(dir : Directory, open: (File) => void) : Component { + var c = new Component( + filelist + ) + + filelist = dir.files().map((f) => button(f)) + + when button(f) is clicked { + open(f) + } + + return c + } +} +``` + +``` +module settings { + settings() : Component { + var c = new Component( + language = select("korean", "english") + theme = select("light", "dark") + ) + + when language(l) is selected { + global context.lang = l + } + + when theme(t) is selected { + global context.theme = t + } + + return c + } +} + +``` +module frontend { + main() : Component { + var docv + + var open = (f) => { + with doc = openfile(f) { + docv = document.documentViewer(doc) + } + } + + var filelist = filelist.fileList(rootdir, open) + + var c = new Component( + document = docv + filelist = filelist + ) + + return c + } +} +``` From becef4d32184eb4f93c62c4206e9e7efeb42383b Mon Sep 17 00:00:00 2001 From: Hyeonung Baek Date: Sun, 15 May 2022 16:02:03 +0900 Subject: [PATCH 2/2] fix png --- tools/template/interface.png | Bin 13679 -> 13677 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/tools/template/interface.png b/tools/template/interface.png index fb31e77e3fb0a083e49850eece10c59ec18237ae..7992d43db1d78082a135820617b36c2ec1bc278b 100644 GIT binary patch delta 18 ZcmaE#^)`#8Gr-S%BkLXZ&5zi7bpcZE2oeAQ delta 21 ccmaEx^*)QWGr-TCcO%Okc1GUK57>Kk0b_OuD*ylh