Files
Lichtkasten DevandClaude Opus 5.5 b2210757dd Fixes aus dem Bundesliga-Einsatz
- Upload: kein Absturz mehr bei abreißender Verbindung (Restzeit-Berechnung lief über), SIGPIPE ignoriert;
  bei Netzwechsel werden laufende Übertragungen abgebrochen und auf dem neuen Netz automatisch neu
  gestartet (Versuch zählt nicht), ohne Netz warten sie; tote Verbindungen enden nach 45 s
- LR-Export: Bilder, die sich auf der Platte ändern, werden neu eingelesen (vorher blieb der erste,
  unvollständige Stand stehen); nie leeres IPTC über das JPEG schreiben; Zuordnung auch mit altem Plugin
- I-Fenster: Cursor in der Beschreibung steht oben (wie PM), nicht am Ende
- ⌘A wählt alle Bilder, ⌘⌫ legt die Auswahl (RAW + JPEG + XMP) nach Rückfrage in den Papierkorb
- Gesendet-Status getrennt: grünes FTP- und blaues Immich-Abzeichen, Filter je Ziel, Info in Lupe/I-Fenster
- nach dem Ingest sind die neu importierten Bilder ausgewählt (direkt weiter nach Lightroom)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012bGzgsxrmbBhDzeMV2L57D
2026-11-06 23:51:05 +00:00

121 lines
4.6 KiB
Swift
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import AppKit
import SwiftUI
import LichtkastenCore
/// Replaces a code right before the cursor (PM-style live code replacement) and keeps the cursor in place.
/// Returns true if something was replaced. Undo (⌘Z) restores the code.
@MainActor
func applyCodeExpansion(_ tv: NSTextView, codes: CodeReplacements?) -> Bool {
guard let codes else { return false }
let sel = tv.selectedRange()
guard sel.length == 0, let (range, rep) = codes.pendingExpansion(in: tv.string, cursor: sel.location) else { return false }
let afterReplaced = sel.location - (range.location + range.length) // e.g. the typed space after "w10"
tv.insertText(rep, replacementRange: range)
let newCursor = range.location + (rep as NSString).length + afterReplaced
tv.setSelectedRange(NSRange(location: min(newCursor, (tv.string as NSString).length), length: 0))
return true
}
/// Multi-line field (caption, keywords …) with live code replacement.
struct CodeTextView: NSViewRepresentable {
@Binding var text: String
var codes: CodeReplacements?
func makeCoordinator() -> Coordinator { Coordinator(self) }
func makeNSView(context: Context) -> NSScrollView {
let sv = NSTextView.scrollableTextView()
sv.borderType = .bezelBorder
sv.hasVerticalScroller = true
guard let tv = sv.documentView as? NSTextView else { return sv }
tv.delegate = context.coordinator
tv.isRichText = false
tv.importsGraphics = false
tv.allowsUndo = true
tv.font = .systemFont(ofSize: 13)
tv.isAutomaticQuoteSubstitutionEnabled = false
tv.isAutomaticDashSubstitutionEnabled = false
tv.isAutomaticTextReplacementEnabled = false
tv.isContinuousSpellCheckingEnabled = true
tv.textContainerInset = NSSize(width: 3, height: 4)
tv.string = text
CodeTextView.cursorToStart(tv)
return sv
}
func updateNSView(_ sv: NSScrollView, context: Context) {
context.coordinator.parent = self
guard let tv = sv.documentView as? NSTextView, tv.string != text, !context.coordinator.editing else { return }
tv.string = text
CodeTextView.cursorToStart(tv)
}
/// Like PM: a newly loaded caption starts with the cursor at the very top – on the empty placeholder
/// line for the people (setting `string` would leave it at the end).
static func cursorToStart(_ tv: NSTextView) {
tv.setSelectedRange(NSRange(location: 0, length: 0))
tv.scrollRangeToVisible(NSRange(location: 0, length: 0))
}
final class Coordinator: NSObject, NSTextViewDelegate {
var parent: CodeTextView
var expanding = false
var editing = false
init(_ p: CodeTextView) { parent = p }
func textDidChange(_ notification: Notification) {
guard let tv = notification.object as? NSTextView else { return }
if !expanding {
expanding = true
MainActor.assumeIsolated { _ = applyCodeExpansion(tv, codes: parent.codes) }
expanding = false
}
editing = true
parent.text = tv.string
DispatchQueue.main.async { self.editing = false }
}
}
}
/// Single-line field with live code replacement (event, city, test field …).
struct CodeTextField: NSViewRepresentable {
@Binding var text: String
var codes: CodeReplacements?
var placeholder: String = ""
func makeCoordinator() -> Coordinator { Coordinator(self) }
func makeNSView(context: Context) -> NSTextField {
let f = NSTextField(string: text)
f.delegate = context.coordinator
f.placeholderString = placeholder
f.bezelStyle = .roundedBezel
f.lineBreakMode = .byTruncatingTail
f.cell?.isScrollable = true
f.font = .systemFont(ofSize: 13)
return f
}
func updateNSView(_ f: NSTextField, context: Context) {
context.coordinator.parent = self
f.placeholderString = placeholder
if f.stringValue != text, f.currentEditor() == nil { f.stringValue = text }
}
final class Coordinator: NSObject, NSTextFieldDelegate {
var parent: CodeTextField
var expanding = false
init(_ p: CodeTextField) { parent = p }
func controlTextDidChange(_ obj: Notification) {
guard let f = obj.object as? NSTextField else { return }
if !expanding, let editor = f.currentEditor() as? NSTextView {
expanding = true
MainActor.assumeIsolated { _ = applyCodeExpansion(editor, codes: parent.codes) }
expanding = false
}
parent.text = f.stringValue
}
}
}