git.iko.soy/parseable-macos
on master help sign in
Add text wrapping toggle to LiveTailView and QueryView (#33)
fd05280iko
ParseableViewer/Views/LiveTailView.swift+10
@@ -7,6 +7,7 @@ struct LiveTailView: View {
7 @State private var autoScroll = true
7 @State private var autoScroll = true
8 @State private var pulseOpacity: Double = 1.0
8 @State private var pulseOpacity: Double = 1.0
9 @State private var showColumnPopover = false
9 @State private var showColumnPopover = false
10+ @State private var wrapText = false
10 @State private var sortColumn: String?
11 @State private var sortColumn: String?
11 @State private var sortAscending = false
12 @State private var sortAscending = false
12 @State private var columnWidths: [String: CGFloat] = [:]
13 @State private var columnWidths: [String: CGFloat] = [:]
@@ -70,6 +71,14 @@ struct LiveTailView: View {
70 .accessibilityLabel("Filter live tail entries")
71 .accessibilityLabel("Filter live tail entries")
71 }
72 }
72
73
74+ Button {
75+ wrapText.toggle()
76+ } label: {
77+ Image(systemName: wrapText ? "text.word.spacing" : "text.line.first.and.arrowtriangle.forward")
78+ }
79+ .help(wrapText ? "Disable text wrapping" : "Enable text wrapping")
80+ .accessibilityLabel(wrapText ? "Disable text wrapping" : "Enable text wrapping")
81+
73 if !viewModel.columns.isEmpty {
82 if !viewModel.columns.isEmpty {
74 Button {
83 Button {
75 showColumnPopover.toggle()
84 showColumnPopover.toggle()
@@ -283,6 +292,7 @@ struct LiveTailView: View {
283 columnWidths: columnWidths,
292 columnWidths: columnWidths,
284 isSelected: selectedRecord == sorted[index].record,
293 isSelected: selectedRecord == sorted[index].record,
285 isAlternate: index % 2 == 1,
294 isAlternate: index % 2 == 1,
295+ wrapText: wrapText,
286 onCellFilter: { column, value, exclude in
296 onCellFilter: { column, value, exclude in
287 viewModel.addColumnFilter(column: column, value: value, exclude: exclude)
297 viewModel.addColumnFilter(column: column, value: value, exclude: exclude)
288 }
298 }
ParseableViewer/Views/LogTableView.swift+6−3
@@ -149,6 +149,7 @@ struct LogTableView: View {
149 let columns: [String]
149 let columns: [String]
150 @Binding var selectedRecord: LogRecord?
150 @Binding var selectedRecord: LogRecord?
151 var isLoading: Bool = false
151 var isLoading: Bool = false
152+ var wrapText: Bool = false
152 var onCellFilter: ((_ column: String, _ value: JSONValue?, _ exclude: Bool) -> Void)?
153 var onCellFilter: ((_ column: String, _ value: JSONValue?, _ exclude: Bool) -> Void)?
153 var onMoveColumn: ((String, String) -> Void)?
154 var onMoveColumn: ((String, String) -> Void)?
154 @State private var sortColumn: String?
155 @State private var sortColumn: String?
@@ -188,6 +189,7 @@ struct LogTableView: View {
188 columnWidths: columnWidths,
189 columnWidths: columnWidths,
189 isSelected: selectedIndex == index,
190 isSelected: selectedIndex == index,
190 isAlternate: index % 2 == 1,
191 isAlternate: index % 2 == 1,
192+ wrapText: wrapText,
191 onCellFilter: onCellFilter
193 onCellFilter: onCellFilter
192 )
194 )
193 .onTapGesture {
195 .onTapGesture {
@@ -529,18 +531,19 @@ struct LogRowView: View {
529 let columnWidths: [String: CGFloat]
531 let columnWidths: [String: CGFloat]
530 let isSelected: Bool
532 let isSelected: Bool
531 let isAlternate: Bool
533 let isAlternate: Bool
534+ var wrapText: Bool = false
532 var onCellFilter: ((_ column: String, _ value: JSONValue?, _ exclude: Bool) -> Void)?
535 var onCellFilter: ((_ column: String, _ value: JSONValue?, _ exclude: Bool) -> Void)?
533
536
534 var body: some View {
537 var body: some View {
535− HStack(spacing: 0) {
538+ HStack(alignment: .top, spacing: 0) {
536 ForEach(columns, id: \.self) { column in
539 ForEach(columns, id: \.self) { column in
537 let value = record[column]
540 let value = record[column]
538 Text(value?.displayString ?? "")
541 Text(value?.displayString ?? "")
539 .font(.system(.caption, design: .monospaced))
542 .font(.system(.caption, design: .monospaced))
540− .lineLimit(1)
543+ .lineLimit(wrapText ? nil : 1)
541 .padding(.horizontal, 6)
544 .padding(.horizontal, 6)
542 .padding(.vertical, 3)
545 .padding(.vertical, 3)
543− .frame(width: columnWidths[column] ?? 120, alignment: .leading)
546+ .frame(width: columnWidths[column] ?? 120, alignment: .topLeading)
544 .foregroundStyle(colorForValue(column: column, value: value))
547 .foregroundStyle(colorForValue(column: column, value: value))
545 .contextMenu {
548 .contextMenu {
546 Button("Copy Value") {
549 Button("Copy Value") {
ParseableViewer/Views/QueryView.swift+10
@@ -8,6 +8,7 @@ struct QueryView: View {
8 @State private var exportError: String?
8 @State private var exportError: String?
9 @State private var showExportError = false
9 @State private var showExportError = false
10 @State private var showColumnPopover = false
10 @State private var showColumnPopover = false
11+ @State private var wrapText = false
11
12
12 var body: some View {
13 var body: some View {
13 @Bindable var vm = viewModel
14 @Bindable var vm = viewModel
@@ -192,6 +193,14 @@ struct QueryView: View {
192
193
193 Spacer()
194 Spacer()
194
195
196+ Button {
197+ wrapText.toggle()
198+ } label: {
199+ Image(systemName: wrapText ? "text.word.spacing" : "text.line.first.and.arrowtriangle.forward")
200+ }
201+ .help(wrapText ? "Disable text wrapping" : "Enable text wrapping")
202+ .accessibilityLabel(wrapText ? "Disable text wrapping" : "Enable text wrapping")
203+
195 if !viewModel.columns.isEmpty {
204 if !viewModel.columns.isEmpty {
196 Button {
205 Button {
197 showColumnPopover.toggle()
206 showColumnPopover.toggle()
@@ -223,6 +232,7 @@ struct QueryView: View {
223 columns: viewModel.visibleColumns,
232 columns: viewModel.visibleColumns,
224 selectedRecord: $vm.selectedLogEntry,
233 selectedRecord: $vm.selectedLogEntry,
225 isLoading: viewModel.isLoading,
234 isLoading: viewModel.isLoading,
235+ wrapText: wrapText,
226 onCellFilter: { column, value, exclude in
236 onCellFilter: { column, value, exclude in
227 viewModel.addColumnFilter(column: column, value: value, exclude: exclude)
237 viewModel.addColumnFilter(column: column, value: value, exclude: exclude)
228 Task {
238 Task {