Compare commits

...

2 Commits

Author SHA1 Message Date
becef4d321 fix png 2022-05-15 16:03:01 +09:00
c71ed22406 Add pseudocode 2022-05-15 16:02:24 +09:00
2 changed files with 104 additions and 33 deletions

View File

@ -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 { module chunk {
type mode = Read | Write type mode = Read | Write
struct Chunk { struct Chunk {
id: string id: string
content: string content: string
type: string type: string
} }
newChunk() { newChunk() {
{ id = uuid() { id = uuid()
; content = "" ; content = ""
; type = "" ; type = ""
} }
} }
chunkViewer(chunk : Chunk, deleteThis : () => void) : Component { chunkViewer(chunk : Chunk, focusedChunk : State<string>, deleteThis : () => void) : Component {
var mode = Read var mode = Read
var c = new Component( var c = new Component(
content { value = chunk.content } content { value = chunk.content }
settypebutton settypebutton
editbutton editbutton
deletebutton deletebutton
) )
when mode becomes Read { chunk.content = content } 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 editbutton is clicked { mode = (mode = Read) ? Write : Read }
when deletebutton is clicked { deleteThis() } when deletebutton is clicked { deleteThis() }
when settypebutton is clicked { chunk.type = prompt() } when settypebutton is clicked { chunk.type = prompt() }
return c 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 { module document {
struct Document { struct Document {
title: string title: string
@ -401,25 +409,88 @@ module document {
tags: string set tags: string set
chunks: chunk.Chunk array chunks: chunk.Chunk array
} }
documentViewer(doc: document) : Component { documentViewer(doc: document) : Component {
var focusedChunk = null var focusedChunk = null
var c = new Component( var c = new Component(
taglist { value: tags } taglist { value: tags }
chunklist chunklist
) )
delete(id) { delete(id) {
i = doc.chunks.find((c) => c.id = id) i = doc.chunks.find((c) => c.id = id)
doc.chunks.remove(i) doc.chunks.remove(i)
} }
chunklist = doc.chunks.concat_map((c, 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 divider(i) clicked { doc.chunks.insert(i, c) }
when chunkViewer(c) is dropped on divider(i) { doc.chunks.move(c, i) } when chunkViewer(c) is dropped on divider(i) { doc.chunks.move(c, i) }
return c
} }
} }
``` ```
```
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
}
}
```

Binary file not shown.

Before

Width:  |  Height:  |  Size: 13 KiB

After

Width:  |  Height:  |  Size: 13 KiB