Improves helder
This commit is contained in:
@@ -284,7 +284,7 @@ final class CodeEditorController: NSObject, NSTextViewDelegate, NSLayoutManagerD
|
||||
private func applyWrap(_ on: Bool) {
|
||||
guard wrap != on else { return }
|
||||
wrap = on
|
||||
scrollView.hasHorizontalScroller = !on
|
||||
scrollView.hasHorizontalScroller = false
|
||||
textView.isHorizontallyResizable = !on
|
||||
container.widthTracksTextView = on
|
||||
textView.autoresizingMask = on ? [.width] : []
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import AppKit
|
||||
|
||||
/// The NSTextView that holds the code. It only forwards gestures; `CodeEditorController` decides.
|
||||
final class CodeTextView: NSTextView {
|
||||
final class CodeTextView: PointerBoundTextView {
|
||||
weak var controller: CodeEditorController?
|
||||
|
||||
/// Pointer travel that still counts as a click and not as a text selection.
|
||||
|
||||
@@ -33,7 +33,8 @@ private struct EditorWorkspace: View {
|
||||
if let path = editor.activePath {
|
||||
let presentation = editor.presentation(for: path)
|
||||
EditorBar(editor: editor, presentation: presentation)
|
||||
EditorPane(editor: editor, presentation: presentation, fontScale: model.layout.textScale)
|
||||
EditorPane(editor: editor, presentation: presentation, fontScale: model.layout.textScale,
|
||||
isColumnShown: model.layout.isVisible(.editor))
|
||||
} else {
|
||||
EditorBar()
|
||||
EditorEmptyState()
|
||||
|
||||
@@ -8,6 +8,8 @@ struct EditorPane: View {
|
||||
let presentation: EditorPresentation
|
||||
/// View → Zoom.
|
||||
var fontScale: CGFloat = 1
|
||||
/// False while the File pane toggle hides the column: the code view then takes no focus or select-all.
|
||||
var isColumnShown = true
|
||||
|
||||
var body: some View {
|
||||
let path = presentation.path
|
||||
@@ -15,7 +17,7 @@ struct EditorPane: View {
|
||||
ZStack {
|
||||
// Kept alive while hidden, so a trip to Preview keeps each file's undo history and colours.
|
||||
if presentation.kind == .text {
|
||||
CodeEditorView(configuration: configuration(path, isShown: showsCode), actions: actions)
|
||||
CodeEditorView(configuration: configuration(path, isShown: showsCode && isColumnShown), actions: actions)
|
||||
.opacity(showsCode ? 1 : 0)
|
||||
.allowsHitTesting(showsCode)
|
||||
}
|
||||
|
||||
@@ -7,7 +7,6 @@ public struct PassOnPanel: View {
|
||||
let insert: (String) -> Void
|
||||
let cancel: () -> Void
|
||||
@State private var note = ""
|
||||
@FocusState private var focused: Bool
|
||||
|
||||
public init(request: PassOnRequest, insert: @escaping (String) -> Void, cancel: @escaping () -> Void) {
|
||||
self.request = request
|
||||
@@ -42,14 +41,8 @@ public struct PassOnPanel: View {
|
||||
Spacer()
|
||||
EscChip()
|
||||
}
|
||||
TextField("", text: $note, prompt: Text("Add a note (optional)…").foregroundStyle(Palette.text4))
|
||||
.textFieldStyle(.plain)
|
||||
.typeRole(TypeRole(.monoRegular, 13))
|
||||
.foregroundStyle(Palette.text1)
|
||||
.focused($focused)
|
||||
.onSubmit { insert(composed) }
|
||||
.onExitCommand(perform: cancel)
|
||||
.padding(.horizontal, 10)
|
||||
OverlayCommandField(text: $note, placeholder: "Add a note (optional)…", font: TypeRole(.monoRegular, 13).nsFont,
|
||||
initialSelection: nil, horizontalInset: 10, onKey: handle)
|
||||
.frame(height: 38)
|
||||
.background(Palette.editor, in: RoundedRectangle(cornerRadius: Metrics.radiusSmall))
|
||||
.overlay(RoundedRectangle(cornerRadius: Metrics.radiusSmall).stroke(Palette.amber, lineWidth: Metrics.accentRule))
|
||||
@@ -68,7 +61,15 @@ public struct PassOnPanel: View {
|
||||
.background(Palette.panel, in: RoundedRectangle(cornerRadius: Metrics.radiusMedium))
|
||||
.overlay(RoundedRectangle(cornerRadius: Metrics.radiusMedium).stroke(Palette.raised, lineWidth: Metrics.hairline))
|
||||
.shadow(color: Palette.menuShadow, radius: Metrics.menuShadowRadius, y: Metrics.menuShadowY)
|
||||
.onAppear { focused = true }
|
||||
}
|
||||
|
||||
private func handle(_ key: OverlayKey) -> Bool {
|
||||
switch key {
|
||||
case .enter: insert(composed)
|
||||
case .escape: cancel()
|
||||
default: return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
@ViewBuilder
|
||||
|
||||
Reference in New Issue
Block a user