From 5188619eeeb9267e2b0fe6c23f48cc931dcebaa6 Mon Sep 17 00:00:00 2001 From: Oschly Date: Tue, 19 May 2026 19:44:54 +0200 Subject: [PATCH] Improve the code formatting --- Thesis/Chapters/3. Implementation.typ | 27 +++++++----- Thesis/main.pdf | 4 +- Thesis/style.typ | 59 ++++++++++++++++++++------- Thesis/title_page.typ | 1 - Thesis/zut.tmTheme | 58 ++++++++++++++++++++++++++ 5 files changed, 121 insertions(+), 28 deletions(-) create mode 100644 Thesis/zut.tmTheme diff --git a/Thesis/Chapters/3. Implementation.typ b/Thesis/Chapters/3. Implementation.typ index 656cbdd..f4e6f35 100644 --- a/Thesis/Chapters/3. Implementation.typ +++ b/Thesis/Chapters/3. Implementation.typ @@ -265,20 +265,27 @@ Przykładowy zapis instancji obiektu `NoteMessage` wygląda następująco: Po tym jak serwer odbierze wysłaną wiadomość, wywoływana jest metoda `session`, która w argumentach przekazuje zakodowane dane, sesję serwera oraz identyfikator użytkownika, który wysłał załączone dane. Po udanym zdekodowaniu danych, wybieramy wszystkich użytkowników, którzy dołączyli do sesji edycji notatki i wysyłamy do nich kopię otrzymanej wiadomości, a serwer dodatkowo wysyła identyczną kopię do warstwy prezentacji. -```swift + +#let code_session_did_receive_data_server = [```swift func session(_ session: MCSession, didReceive data: Data, fromPeer peerID: MCPeerID) { guard let message = try? JSONDecoder().decode(NoteMessage.self, from: data) else { return } + let otherPeers = session.connectedPeers.filter { $0 != peerID } - let otherPeers = session.connectedPeers.filter { $0 != peerID } - if !otherPeers.isEmpty { - try? session.send(data, toPeers: otherPeers, with: .reliable) - } + if !otherPeers.isEmpty { + try? session.send(data, toPeers: otherPeers, with: .reliable) + } - DispatchQueue.main.async { - self.noteChangesEmitter.send(message) - } -} -``` + DispatchQueue.main.async { + self.noteChangesEmitter.send(message) + } + } +```] + +#figure( + code_session_did_receive_data_server, + kind: raw, + caption: [Implementacja metody session do otrzymywania danych od innych klientów], +) == Algorytm rozwiązywania konfliktów diff --git a/Thesis/main.pdf b/Thesis/main.pdf index 814727c..6645c14 100644 --- a/Thesis/main.pdf +++ b/Thesis/main.pdf @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:05a3e6b7df81d633f1410a1db7a6e1877495e5c07599bbd6152da39a7a1fab5c -size 389280 +oid sha256:4fa680ed5a556d26aa38946bf01f783ece72c38cfdac4127fe80dab594a448b9 +size 475892 diff --git a/Thesis/style.typ b/Thesis/style.typ index 9587608..ca00daf 100644 --- a/Thesis/style.typ +++ b/Thesis/style.typ @@ -253,29 +253,58 @@ ] } - show raw.where(block: false): it => { - box( - fill: gray-zut.lighten(93%), - inset: (x: 3pt, y: 1pt), - radius: 2pt, + set raw(theme: "zut.tmTheme") + show raw.where(block: true): it => { + let lines = it.lines + + block( + fill: gray-zut.lighten(100%), + radius: 4pt, + clip: true, + width: 100%, )[ #set text(size: 10pt, font: ("Fira Mono", "Courier New")) - #it + #grid( + columns: (auto, 1fr), + inset: (left: 10pt, right: 10pt, top: 2pt, bottom: 2pt), + align: (x, y) => if x == 0 { right + top } else { left + top }, + + grid.vline(x: 1, stroke: (paint: luma(160), thickness: 1pt)), + + ..lines + .map(line => ( + text(fill: luma(160), size: 9pt)[#line.number], + line.body, + )) + .flatten(), + ) ] } - // ── 3.7 PODPISY RYSUNKÓW I TABEL ──────────────────────── set figure(gap: 0.8em) + let raw-fig-counter = counter("raw-fig") - show figure.caption: it => { - set text(size: 9.5pt, font: "Fira Sans") - let kind-label = if it.kind == image { [Rysunek] } else if it.kind == table { [Tabela] } else { [Algorytm] } - [ - #text(fill: blue-zut, weight: "bold")[ - #kind-label #it.counter.display() - ]#it.separator#it.body - ] + show heading.where(level: 1): it => { + raw-fig-counter.update(1) + it + } + + show figure.where(kind: raw): it => { + // Step the custom counter + raw-fig-counter.step() + + // Build the number: heading-index.figure-index + let heading-num = counter(heading.where(level: 1)).display() + let fig-num = raw-fig-counter.display("1") + let full-number = heading-num + "." + fig-num + + it.body + v(10pt, weak: true) + align(center, block(width: auto)[ + #text(weight: "bold", fill: blue-zut, font: "Fira Sans")[Algorytm #full-number:] + #text(font: "Fira Sans")[#it.caption.body] + ]) } diff --git a/Thesis/title_page.typ b/Thesis/title_page.typ index e36492d..329be96 100644 --- a/Thesis/title_page.typ +++ b/Thesis/title_page.typ @@ -76,4 +76,3 @@ // Miasto i rok #move(text(size: 14.2pt)[#placesubmit, #yearsubmit], dx: 8pt, dy: -10pt) ] - diff --git a/Thesis/zut.tmTheme b/Thesis/zut.tmTheme new file mode 100644 index 0000000..0873fce --- /dev/null +++ b/Thesis/zut.tmTheme @@ -0,0 +1,58 @@ + + + + + name + ZUT + settings + + + + settings + + foreground#000000 + background#F0F0F0 + + + + + nameKeyword + scope + keyword, storage.type, storage.modifier, keyword.control + settings + + foreground#800080 + + + + + nameString + scopestring + settings + + foreground#008000 + + + + + nameComment + scopecomment + settings + + foreground#808080 + + + + + nameNumber + scopeconstant.numeric + settings + + foreground#0000CD + + + + + +