Commit efcb745f9c

efcb745f9cd572c1aa12599a3bf435975159e0aa

parent: 1a9e2f9977

Unsigned

Wraient <wraient.911@gmail.com> · 2025-02-17 15:20 UTC

chore: Vendor update

Layout: unified · split

vendor/github.com/charmbracelet/bubbletea/.golangci-soft.yml +2 −8
@@ -1,5 +1,6 @@
11run:
22 tests: false
3 issues-exit-code: 0
34
45issues:
56 include:
@@ -14,16 +15,13 @@ issues:
1415
1516linters:
1617 enable:
17 # - dupl
1818 - exhaustive
19 # - exhaustivestruct
2019 - goconst
2120 - godot
2221 - godox
23 - gomnd
22 - mnd
2423 - gomoddirectives
2524 - goprintffuncname
26 # - lll
2725 - misspell
2826 - nakedret
2927 - nestif
@@ -34,13 +32,9 @@ linters:
3432
3533 # disable default linters, they are already enabled in .golangci.yml
3634 disable:
37 - deadcode
3835 - errcheck
3936 - gosimple
4037 - govet
4138 - ineffassign
4239 - staticcheck
43 - structcheck
44 - typecheck
4540 - unused
46 - varcheck
vendor/github.com/charmbracelet/bubbletea/.golangci.yml −2
@@ -15,12 +15,10 @@ issues:
1515linters:
1616 enable:
1717 - bodyclose
18 - exportloopref
1918 - gofumpt
2019 - goimports
2120 - gosec
2221 - nilerr
23 - predeclared
2422 - revive
2523 - rowserrcheck
2624 - sqlclosecheck
vendor/github.com/charmbracelet/bubbletea/.goreleaser.yml +2 −3
@@ -1,6 +1,5 @@
1# yaml-language-server: $schema=https://goreleaser.com/static/schema-pro.json
2version: 2
13includes:
24 - from_url:
35 url: charmbracelet/meta/main/goreleaser-lib.yaml
4
5# yaml-language-server: $schema=https://goreleaser.com/static/schema-pro.json
6
vendor/github.com/charmbracelet/bubbletea/CONTRIBUTING.md deleted −13
@@ -1,13 +0,0 @@
1# Contributing
2
3Pull requests are welcome for any changes.
4
5Consider opening an issue for larger changes to get feedback on the idea from the team.
6
7If your change touches parts of the Bubble Tea renderer or internals, make sure
8that all the examples in the `examples/` folder continue to run correctly.
9
10For commit messages, please use conventional commits[^1] to make it easier to
11generate release notes.
12
13[^1]: https://www.conventionalcommits.org/en/v1.0.0
vendor/github.com/charmbracelet/bubbletea/inputreader_windows.go +13 −3
@@ -57,7 +57,7 @@ func newInputReader(r io.Reader) (cancelreader.CancelReader, error) {
5757func (r *conInputReader) Cancel() bool {
5858 r.setCanceled()
5959
60 return windows.CancelIo(r.conin) == nil
60 return windows.CancelIoEx(r.conin, nil) == nil || windows.CancelIo(r.conin) == nil
6161}
6262
6363// Close implements cancelreader.CancelReader.
@@ -73,8 +73,11 @@ func (r *conInputReader) Close() error {
7373}
7474
7575// Read implements cancelreader.CancelReader.
76func (*conInputReader) Read(_ []byte) (n int, err error) {
77 return 0, nil
76func (r *conInputReader) Read(_ []byte) (n int, err error) {
77 if r.isCanceled() {
78 err = cancelreader.ErrCanceled
79 }
80 return
7881}
7982
8083func prepareConsole(input windows.Handle, modes ...uint32) (originalMode uint32, err error) {
@@ -105,3 +108,10 @@ func (c *cancelMixin) setCanceled() {
105108
106109 c.unsafeCanceled = true
107110}
111
112func (c *cancelMixin) isCanceled() bool {
113 c.lock.Lock()
114 defer c.lock.Unlock()
115
116 return c.unsafeCanceled
117}
vendor/github.com/charmbracelet/bubbletea/key_windows.go +15 −6
@@ -10,23 +10,26 @@ import (
1010
1111 "github.com/erikgeiser/coninput"
1212 localereader "github.com/mattn/go-localereader"
13 "golang.org/x/sys/windows"
13 "github.com/muesli/cancelreader"
1414)
1515
1616func readInputs(ctx context.Context, msgs chan<- Msg, input io.Reader) error {
1717 if coninReader, ok := input.(*conInputReader); ok {
18 return readConInputs(ctx, msgs, coninReader.conin)
18 return readConInputs(ctx, msgs, coninReader)
1919 }
2020
2121 return readAnsiInputs(ctx, msgs, localereader.NewReader(input))
2222}
2323
24func readConInputs(ctx context.Context, msgsch chan<- Msg, con windows.Handle) error {
24func readConInputs(ctx context.Context, msgsch chan<- Msg, con *conInputReader) error {
2525 var ps coninput.ButtonState // keep track of previous mouse state
2626 var ws coninput.WindowBufferSizeEventRecord // keep track of the last window size event
2727 for {
28 events, err := coninput.ReadNConsoleInputs(con, 16)
28 events, err := coninput.ReadNConsoleInputs(con.conin, 16)
2929 if err != nil {
30 if con.isCanceled() {
31 return cancelreader.ErrCanceled
32 }
3033 return fmt.Errorf("read coninput events: %w", err)
3134 }
3235
@@ -274,7 +277,11 @@ func keyType(e coninput.KeyEventRecord) KeyType {
274277 case coninput.VK_DELETE:
275278 return KeyDelete
276279 default:
277 if e.ControlKeyState&(coninput.LEFT_CTRL_PRESSED|coninput.RIGHT_CTRL_PRESSED) == 0 {
280 switch {
281 case e.ControlKeyState.Contains(coninput.LEFT_CTRL_PRESSED) && e.ControlKeyState.Contains(coninput.RIGHT_ALT_PRESSED):
282 // AltGr is pressed, then it's a rune.
283 fallthrough
284 case !e.ControlKeyState.Contains(coninput.LEFT_CTRL_PRESSED) && !e.ControlKeyState.Contains(coninput.RIGHT_CTRL_PRESSED):
278285 return KeyRunes
279286 }
280287
@@ -334,7 +341,7 @@ func keyType(e coninput.KeyEventRecord) KeyType {
334341 case '\x1a':
335342 return KeyCtrlZ
336343 case '\x1b':
337 return KeyCtrlCloseBracket
344 return KeyCtrlOpenBracket // KeyEscape
338345 case '\x1c':
339346 return KeyCtrlBackslash
340347 case '\x1f':
@@ -344,6 +351,8 @@ func keyType(e coninput.KeyEventRecord) KeyType {
344351 switch code {
345352 case coninput.VK_OEM_4:
346353 return KeyCtrlOpenBracket
354 case coninput.VK_OEM_6:
355 return KeyCtrlCloseBracket
347356 }
348357
349358 return KeyRunes
vendor/github.com/charmbracelet/bubbletea/options.go +3
@@ -185,6 +185,9 @@ func WithoutRenderer() ProgramOption {
185185//
186186// This feature is provisional, and may be changed or removed in a future version
187187// of this package.
188//
189// Deprecated: this incurs a noticeable performance hit. A future release will
190// optimize ANSI automatically without the performance penalty.
188191func WithANSICompressor() ProgramOption {
189192 return func(p *Program) {
190193 p.startupOptions |= withANSICompressor
vendor/github.com/charmbracelet/bubbletea/standard_renderer.go +136 −105
@@ -34,7 +34,9 @@ type standardRenderer struct {
3434 ticker *time.Ticker
3535 done chan struct{}
3636 lastRender string
37 lastRenderedLines []string
3738 linesRendered int
39 altLinesRendered int
3840 useANSICompressor bool
3941 once sync.Once
4042
@@ -161,13 +163,20 @@ func (r *standardRenderer) flush() {
161163 defer r.mtx.Unlock()
162164
163165 if r.buf.Len() == 0 || r.buf.String() == r.lastRender {
164 // Nothing to do
166 // Nothing to do.
165167 return
166168 }
167169
168 // Output buffer
170 // Output buffer.
169171 buf := &bytes.Buffer{}
170172
173 // Moving to the beginning of the section, that we rendered.
174 if r.altScreenActive {
175 buf.WriteString(ansi.CursorHomePosition)
176 } else if r.linesRendered > 1 {
177 buf.WriteString(ansi.CursorUp(r.linesRendered - 1))
178 }
179
171180 newLines := strings.Split(r.buf.String(), "\n")
172181
173182 // If we know the output's height, we can use it to determine how many
@@ -178,97 +187,87 @@ func (r *standardRenderer) flush() {
178187 newLines = newLines[len(newLines)-r.height:]
179188 }
180189
181 numLinesThisFlush := len(newLines)
182 oldLines := strings.Split(r.lastRender, "\n")
183 skipLines := make(map[int]struct{})
184190 flushQueuedMessages := len(r.queuedMessageLines) > 0 && !r.altScreenActive
185191
186 // Clear any lines we painted in the last render.
187 if r.linesRendered > 0 {
188 for i := r.linesRendered - 1; i > 0; i-- {
189 // if we are clearing queued messages, we want to clear all lines, since
190 // printing messages allows for native terminal word-wrap, we
191 // don't have control over the queued lines
192 if flushQueuedMessages {
193 buf.WriteString(ansi.EraseEntireLine)
194 } else if (len(newLines) <= len(oldLines)) && (len(newLines) > i && len(oldLines) > i) && (newLines[i] == oldLines[i]) {
195 // If the number of lines we want to render hasn't increased and
196 // new line is the same as the old line we can skip rendering for
197 // this line as a performance optimization.
198 skipLines[i] = struct{}{}
199 } else if _, exists := r.ignoreLines[i]; !exists {
200 buf.WriteString(ansi.EraseEntireLine)
201 }
202
203 buf.WriteString(ansi.CursorUp1)
204 }
205
206 if _, exists := r.ignoreLines[0]; !exists {
207 // We need to return to the start of the line here to properly
208 // erase it. Going back the entire width of the terminal will
209 // usually be farther than we need to go, but terminal emulators
210 // will stop the cursor at the start of the line as a rule.
211 //
212 // We use this sequence in particular because it's part of the ANSI
213 // standard (whereas others are proprietary to, say, VT100/VT52).
214 // If cursor previous line (ESC[ + <n> + F) were better supported
215 // we could use that above to eliminate this step.
216 buf.WriteString(ansi.CursorLeft(r.width))
217 buf.WriteString(ansi.EraseEntireLine)
218 }
219 }
220
221 // Merge the set of lines we're skipping as a rendering optimization with
222 // the set of lines we've explicitly asked the renderer to ignore.
223 for k, v := range r.ignoreLines {
224 skipLines[k] = v
225 }
226
227192 if flushQueuedMessages {
228 // Dump the lines we've queued up for printing
193 // Dump the lines we've queued up for printing.
229194 for _, line := range r.queuedMessageLines {
195 if ansi.StringWidth(line) < r.width {
196 // We only erase the rest of the line when the line is shorter than
197 // the width of the terminal. When the cursor reaches the end of
198 // the line, any escape sequences that follow will only affect the
199 // last cell of the line.
200
201 // Removing previously rendered content at the end of line.
202 line = line + ansi.EraseLineRight
203 }
204
230205 _, _ = buf.WriteString(line)
231206 _, _ = buf.WriteString("\r\n")
232207 }
233 // clear the queued message lines
208 // Clear the queued message lines.
234209 r.queuedMessageLines = []string{}
235210 }
236211
237 // Paint new lines
212 // Paint new lines.
238213 for i := 0; i < len(newLines); i++ {
239 if _, skip := skipLines[i]; skip {
214 canSkip := !flushQueuedMessages && // Queuing messages triggers repaint -> we don't have access to previous frame content.
215 len(r.lastRenderedLines) > i && r.lastRenderedLines[i] == newLines[i] // Previously rendered line is the same.
216
217 if _, ignore := r.ignoreLines[i]; ignore || canSkip {
240218 // Unless this is the last line, move the cursor down.
241219 if i < len(newLines)-1 {
242 buf.WriteString(ansi.CursorDown1)
243 }
244 } else {
245 if i == 0 && r.lastRender == "" {
246 // On first render, reset the cursor to the start of the line
247 // before writing anything.
248 buf.WriteByte('\r')
220 buf.WriteByte('\n')
249221 }
222 continue
223 }
250224
251 line := newLines[i]
252
253 // Truncate lines wider than the width of the window to avoid
254 // wrapping, which will mess up rendering. If we don't have the
255 // width of the window this will be ignored.
256 //
257 // Note that on Windows we only get the width of the window on
258 // program initialization, so after a resize this won't perform
259 // correctly (signal SIGWINCH is not supported on Windows).
260 if r.width > 0 {
261 line = ansi.Truncate(line, r.width, "")
262 }
225 if i == 0 && r.lastRender == "" {
226 // On first render, reset the cursor to the start of the line
227 // before writing anything.
228 buf.WriteByte('\r')
229 }
263230
264 _, _ = buf.WriteString(line)
231 line := newLines[i]
232
233 // Truncate lines wider than the width of the window to avoid
234 // wrapping, which will mess up rendering. If we don't have the
235 // width of the window this will be ignored.
236 //
237 // Note that on Windows we only get the width of the window on
238 // program initialization, so after a resize this won't perform
239 // correctly (signal SIGWINCH is not supported on Windows).
240 if r.width > 0 {
241 line = ansi.Truncate(line, r.width, "")
242 }
265243
266 if i < len(newLines)-1 {
267 _, _ = buf.WriteString("\r\n")
268 }
244 if ansi.StringWidth(line) < r.width {
245 // We only erase the rest of the line when the line is shorter than
246 // the width of the terminal. When the cursor reaches the end of
247 // the line, any escape sequences that follow will only affect the
248 // last cell of the line.
249
250 // Removing previously rendered content at the end of line.
251 line = line + ansi.EraseLineRight
252 }
253
254 _, _ = buf.WriteString(line)
255
256 if i < len(newLines)-1 {
257 _, _ = buf.WriteString("\r\n")
269258 }
270259 }
271 r.linesRendered = numLinesThisFlush
260
261 // Clearing left over content from last render.
262 if r.lastLinesRendered() > len(newLines) {
263 buf.WriteString(ansi.EraseScreenBelow)
264 }
265
266 if r.altScreenActive {
267 r.altLinesRendered = len(newLines)
268 } else {
269 r.linesRendered = len(newLines)
270 }
272271
273272 // Make sure the cursor is at the start of the last line to keep rendering
274273 // behavior consistent.
@@ -276,16 +275,29 @@ func (r *standardRenderer) flush() {
276275 // This case fixes a bug in macOS terminal. In other terminals the
277276 // other case seems to do the job regardless of whether or not we're
278277 // using the full terminal window.
279 buf.WriteString(ansi.MoveCursor(r.linesRendered, 0))
278 buf.WriteString(ansi.CursorPosition(0, len(newLines)))
280279 } else {
281 buf.WriteString(ansi.CursorLeft(r.width))
280 buf.WriteString(ansi.CursorBackward(r.width))
282281 }
283282
284283 _, _ = r.out.Write(buf.Bytes())
285284 r.lastRender = r.buf.String()
285
286 // Save previously rendered lines for comparison in the next render. If we
287 // don't do this, we can't skip rendering lines that haven't changed.
288 // See https://github.com/charmbracelet/bubbletea/pull/1233
289 r.lastRenderedLines = newLines
286290 r.buf.Reset()
287291}
288292
293// lastLinesRendered returns the number of lines rendered lastly.
294func (r *standardRenderer) lastLinesRendered() int {
295 if r.altScreenActive {
296 return r.altLinesRendered
297 }
298 return r.linesRendered
299}
300
289301// write writes to the internal buffer. The buffer will be outputted via the
290302// ticker which calls flush().
291303func (r *standardRenderer) write(s string) {
@@ -306,14 +318,15 @@ func (r *standardRenderer) write(s string) {
306318
307319func (r *standardRenderer) repaint() {
308320 r.lastRender = ""
321 r.lastRenderedLines = nil
309322}
310323
311324func (r *standardRenderer) clearScreen() {
312325 r.mtx.Lock()
313326 defer r.mtx.Unlock()
314327
315 r.execute(ansi.EraseEntireDisplay)
316 r.execute(ansi.MoveCursorOrigin)
328 r.execute(ansi.EraseEntireScreen)
329 r.execute(ansi.CursorHomePosition)
317330
318331 r.repaint()
319332}
@@ -334,7 +347,7 @@ func (r *standardRenderer) enterAltScreen() {
334347 }
335348
336349 r.altScreenActive = true
337 r.execute(ansi.EnableAltScreenBuffer)
350 r.execute(ansi.SetAltScreenSaveCursorMode)
338351
339352 // Ensure that the terminal is cleared, even when it doesn't support
340353 // alt screen (or alt screen support is disabled, like GNU screen by
@@ -342,8 +355,8 @@ func (r *standardRenderer) enterAltScreen() {
342355 //
343356 // Note: we can't use r.clearScreen() here because the mutex is already
344357 // locked.
345 r.execute(ansi.EraseEntireDisplay)
346 r.execute(ansi.MoveCursorOrigin)
358 r.execute(ansi.EraseEntireScreen)
359 r.execute(ansi.CursorHomePosition)
347360
348361 // cmd.exe and other terminals keep separate cursor states for the AltScreen
349362 // and the main buffer. We have to explicitly reset the cursor visibility
@@ -354,6 +367,9 @@ func (r *standardRenderer) enterAltScreen() {
354367 r.execute(ansi.ShowCursor)
355368 }
356369
370 // Entering the alt screen resets the lines rendered count.
371 r.altLinesRendered = 0
372
357373 r.repaint()
358374}
359375
@@ -366,7 +382,7 @@ func (r *standardRenderer) exitAltScreen() {
366382 }
367383
368384 r.altScreenActive = false
369 r.execute(ansi.DisableAltScreenBuffer)
385 r.execute(ansi.ResetAltScreenSaveCursorMode)
370386
371387 // cmd.exe and other terminals keep separate cursor states for the AltScreen
372388 // and the main buffer. We have to explicitly reset the cursor visibility
@@ -400,49 +416,49 @@ func (r *standardRenderer) enableMouseCellMotion() {
400416 r.mtx.Lock()
401417 defer r.mtx.Unlock()
402418
403 r.execute(ansi.EnableMouseCellMotion)
419 r.execute(ansi.SetButtonEventMouseMode)
404420}
405421
406422func (r *standardRenderer) disableMouseCellMotion() {
407423 r.mtx.Lock()
408424 defer r.mtx.Unlock()
409425
410 r.execute(ansi.DisableMouseCellMotion)
426 r.execute(ansi.ResetButtonEventMouseMode)
411427}
412428
413429func (r *standardRenderer) enableMouseAllMotion() {
414430 r.mtx.Lock()
415431 defer r.mtx.Unlock()
416432
417 r.execute(ansi.EnableMouseAllMotion)
433 r.execute(ansi.SetAnyEventMouseMode)
418434}
419435
420436func (r *standardRenderer) disableMouseAllMotion() {
421437 r.mtx.Lock()
422438 defer r.mtx.Unlock()
423439
424 r.execute(ansi.DisableMouseAllMotion)
440 r.execute(ansi.ResetAnyEventMouseMode)
425441}
426442
427443func (r *standardRenderer) enableMouseSGRMode() {
428444 r.mtx.Lock()
429445 defer r.mtx.Unlock()
430446
431 r.execute(ansi.EnableMouseSgrExt)
447 r.execute(ansi.SetSgrExtMouseMode)
432448}
433449
434450func (r *standardRenderer) disableMouseSGRMode() {
435451 r.mtx.Lock()
436452 defer r.mtx.Unlock()
437453
438 r.execute(ansi.DisableMouseSgrExt)
454 r.execute(ansi.ResetSgrExtMouseMode)
439455}
440456
441457func (r *standardRenderer) enableBracketedPaste() {
442458 r.mtx.Lock()
443459 defer r.mtx.Unlock()
444460
445 r.execute(ansi.EnableBracketedPaste)
461 r.execute(ansi.SetBracketedPasteMode)
446462 r.bpActive = true
447463}
448464
@@ -450,7 +466,7 @@ func (r *standardRenderer) disableBracketedPaste() {
450466 r.mtx.Lock()
451467 defer r.mtx.Unlock()
452468
453 r.execute(ansi.DisableBracketedPaste)
469 r.execute(ansi.ResetBracketedPasteMode)
454470 r.bpActive = false
455471}
456472
@@ -465,7 +481,7 @@ func (r *standardRenderer) enableReportFocus() {
465481 r.mtx.Lock()
466482 defer r.mtx.Unlock()
467483
468 r.execute(ansi.EnableReportFocus)
484 r.execute(ansi.SetFocusEventMode)
469485 r.reportingFocus = true
470486}
471487
@@ -473,7 +489,7 @@ func (r *standardRenderer) disableReportFocus() {
473489 r.mtx.Lock()
474490 defer r.mtx.Unlock()
475491
476 r.execute(ansi.DisableReportFocus)
492 r.execute(ansi.ResetFocusEventMode)
477493 r.reportingFocus = false
478494}
479495
@@ -494,7 +510,7 @@ func (r *standardRenderer) setWindowTitle(title string) {
494510func (r *standardRenderer) setIgnoredLines(from int, to int) {
495511 // Lock if we're going to be clearing some lines since we don't want
496512 // anything jacking our cursor.
497 if r.linesRendered > 0 {
513 if r.lastLinesRendered() > 0 {
498514 r.mtx.Lock()
499515 defer r.mtx.Unlock()
500516 }
@@ -507,16 +523,17 @@ func (r *standardRenderer) setIgnoredLines(from int, to int) {
507523 }
508524
509525 // Erase ignored lines
510 if r.linesRendered > 0 {
526 lastLinesRendered := r.lastLinesRendered()
527 if lastLinesRendered > 0 {
511528 buf := &bytes.Buffer{}
512529
513 for i := r.linesRendered - 1; i >= 0; i-- {
530 for i := lastLinesRendered - 1; i >= 0; i-- {
514531 if _, exists := r.ignoreLines[i]; exists {
515532 buf.WriteString(ansi.EraseEntireLine)
516533 }
517 buf.WriteString(ansi.CursorUp1)
534 buf.WriteString(ansi.CUU1)
518535 }
519 buf.WriteString(ansi.MoveCursor(r.linesRendered, 0)) // put cursor back
536 buf.WriteString(ansi.CursorPosition(0, lastLinesRendered)) // put cursor back
520537 _, _ = r.out.Write(buf.Bytes())
521538 }
522539}
@@ -546,20 +563,23 @@ func (r *standardRenderer) clearIgnoredLines() {
546563// use in high-performance rendering, such as a pager that could potentially
547564// be rendering very complicated ansi. In cases where the content is simpler
548565// standard Bubble Tea rendering should suffice.
566//
567// Deprecated: This option is deprecated and will be removed in a future
568// version of this package.
549569func (r *standardRenderer) insertTop(lines []string, topBoundary, bottomBoundary int) {
550570 r.mtx.Lock()
551571 defer r.mtx.Unlock()
552572
553573 buf := &bytes.Buffer{}
554574
555 buf.WriteString(ansi.SetScrollingRegion(topBoundary, bottomBoundary))
556 buf.WriteString(ansi.MoveCursor(topBoundary, 0))
575 buf.WriteString(ansi.SetTopBottomMargins(topBoundary, bottomBoundary))
576 buf.WriteString(ansi.CursorPosition(0, topBoundary))
557577 buf.WriteString(ansi.InsertLine(len(lines)))
558578 _, _ = buf.WriteString(strings.Join(lines, "\r\n"))
559 buf.WriteString(ansi.SetScrollingRegion(0, r.height))
579 buf.WriteString(ansi.SetTopBottomMargins(0, r.height))
560580
561581 // Move cursor back to where the main rendering routine expects it to be
562 buf.WriteString(ansi.MoveCursor(r.linesRendered, 0))
582 buf.WriteString(ansi.CursorPosition(0, r.lastLinesRendered()))
563583
564584 _, _ = r.out.Write(buf.Bytes())
565585}
@@ -573,19 +593,22 @@ func (r *standardRenderer) insertTop(lines []string, topBoundary, bottomBoundary
573593// See note in insertTop() for caveats, how this function only makes sense for
574594// full-window applications, and how it differs from the normal way we do
575595// rendering in Bubble Tea.
596//
597// Deprecated: This option is deprecated and will be removed in a future
598// version of this package.
576599func (r *standardRenderer) insertBottom(lines []string, topBoundary, bottomBoundary int) {
577600 r.mtx.Lock()
578601 defer r.mtx.Unlock()
579602
580603 buf := &bytes.Buffer{}
581604
582 buf.WriteString(ansi.SetScrollingRegion(topBoundary, bottomBoundary))
583 buf.WriteString(ansi.MoveCursor(bottomBoundary, 0))
605 buf.WriteString(ansi.SetTopBottomMargins(topBoundary, bottomBoundary))
606 buf.WriteString(ansi.CursorPosition(0, bottomBoundary))
584607 _, _ = buf.WriteString("\r\n" + strings.Join(lines, "\r\n"))
585 buf.WriteString(ansi.SetScrollingRegion(0, r.height))
608 buf.WriteString(ansi.SetTopBottomMargins(0, r.height))
586609
587610 // Move cursor back to where the main rendering routine expects it to be
588 buf.WriteString(ansi.MoveCursor(r.linesRendered, 0))
611 buf.WriteString(ansi.CursorPosition(0, r.lastLinesRendered()))
589612
590613 _, _ = r.out.Write(buf.Bytes())
591614}
@@ -657,6 +680,8 @@ type syncScrollAreaMsg struct {
657680// should also be called on resize (WindowSizeMsg).
658681//
659682// For high-performance, scroll-based rendering only.
683//
684// Deprecated: This option will be removed in a future version of this package.
660685func SyncScrollArea(lines []string, topBoundary int, bottomBoundary int) Cmd {
661686 return func() Msg {
662687 return syncScrollAreaMsg{
@@ -673,6 +698,8 @@ type clearScrollAreaMsg struct{}
673698// those lines to the main rendering routine.
674699//
675700// For high-performance, scroll-based rendering only.
701//
702// Deprecated: This option will be removed in a future version of this package.
676703func ClearScrollArea() Msg {
677704 return clearScrollAreaMsg{}
678705}
@@ -688,6 +715,8 @@ type scrollUpMsg struct {
688715// from view.
689716//
690717// For high-performance, scroll-based rendering only.
718//
719// Deprecated: This option will be removed in a future version of this package.
691720func ScrollUp(newLines []string, topBoundary, bottomBoundary int) Cmd {
692721 return func() Msg {
693722 return scrollUpMsg{
@@ -709,6 +738,8 @@ type scrollDownMsg struct {
709738// disappear from view.
710739//
711740// For high-performance, scroll-based rendering only.
741//
742// Deprecated: This option will be removed in a future version of this package.
712743func ScrollDown(newLines []string, topBoundary, bottomBoundary int) Cmd {
713744 return func() Msg {
714745 return scrollDownMsg{
vendor/github.com/charmbracelet/bubbletea/tea.go +37 −9
@@ -26,9 +26,13 @@ import (
2626 "golang.org/x/sync/errgroup"
2727)
2828
29// ErrProgramKilled is returned by [Program.Run] when the program got killed.
29// ErrProgramKilled is returned by [Program.Run] when the program gets killed.
3030var ErrProgramKilled = errors.New("program was killed")
3131
32// ErrInterrupted is returned by [Program.Run] when the program get a SIGINT
33// signal, or when it receives a [InterruptMsg].
34var ErrInterrupted = errors.New("program was interrupted")
35
3236// Msg contain data from the result of a IO operation. Msgs trigger the update
3337// function and, henceforth, the UI.
3438type Msg interface{}
@@ -186,8 +190,8 @@ func Quit() Msg {
186190 return QuitMsg{}
187191}
188192
189// QuitMsg signals that the program should quit. You can send a QuitMsg with
190// Quit.
193// QuitMsg signals that the program should quit. You can send a [QuitMsg] with
194// [Quit].
191195type QuitMsg struct{}
192196
193197// Suspend is a special command that tells the Bubble Tea program to suspend.
@@ -199,13 +203,28 @@ func Suspend() Msg {
199203// This usually happens when ctrl+z is pressed on common programs, but since
200204// bubbletea puts the terminal in raw mode, we need to handle it in a
201205// per-program basis.
202// You can send this message with Suspend.
206//
207// You can send this message with [Suspend()].
203208type SuspendMsg struct{}
204209
205210// ResumeMsg can be listen to to do something once a program is resumed back
206211// from a suspend state.
207212type ResumeMsg struct{}
208213
214// InterruptMsg signals the program should suspend.
215// This usually happens when ctrl+c is pressed on common programs, but since
216// bubbletea puts the terminal in raw mode, we need to handle it in a
217// per-program basis.
218//
219// You can send this message with [Interrupt()].
220type InterruptMsg struct{}
221
222// Interrupt is a special command that tells the Bubble Tea program to
223// interrupt.
224func Interrupt() Msg {
225 return InterruptMsg{}
226}
227
209228// NewProgram creates a new Program.
210229func NewProgram(model Model, opts ...ProgramOption) *Program {
211230 p := &Program{
@@ -263,9 +282,14 @@ func (p *Program) handleSignals() chan struct{} {
263282 case <-p.ctx.Done():
264283 return
265284
266 case <-sig:
285 case s := <-sig:
267286 if atomic.LoadUint32(&p.ignoreSignals) == 0 {
268 p.msgs <- QuitMsg{}
287 switch s {
288 case syscall.SIGINT:
289 p.msgs <- InterruptMsg{}
290 default:
291 p.msgs <- QuitMsg{}
292 }
269293 return
270294 }
271295 }
@@ -362,6 +386,9 @@ func (p *Program) eventLoop(model Model, cmds chan Cmd) (Model, error) {
362386 case QuitMsg:
363387 return model, nil
364388
389 case InterruptMsg:
390 return model, ErrInterrupted
391
365392 case SuspendMsg:
366393 if suspendSupported {
367394 p.suspend()
@@ -593,10 +620,11 @@ func (p *Program) Run() (Model, error) {
593620
594621 // Run event loop, handle updates and draw.
595622 model, err := p.eventLoop(model, cmds)
596 killed := p.ctx.Err() != nil
597 if killed {
623 killed := p.ctx.Err() != nil || err != nil
624 if killed && err == nil {
598625 err = fmt.Errorf("%w: %s", ErrProgramKilled, p.ctx.Err())
599 } else {
626 }
627 if err == nil {
600628 // Ensure we rendered the final state of the model.
601629 p.renderer.write(model.View())
602630 }
vendor/github.com/charmbracelet/lipgloss/.golangci-soft.yml +1 −7
@@ -14,16 +14,13 @@ issues:
1414
1515linters:
1616 enable:
17 # - dupl
1817 - exhaustive
19 # - exhaustivestruct
2018 - goconst
2119 - godot
2220 - godox
23 - gomnd
21 - mnd
2422 - gomoddirectives
2523 - goprintffuncname
26 # - lll
2724 - misspell
2825 - nakedret
2926 - nestif
@@ -34,13 +31,10 @@ linters:
3431
3532 # disable default linters, they are already enabled in .golangci.yml
3633 disable:
37 - deadcode
3834 - errcheck
3935 - gosimple
4036 - govet
4137 - ineffassign
4238 - staticcheck
43 - structcheck
4439 - typecheck
4540 - unused
46 - varcheck
vendor/github.com/charmbracelet/lipgloss/.golangci.yml −2
@@ -15,12 +15,10 @@ issues:
1515linters:
1616 enable:
1717 - bodyclose
18 - exportloopref
1918 - gofumpt
2019 - goimports
2120 - gosec
2221 - nilerr
23 - predeclared
2422 - revive
2523 - rowserrcheck
2624 - sqlclosecheck
vendor/github.com/charmbracelet/lipgloss/style.go +4 −2
@@ -353,6 +353,8 @@ func (s Style) Render(strs ...string) string {
353353
354354 // Potentially convert tabs to spaces
355355 str = s.maybeConvertTabs(str)
356 // carriage returns can cause strange behaviour when rendering.
357 str = strings.ReplaceAll(str, "\r\n", "\n")
356358
357359 // Strip newlines in single line mode
358360 if inline {
@@ -562,14 +564,14 @@ func pad(str string, n int, style *termenv.Style) string {
562564 return b.String()
563565}
564566
565func max(a, b int) int { //nolint:unparam
567func max(a, b int) int { //nolint:unparam,predeclared
566568 if a > b {
567569 return a
568570 }
569571 return b
570572}
571573
572func min(a, b int) int {
574func min(a, b int) int { //nolint:predeclared
573575 if a < b {
574576 return a
575577 }
vendor/github.com/charmbracelet/x/ansi/background.go +111 −3
@@ -1,9 +1,73 @@
11package ansi
22
33import (
4 "fmt"
45 "image/color"
56)
67
8// Colorizer is a [color.Color] interface that can be formatted as a string.
9type Colorizer interface {
10 color.Color
11 fmt.Stringer
12}
13
14// HexColorizer is a [color.Color] that can be formatted as a hex string.
15type HexColorizer struct{ color.Color }
16
17var _ Colorizer = HexColorizer{}
18
19// String returns the color as a hex string. If the color is nil, an empty
20// string is returned.
21func (h HexColorizer) String() string {
22 if h.Color == nil {
23 return ""
24 }
25 r, g, b, _ := h.RGBA()
26 // Get the lower 8 bits
27 r &= 0xff
28 g &= 0xff
29 b &= 0xff
30 return fmt.Sprintf("#%02x%02x%02x", uint8(r), uint8(g), uint8(b)) //nolint:gosec
31}
32
33// XRGBColorizer is a [color.Color] that can be formatted as an XParseColor
34// rgb: string.
35//
36// See: https://linux.die.net/man/3/xparsecolor
37type XRGBColorizer struct{ color.Color }
38
39var _ Colorizer = XRGBColorizer{}
40
41// String returns the color as an XParseColor rgb: string. If the color is nil,
42// an empty string is returned.
43func (x XRGBColorizer) String() string {
44 if x.Color == nil {
45 return ""
46 }
47 r, g, b, _ := x.RGBA()
48 // Get the lower 8 bits
49 return fmt.Sprintf("rgb:%04x/%04x/%04x", r, g, b)
50}
51
52// XRGBAColorizer is a [color.Color] that can be formatted as an XParseColor
53// rgba: string.
54//
55// See: https://linux.die.net/man/3/xparsecolor
56type XRGBAColorizer struct{ color.Color }
57
58var _ Colorizer = XRGBAColorizer{}
59
60// String returns the color as an XParseColor rgba: string. If the color is nil,
61// an empty string is returned.
62func (x XRGBAColorizer) String() string {
63 if x.Color == nil {
64 return ""
65 }
66 r, g, b, a := x.RGBA()
67 // Get the lower 8 bits
68 return fmt.Sprintf("rgba:%04x/%04x/%04x/%04x", r, g, b, a)
69}
70
771// SetForegroundColor returns a sequence that sets the default terminal
872// foreground color.
973//
@@ -14,7 +78,16 @@ import (
1478//
1579// See: https://invisible-island.net/xterm/ctlseqs/ctlseqs.html#h3-Operating-System-Commands
1680func SetForegroundColor(c color.Color) string {
17 return "\x1b]10;" + colorToHexString(c) + "\x07"
81 var s string
82 switch c := c.(type) {
83 case Colorizer:
84 s = c.String()
85 case fmt.Stringer:
86 s = c.String()
87 default:
88 s = HexColorizer{c}.String()
89 }
90 return "\x1b]10;" + s + "\x07"
1891}
1992
2093// RequestForegroundColor is a sequence that requests the current default
@@ -23,6 +96,12 @@ func SetForegroundColor(c color.Color) string {
2396// See: https://invisible-island.net/xterm/ctlseqs/ctlseqs.html#h3-Operating-System-Commands
2497const RequestForegroundColor = "\x1b]10;?\x07"
2598
99// ResetForegroundColor is a sequence that resets the default terminal
100// foreground color.
101//
102// See: https://invisible-island.net/xterm/ctlseqs/ctlseqs.html#h3-Operating-System-Commands
103const ResetForegroundColor = "\x1b]110\x07"
104
26105// SetBackgroundColor returns a sequence that sets the default terminal
27106// background color.
28107//
@@ -33,7 +112,16 @@ const RequestForegroundColor = "\x1b]10;?\x07"
33112//
34113// See: https://invisible-island.net/xterm/ctlseqs/ctlseqs.html#h3-Operating-System-Commands
35114func SetBackgroundColor(c color.Color) string {
36 return "\x1b]11;" + colorToHexString(c) + "\x07"
115 var s string
116 switch c := c.(type) {
117 case Colorizer:
118 s = c.String()
119 case fmt.Stringer:
120 s = c.String()
121 default:
122 s = HexColorizer{c}.String()
123 }
124 return "\x1b]11;" + s + "\x07"
37125}
38126
39127// RequestBackgroundColor is a sequence that requests the current default
@@ -42,6 +130,12 @@ func SetBackgroundColor(c color.Color) string {
42130// See: https://invisible-island.net/xterm/ctlseqs/ctlseqs.html#h3-Operating-System-Commands
43131const RequestBackgroundColor = "\x1b]11;?\x07"
44132
133// ResetBackgroundColor is a sequence that resets the default terminal
134// background color.
135//
136// See: https://invisible-island.net/xterm/ctlseqs/ctlseqs.html#h3-Operating-System-Commands
137const ResetBackgroundColor = "\x1b]111\x07"
138
45139// SetCursorColor returns a sequence that sets the terminal cursor color.
46140//
47141// OSC 12 ; color ST
@@ -51,7 +145,16 @@ const RequestBackgroundColor = "\x1b]11;?\x07"
51145//
52146// See: https://invisible-island.net/xterm/ctlseqs/ctlseqs.html#h3-Operating-System-Commands
53147func SetCursorColor(c color.Color) string {
54 return "\x1b]12;" + colorToHexString(c) + "\x07"
148 var s string
149 switch c := c.(type) {
150 case Colorizer:
151 s = c.String()
152 case fmt.Stringer:
153 s = c.String()
154 default:
155 s = HexColorizer{c}.String()
156 }
157 return "\x1b]12;" + s + "\x07"
55158}
56159
57160// RequestCursorColor is a sequence that requests the current terminal cursor
@@ -59,3 +162,8 @@ func SetCursorColor(c color.Color) string {
59162//
60163// See: https://invisible-island.net/xterm/ctlseqs/ctlseqs.html#h3-Operating-System-Commands
61164const RequestCursorColor = "\x1b]12;?\x07"
165
166// ResetCursorColor is a sequence that resets the terminal cursor color.
167//
168// See: https://invisible-island.net/xterm/ctlseqs/ctlseqs.html#h3-Operating-System-Commands
169const ResetCursorColor = "\x1b]112\x07"
vendor/github.com/charmbracelet/x/ansi/c0.go +7
@@ -69,4 +69,11 @@ const (
6969 RS = 0x1E
7070 // US is the unit separator character (Caret: ^_).
7171 US = 0x1F
72
73 // LS0 is the locking shift 0 character.
74 // This is an alias for [SI].
75 LS0 = SI
76 // LS1 is the locking shift 1 character.
77 // This is an alias for [SO].
78 LS1 = SO
7279)
vendor/github.com/charmbracelet/x/ansi/charset.go added +55
@@ -0,0 +1,55 @@
1package ansi
2
3// SelectCharacterSet sets the G-set character designator to the specified
4// character set.
5//
6// ESC Ps Pd
7//
8// Where Ps is the G-set character designator, and Pd is the identifier.
9// For 94-character sets, the designator can be one of:
10// - ( G0
11// - ) G1
12// - * G2
13// - + G3
14//
15// For 96-character sets, the designator can be one of:
16// - - G1
17// - . G2
18// - / G3
19//
20// Some common 94-character sets are:
21// - 0 DEC Special Drawing Set
22// - A United Kingdom (UK)
23// - B United States (USASCII)
24//
25// Examples:
26//
27// ESC ( B Select character set G0 = United States (USASCII)
28// ESC ( 0 Select character set G0 = Special Character and Line Drawing Set
29// ESC ) 0 Select character set G1 = Special Character and Line Drawing Set
30// ESC * A Select character set G2 = United Kingdom (UK)
31//
32// See: https://vt100.net/docs/vt510-rm/SCS.html
33func SelectCharacterSet(gset byte, charset byte) string {
34 return "\x1b" + string(gset) + string(charset)
35}
36
37// SCS is an alias for SelectCharacterSet.
38func SCS(gset byte, charset byte) string {
39 return SelectCharacterSet(gset, charset)
40}
41
42// Locking Shift 1 Right (LS1R) shifts G1 into GR character set.
43const LS1R = "\x1b~"
44
45// Locking Shift 2 (LS2) shifts G2 into GL character set.
46const LS2 = "\x1bn"
47
48// Locking Shift 2 Right (LS2R) shifts G2 into GR character set.
49const LS2R = "\x1b}"
50
51// Locking Shift 3 (LS3) shifts G3 into GL character set.
52const LS3 = "\x1bo"
53
54// Locking Shift 3 Right (LS3R) shifts G3 into GR character set.
55const LS3R = "\x1b|"
vendor/github.com/charmbracelet/x/ansi/color.go +1 −1
@@ -178,7 +178,7 @@ func ansiToRGB(ansi uint32) (uint32, uint32, uint32) {
178178//
179179// r, g, b := hexToRGB(0x0000FF)
180180func hexToRGB(hex uint32) (uint32, uint32, uint32) {
181 return hex >> 16, hex >> 8 & 0xff, hex & 0xff
181 return hex >> 16 & 0xff, hex >> 8 & 0xff, hex & 0xff
182182}
183183
184184// toRGBA converts an RGB 8-bit color values to 32-bit color values suitable
vendor/github.com/charmbracelet/x/ansi/csi.go deleted −141
@@ -1,141 +0,0 @@
1package ansi
2
3import (
4 "bytes"
5 "strconv"
6
7 "github.com/charmbracelet/x/ansi/parser"
8)
9
10// CsiSequence represents a control sequence introducer (CSI) sequence.
11//
12// The sequence starts with a CSI sequence, CSI (0x9B) in a 8-bit environment
13// or ESC [ (0x1B 0x5B) in a 7-bit environment, followed by any number of
14// parameters in the range of 0x30-0x3F, then by any number of intermediate
15// byte in the range of 0x20-0x2F, then finally with a single final byte in the
16// range of 0x20-0x7E.
17//
18// CSI P..P I..I F
19//
20// See ECMA-48 § 5.4.
21type CsiSequence struct {
22 // Params contains the raw parameters of the sequence.
23 // This is a slice of integers, where each integer is a 32-bit integer
24 // containing the parameter value in the lower 31 bits and a flag in the
25 // most significant bit indicating whether there are more sub-parameters.
26 Params []int
27
28 // Cmd contains the raw command of the sequence.
29 // The command is a 32-bit integer containing the CSI command byte in the
30 // lower 8 bits, the private marker in the next 8 bits, and the intermediate
31 // byte in the next 8 bits.
32 //
33 // CSI ? u
34 //
35 // Is represented as:
36 //
37 // 'u' | '?' << 8
38 Cmd int
39}
40
41var _ Sequence = CsiSequence{}
42
43// Marker returns the marker byte of the CSI sequence.
44// This is always gonna be one of the following '<' '=' '>' '?' and in the
45// range of 0x3C-0x3F.
46// Zero is returned if the sequence does not have a marker.
47func (s CsiSequence) Marker() int {
48 return parser.Marker(s.Cmd)
49}
50
51// Intermediate returns the intermediate byte of the CSI sequence.
52// An intermediate byte is in the range of 0x20-0x2F. This includes these
53// characters from ' ', '!', '"', '#', '$', '%', '&', ”', '(', ')', '*', '+',
54// ',', '-', '.', '/'.
55// Zero is returned if the sequence does not have an intermediate byte.
56func (s CsiSequence) Intermediate() int {
57 return parser.Intermediate(s.Cmd)
58}
59
60// Command returns the command byte of the CSI sequence.
61func (s CsiSequence) Command() int {
62 return parser.Command(s.Cmd)
63}
64
65// Param returns the parameter at the given index.
66// It returns -1 if the parameter does not exist.
67func (s CsiSequence) Param(i int) int {
68 return parser.Param(s.Params, i)
69}
70
71// HasMore returns true if the parameter has more sub-parameters.
72func (s CsiSequence) HasMore(i int) bool {
73 return parser.HasMore(s.Params, i)
74}
75
76// Subparams returns the sub-parameters of the given parameter.
77// It returns nil if the parameter does not exist.
78func (s CsiSequence) Subparams(i int) []int {
79 return parser.Subparams(s.Params, i)
80}
81
82// Len returns the number of parameters in the sequence.
83// This will return the number of parameters in the sequence, excluding any
84// sub-parameters.
85func (s CsiSequence) Len() int {
86 return parser.Len(s.Params)
87}
88
89// Range iterates over the parameters of the sequence and calls the given
90// function for each parameter.
91// The function should return false to stop the iteration.
92func (s CsiSequence) Range(fn func(i int, param int, hasMore bool) bool) {
93 parser.Range(s.Params, fn)
94}
95
96// Clone returns a copy of the CSI sequence.
97func (s CsiSequence) Clone() Sequence {
98 return CsiSequence{
99 Params: append([]int(nil), s.Params...),
100 Cmd: s.Cmd,
101 }
102}
103
104// String returns a string representation of the sequence.
105// The string will always be in the 7-bit format i.e (ESC [ P..P I..I F).
106func (s CsiSequence) String() string {
107 return s.buffer().String()
108}
109
110// buffer returns a buffer containing the sequence.
111func (s CsiSequence) buffer() *bytes.Buffer {
112 var b bytes.Buffer
113 b.WriteString("\x1b[")
114 if m := s.Marker(); m != 0 {
115 b.WriteByte(byte(m))
116 }
117 s.Range(func(i, param int, hasMore bool) bool {
118 if param >= 0 {
119 b.WriteString(strconv.Itoa(param))
120 }
121 if i < len(s.Params)-1 {
122 if hasMore {
123 b.WriteByte(':')
124 } else {
125 b.WriteByte(';')
126 }
127 }
128 return true
129 })
130 if i := s.Intermediate(); i != 0 {
131 b.WriteByte(byte(i))
132 }
133 b.WriteByte(byte(s.Command()))
134 return &b
135}
136
137// Bytes returns the byte representation of the sequence.
138// The bytes will always be in the 7-bit format i.e (ESC [ P..P I..I F).
139func (s CsiSequence) Bytes() []byte {
140 return s.buffer().Bytes()
141}
vendor/github.com/charmbracelet/x/ansi/ctrl.go +121 −1
@@ -1,12 +1,62 @@
11package ansi
22
3import (
4 "strconv"
5 "strings"
6)
7
8// RequestNameVersion (XTVERSION) is a control sequence that requests the
9// terminal's name and version. It responds with a DSR sequence identifying the
10// terminal.
11//
12// CSI > 0 q
13// DCS > | text ST
14//
15// See https://invisible-island.net/xterm/ctlseqs/ctlseqs.html#h3-PC-Style-Function-Keys
16const (
17 RequestNameVersion = "\x1b[>q"
18 XTVERSION = RequestNameVersion
19)
20
321// RequestXTVersion is a control sequence that requests the terminal's XTVERSION. It responds with a DSR sequence identifying the version.
422//
523// CSI > Ps q
624// DCS > | text ST
725//
826// See https://invisible-island.net/xterm/ctlseqs/ctlseqs.html#h3-PC-Style-Function-Keys
9const RequestXTVersion = "\x1b[>0q"
27//
28// Deprecated: use [RequestNameVersion] instead.
29const RequestXTVersion = RequestNameVersion
30
31// PrimaryDeviceAttributes (DA1) is a control sequence that reports the
32// terminal's primary device attributes.
33//
34// CSI c
35// CSI 0 c
36// CSI ? Ps ; ... c
37//
38// If no attributes are given, or if the attribute is 0, this function returns
39// the request sequence. Otherwise, it returns the response sequence.
40//
41// See https://vt100.net/docs/vt510-rm/DA1.html
42func PrimaryDeviceAttributes(attrs ...int) string {
43 if len(attrs) == 0 {
44 return RequestPrimaryDeviceAttributes
45 } else if len(attrs) == 1 && attrs[0] == 0 {
46 return "\x1b[0c"
47 }
48
49 as := make([]string, len(attrs))
50 for i, a := range attrs {
51 as[i] = strconv.Itoa(a)
52 }
53 return "\x1b[?" + strings.Join(as, ";") + "c"
54}
55
56// DA1 is an alias for [PrimaryDeviceAttributes].
57func DA1(attrs ...int) string {
58 return PrimaryDeviceAttributes(attrs...)
59}
1060
1161// RequestPrimaryDeviceAttributes is a control sequence that requests the
1262// terminal's primary device attributes (DA1).
@@ -15,3 +65,73 @@ const RequestXTVersion = "\x1b[>0q"
1565//
1666// See https://vt100.net/docs/vt510-rm/DA1.html
1767const RequestPrimaryDeviceAttributes = "\x1b[c"
68
69// SecondaryDeviceAttributes (DA2) is a control sequence that reports the
70// terminal's secondary device attributes.
71//
72// CSI > c
73// CSI > 0 c
74// CSI > Ps ; ... c
75//
76// See https://vt100.net/docs/vt510-rm/DA2.html
77func SecondaryDeviceAttributes(attrs ...int) string {
78 if len(attrs) == 0 {
79 return RequestSecondaryDeviceAttributes
80 }
81
82 as := make([]string, len(attrs))
83 for i, a := range attrs {
84 as[i] = strconv.Itoa(a)
85 }
86 return "\x1b[>" + strings.Join(as, ";") + "c"
87}
88
89// DA2 is an alias for [SecondaryDeviceAttributes].
90func DA2(attrs ...int) string {
91 return SecondaryDeviceAttributes(attrs...)
92}
93
94// RequestSecondaryDeviceAttributes is a control sequence that requests the
95// terminal's secondary device attributes (DA2).
96//
97// CSI > c
98//
99// See https://vt100.net/docs/vt510-rm/DA2.html
100const RequestSecondaryDeviceAttributes = "\x1b[>c"
101
102// TertiaryDeviceAttributes (DA3) is a control sequence that reports the
103// terminal's tertiary device attributes.
104//
105// CSI = c
106// CSI = 0 c
107// DCS ! | Text ST
108//
109// Where Text is the unit ID for the terminal.
110//
111// If no unit ID is given, or if the unit ID is 0, this function returns the
112// request sequence. Otherwise, it returns the response sequence.
113//
114// See https://vt100.net/docs/vt510-rm/DA3.html
115func TertiaryDeviceAttributes(unitID string) string {
116 switch unitID {
117 case "":
118 return RequestTertiaryDeviceAttributes
119 case "0":
120 return "\x1b[=0c"
121 }
122
123 return "\x1bP!|" + unitID + "\x1b\\"
124}
125
126// DA3 is an alias for [TertiaryDeviceAttributes].
127func DA3(unitID string) string {
128 return TertiaryDeviceAttributes(unitID)
129}
130
131// RequestTertiaryDeviceAttributes is a control sequence that requests the
132// terminal's tertiary device attributes (DA3).
133//
134// CSI = c
135//
136// See https://vt100.net/docs/vt510-rm/DA3.html
137const RequestTertiaryDeviceAttributes = "\x1b[=c"
vendor/github.com/charmbracelet/x/ansi/cursor.go +420 −22
@@ -8,7 +8,10 @@ import "strconv"
88// ESC 7
99//
1010// See: https://vt100.net/docs/vt510-rm/DECSC.html
11const SaveCursor = "\x1b7"
11const (
12 SaveCursor = "\x1b7"
13 DECSC = SaveCursor
14)
1215
1316// RestoreCursor (DECRC) is an escape sequence that restores the cursor
1417// position.
@@ -16,10 +19,13 @@ const SaveCursor = "\x1b7"
1619// ESC 8
1720//
1821// See: https://vt100.net/docs/vt510-rm/DECRC.html
19const RestoreCursor = "\x1b8"
22const (
23 RestoreCursor = "\x1b8"
24 DECRC = RestoreCursor
25)
2026
21// RequestCursorPosition (CPR) is an escape sequence that requests the current
22// cursor position.
27// RequestCursorPosition is an escape sequence that requests the current cursor
28// position.
2329//
2430// CSI 6 n
2531//
@@ -30,6 +36,8 @@ const RestoreCursor = "\x1b8"
3036//
3137// Where Pl is the line number and Pc is the column number.
3238// See: https://vt100.net/docs/vt510-rm/CPR.html
39//
40// Deprecated: use [RequestCursorPositionReport] instead.
3341const RequestCursorPosition = "\x1b[6n"
3442
3543// RequestExtendedCursorPosition (DECXCPR) is a sequence for requesting the
@@ -45,6 +53,8 @@ const RequestCursorPosition = "\x1b[6n"
4553// Where Pl is the line number, Pc is the column number, and Pp is the page
4654// number.
4755// See: https://vt100.net/docs/vt510-rm/DECXCPR.html
56//
57// Deprecated: use [RequestExtendedCursorPositionReport] instead.
4858const RequestExtendedCursorPosition = "\x1b[?6n"
4959
5060// CursorUp (CUU) returns a sequence for moving the cursor up n cells.
@@ -60,9 +70,19 @@ func CursorUp(n int) string {
6070 return "\x1b[" + s + "A"
6171}
6272
73// CUU is an alias for [CursorUp].
74func CUU(n int) string {
75 return CursorUp(n)
76}
77
78// CUU1 is a sequence for moving the cursor up one cell.
79const CUU1 = "\x1b[A"
80
6381// CursorUp1 is a sequence for moving the cursor up one cell.
6482//
6583// This is equivalent to CursorUp(1).
84//
85// Deprecated: use [CUU1] instead.
6686const CursorUp1 = "\x1b[A"
6787
6888// CursorDown (CUD) returns a sequence for moving the cursor down n cells.
@@ -78,17 +98,27 @@ func CursorDown(n int) string {
7898 return "\x1b[" + s + "B"
7999}
80100
101// CUD is an alias for [CursorDown].
102func CUD(n int) string {
103 return CursorDown(n)
104}
105
106// CUD1 is a sequence for moving the cursor down one cell.
107const CUD1 = "\x1b[B"
108
81109// CursorDown1 is a sequence for moving the cursor down one cell.
82110//
83111// This is equivalent to CursorDown(1).
112//
113// Deprecated: use [CUD1] instead.
84114const CursorDown1 = "\x1b[B"
85115
86// CursorRight (CUF) returns a sequence for moving the cursor right n cells.
116// CursorForward (CUF) returns a sequence for moving the cursor right n cells.
87117//
88// CSI n C
118// # CSI n C
89119//
90120// See: https://vt100.net/docs/vt510-rm/CUF.html
91func CursorRight(n int) string {
121func CursorForward(n int) string {
92122 var s string
93123 if n > 1 {
94124 s = strconv.Itoa(n)
@@ -96,17 +126,38 @@ func CursorRight(n int) string {
96126 return "\x1b[" + s + "C"
97127}
98128
129// CUF is an alias for [CursorForward].
130func CUF(n int) string {
131 return CursorForward(n)
132}
133
134// CUF1 is a sequence for moving the cursor right one cell.
135const CUF1 = "\x1b[C"
136
137// CursorRight (CUF) returns a sequence for moving the cursor right n cells.
138//
139// CSI n C
140//
141// See: https://vt100.net/docs/vt510-rm/CUF.html
142//
143// Deprecated: use [CursorForward] instead.
144func CursorRight(n int) string {
145 return CursorForward(n)
146}
147
99148// CursorRight1 is a sequence for moving the cursor right one cell.
100149//
101150// This is equivalent to CursorRight(1).
102const CursorRight1 = "\x1b[C"
151//
152// Deprecated: use [CUF1] instead.
153const CursorRight1 = CUF1
103154
104// CursorLeft (CUB) returns a sequence for moving the cursor left n cells.
155// CursorBackward (CUB) returns a sequence for moving the cursor left n cells.
105156//
106// CSI n D
157// # CSI n D
107158//
108159// See: https://vt100.net/docs/vt510-rm/CUB.html
109func CursorLeft(n int) string {
160func CursorBackward(n int) string {
110161 var s string
111162 if n > 1 {
112163 s = strconv.Itoa(n)
@@ -114,10 +165,31 @@ func CursorLeft(n int) string {
114165 return "\x1b[" + s + "D"
115166}
116167
168// CUB is an alias for [CursorBackward].
169func CUB(n int) string {
170 return CursorBackward(n)
171}
172
173// CUB1 is a sequence for moving the cursor left one cell.
174const CUB1 = "\x1b[D"
175
176// CursorLeft (CUB) returns a sequence for moving the cursor left n cells.
177//
178// CSI n D
179//
180// See: https://vt100.net/docs/vt510-rm/CUB.html
181//
182// Deprecated: use [CursorBackward] instead.
183func CursorLeft(n int) string {
184 return CursorBackward(n)
185}
186
117187// CursorLeft1 is a sequence for moving the cursor left one cell.
118188//
119189// This is equivalent to CursorLeft(1).
120const CursorLeft1 = "\x1b[D"
190//
191// Deprecated: use [CUB1] instead.
192const CursorLeft1 = CUB1
121193
122194// CursorNextLine (CNL) returns a sequence for moving the cursor to the
123195// beginning of the next line n times.
@@ -133,6 +205,11 @@ func CursorNextLine(n int) string {
133205 return "\x1b[" + s + "E"
134206}
135207
208// CNL is an alias for [CursorNextLine].
209func CNL(n int) string {
210 return CursorNextLine(n)
211}
212
136213// CursorPreviousLine (CPL) returns a sequence for moving the cursor to the
137214// beginning of the previous line n times.
138215//
@@ -147,25 +224,266 @@ func CursorPreviousLine(n int) string {
147224 return "\x1b[" + s + "F"
148225}
149226
150// MoveCursor (CUP) returns a sequence for moving the cursor to the given row
151// and column.
227// CPL is an alias for [CursorPreviousLine].
228func CPL(n int) string {
229 return CursorPreviousLine(n)
230}
231
232// CursorHorizontalAbsolute (CHA) returns a sequence for moving the cursor to
233// the given column.
234//
235// Default is 1.
236//
237// CSI n G
238//
239// See: https://vt100.net/docs/vt510-rm/CHA.html
240func CursorHorizontalAbsolute(col int) string {
241 var s string
242 if col > 0 {
243 s = strconv.Itoa(col)
244 }
245 return "\x1b[" + s + "G"
246}
247
248// CHA is an alias for [CursorHorizontalAbsolute].
249func CHA(col int) string {
250 return CursorHorizontalAbsolute(col)
251}
252
253// CursorPosition (CUP) returns a sequence for setting the cursor to the
254// given row and column.
255//
256// Default is 1,1.
152257//
153258// CSI n ; m H
154259//
155260// See: https://vt100.net/docs/vt510-rm/CUP.html
156func MoveCursor(row, col int) string {
157 if row < 0 {
158 row = 0
261func CursorPosition(col, row int) string {
262 if row <= 0 && col <= 0 {
263 return HomeCursorPosition
264 }
265
266 var r, c string
267 if row > 0 {
268 r = strconv.Itoa(row)
159269 }
160 if col < 0 {
161 col = 0
270 if col > 0 {
271 c = strconv.Itoa(col)
162272 }
163 return "\x1b[" + strconv.Itoa(row) + ";" + strconv.Itoa(col) + "H"
273 return "\x1b[" + r + ";" + c + "H"
164274}
165275
276// CUP is an alias for [CursorPosition].
277func CUP(col, row int) string {
278 return CursorPosition(col, row)
279}
280
281// CursorHomePosition is a sequence for moving the cursor to the upper left
282// corner of the scrolling region. This is equivalent to `CursorPosition(1, 1)`.
283const CursorHomePosition = "\x1b[H"
284
285// SetCursorPosition (CUP) returns a sequence for setting the cursor to the
286// given row and column.
287//
288// CSI n ; m H
289//
290// See: https://vt100.net/docs/vt510-rm/CUP.html
291//
292// Deprecated: use [CursorPosition] instead.
293func SetCursorPosition(col, row int) string {
294 if row <= 0 && col <= 0 {
295 return HomeCursorPosition
296 }
297
298 var r, c string
299 if row > 0 {
300 r = strconv.Itoa(row)
301 }
302 if col > 0 {
303 c = strconv.Itoa(col)
304 }
305 return "\x1b[" + r + ";" + c + "H"
306}
307
308// HomeCursorPosition is a sequence for moving the cursor to the upper left
309// corner of the scrolling region. This is equivalent to `SetCursorPosition(1, 1)`.
310//
311// Deprecated: use [CursorHomePosition] instead.
312const HomeCursorPosition = CursorHomePosition
313
314// MoveCursor (CUP) returns a sequence for setting the cursor to the
315// given row and column.
316//
317// CSI n ; m H
318//
319// See: https://vt100.net/docs/vt510-rm/CUP.html
320//
321// Deprecated: use [CursorPosition] instead.
322func MoveCursor(col, row int) string {
323 return SetCursorPosition(col, row)
324}
325
326// CursorOrigin is a sequence for moving the cursor to the upper left corner of
327// the display. This is equivalent to `SetCursorPosition(1, 1)`.
328//
329// Deprecated: use [CursorHomePosition] instead.
330const CursorOrigin = "\x1b[1;1H"
331
166332// MoveCursorOrigin is a sequence for moving the cursor to the upper left
167// corner of the screen. This is equivalent to MoveCursor(1, 1).
168const MoveCursorOrigin = "\x1b[1;1H"
333// corner of the display. This is equivalent to `SetCursorPosition(1, 1)`.
334//
335// Deprecated: use [CursorHomePosition] instead.
336const MoveCursorOrigin = CursorOrigin
337
338// CursorHorizontalForwardTab (CHT) returns a sequence for moving the cursor to
339// the next tab stop n times.
340//
341// Default is 1.
342//
343// CSI n I
344//
345// See: https://vt100.net/docs/vt510-rm/CHT.html
346func CursorHorizontalForwardTab(n int) string {
347 var s string
348 if n > 1 {
349 s = strconv.Itoa(n)
350 }
351 return "\x1b[" + s + "I"
352}
353
354// CHT is an alias for [CursorHorizontalForwardTab].
355func CHT(n int) string {
356 return CursorHorizontalForwardTab(n)
357}
358
359// EraseCharacter (ECH) returns a sequence for erasing n characters and moving
360// the cursor to the right. This doesn't affect other cell attributes.
361//
362// Default is 1.
363//
364// CSI n X
365//
366// See: https://vt100.net/docs/vt510-rm/ECH.html
367func EraseCharacter(n int) string {
368 var s string
369 if n > 1 {
370 s = strconv.Itoa(n)
371 }
372 return "\x1b[" + s + "X"
373}
374
375// ECH is an alias for [EraseCharacter].
376func ECH(n int) string {
377 return EraseCharacter(n)
378}
379
380// CursorBackwardTab (CBT) returns a sequence for moving the cursor to the
381// previous tab stop n times.
382//
383// Default is 1.
384//
385// CSI n Z
386//
387// See: https://vt100.net/docs/vt510-rm/CBT.html
388func CursorBackwardTab(n int) string {
389 var s string
390 if n > 1 {
391 s = strconv.Itoa(n)
392 }
393 return "\x1b[" + s + "Z"
394}
395
396// CBT is an alias for [CursorBackwardTab].
397func CBT(n int) string {
398 return CursorBackwardTab(n)
399}
400
401// VerticalPositionAbsolute (VPA) returns a sequence for moving the cursor to
402// the given row.
403//
404// Default is 1.
405//
406// CSI n d
407//
408// See: https://vt100.net/docs/vt510-rm/VPA.html
409func VerticalPositionAbsolute(row int) string {
410 var s string
411 if row > 0 {
412 s = strconv.Itoa(row)
413 }
414 return "\x1b[" + s + "d"
415}
416
417// VPA is an alias for [VerticalPositionAbsolute].
418func VPA(row int) string {
419 return VerticalPositionAbsolute(row)
420}
421
422// VerticalPositionRelative (VPR) returns a sequence for moving the cursor down
423// n rows relative to the current position.
424//
425// Default is 1.
426//
427// CSI n e
428//
429// See: https://vt100.net/docs/vt510-rm/VPR.html
430func VerticalPositionRelative(n int) string {
431 var s string
432 if n > 1 {
433 s = strconv.Itoa(n)
434 }
435 return "\x1b[" + s + "e"
436}
437
438// VPR is an alias for [VerticalPositionRelative].
439func VPR(n int) string {
440 return VerticalPositionRelative(n)
441}
442
443// HorizontalVerticalPosition (HVP) returns a sequence for moving the cursor to
444// the given row and column.
445//
446// Default is 1,1.
447//
448// CSI n ; m f
449//
450// This has the same effect as [CursorPosition].
451//
452// See: https://vt100.net/docs/vt510-rm/HVP.html
453func HorizontalVerticalPosition(col, row int) string {
454 var r, c string
455 if row > 0 {
456 r = strconv.Itoa(row)
457 }
458 if col > 0 {
459 c = strconv.Itoa(col)
460 }
461 return "\x1b[" + r + ";" + c + "f"
462}
463
464// HVP is an alias for [HorizontalVerticalPosition].
465func HVP(col, row int) string {
466 return HorizontalVerticalPosition(col, row)
467}
468
469// HorizontalVerticalHomePosition is a sequence for moving the cursor to the
470// upper left corner of the scrolling region. This is equivalent to
471// `HorizontalVerticalPosition(1, 1)`.
472const HorizontalVerticalHomePosition = "\x1b[f"
473
474// SaveCurrentCursorPosition (SCOSC) is a sequence for saving the current cursor
475// position for SCO console mode.
476//
477// CSI s
478//
479// This acts like [DECSC], except the page number where the cursor is located
480// is not saved.
481//
482// See: https://vt100.net/docs/vt510-rm/SCOSC.html
483const (
484 SaveCurrentCursorPosition = "\x1b[s"
485 SCOSC = SaveCurrentCursorPosition
486)
169487
170488// SaveCursorPosition (SCP or SCOSC) is a sequence for saving the cursor
171489// position.
@@ -176,8 +494,24 @@ const MoveCursorOrigin = "\x1b[1;1H"
176494// not saved.
177495//
178496// See: https://vt100.net/docs/vt510-rm/SCOSC.html
497//
498// Deprecated: use [SaveCurrentCursorPosition] instead.
179499const SaveCursorPosition = "\x1b[s"
180500
501// RestoreCurrentCursorPosition (SCORC) is a sequence for restoring the current
502// cursor position for SCO console mode.
503//
504// CSI u
505//
506// This acts like [DECRC], except the page number where the cursor was saved is
507// not restored.
508//
509// See: https://vt100.net/docs/vt510-rm/SCORC.html
510const (
511 RestoreCurrentCursorPosition = "\x1b[u"
512 SCORC = RestoreCurrentCursorPosition
513)
514
181515// RestoreCursorPosition (RCP or SCORC) is a sequence for restoring the cursor
182516// position.
183517//
@@ -187,10 +521,14 @@ const SaveCursorPosition = "\x1b[s"
187521// cursor was saved.
188522//
189523// See: https://vt100.net/docs/vt510-rm/SCORC.html
524//
525// Deprecated: use [RestoreCurrentCursorPosition] instead.
190526const RestoreCursorPosition = "\x1b[u"
191527
192528// SetCursorStyle (DECSCUSR) returns a sequence for changing the cursor style.
193529//
530// Default is 1.
531//
194532// CSI Ps SP q
195533//
196534// Where Ps is the cursor style:
@@ -212,6 +550,11 @@ func SetCursorStyle(style int) string {
212550 return "\x1b[" + strconv.Itoa(style) + " q"
213551}
214552
553// DECSCUSR is an alias for [SetCursorStyle].
554func DECSCUSR(style int) string {
555 return SetCursorStyle(style)
556}
557
215558// SetPointerShape returns a sequence for changing the mouse pointer cursor
216559// shape. Use "default" for the default pointer shape.
217560//
@@ -233,3 +576,58 @@ func SetCursorStyle(style int) string {
233576func SetPointerShape(shape string) string {
234577 return "\x1b]22;" + shape + "\x07"
235578}
579
580// ReverseIndex (RI) is an escape sequence for moving the cursor up one line in
581// the same column. If the cursor is at the top margin, the screen scrolls
582// down.
583//
584// This has the same effect as [RI].
585const ReverseIndex = "\x1bM"
586
587// HorizontalPositionAbsolute (HPA) returns a sequence for moving the cursor to
588// the given column. This has the same effect as [CUP].
589//
590// Default is 1.
591//
592// CSI n `
593//
594// See: https://vt100.net/docs/vt510-rm/HPA.html
595func HorizontalPositionAbsolute(col int) string {
596 var s string
597 if col > 0 {
598 s = strconv.Itoa(col)
599 }
600 return "\x1b[" + s + "`"
601}
602
603// HPA is an alias for [HorizontalPositionAbsolute].
604func HPA(col int) string {
605 return HorizontalPositionAbsolute(col)
606}
607
608// HorizontalPositionRelative (HPR) returns a sequence for moving the cursor
609// right n columns relative to the current position. This has the same effect
610// as [CUP].
611//
612// Default is 1.
613//
614// CSI n a
615//
616// See: https://vt100.net/docs/vt510-rm/HPR.html
617func HorizontalPositionRelative(n int) string {
618 var s string
619 if n > 0 {
620 s = strconv.Itoa(n)
621 }
622 return "\x1b[" + s + "a"
623}
624
625// HPR is an alias for [HorizontalPositionRelative].
626func HPR(n int) string {
627 return HorizontalPositionRelative(n)
628}
629
630// Index (IND) is an escape sequence for moving the cursor down one line in the
631// same column. If the cursor is at the bottom margin, the screen scrolls up.
632// This has the same effect as [IND].
633const Index = "\x1bD"
vendor/github.com/charmbracelet/x/ansi/cwd.go added +26
@@ -0,0 +1,26 @@
1package ansi
2
3import (
4 "net/url"
5 "path"
6)
7
8// NotifyWorkingDirectory returns a sequence that notifies the terminal
9// of the current working directory.
10//
11// OSC 7 ; Pt BEL
12//
13// Where Pt is a URL in the format "file://[host]/[path]".
14// Set host to "localhost" if this is a path on the local computer.
15//
16// See: https://wezfurlong.org/wezterm/shell-integration.html#osc-7-escape-sequence-to-set-the-working-directory
17// See: https://iterm2.com/documentation-escape-codes.html#:~:text=RemoteHost%20and%20CurrentDir%3A-,OSC%207,-%3B%20%5BPs%5D%20ST
18func NotifyWorkingDirectory(host string, paths ...string) string {
19 path := path.Join(paths...)
20 u := &url.URL{
21 Scheme: "file",
22 Host: host,
23 Path: path,
24 }
25 return "\x1b]7;" + u.String() + "\x07"
26}
vendor/github.com/charmbracelet/x/ansi/dcs.go deleted −148
@@ -1,148 +0,0 @@
1package ansi
2
3import (
4 "bytes"
5 "strconv"
6
7 "github.com/charmbracelet/x/ansi/parser"
8)
9
10// DcsSequence represents a Device Control String (DCS) escape sequence.
11//
12// The DCS sequence is used to send device control strings to the terminal. The
13// sequence starts with the C1 control code character DCS (0x9B) or ESC P in
14// 7-bit environments, followed by parameter bytes, intermediate bytes, a
15// command byte, followed by data bytes, and ends with the C1 control code
16// character ST (0x9C) or ESC \ in 7-bit environments.
17//
18// This follows the parameter string format.
19// See ECMA-48 § 5.4.1
20type DcsSequence struct {
21 // Params contains the raw parameters of the sequence.
22 // This is a slice of integers, where each integer is a 32-bit integer
23 // containing the parameter value in the lower 31 bits and a flag in the
24 // most significant bit indicating whether there are more sub-parameters.
25 Params []int
26
27 // Data contains the string raw data of the sequence.
28 // This is the data between the final byte and the escape sequence terminator.
29 Data []byte
30
31 // Cmd contains the raw command of the sequence.
32 // The command is a 32-bit integer containing the DCS command byte in the
33 // lower 8 bits, the private marker in the next 8 bits, and the intermediate
34 // byte in the next 8 bits.
35 //
36 // DCS > 0 ; 1 $ r <data> ST
37 //
38 // Is represented as:
39 //
40 // 'r' | '>' << 8 | '$' << 16
41 Cmd int
42}
43
44var _ Sequence = DcsSequence{}
45
46// Marker returns the marker byte of the DCS sequence.
47// This is always gonna be one of the following '<' '=' '>' '?' and in the
48// range of 0x3C-0x3F.
49// Zero is returned if the sequence does not have a marker.
50func (s DcsSequence) Marker() int {
51 return parser.Marker(s.Cmd)
52}
53
54// Intermediate returns the intermediate byte of the DCS sequence.
55// An intermediate byte is in the range of 0x20-0x2F. This includes these
56// characters from ' ', '!', '"', '#', '$', '%', '&', ”', '(', ')', '*', '+',
57// ',', '-', '.', '/'.
58// Zero is returned if the sequence does not have an intermediate byte.
59func (s DcsSequence) Intermediate() int {
60 return parser.Intermediate(s.Cmd)
61}
62
63// Command returns the command byte of the CSI sequence.
64func (s DcsSequence) Command() int {
65 return parser.Command(s.Cmd)
66}
67
68// Param returns the parameter at the given index.
69// It returns -1 if the parameter does not exist.
70func (s DcsSequence) Param(i int) int {
71 return parser.Param(s.Params, i)
72}
73
74// HasMore returns true if the parameter has more sub-parameters.
75func (s DcsSequence) HasMore(i int) bool {
76 return parser.HasMore(s.Params, i)
77}
78
79// Subparams returns the sub-parameters of the given parameter.
80// It returns nil if the parameter does not exist.
81func (s DcsSequence) Subparams(i int) []int {
82 return parser.Subparams(s.Params, i)
83}
84
85// Len returns the number of parameters in the sequence.
86// This will return the number of parameters in the sequence, excluding any
87// sub-parameters.
88func (s DcsSequence) Len() int {
89 return parser.Len(s.Params)
90}
91
92// Range iterates over the parameters of the sequence and calls the given
93// function for each parameter.
94// The function should return false to stop the iteration.
95func (s DcsSequence) Range(fn func(i int, param int, hasMore bool) bool) {
96 parser.Range(s.Params, fn)
97}
98
99// Clone returns a copy of the DCS sequence.
100func (s DcsSequence) Clone() Sequence {
101 return DcsSequence{
102 Params: append([]int(nil), s.Params...),
103 Data: append([]byte(nil), s.Data...),
104 Cmd: s.Cmd,
105 }
106}
107
108// String returns a string representation of the sequence.
109// The string will always be in the 7-bit format i.e (ESC P p..p i..i f <data> ESC \).
110func (s DcsSequence) String() string {
111 return s.buffer().String()
112}
113
114// buffer returns a buffer containing the sequence.
115func (s DcsSequence) buffer() *bytes.Buffer {
116 var b bytes.Buffer
117 b.WriteString("\x1bP")
118 if m := s.Marker(); m != 0 {
119 b.WriteByte(byte(m))
120 }
121 s.Range(func(i, param int, hasMore bool) bool {
122 if param >= -1 {
123 b.WriteString(strconv.Itoa(param))
124 }
125 if i < len(s.Params)-1 {
126 if hasMore {
127 b.WriteByte(':')
128 } else {
129 b.WriteByte(';')
130 }
131 }
132 return true
133 })
134 if i := s.Intermediate(); i != 0 {
135 b.WriteByte(byte(i))
136 }
137 b.WriteByte(byte(s.Command()))
138 b.Write(s.Data)
139 b.WriteByte(ESC)
140 b.WriteByte('\\')
141 return &b
142}
143
144// Bytes returns the byte representation of the sequence.
145// The bytes will always be in the 7-bit format i.e (ESC P p..p i..i F <data> ESC \).
146func (s DcsSequence) Bytes() []byte {
147 return s.buffer().Bytes()
148}
vendor/github.com/charmbracelet/x/ansi/focus.go added +9
@@ -0,0 +1,9 @@
1package ansi
2
3// Focus is an escape sequence to notify the terminal that it has focus.
4// This is used with [FocusEventMode].
5const Focus = "\x1b[I"
6
7// Blur is an escape sequence to notify the terminal that it has lost focus.
8// This is used with [FocusEventMode].
9const Blur = "\x1b[O"
vendor/github.com/charmbracelet/x/ansi/graphics.go added +199
@@ -0,0 +1,199 @@
1package ansi
2
3import (
4 "bytes"
5 "encoding/base64"
6 "errors"
7 "fmt"
8 "image"
9 "io"
10 "os"
11 "strings"
12
13 "github.com/charmbracelet/x/ansi/kitty"
14)
15
16// KittyGraphics returns a sequence that encodes the given image in the Kitty
17// graphics protocol.
18//
19// APC G [comma separated options] ; [base64 encoded payload] ST
20//
21// See https://sw.kovidgoyal.net/kitty/graphics-protocol/
22func KittyGraphics(payload []byte, opts ...string) string {
23 var buf bytes.Buffer
24 buf.WriteString("\x1b_G")
25 buf.WriteString(strings.Join(opts, ","))
26 if len(payload) > 0 {
27 buf.WriteString(";")
28 buf.Write(payload)
29 }
30 buf.WriteString("\x1b\\")
31 return buf.String()
32}
33
34var (
35 // KittyGraphicsTempDir is the directory where temporary files are stored.
36 // This is used in [WriteKittyGraphics] along with [os.CreateTemp].
37 KittyGraphicsTempDir = ""
38
39 // KittyGraphicsTempPattern is the pattern used to create temporary files.
40 // This is used in [WriteKittyGraphics] along with [os.CreateTemp].
41 // The Kitty Graphics protocol requires the file path to contain the
42 // substring "tty-graphics-protocol".
43 KittyGraphicsTempPattern = "tty-graphics-protocol-*"
44)
45
46// WriteKittyGraphics writes an image using the Kitty Graphics protocol with
47// the given options to w. It chunks the written data if o.Chunk is true.
48//
49// You can omit m and use nil when rendering an image from a file. In this
50// case, you must provide a file path in o.File and use o.Transmission =
51// [kitty.File]. You can also use o.Transmission = [kitty.TempFile] to write
52// the image to a temporary file. In that case, the file path is ignored, and
53// the image is written to a temporary file that is automatically deleted by
54// the terminal.
55//
56// See https://sw.kovidgoyal.net/kitty/graphics-protocol/
57func WriteKittyGraphics(w io.Writer, m image.Image, o *kitty.Options) error {
58 if o == nil {
59 o = &kitty.Options{}
60 }
61
62 if o.Transmission == 0 && len(o.File) != 0 {
63 o.Transmission = kitty.File
64 }
65
66 var data bytes.Buffer // the data to be encoded into base64
67 e := &kitty.Encoder{
68 Compress: o.Compression == kitty.Zlib,
69 Format: o.Format,
70 }
71
72 switch o.Transmission {
73 case kitty.Direct:
74 if err := e.Encode(&data, m); err != nil {
75 return fmt.Errorf("failed to encode direct image: %w", err)
76 }
77
78 case kitty.SharedMemory:
79 // TODO: Implement shared memory
80 return fmt.Errorf("shared memory transmission is not yet implemented")
81
82 case kitty.File:
83 if len(o.File) == 0 {
84 return kitty.ErrMissingFile
85 }
86
87 f, err := os.Open(o.File)
88 if err != nil {
89 return fmt.Errorf("failed to open file: %w", err)
90 }
91
92 defer f.Close() //nolint:errcheck
93
94 stat, err := f.Stat()
95 if err != nil {
96 return fmt.Errorf("failed to get file info: %w", err)
97 }
98
99 mode := stat.Mode()
100 if !mode.IsRegular() {
101 return fmt.Errorf("file is not a regular file")
102 }
103
104 // Write the file path to the buffer
105 if _, err := data.WriteString(f.Name()); err != nil {
106 return fmt.Errorf("failed to write file path to buffer: %w", err)
107 }
108
109 case kitty.TempFile:
110 f, err := os.CreateTemp(KittyGraphicsTempDir, KittyGraphicsTempPattern)
111 if err != nil {
112 return fmt.Errorf("failed to create file: %w", err)
113 }
114
115 defer f.Close() //nolint:errcheck
116
117 if err := e.Encode(f, m); err != nil {
118 return fmt.Errorf("failed to encode image to file: %w", err)
119 }
120
121 // Write the file path to the buffer
122 if _, err := data.WriteString(f.Name()); err != nil {
123 return fmt.Errorf("failed to write file path to buffer: %w", err)
124 }
125 }
126
127 // Encode image to base64
128 var payload bytes.Buffer // the base64 encoded image to be written to w
129 b64 := base64.NewEncoder(base64.StdEncoding, &payload)
130 if _, err := data.WriteTo(b64); err != nil {
131 return fmt.Errorf("failed to write base64 encoded image to payload: %w", err)
132 }
133 if err := b64.Close(); err != nil {
134 return err
135 }
136
137 // If not chunking, write all at once
138 if !o.Chunk {
139 _, err := io.WriteString(w, KittyGraphics(payload.Bytes(), o.Options()...))
140 return err
141 }
142
143 // Write in chunks
144 var (
145 err error
146 n int
147 )
148 chunk := make([]byte, kitty.MaxChunkSize)
149 isFirstChunk := true
150
151 for {
152 // Stop if we read less than the chunk size [kitty.MaxChunkSize].
153 n, err = io.ReadFull(&payload, chunk)
154 if errors.Is(err, io.ErrUnexpectedEOF) || errors.Is(err, io.EOF) {
155 break
156 }
157 if err != nil {
158 return fmt.Errorf("failed to read chunk: %w", err)
159 }
160
161 opts := buildChunkOptions(o, isFirstChunk, false)
162 if _, err := io.WriteString(w, KittyGraphics(chunk[:n], opts...)); err != nil {
163 return err
164 }
165
166 isFirstChunk = false
167 }
168
169 // Write the last chunk
170 opts := buildChunkOptions(o, isFirstChunk, true)
171 _, err = io.WriteString(w, KittyGraphics(chunk[:n], opts...))
172 return err
173}
174
175// buildChunkOptions creates the options slice for a chunk
176func buildChunkOptions(o *kitty.Options, isFirstChunk, isLastChunk bool) []string {
177 var opts []string
178 if isFirstChunk {
179 opts = o.Options()
180 } else {
181 // These options are allowed in subsequent chunks
182 if o.Quite > 0 {
183 opts = append(opts, fmt.Sprintf("q=%d", o.Quite))
184 }
185 if o.Action == kitty.Frame {
186 opts = append(opts, "a=f")
187 }
188 }
189
190 if !isFirstChunk || !isLastChunk {
191 // We don't need to encode the (m=) option when we only have one chunk.
192 if isLastChunk {
193 opts = append(opts, "m=0")
194 } else {
195 opts = append(opts, "m=1")
196 }
197 }
198 return opts
199}
vendor/github.com/charmbracelet/x/ansi/iterm2.go added +18
@@ -0,0 +1,18 @@
1package ansi
2
3import "fmt"
4
5// ITerm2 returns a sequence that uses the iTerm2 proprietary protocol. Use the
6// iterm2 package for a more convenient API.
7//
8// OSC 1337 ; key = value ST
9//
10// Example:
11//
12// ITerm2(iterm2.File{...})
13//
14// See https://iterm2.com/documentation-escape-codes.html
15// See https://iterm2.com/documentation-images.html
16func ITerm2(data any) string {
17 return "\x1b]1337;" + fmt.Sprint(data) + "\x07"
18}
vendor/github.com/charmbracelet/x/ansi/keypad.go added +28
@@ -0,0 +1,28 @@
1package ansi
2
3// Keypad Application Mode (DECKPAM) is a mode that determines whether the
4// keypad sends application sequences or ANSI sequences.
5//
6// This works like enabling [DECNKM].
7// Use [NumericKeypadMode] to set the numeric keypad mode.
8//
9// ESC =
10//
11// See: https://vt100.net/docs/vt510-rm/DECKPAM.html
12const (
13 KeypadApplicationMode = "\x1b="
14 DECKPAM = KeypadApplicationMode
15)
16
17// Keypad Numeric Mode (DECKPNM) is a mode that determines whether the keypad
18// sends application sequences or ANSI sequences.
19//
20// This works the same as disabling [DECNKM].
21//
22// ESC >
23//
24// See: https://vt100.net/docs/vt510-rm/DECKPNM.html
25const (
26 KeypadNumericMode = "\x1b>"
27 DECKPNM = KeypadNumericMode
28)
vendor/github.com/charmbracelet/x/ansi/kitty.go +1 −1
@@ -72,7 +72,7 @@ func PushKittyKeyboard(flags int) string {
7272// Keyboard stack to disable the protocol.
7373//
7474// This is equivalent to PushKittyKeyboard(0).
75const DisableKittyKeyboard = "\x1b[>0u"
75const DisableKittyKeyboard = "\x1b[>u"
7676
7777// PopKittyKeyboard returns a sequence to pop n number of flags from the
7878// terminal Kitty Keyboard stack.
vendor/github.com/charmbracelet/x/ansi/kitty/decoder.go added +85
@@ -0,0 +1,85 @@
1package kitty
2
3import (
4 "compress/zlib"
5 "fmt"
6 "image"
7 "image/color"
8 "image/png"
9 "io"
10)
11
12// Decoder is a decoder for the Kitty graphics protocol. It supports decoding
13// images in the 24-bit [RGB], 32-bit [RGBA], and [PNG] formats. It can also
14// decompress data using zlib.
15// The default format is 32-bit [RGBA].
16type Decoder struct {
17 // Uses zlib decompression.
18 Decompress bool
19
20 // Can be one of [RGB], [RGBA], or [PNG].
21 Format int
22
23 // Width of the image in pixels. This can be omitted if the image is [PNG]
24 // formatted.
25 Width int
26
27 // Height of the image in pixels. This can be omitted if the image is [PNG]
28 // formatted.
29 Height int
30}
31
32// Decode decodes the image data from r in the specified format.
33func (d *Decoder) Decode(r io.Reader) (image.Image, error) {
34 if d.Decompress {
35 zr, err := zlib.NewReader(r)
36 if err != nil {
37 return nil, fmt.Errorf("failed to create zlib reader: %w", err)
38 }
39
40 defer zr.Close() //nolint:errcheck
41 r = zr
42 }
43
44 if d.Format == 0 {
45 d.Format = RGBA
46 }
47
48 switch d.Format {
49 case RGBA, RGB:
50 return d.decodeRGBA(r, d.Format == RGBA)
51
52 case PNG:
53 return png.Decode(r)
54
55 default:
56 return nil, fmt.Errorf("unsupported format: %d", d.Format)
57 }
58}
59
60// decodeRGBA decodes the image data in 32-bit RGBA or 24-bit RGB formats.
61func (d *Decoder) decodeRGBA(r io.Reader, alpha bool) (image.Image, error) {
62 m := image.NewRGBA(image.Rect(0, 0, d.Width, d.Height))
63
64 var buf []byte
65 if alpha {
66 buf = make([]byte, 4)
67 } else {
68 buf = make([]byte, 3)
69 }
70
71 for y := 0; y < d.Height; y++ {
72 for x := 0; x < d.Width; x++ {
73 if _, err := io.ReadFull(r, buf[:]); err != nil {
74 return nil, fmt.Errorf("failed to read pixel data: %w", err)
75 }
76 if alpha {
77 m.SetRGBA(x, y, color.RGBA{buf[0], buf[1], buf[2], buf[3]})
78 } else {
79 m.SetRGBA(x, y, color.RGBA{buf[0], buf[1], buf[2], 0xff})
80 }
81 }
82 }
83
84 return m, nil
85}
vendor/github.com/charmbracelet/x/ansi/kitty/encoder.go added +64
@@ -0,0 +1,64 @@
1package kitty
2
3import (
4 "compress/zlib"
5 "fmt"
6 "image"
7 "image/png"
8 "io"
9)
10
11// Encoder is an encoder for the Kitty graphics protocol. It supports encoding
12// images in the 24-bit [RGB], 32-bit [RGBA], and [PNG] formats, and
13// compressing the data using zlib.
14// The default format is 32-bit [RGBA].
15type Encoder struct {
16 // Uses zlib compression.
17 Compress bool
18
19 // Can be one of [RGBA], [RGB], or [PNG].
20 Format int
21}
22
23// Encode encodes the image data in the specified format and writes it to w.
24func (e *Encoder) Encode(w io.Writer, m image.Image) error {
25 if m == nil {
26 return nil
27 }
28
29 if e.Compress {
30 zw := zlib.NewWriter(w)
31 defer zw.Close() //nolint:errcheck
32 w = zw
33 }
34
35 if e.Format == 0 {
36 e.Format = RGBA
37 }
38
39 switch e.Format {
40 case RGBA, RGB:
41 bounds := m.Bounds()
42 for y := bounds.Min.Y; y < bounds.Max.Y; y++ {
43 for x := bounds.Min.X; x < bounds.Max.X; x++ {
44 r, g, b, a := m.At(x, y).RGBA()
45 switch e.Format {
46 case RGBA:
47 w.Write([]byte{byte(r >> 8), byte(g >> 8), byte(b >> 8), byte(a >> 8)}) //nolint:errcheck
48 case RGB:
49 w.Write([]byte{byte(r >> 8), byte(g >> 8), byte(b >> 8)}) //nolint:errcheck
50 }
51 }
52 }
53
54 case PNG:
55 if err := png.Encode(w, m); err != nil {
56 return fmt.Errorf("failed to encode PNG: %w", err)
57 }
58
59 default:
60 return fmt.Errorf("unsupported format: %d", e.Format)
61 }
62
63 return nil
64}
vendor/github.com/charmbracelet/x/ansi/kitty/graphics.go added +414
@@ -0,0 +1,414 @@
1package kitty
2
3import "errors"
4
5// ErrMissingFile is returned when the file path is missing.
6var ErrMissingFile = errors.New("missing file path")
7
8// MaxChunkSize is the maximum chunk size for the image data.
9const MaxChunkSize = 1024 * 4
10
11// Placeholder is a special Unicode character that can be used as a placeholder
12// for an image.
13const Placeholder = '\U0010EEEE'
14
15// Graphics image format.
16const (
17 // 32-bit RGBA format.
18 RGBA = 32
19
20 // 24-bit RGB format.
21 RGB = 24
22
23 // PNG format.
24 PNG = 100
25)
26
27// Compression types.
28const (
29 Zlib = 'z'
30)
31
32// Transmission types.
33const (
34 // The data transmitted directly in the escape sequence.
35 Direct = 'd'
36
37 // The data transmitted in a regular file.
38 File = 'f'
39
40 // A temporary file is used and deleted after transmission.
41 TempFile = 't'
42
43 // A shared memory object.
44 // For POSIX see https://pubs.opengroup.org/onlinepubs/9699919799/functions/shm_open.html
45 // For Windows see https://docs.microsoft.com/en-us/windows/win32/memory/creating-named-shared-memory
46 SharedMemory = 's'
47)
48
49// Action types.
50const (
51 // Transmit image data.
52 Transmit = 't'
53 // TransmitAndPut transmit image data and display (put) it.
54 TransmitAndPut = 'T'
55 // Query terminal for image info.
56 Query = 'q'
57 // Put (display) previously transmitted image.
58 Put = 'p'
59 // Delete image.
60 Delete = 'd'
61 // Frame transmits data for animation frames.
62 Frame = 'f'
63 // Animate controls animation.
64 Animate = 'a'
65 // Compose composes animation frames.
66 Compose = 'c'
67)
68
69// Delete types.
70const (
71 // Delete all placements visible on screen
72 DeleteAll = 'a'
73 // Delete all images with the specified id, specified using the i key. If
74 // you specify a p key for the placement id as well, then only the
75 // placement with the specified image id and placement id will be deleted.
76 DeleteID = 'i'
77 // Delete newest image with the specified number, specified using the I
78 // key. If you specify a p key for the placement id as well, then only the
79 // placement with the specified number and placement id will be deleted.
80 DeleteNumber = 'n'
81 // Delete all placements that intersect with the current cursor position.
82 DeleteCursor = 'c'
83 // Delete animation frames.
84 DeleteFrames = 'f'
85 // Delete all placements that intersect a specific cell, the cell is
86 // specified using the x and y keys
87 DeleteCell = 'p'
88 // Delete all placements that intersect a specific cell having a specific
89 // z-index. The cell and z-index is specified using the x, y and z keys.
90 DeleteCellZ = 'q'
91 // Delete all images whose id is greater than or equal to the value of the x
92 // key and less than or equal to the value of the y.
93 DeleteRange = 'r'
94 // Delete all placements that intersect the specified column, specified using
95 // the x key.
96 DeleteColumn = 'x'
97 // Delete all placements that intersect the specified row, specified using
98 // the y key.
99 DeleteRow = 'y'
100 // Delete all placements that have the specified z-index, specified using the
101 // z key.
102 DeleteZ = 'z'
103)
104
105// Diacritic returns the diacritic rune at the specified index. If the index is
106// out of bounds, the first diacritic rune is returned.
107func Diacritic(i int) rune {
108 if i < 0 || i >= len(diacritics) {
109 return diacritics[0]
110 }
111 return diacritics[i]
112}
113
114// From https://sw.kovidgoyal.net/kitty/_downloads/f0a0de9ec8d9ff4456206db8e0814937/rowcolumn-diacritics.txt
115// See https://sw.kovidgoyal.net/kitty/graphics-protocol/#unicode-placeholders for further explanation.
116var diacritics = []rune{
117 '\u0305',
118 '\u030D',
119 '\u030E',
120 '\u0310',
121 '\u0312',
122 '\u033D',
123 '\u033E',
124 '\u033F',
125 '\u0346',
126 '\u034A',
127 '\u034B',
128 '\u034C',
129 '\u0350',
130 '\u0351',
131 '\u0352',
132 '\u0357',
133 '\u035B',
134 '\u0363',
135 '\u0364',
136 '\u0365',
137 '\u0366',
138 '\u0367',
139 '\u0368',
140 '\u0369',
141 '\u036A',
142 '\u036B',
143 '\u036C',
144 '\u036D',
145 '\u036E',
146 '\u036F',
147 '\u0483',
148 '\u0484',
149 '\u0485',
150 '\u0486',
151 '\u0487',
152 '\u0592',
153 '\u0593',
154 '\u0594',
155 '\u0595',
156 '\u0597',
157 '\u0598',
158 '\u0599',
159 '\u059C',
160 '\u059D',
161 '\u059E',
162 '\u059F',
163 '\u05A0',
164 '\u05A1',
165 '\u05A8',
166 '\u05A9',
167 '\u05AB',
168 '\u05AC',
169 '\u05AF',
170 '\u05C4',
171 '\u0610',
172 '\u0611',
173 '\u0612',
174 '\u0613',
175 '\u0614',
176 '\u0615',
177 '\u0616',
178 '\u0617',
179 '\u0657',
180 '\u0658',
181 '\u0659',
182 '\u065A',
183 '\u065B',
184 '\u065D',
185 '\u065E',
186 '\u06D6',
187 '\u06D7',
188 '\u06D8',
189 '\u06D9',
190 '\u06DA',
191 '\u06DB',
192 '\u06DC',
193 '\u06DF',
194 '\u06E0',
195 '\u06E1',
196 '\u06E2',
197 '\u06E4',
198 '\u06E7',
199 '\u06E8',
200 '\u06EB',
201 '\u06EC',
202 '\u0730',
203 '\u0732',
204 '\u0733',
205 '\u0735',
206 '\u0736',
207 '\u073A',
208 '\u073D',
209 '\u073F',
210 '\u0740',
211 '\u0741',
212 '\u0743',
213 '\u0745',
214 '\u0747',
215 '\u0749',
216 '\u074A',
217 '\u07EB',
218 '\u07EC',
219 '\u07ED',
220 '\u07EE',
221 '\u07EF',
222 '\u07F0',
223 '\u07F1',
224 '\u07F3',
225 '\u0816',
226 '\u0817',
227 '\u0818',
228 '\u0819',
229 '\u081B',
230 '\u081C',
231 '\u081D',
232 '\u081E',
233 '\u081F',
234 '\u0820',
235 '\u0821',
236 '\u0822',
237 '\u0823',
238 '\u0825',
239 '\u0826',
240 '\u0827',
241 '\u0829',
242 '\u082A',
243 '\u082B',
244 '\u082C',
245 '\u082D',
246 '\u0951',
247 '\u0953',
248 '\u0954',
249 '\u0F82',
250 '\u0F83',
251 '\u0F86',
252 '\u0F87',
253 '\u135D',
254 '\u135E',
255 '\u135F',
256 '\u17DD',
257 '\u193A',
258 '\u1A17',
259 '\u1A75',
260 '\u1A76',
261 '\u1A77',
262 '\u1A78',
263 '\u1A79',
264 '\u1A7A',
265 '\u1A7B',
266 '\u1A7C',
267 '\u1B6B',
268 '\u1B6D',
269 '\u1B6E',
270 '\u1B6F',
271 '\u1B70',
272 '\u1B71',
273 '\u1B72',
274 '\u1B73',
275 '\u1CD0',
276 '\u1CD1',
277 '\u1CD2',
278 '\u1CDA',
279 '\u1CDB',
280 '\u1CE0',
281 '\u1DC0',
282 '\u1DC1',
283 '\u1DC3',
284 '\u1DC4',
285 '\u1DC5',
286 '\u1DC6',
287 '\u1DC7',
288 '\u1DC8',
289 '\u1DC9',
290 '\u1DCB',
291 '\u1DCC',
292 '\u1DD1',
293 '\u1DD2',
294 '\u1DD3',
295 '\u1DD4',
296 '\u1DD5',
297 '\u1DD6',
298 '\u1DD7',
299 '\u1DD8',
300 '\u1DD9',
301 '\u1DDA',
302 '\u1DDB',
303 '\u1DDC',
304 '\u1DDD',
305 '\u1DDE',
306 '\u1DDF',
307 '\u1DE0',
308 '\u1DE1',
309 '\u1DE2',
310 '\u1DE3',
311 '\u1DE4',
312 '\u1DE5',
313 '\u1DE6',
314 '\u1DFE',
315 '\u20D0',
316 '\u20D1',
317 '\u20D4',
318 '\u20D5',
319 '\u20D6',
320 '\u20D7',
321 '\u20DB',
322 '\u20DC',
323 '\u20E1',
324 '\u20E7',
325 '\u20E9',
326 '\u20F0',
327 '\u2CEF',
328 '\u2CF0',
329 '\u2CF1',
330 '\u2DE0',
331 '\u2DE1',
332 '\u2DE2',
333 '\u2DE3',
334 '\u2DE4',
335 '\u2DE5',
336 '\u2DE6',
337 '\u2DE7',
338 '\u2DE8',
339 '\u2DE9',
340 '\u2DEA',
341 '\u2DEB',
342 '\u2DEC',
343 '\u2DED',
344 '\u2DEE',
345 '\u2DEF',
346 '\u2DF0',
347 '\u2DF1',
348 '\u2DF2',
349 '\u2DF3',
350 '\u2DF4',
351 '\u2DF5',
352 '\u2DF6',
353 '\u2DF7',
354 '\u2DF8',
355 '\u2DF9',
356 '\u2DFA',
357 '\u2DFB',
358 '\u2DFC',
359 '\u2DFD',
360 '\u2DFE',
361 '\u2DFF',
362 '\uA66F',
363 '\uA67C',
364 '\uA67D',
365 '\uA6F0',
366 '\uA6F1',
367 '\uA8E0',
368 '\uA8E1',
369 '\uA8E2',
370 '\uA8E3',
371 '\uA8E4',
372 '\uA8E5',
373 '\uA8E6',
374 '\uA8E7',
375 '\uA8E8',
376 '\uA8E9',
377 '\uA8EA',
378 '\uA8EB',
379 '\uA8EC',
380 '\uA8ED',
381 '\uA8EE',
382 '\uA8EF',
383 '\uA8F0',
384 '\uA8F1',
385 '\uAAB0',
386 '\uAAB2',
387 '\uAAB3',
388 '\uAAB7',
389 '\uAAB8',
390 '\uAABE',
391 '\uAABF',
392 '\uAAC1',
393 '\uFE20',
394 '\uFE21',
395 '\uFE22',
396 '\uFE23',
397 '\uFE24',
398 '\uFE25',
399 '\uFE26',
400 '\U00010A0F',
401 '\U00010A38',
402 '\U0001D185',
403 '\U0001D186',
404 '\U0001D187',
405 '\U0001D188',
406 '\U0001D189',
407 '\U0001D1AA',
408 '\U0001D1AB',
409 '\U0001D1AC',
410 '\U0001D1AD',
411 '\U0001D242',
412 '\U0001D243',
413 '\U0001D244',
414}
vendor/github.com/charmbracelet/x/ansi/kitty/options.go added +367
@@ -0,0 +1,367 @@
1package kitty
2
3import (
4 "encoding"
5 "fmt"
6 "strconv"
7 "strings"
8)
9
10var (
11 _ encoding.TextMarshaler = Options{}
12 _ encoding.TextUnmarshaler = &Options{}
13)
14
15// Options represents a Kitty Graphics Protocol options.
16type Options struct {
17 // Common options.
18
19 // Action (a=t) is the action to be performed on the image. Can be one of
20 // [Transmit], [TransmitDisplay], [Query], [Put], [Delete], [Frame],
21 // [Animate], [Compose].
22 Action byte
23
24 // Quite mode (q=0) is the quiet mode. Can be either zero, one, or two
25 // where zero is the default, 1 suppresses OK responses, and 2 suppresses
26 // both OK and error responses.
27 Quite byte
28
29 // Transmission options.
30
31 // ID (i=) is the image ID. The ID is a unique identifier for the image.
32 // Must be a positive integer up to [math.MaxUint32].
33 ID int
34
35 // PlacementID (p=) is the placement ID. The placement ID is a unique
36 // identifier for the placement of the image. Must be a positive integer up
37 // to [math.MaxUint32].
38 PlacementID int
39
40 // Number (I=0) is the number of images to be transmitted.
41 Number int
42
43 // Format (f=32) is the image format. One of [RGBA], [RGB], [PNG].
44 Format int
45
46 // ImageWidth (s=0) is the transmitted image width.
47 ImageWidth int
48
49 // ImageHeight (v=0) is the transmitted image height.
50 ImageHeight int
51
52 // Compression (o=) is the image compression type. Can be [Zlib] or zero.
53 Compression byte
54
55 // Transmission (t=d) is the image transmission type. Can be [Direct], [File],
56 // [TempFile], or[SharedMemory].
57 Transmission byte
58
59 // File is the file path to be used when the transmission type is [File].
60 // If [Options.Transmission] is omitted i.e. zero and this is non-empty,
61 // the transmission type is set to [File].
62 File string
63
64 // Size (S=0) is the size to be read from the transmission medium.
65 Size int
66
67 // Offset (O=0) is the offset byte to start reading from the transmission
68 // medium.
69 Offset int
70
71 // Chunk (m=) whether the image is transmitted in chunks. Can be either
72 // zero or one. When true, the image is transmitted in chunks. Each chunk
73 // must be a multiple of 4, and up to [MaxChunkSize] bytes. Each chunk must
74 // have the m=1 option except for the last chunk which must have m=0.
75 Chunk bool
76
77 // Display options.
78
79 // X (x=0) is the pixel X coordinate of the image to start displaying.
80 X int
81
82 // Y (y=0) is the pixel Y coordinate of the image to start displaying.
83 Y int
84
85 // Z (z=0) is the Z coordinate of the image to display.
86 Z int
87
88 // Width (w=0) is the width of the image to display.
89 Width int
90
91 // Height (h=0) is the height of the image to display.
92 Height int
93
94 // OffsetX (X=0) is the OffsetX coordinate of the cursor cell to start
95 // displaying the image. OffsetX=0 is the leftmost cell. This must be
96 // smaller than the terminal cell width.
97 OffsetX int
98
99 // OffsetY (Y=0) is the OffsetY coordinate of the cursor cell to start
100 // displaying the image. OffsetY=0 is the topmost cell. This must be
101 // smaller than the terminal cell height.
102 OffsetY int
103
104 // Columns (c=0) is the number of columns to display the image. The image
105 // will be scaled to fit the number of columns.
106 Columns int
107
108 // Rows (r=0) is the number of rows to display the image. The image will be
109 // scaled to fit the number of rows.
110 Rows int
111
112 // VirtualPlacement (U=0) whether to use virtual placement. This is used
113 // with Unicode [Placeholder] to display images.
114 VirtualPlacement bool
115
116 // DoNotMoveCursor (C=0) whether to move the cursor after displaying the
117 // image.
118 DoNotMoveCursor bool
119
120 // ParentID (P=0) is the parent image ID. The parent ID is the ID of the
121 // image that is the parent of the current image. This is used with Unicode
122 // [Placeholder] to display images relative to the parent image.
123 ParentID int
124
125 // ParentPlacementID (Q=0) is the parent placement ID. The parent placement
126 // ID is the ID of the placement of the parent image. This is used with
127 // Unicode [Placeholder] to display images relative to the parent image.
128 ParentPlacementID int
129
130 // Delete options.
131
132 // Delete (d=a) is the delete action. Can be one of [DeleteAll],
133 // [DeleteID], [DeleteNumber], [DeleteCursor], [DeleteFrames],
134 // [DeleteCell], [DeleteCellZ], [DeleteRange], [DeleteColumn], [DeleteRow],
135 // [DeleteZ].
136 Delete byte
137
138 // DeleteResources indicates whether to delete the resources associated
139 // with the image.
140 DeleteResources bool
141}
142
143// Options returns the options as a slice of a key-value pairs.
144func (o *Options) Options() (opts []string) {
145 opts = []string{}
146 if o.Format == 0 {
147 o.Format = RGBA
148 }
149
150 if o.Action == 0 {
151 o.Action = Transmit
152 }
153
154 if o.Delete == 0 {
155 o.Delete = DeleteAll
156 }
157
158 if o.Transmission == 0 {
159 if len(o.File) > 0 {
160 o.Transmission = File
161 } else {
162 o.Transmission = Direct
163 }
164 }
165
166 if o.Format != RGBA {
167 opts = append(opts, fmt.Sprintf("f=%d", o.Format))
168 }
169
170 if o.Quite > 0 {
171 opts = append(opts, fmt.Sprintf("q=%d", o.Quite))
172 }
173
174 if o.ID > 0 {
175 opts = append(opts, fmt.Sprintf("i=%d", o.ID))
176 }
177
178 if o.PlacementID > 0 {
179 opts = append(opts, fmt.Sprintf("p=%d", o.PlacementID))
180 }
181
182 if o.Number > 0 {
183 opts = append(opts, fmt.Sprintf("I=%d", o.Number))
184 }
185
186 if o.ImageWidth > 0 {
187 opts = append(opts, fmt.Sprintf("s=%d", o.ImageWidth))
188 }
189
190 if o.ImageHeight > 0 {
191 opts = append(opts, fmt.Sprintf("v=%d", o.ImageHeight))
192 }
193
194 if o.Transmission != Direct {
195 opts = append(opts, fmt.Sprintf("t=%c", o.Transmission))
196 }
197
198 if o.Size > 0 {
199 opts = append(opts, fmt.Sprintf("S=%d", o.Size))
200 }
201
202 if o.Offset > 0 {
203 opts = append(opts, fmt.Sprintf("O=%d", o.Offset))
204 }
205
206 if o.Compression == Zlib {
207 opts = append(opts, fmt.Sprintf("o=%c", o.Compression))
208 }
209
210 if o.VirtualPlacement {
211 opts = append(opts, "U=1")
212 }
213
214 if o.DoNotMoveCursor {
215 opts = append(opts, "C=1")
216 }
217
218 if o.ParentID > 0 {
219 opts = append(opts, fmt.Sprintf("P=%d", o.ParentID))
220 }
221
222 if o.ParentPlacementID > 0 {
223 opts = append(opts, fmt.Sprintf("Q=%d", o.ParentPlacementID))
224 }
225
226 if o.X > 0 {
227 opts = append(opts, fmt.Sprintf("x=%d", o.X))
228 }
229
230 if o.Y > 0 {
231 opts = append(opts, fmt.Sprintf("y=%d", o.Y))
232 }
233
234 if o.Z > 0 {
235 opts = append(opts, fmt.Sprintf("z=%d", o.Z))
236 }
237
238 if o.Width > 0 {
239 opts = append(opts, fmt.Sprintf("w=%d", o.Width))
240 }
241
242 if o.Height > 0 {
243 opts = append(opts, fmt.Sprintf("h=%d", o.Height))
244 }
245
246 if o.OffsetX > 0 {
247 opts = append(opts, fmt.Sprintf("X=%d", o.OffsetX))
248 }
249
250 if o.OffsetY > 0 {
251 opts = append(opts, fmt.Sprintf("Y=%d", o.OffsetY))
252 }
253
254 if o.Columns > 0 {
255 opts = append(opts, fmt.Sprintf("c=%d", o.Columns))
256 }
257
258 if o.Rows > 0 {
259 opts = append(opts, fmt.Sprintf("r=%d", o.Rows))
260 }
261
262 if o.Delete != DeleteAll || o.DeleteResources {
263 da := o.Delete
264 if o.DeleteResources {
265 da = da - ' ' // to uppercase
266 }
267
268 opts = append(opts, fmt.Sprintf("d=%c", da))
269 }
270
271 if o.Action != Transmit {
272 opts = append(opts, fmt.Sprintf("a=%c", o.Action))
273 }
274
275 return
276}
277
278// String returns the string representation of the options.
279func (o Options) String() string {
280 return strings.Join(o.Options(), ",")
281}
282
283// MarshalText returns the string representation of the options.
284func (o Options) MarshalText() ([]byte, error) {
285 return []byte(o.String()), nil
286}
287
288// UnmarshalText parses the options from the given string.
289func (o *Options) UnmarshalText(text []byte) error {
290 opts := strings.Split(string(text), ",")
291 for _, opt := range opts {
292 ps := strings.SplitN(opt, "=", 2)
293 if len(ps) != 2 || len(ps[1]) == 0 {
294 continue
295 }
296
297 switch ps[0] {
298 case "a":
299 o.Action = ps[1][0]
300 case "o":
301 o.Compression = ps[1][0]
302 case "t":
303 o.Transmission = ps[1][0]
304 case "d":
305 d := ps[1][0]
306 if d >= 'A' && d <= 'Z' {
307 o.DeleteResources = true
308 d = d + ' ' // to lowercase
309 }
310 o.Delete = d
311 case "i", "q", "p", "I", "f", "s", "v", "S", "O", "m", "x", "y", "z", "w", "h", "X", "Y", "c", "r", "U", "P", "Q":
312 v, err := strconv.Atoi(ps[1])
313 if err != nil {
314 continue
315 }
316
317 switch ps[0] {
318 case "i":
319 o.ID = v
320 case "q":
321 o.Quite = byte(v)
322 case "p":
323 o.PlacementID = v
324 case "I":
325 o.Number = v
326 case "f":
327 o.Format = v
328 case "s":
329 o.ImageWidth = v
330 case "v":
331 o.ImageHeight = v
332 case "S":
333 o.Size = v
334 case "O":
335 o.Offset = v
336 case "m":
337 o.Chunk = v == 0 || v == 1
338 case "x":
339 o.X = v
340 case "y":
341 o.Y = v
342 case "z":
343 o.Z = v
344 case "w":
345 o.Width = v
346 case "h":
347 o.Height = v
348 case "X":
349 o.OffsetX = v
350 case "Y":
351 o.OffsetY = v
352 case "c":
353 o.Columns = v
354 case "r":
355 o.Rows = v
356 case "U":
357 o.VirtualPlacement = v == 1
358 case "P":
359 o.ParentID = v
360 case "Q":
361 o.ParentPlacementID = v
362 }
363 }
364 }
365
366 return nil
367}
vendor/github.com/charmbracelet/x/ansi/method.go added +172
@@ -0,0 +1,172 @@
1package ansi
2
3// Method is a type that represents the how the renderer should calculate the
4// display width of cells.
5type Method uint8
6
7// Display width modes.
8const (
9 WcWidth Method = iota
10 GraphemeWidth
11)
12
13// StringWidth returns the width of a string in cells. This is the number of
14// cells that the string will occupy when printed in a terminal. ANSI escape
15// codes are ignored and wide characters (such as East Asians and emojis) are
16// accounted for.
17func (m Method) StringWidth(s string) int {
18 return stringWidth(m, s)
19}
20
21// Truncate truncates a string to a given length, adding a tail to the end if
22// the string is longer than the given length. This function is aware of ANSI
23// escape codes and will not break them, and accounts for wide-characters (such
24// as East-Asian characters and emojis).
25func (m Method) Truncate(s string, length int, tail string) string {
26 return truncate(m, s, length, tail)
27}
28
29// TruncateLeft truncates a string to a given length, adding a prefix to the
30// beginning if the string is longer than the given length. This function is
31// aware of ANSI escape codes and will not break them, and accounts for
32// wide-characters (such as East-Asian characters and emojis).
33func (m Method) TruncateLeft(s string, length int, prefix string) string {
34 return truncateLeft(m, s, length, prefix)
35}
36
37// Cut the string, without adding any prefix or tail strings. This function is
38// aware of ANSI escape codes and will not break them, and accounts for
39// wide-characters (such as East-Asian characters and emojis). Note that the
40// [left] parameter is inclusive, while [right] isn't.
41func (m Method) Cut(s string, left, right int) string {
42 return cut(m, s, left, right)
43}
44
45// Hardwrap wraps a string or a block of text to a given line length, breaking
46// word boundaries. This will preserve ANSI escape codes and will account for
47// wide-characters in the string.
48// When preserveSpace is true, spaces at the beginning of a line will be
49// preserved.
50// This treats the text as a sequence of graphemes.
51func (m Method) Hardwrap(s string, length int, preserveSpace bool) string {
52 return hardwrap(m, s, length, preserveSpace)
53}
54
55// Wordwrap wraps a string or a block of text to a given line length, not
56// breaking word boundaries. This will preserve ANSI escape codes and will
57// account for wide-characters in the string.
58// The breakpoints string is a list of characters that are considered
59// breakpoints for word wrapping. A hyphen (-) is always considered a
60// breakpoint.
61//
62// Note: breakpoints must be a string of 1-cell wide rune characters.
63func (m Method) Wordwrap(s string, length int, breakpoints string) string {
64 return wordwrap(m, s, length, breakpoints)
65}
66
67// Wrap wraps a string or a block of text to a given line length, breaking word
68// boundaries if necessary. This will preserve ANSI escape codes and will
69// account for wide-characters in the string. The breakpoints string is a list
70// of characters that are considered breakpoints for word wrapping. A hyphen
71// (-) is always considered a breakpoint.
72//
73// Note: breakpoints must be a string of 1-cell wide rune characters.
74func (m Method) Wrap(s string, length int, breakpoints string) string {
75 return wrap(m, s, length, breakpoints)
76}
77
78// DecodeSequence decodes the first ANSI escape sequence or a printable
79// grapheme from the given data. It returns the sequence slice, the number of
80// bytes read, the cell width for each sequence, and the new state.
81//
82// The cell width will always be 0 for control and escape sequences, 1 for
83// ASCII printable characters, and the number of cells other Unicode characters
84// occupy. It uses the uniseg package to calculate the width of Unicode
85// graphemes and characters. This means it will always do grapheme clustering
86// (mode 2027).
87//
88// Passing a non-nil [*Parser] as the last argument will allow the decoder to
89// collect sequence parameters, data, and commands. The parser cmd will have
90// the packed command value that contains intermediate and prefix characters.
91// In the case of a OSC sequence, the cmd will be the OSC command number. Use
92// [Cmd] and [Param] types to unpack command intermediates and prefixes as well
93// as parameters.
94//
95// Zero [Cmd] means the CSI, DCS, or ESC sequence is invalid. Moreover, checking the
96// validity of other data sequences, OSC, DCS, etc, will require checking for
97// the returned sequence terminator bytes such as ST (ESC \\) and BEL).
98//
99// We store the command byte in [Cmd] in the most significant byte, the
100// prefix byte in the next byte, and the intermediate byte in the least
101// significant byte. This is done to avoid using a struct to store the command
102// and its intermediates and prefixes. The command byte is always the least
103// significant byte i.e. [Cmd & 0xff]. Use the [Cmd] type to unpack the
104// command, intermediate, and prefix bytes. Note that we only collect the last
105// prefix character and intermediate byte.
106//
107// The [p.Params] slice will contain the parameters of the sequence. Any
108// sub-parameter will have the [parser.HasMoreFlag] set. Use the [Param] type
109// to unpack the parameters.
110//
111// Example:
112//
113// var state byte // the initial state is always zero [NormalState]
114// p := NewParser(32, 1024) // create a new parser with a 32 params buffer and 1024 data buffer (optional)
115// input := []byte("\x1b[31mHello, World!\x1b[0m")
116// for len(input) > 0 {
117// seq, width, n, newState := DecodeSequence(input, state, p)
118// log.Printf("seq: %q, width: %d", seq, width)
119// state = newState
120// input = input[n:]
121// }
122func (m Method) DecodeSequence(data []byte, state byte, p *Parser) (seq []byte, width, n int, newState byte) {
123 return decodeSequence(m, data, state, p)
124}
125
126// DecodeSequenceInString decodes the first ANSI escape sequence or a printable
127// grapheme from the given data. It returns the sequence slice, the number of
128// bytes read, the cell width for each sequence, and the new state.
129//
130// The cell width will always be 0 for control and escape sequences, 1 for
131// ASCII printable characters, and the number of cells other Unicode characters
132// occupy. It uses the uniseg package to calculate the width of Unicode
133// graphemes and characters. This means it will always do grapheme clustering
134// (mode 2027).
135//
136// Passing a non-nil [*Parser] as the last argument will allow the decoder to
137// collect sequence parameters, data, and commands. The parser cmd will have
138// the packed command value that contains intermediate and prefix characters.
139// In the case of a OSC sequence, the cmd will be the OSC command number. Use
140// [Cmd] and [Param] types to unpack command intermediates and prefixes as well
141// as parameters.
142//
143// Zero [Cmd] means the CSI, DCS, or ESC sequence is invalid. Moreover, checking the
144// validity of other data sequences, OSC, DCS, etc, will require checking for
145// the returned sequence terminator bytes such as ST (ESC \\) and BEL).
146//
147// We store the command byte in [Cmd] in the most significant byte, the
148// prefix byte in the next byte, and the intermediate byte in the least
149// significant byte. This is done to avoid using a struct to store the command
150// and its intermediates and prefixes. The command byte is always the least
151// significant byte i.e. [Cmd & 0xff]. Use the [Cmd] type to unpack the
152// command, intermediate, and prefix bytes. Note that we only collect the last
153// prefix character and intermediate byte.
154//
155// The [p.Params] slice will contain the parameters of the sequence. Any
156// sub-parameter will have the [parser.HasMoreFlag] set. Use the [Param] type
157// to unpack the parameters.
158//
159// Example:
160//
161// var state byte // the initial state is always zero [NormalState]
162// p := NewParser(32, 1024) // create a new parser with a 32 params buffer and 1024 data buffer (optional)
163// input := []byte("\x1b[31mHello, World!\x1b[0m")
164// for len(input) > 0 {
165// seq, width, n, newState := DecodeSequenceInString(input, state, p)
166// log.Printf("seq: %q, width: %d", seq, width)
167// state = newState
168// input = input[n:]
169// }
170func (m Method) DecodeSequenceInString(data string, state byte, p *Parser) (seq string, width, n int, newState byte) {
171 return decodeSequence(m, data, state, p)
172}
vendor/github.com/charmbracelet/x/ansi/mode.go +626 −16
@@ -1,109 +1,677 @@
11package ansi
22
3// This file define uses multiple sequences to set (SM), reset (RM), and request
4// (DECRQM) different ANSI and DEC modes.
3import (
4 "strconv"
5 "strings"
6)
7
8// ModeSetting represents a mode setting.
9type ModeSetting byte
10
11// ModeSetting constants.
12const (
13 ModeNotRecognized ModeSetting = iota
14 ModeSet
15 ModeReset
16 ModePermanentlySet
17 ModePermanentlyReset
18)
19
20// IsNotRecognized returns true if the mode is not recognized.
21func (m ModeSetting) IsNotRecognized() bool {
22 return m == ModeNotRecognized
23}
24
25// IsSet returns true if the mode is set or permanently set.
26func (m ModeSetting) IsSet() bool {
27 return m == ModeSet || m == ModePermanentlySet
28}
29
30// IsReset returns true if the mode is reset or permanently reset.
31func (m ModeSetting) IsReset() bool {
32 return m == ModeReset || m == ModePermanentlyReset
33}
34
35// IsPermanentlySet returns true if the mode is permanently set.
36func (m ModeSetting) IsPermanentlySet() bool {
37 return m == ModePermanentlySet
38}
39
40// IsPermanentlyReset returns true if the mode is permanently reset.
41func (m ModeSetting) IsPermanentlyReset() bool {
42 return m == ModePermanentlyReset
43}
44
45// Mode represents an interface for terminal modes.
46// Modes can be set, reset, and requested.
47type Mode interface {
48 Mode() int
49}
50
51// SetMode (SM) returns a sequence to set a mode.
52// The mode arguments are a list of modes to set.
53//
54// If one of the modes is a [DECMode], the function will returns two escape
55// sequences.
56//
57// ANSI format:
58//
59// CSI Pd ; ... ; Pd h
60//
61// DEC format:
62//
63// CSI ? Pd ; ... ; Pd h
564//
665// See: https://vt100.net/docs/vt510-rm/SM.html
66func SetMode(modes ...Mode) string {
67 return setMode(false, modes...)
68}
69
70// SM is an alias for [SetMode].
71func SM(modes ...Mode) string {
72 return SetMode(modes...)
73}
74
75// ResetMode (RM) returns a sequence to reset a mode.
76// The mode arguments are a list of modes to reset.
77//
78// If one of the modes is a [DECMode], the function will returns two escape
79// sequences.
80//
81// ANSI format:
82//
83// CSI Pd ; ... ; Pd l
84//
85// DEC format:
86//
87// CSI ? Pd ; ... ; Pd l
88//
789// See: https://vt100.net/docs/vt510-rm/RM.html
8// See: https://vt100.net/docs/vt510-rm/DECRQM.html
90func ResetMode(modes ...Mode) string {
91 return setMode(true, modes...)
92}
93
94// RM is an alias for [ResetMode].
95func RM(modes ...Mode) string {
96 return ResetMode(modes...)
97}
98
99func setMode(reset bool, modes ...Mode) (s string) {
100 if len(modes) == 0 {
101 return
102 }
103
104 cmd := "h"
105 if reset {
106 cmd = "l"
107 }
108
109 seq := "\x1b["
110 if len(modes) == 1 {
111 switch modes[0].(type) {
112 case DECMode:
113 seq += "?"
114 }
115 return seq + strconv.Itoa(modes[0].Mode()) + cmd
116 }
117
118 dec := make([]string, 0, len(modes)/2)
119 ansi := make([]string, 0, len(modes)/2)
120 for _, m := range modes {
121 switch m.(type) {
122 case DECMode:
123 dec = append(dec, strconv.Itoa(m.Mode()))
124 case ANSIMode:
125 ansi = append(ansi, strconv.Itoa(m.Mode()))
126 }
127 }
128
129 if len(ansi) > 0 {
130 s += seq + strings.Join(ansi, ";") + cmd
131 }
132 if len(dec) > 0 {
133 s += seq + "?" + strings.Join(dec, ";") + cmd
134 }
135 return
136}
137
138// RequestMode (DECRQM) returns a sequence to request a mode from the terminal.
139// The terminal responds with a report mode function [DECRPM].
9140//
10// The terminal then responds to the request with a Report Mode function
11// (DECRPM) in the format:
141// ANSI format:
142//
143// CSI Pa $ p
144//
145// DEC format:
146//
147// CSI ? Pa $ p
148//
149// See: https://vt100.net/docs/vt510-rm/DECRQM.html
150func RequestMode(m Mode) string {
151 seq := "\x1b["
152 switch m.(type) {
153 case DECMode:
154 seq += "?"
155 }
156 return seq + strconv.Itoa(m.Mode()) + "$p"
157}
158
159// DECRQM is an alias for [RequestMode].
160func DECRQM(m Mode) string {
161 return RequestMode(m)
162}
163
164// ReportMode (DECRPM) returns a sequence that the terminal sends to the host
165// in response to a mode request [DECRQM].
12166//
13167// ANSI format:
14168//
15// CSI Pa ; Ps ; $ y
169// CSI Pa ; Ps ; $ y
16170//
17171// DEC format:
18172//
19// CSI ? Pa ; Ps $ y
173// CSI ? Pa ; Ps $ y
20174//
21175// Where Pa is the mode number, and Ps is the mode value.
176//
177// 0: Not recognized
178// 1: Set
179// 2: Reset
180// 3: Permanent set
181// 4: Permanent reset
182//
22183// See: https://vt100.net/docs/vt510-rm/DECRPM.html
184func ReportMode(mode Mode, value ModeSetting) string {
185 if value > 4 {
186 value = 0
187 }
188 switch mode.(type) {
189 case DECMode:
190 return "\x1b[?" + strconv.Itoa(mode.Mode()) + ";" + strconv.Itoa(int(value)) + "$y"
191 }
192 return "\x1b[" + strconv.Itoa(mode.Mode()) + ";" + strconv.Itoa(int(value)) + "$y"
193}
194
195// DECRPM is an alias for [ReportMode].
196func DECRPM(mode Mode, value ModeSetting) string {
197 return ReportMode(mode, value)
198}
199
200// ANSIMode represents an ANSI terminal mode.
201type ANSIMode int //nolint:revive
202
203// Mode returns the ANSI mode as an integer.
204func (m ANSIMode) Mode() int {
205 return int(m)
206}
207
208// DECMode represents a private DEC terminal mode.
209type DECMode int
23210
24// Application Cursor Keys (DECCKM) is a mode that determines whether the
25// cursor keys send ANSI cursor sequences or application sequences.
211// Mode returns the DEC mode as an integer.
212func (m DECMode) Mode() int {
213 return int(m)
214}
215
216// Keyboard Action Mode (KAM) is a mode that controls locking of the keyboard.
217// When the keyboard is locked, it cannot send data to the terminal.
218//
219// See: https://vt100.net/docs/vt510-rm/KAM.html
220const (
221 KeyboardActionMode = ANSIMode(2)
222 KAM = KeyboardActionMode
223
224 SetKeyboardActionMode = "\x1b[2h"
225 ResetKeyboardActionMode = "\x1b[2l"
226 RequestKeyboardActionMode = "\x1b[2$p"
227)
228
229// Insert/Replace Mode (IRM) is a mode that determines whether characters are
230// inserted or replaced when typed.
231//
232// When enabled, characters are inserted at the cursor position pushing the
233// characters to the right. When disabled, characters replace the character at
234// the cursor position.
235//
236// See: https://vt100.net/docs/vt510-rm/IRM.html
237const (
238 InsertReplaceMode = ANSIMode(4)
239 IRM = InsertReplaceMode
240
241 SetInsertReplaceMode = "\x1b[4h"
242 ResetInsertReplaceMode = "\x1b[4l"
243 RequestInsertReplaceMode = "\x1b[4$p"
244)
245
246// Send Receive Mode (SRM) or Local Echo Mode is a mode that determines whether
247// the terminal echoes characters back to the host. When enabled, the terminal
248// sends characters to the host as they are typed.
249//
250// See: https://vt100.net/docs/vt510-rm/SRM.html
251const (
252 SendReceiveMode = ANSIMode(12)
253 LocalEchoMode = SendReceiveMode
254 SRM = SendReceiveMode
255
256 SetSendReceiveMode = "\x1b[12h"
257 ResetSendReceiveMode = "\x1b[12l"
258 RequestSendReceiveMode = "\x1b[12$p"
259
260 SetLocalEchoMode = "\x1b[12h"
261 ResetLocalEchoMode = "\x1b[12l"
262 RequestLocalEchoMode = "\x1b[12$p"
263)
264
265// Line Feed/New Line Mode (LNM) is a mode that determines whether the terminal
266// interprets the line feed character as a new line.
267//
268// When enabled, the terminal interprets the line feed character as a new line.
269// When disabled, the terminal interprets the line feed character as a line feed.
270//
271// A new line moves the cursor to the first position of the next line.
272// A line feed moves the cursor down one line without changing the column
273// scrolling the screen if necessary.
274//
275// See: https://vt100.net/docs/vt510-rm/LNM.html
276const (
277 LineFeedNewLineMode = ANSIMode(20)
278 LNM = LineFeedNewLineMode
279
280 SetLineFeedNewLineMode = "\x1b[20h"
281 ResetLineFeedNewLineMode = "\x1b[20l"
282 RequestLineFeedNewLineMode = "\x1b[20$p"
283)
284
285// Cursor Keys Mode (DECCKM) is a mode that determines whether the cursor keys
286// send ANSI cursor sequences or application sequences.
26287//
27288// See: https://vt100.net/docs/vt510-rm/DECCKM.html
289const (
290 CursorKeysMode = DECMode(1)
291 DECCKM = CursorKeysMode
292
293 SetCursorKeysMode = "\x1b[?1h"
294 ResetCursorKeysMode = "\x1b[?1l"
295 RequestCursorKeysMode = "\x1b[?1$p"
296)
297
298// Deprecated: use [SetCursorKeysMode] and [ResetCursorKeysMode] instead.
28299const (
29300 EnableCursorKeys = "\x1b[?1h"
30301 DisableCursorKeys = "\x1b[?1l"
31 RequestCursorKeys = "\x1b[?1$p"
302)
303
304// Origin Mode (DECOM) is a mode that determines whether the cursor moves to the
305// home position or the margin position.
306//
307// See: https://vt100.net/docs/vt510-rm/DECOM.html
308const (
309 OriginMode = DECMode(6)
310 DECOM = OriginMode
311
312 SetOriginMode = "\x1b[?6h"
313 ResetOriginMode = "\x1b[?6l"
314 RequestOriginMode = "\x1b[?6$p"
315)
316
317// Auto Wrap Mode (DECAWM) is a mode that determines whether the cursor wraps
318// to the next line when it reaches the right margin.
319//
320// See: https://vt100.net/docs/vt510-rm/DECAWM.html
321const (
322 AutoWrapMode = DECMode(7)
323 DECAWM = AutoWrapMode
324
325 SetAutoWrapMode = "\x1b[?7h"
326 ResetAutoWrapMode = "\x1b[?7l"
327 RequestAutoWrapMode = "\x1b[?7$p"
328)
329
330// X10 Mouse Mode is a mode that determines whether the mouse reports on button
331// presses.
332//
333// The terminal responds with the following encoding:
334//
335// CSI M CbCxCy
336//
337// Where Cb is the button-1, where it can be 1, 2, or 3.
338// Cx and Cy are the x and y coordinates of the mouse event.
339//
340// See: https://invisible-island.net/xterm/ctlseqs/ctlseqs.html#h2-Mouse-Tracking
341const (
342 X10MouseMode = DECMode(9)
343
344 SetX10MouseMode = "\x1b[?9h"
345 ResetX10MouseMode = "\x1b[?9l"
346 RequestX10MouseMode = "\x1b[?9$p"
32347)
33348
34349// Text Cursor Enable Mode (DECTCEM) is a mode that shows/hides the cursor.
35350//
36351// See: https://vt100.net/docs/vt510-rm/DECTCEM.html
37352const (
38 ShowCursor = "\x1b[?25h"
39 HideCursor = "\x1b[?25l"
353 TextCursorEnableMode = DECMode(25)
354 DECTCEM = TextCursorEnableMode
355
356 SetTextCursorEnableMode = "\x1b[?25h"
357 ResetTextCursorEnableMode = "\x1b[?25l"
358 RequestTextCursorEnableMode = "\x1b[?25$p"
359)
360
361// These are aliases for [SetTextCursorEnableMode] and [ResetTextCursorEnableMode].
362const (
363 ShowCursor = SetTextCursorEnableMode
364 HideCursor = ResetTextCursorEnableMode
365)
366
367// Text Cursor Enable Mode (DECTCEM) is a mode that shows/hides the cursor.
368//
369// See: https://vt100.net/docs/vt510-rm/DECTCEM.html
370//
371// Deprecated: use [SetTextCursorEnableMode] and [ResetTextCursorEnableMode] instead.
372const (
373 CursorEnableMode = DECMode(25)
40374 RequestCursorVisibility = "\x1b[?25$p"
41375)
42376
377// Numeric Keypad Mode (DECNKM) is a mode that determines whether the keypad
378// sends application sequences or numeric sequences.
379//
380// This works like [DECKPAM] and [DECKPNM], but uses different sequences.
381//
382// See: https://vt100.net/docs/vt510-rm/DECNKM.html
383const (
384 NumericKeypadMode = DECMode(66)
385 DECNKM = NumericKeypadMode
386
387 SetNumericKeypadMode = "\x1b[?66h"
388 ResetNumericKeypadMode = "\x1b[?66l"
389 RequestNumericKeypadMode = "\x1b[?66$p"
390)
391
392// Backarrow Key Mode (DECBKM) is a mode that determines whether the backspace
393// key sends a backspace or delete character. Disabled by default.
394//
395// See: https://vt100.net/docs/vt510-rm/DECBKM.html
396const (
397 BackarrowKeyMode = DECMode(67)
398 DECBKM = BackarrowKeyMode
399
400 SetBackarrowKeyMode = "\x1b[?67h"
401 ResetBackarrowKeyMode = "\x1b[?67l"
402 RequestBackarrowKeyMode = "\x1b[?67$p"
403)
404
405// Left Right Margin Mode (DECLRMM) is a mode that determines whether the left
406// and right margins can be set with [DECSLRM].
407//
408// See: https://vt100.net/docs/vt510-rm/DECLRMM.html
409const (
410 LeftRightMarginMode = DECMode(69)
411 DECLRMM = LeftRightMarginMode
412
413 SetLeftRightMarginMode = "\x1b[?69h"
414 ResetLeftRightMarginMode = "\x1b[?69l"
415 RequestLeftRightMarginMode = "\x1b[?69$p"
416)
417
418// Normal Mouse Mode is a mode that determines whether the mouse reports on
419// button presses and releases. It will also report modifier keys, wheel
420// events, and extra buttons.
421//
422// It uses the same encoding as [X10MouseMode] with a few differences:
423//
424// See: https://invisible-island.net/xterm/ctlseqs/ctlseqs.html#h2-Mouse-Tracking
425const (
426 NormalMouseMode = DECMode(1000)
427
428 SetNormalMouseMode = "\x1b[?1000h"
429 ResetNormalMouseMode = "\x1b[?1000l"
430 RequestNormalMouseMode = "\x1b[?1000$p"
431)
432
43433// VT Mouse Tracking is a mode that determines whether the mouse reports on
44434// button press and release.
45435//
46436// See: https://invisible-island.net/xterm/ctlseqs/ctlseqs.html#h2-Mouse-Tracking
437//
438// Deprecated: use [NormalMouseMode] instead.
47439const (
440 MouseMode = DECMode(1000)
441
48442 EnableMouse = "\x1b[?1000h"
49443 DisableMouse = "\x1b[?1000l"
50444 RequestMouse = "\x1b[?1000$p"
51445)
52446
447// Highlight Mouse Tracking is a mode that determines whether the mouse reports
448// on button presses, releases, and highlighted cells.
449//
450// It uses the same encoding as [NormalMouseMode] with a few differences:
451//
452// On highlight events, the terminal responds with the following encoding:
453//
454// CSI t CxCy
455// CSI T CxCyCxCyCxCy
456//
457// Where the parameters are startx, starty, endx, endy, mousex, and mousey.
458const (
459 HighlightMouseMode = DECMode(1001)
460
461 SetHighlightMouseMode = "\x1b[?1001h"
462 ResetHighlightMouseMode = "\x1b[?1001l"
463 RequestHighlightMouseMode = "\x1b[?1001$p"
464)
465
53466// VT Hilite Mouse Tracking is a mode that determines whether the mouse reports on
54467// button presses, releases, and highlighted cells.
55468//
56469// See: https://invisible-island.net/xterm/ctlseqs/ctlseqs.html#h2-Mouse-Tracking
470//
471// Deprecated: use [HighlightMouseMode] instead.
57472const (
473 MouseHiliteMode = DECMode(1001)
474
58475 EnableMouseHilite = "\x1b[?1001h"
59476 DisableMouseHilite = "\x1b[?1001l"
60477 RequestMouseHilite = "\x1b[?1001$p"
61478)
62479
480// Button Event Mouse Tracking is essentially the same as [NormalMouseMode],
481// but it also reports button-motion events when a button is pressed.
482//
483// See: https://invisible-island.net/xterm/ctlseqs/ctlseqs.html#h2-Mouse-Tracking
484const (
485 ButtonEventMouseMode = DECMode(1002)
486
487 SetButtonEventMouseMode = "\x1b[?1002h"
488 ResetButtonEventMouseMode = "\x1b[?1002l"
489 RequestButtonEventMouseMode = "\x1b[?1002$p"
490)
491
63492// Cell Motion Mouse Tracking is a mode that determines whether the mouse
64493// reports on button press, release, and motion events.
65494//
66495// See: https://invisible-island.net/xterm/ctlseqs/ctlseqs.html#h2-Mouse-Tracking
496//
497// Deprecated: use [ButtonEventMouseMode] instead.
67498const (
499 MouseCellMotionMode = DECMode(1002)
500
68501 EnableMouseCellMotion = "\x1b[?1002h"
69502 DisableMouseCellMotion = "\x1b[?1002l"
70503 RequestMouseCellMotion = "\x1b[?1002$p"
71504)
72505
506// Any Event Mouse Tracking is the same as [ButtonEventMouseMode], except that
507// all motion events are reported even if no mouse buttons are pressed.
508//
509// See: https://invisible-island.net/xterm/ctlseqs/ctlseqs.html#h2-Mouse-Tracking
510const (
511 AnyEventMouseMode = DECMode(1003)
512
513 SetAnyEventMouseMode = "\x1b[?1003h"
514 ResetAnyEventMouseMode = "\x1b[?1003l"
515 RequestAnyEventMouseMode = "\x1b[?1003$p"
516)
517
73518// All Mouse Tracking is a mode that determines whether the mouse reports on
74519// button press, release, motion, and highlight events.
75520//
76521// See: https://invisible-island.net/xterm/ctlseqs/ctlseqs.html#h2-Mouse-Tracking
522//
523// Deprecated: use [AnyEventMouseMode] instead.
77524const (
525 MouseAllMotionMode = DECMode(1003)
526
78527 EnableMouseAllMotion = "\x1b[?1003h"
79528 DisableMouseAllMotion = "\x1b[?1003l"
80529 RequestMouseAllMotion = "\x1b[?1003$p"
81530)
82531
83// Report Focus is a mode that makes the terminal report focus-in and focus-out events.
532// Focus Event Mode is a mode that determines whether the terminal reports focus
533// and blur events.
534//
535// The terminal sends the following encoding:
84536//
85// See: https://invisible-island.net/xterm/ctlseqs/ctlseqs.html#h3-FocusIn_FocusOut
537// CSI I // Focus In
538// CSI O // Focus Out
539//
540// See: https://invisible-island.net/xterm/ctlseqs/ctlseqs.html#h2-Focus-Tracking
541const (
542 FocusEventMode = DECMode(1004)
543
544 SetFocusEventMode = "\x1b[?1004h"
545 ResetFocusEventMode = "\x1b[?1004l"
546 RequestFocusEventMode = "\x1b[?1004$p"
547)
548
549// Deprecated: use [SetFocusEventMode], [ResetFocusEventMode], and
550// [RequestFocusEventMode] instead.
86551const (
552 ReportFocusMode = DECMode(1004)
553
87554 EnableReportFocus = "\x1b[?1004h"
88555 DisableReportFocus = "\x1b[?1004l"
89556 RequestReportFocus = "\x1b[?1004$p"
90557)
91558
92// SGR Mouse Extension is a mode that determines whether the mouse reports events
93// formatted with SGR parameters.
559// SGR Extended Mouse Mode is a mode that changes the mouse tracking encoding
560// to use SGR parameters.
561//
562// The terminal responds with the following encoding:
563//
564// CSI < Cb ; Cx ; Cy M
565//
566// Where Cb is the same as [NormalMouseMode], and Cx and Cy are the x and y.
94567//
95568// See: https://invisible-island.net/xterm/ctlseqs/ctlseqs.html#h2-Mouse-Tracking
96569const (
570 SgrExtMouseMode = DECMode(1006)
571
572 SetSgrExtMouseMode = "\x1b[?1006h"
573 ResetSgrExtMouseMode = "\x1b[?1006l"
574 RequestSgrExtMouseMode = "\x1b[?1006$p"
575)
576
577// Deprecated: use [SgrExtMouseMode] [SetSgrExtMouseMode],
578// [ResetSgrExtMouseMode], and [RequestSgrExtMouseMode] instead.
579const (
580 MouseSgrExtMode = DECMode(1006)
97581 EnableMouseSgrExt = "\x1b[?1006h"
98582 DisableMouseSgrExt = "\x1b[?1006l"
99583 RequestMouseSgrExt = "\x1b[?1006$p"
100584)
101585
586// UTF-8 Extended Mouse Mode is a mode that changes the mouse tracking encoding
587// to use UTF-8 parameters.
588//
589// See: https://invisible-island.net/xterm/ctlseqs/ctlseqs.html#h2-Mouse-Tracking
590const (
591 Utf8ExtMouseMode = DECMode(1005)
592
593 SetUtf8ExtMouseMode = "\x1b[?1005h"
594 ResetUtf8ExtMouseMode = "\x1b[?1005l"
595 RequestUtf8ExtMouseMode = "\x1b[?1005$p"
596)
597
598// URXVT Extended Mouse Mode is a mode that changes the mouse tracking encoding
599// to use an alternate encoding.
600//
601// See: https://invisible-island.net/xterm/ctlseqs/ctlseqs.html#h2-Mouse-Tracking
602const (
603 UrxvtExtMouseMode = DECMode(1015)
604
605 SetUrxvtExtMouseMode = "\x1b[?1015h"
606 ResetUrxvtExtMouseMode = "\x1b[?1015l"
607 RequestUrxvtExtMouseMode = "\x1b[?1015$p"
608)
609
610// SGR Pixel Extended Mouse Mode is a mode that changes the mouse tracking
611// encoding to use SGR parameters with pixel coordinates.
612//
613// This is similar to [SgrExtMouseMode], but also reports pixel coordinates.
614//
615// See: https://invisible-island.net/xterm/ctlseqs/ctlseqs.html#h2-Mouse-Tracking
616const (
617 SgrPixelExtMouseMode = DECMode(1016)
618
619 SetSgrPixelExtMouseMode = "\x1b[?1016h"
620 ResetSgrPixelExtMouseMode = "\x1b[?1016l"
621 RequestSgrPixelExtMouseMode = "\x1b[?1016$p"
622)
623
624// Alternate Screen Mode is a mode that determines whether the alternate screen
625// buffer is active. When this mode is enabled, the alternate screen buffer is
626// cleared.
627//
628// See: https://invisible-island.net/xterm/ctlseqs/ctlseqs.html#h2-The-Alternate-Screen-Buffer
629const (
630 AltScreenMode = DECMode(1047)
631
632 SetAltScreenMode = "\x1b[?1047h"
633 ResetAltScreenMode = "\x1b[?1047l"
634 RequestAltScreenMode = "\x1b[?1047$p"
635)
636
637// Save Cursor Mode is a mode that saves the cursor position.
638// This is equivalent to [SaveCursor] and [RestoreCursor].
639//
640// See: https://invisible-island.net/xterm/ctlseqs/ctlseqs.html#h2-The-Alternate-Screen-Buffer
641const (
642 SaveCursorMode = DECMode(1048)
643
644 SetSaveCursorMode = "\x1b[?1048h"
645 ResetSaveCursorMode = "\x1b[?1048l"
646 RequestSaveCursorMode = "\x1b[?1048$p"
647)
648
649// Alternate Screen Save Cursor Mode is a mode that saves the cursor position as in
650// [SaveCursorMode], switches to the alternate screen buffer as in [AltScreenMode],
651// and clears the screen on switch.
652//
653// See: https://invisible-island.net/xterm/ctlseqs/ctlseqs.html#h2-The-Alternate-Screen-Buffer
654const (
655 AltScreenSaveCursorMode = DECMode(1049)
656
657 SetAltScreenSaveCursorMode = "\x1b[?1049h"
658 ResetAltScreenSaveCursorMode = "\x1b[?1049l"
659 RequestAltScreenSaveCursorMode = "\x1b[?1049$p"
660)
661
102662// Alternate Screen Buffer is a mode that determines whether the alternate screen
103663// buffer is active.
104664//
105665// See: https://invisible-island.net/xterm/ctlseqs/ctlseqs.html#h2-The-Alternate-Screen-Buffer
666//
667// Deprecated: use [AltScreenSaveCursorMode] instead.
106668const (
669 AltScreenBufferMode = DECMode(1049)
670
671 SetAltScreenBufferMode = "\x1b[?1049h"
672 ResetAltScreenBufferMode = "\x1b[?1049l"
673 RequestAltScreenBufferMode = "\x1b[?1049$p"
674
107675 EnableAltScreenBuffer = "\x1b[?1049h"
108676 DisableAltScreenBuffer = "\x1b[?1049l"
109677 RequestAltScreenBuffer = "\x1b[?1049$p"
@@ -114,6 +682,16 @@ const (
114682//
115683// See: https://cirw.in/blog/bracketed-paste
116684// See: https://invisible-island.net/xterm/ctlseqs/ctlseqs.html#h2-Bracketed-Paste-Mode
685const (
686 BracketedPasteMode = DECMode(2004)
687
688 SetBracketedPasteMode = "\x1b[?2004h"
689 ResetBracketedPasteMode = "\x1b[?2004l"
690 RequestBracketedPasteMode = "\x1b[?2004$p"
691)
692
693// Deprecated: use [SetBracketedPasteMode], [ResetBracketedPasteMode], and
694// [RequestBracketedPasteMode] instead.
117695const (
118696 EnableBracketedPaste = "\x1b[?2004h"
119697 DisableBracketedPaste = "\x1b[?2004l"
@@ -125,6 +703,18 @@ const (
125703//
126704// See: https://gist.github.com/christianparpart/d8a62cc1ab659194337d73e399004036
127705const (
706 SynchronizedOutputMode = DECMode(2026)
707
708 SetSynchronizedOutputMode = "\x1b[?2026h"
709 ResetSynchronizedOutputMode = "\x1b[?2026l"
710 RequestSynchronizedOutputMode = "\x1b[?2026$p"
711)
712
713// Deprecated: use [SynchronizedOutputMode], [SetSynchronizedOutputMode], and
714// [ResetSynchronizedOutputMode], and [RequestSynchronizedOutputMode] instead.
715const (
716 SyncdOutputMode = DECMode(2026)
717
128718 EnableSyncdOutput = "\x1b[?2026h"
129719 DisableSyncdOutput = "\x1b[?2026l"
130720 RequestSyncdOutput = "\x1b[?2026$p"
@@ -136,6 +726,16 @@ const (
136726// emojis.
137727//
138728// See: https://github.com/contour-terminal/terminal-unicode-core
729const (
730 GraphemeClusteringMode = DECMode(2027)
731
732 SetGraphemeClusteringMode = "\x1b[?2027h"
733 ResetGraphemeClusteringMode = "\x1b[?2027l"
734 RequestGraphemeClusteringMode = "\x1b[?2027$p"
735)
736
737// Deprecated: use [SetGraphemeClusteringMode], [ResetGraphemeClusteringMode], and
738// [RequestGraphemeClusteringMode] instead.
139739const (
140740 EnableGraphemeClustering = "\x1b[?2027h"
141741 DisableGraphemeClustering = "\x1b[?2027l"
@@ -146,6 +746,16 @@ const (
146746// Win32 console and Conpty.
147747//
148748// See: https://github.com/microsoft/terminal/blob/main/doc/specs/%234999%20-%20Improved%20keyboard%20handling%20in%20Conpty.md
749const (
750 Win32InputMode = DECMode(9001)
751
752 SetWin32InputMode = "\x1b[?9001h"
753 ResetWin32InputMode = "\x1b[?9001l"
754 RequestWin32InputMode = "\x1b[?9001$p"
755)
756
757// Deprecated: use [SetWin32InputMode], [ResetWin32InputMode], and
758// [RequestWin32InputMode] instead.
149759const (
150760 EnableWin32Input = "\x1b[?9001h"
151761 DisableWin32Input = "\x1b[?9001l"
vendor/github.com/charmbracelet/x/ansi/modes.go added +71
@@ -0,0 +1,71 @@
1package ansi
2
3// Modes represents the terminal modes that can be set or reset. By default,
4// all modes are [ModeNotRecognized].
5type Modes map[Mode]ModeSetting
6
7// NewModes creates a new Modes map. By default, all modes are
8// [ModeNotRecognized].
9func NewModes() Modes {
10 return make(Modes)
11}
12
13// Get returns the setting of a terminal mode. If the mode is not set, it
14// returns [ModeNotRecognized].
15func (m Modes) Get(mode Mode) ModeSetting {
16 return m[mode]
17}
18
19// Delete deletes a terminal mode. This has the same effect as setting the mode
20// to [ModeNotRecognized].
21func (m Modes) Delete(mode Mode) {
22 delete(m, mode)
23}
24
25// Set sets a terminal mode to [ModeSet].
26func (m Modes) Set(modes ...Mode) {
27 for _, mode := range modes {
28 m[mode] = ModeSet
29 }
30}
31
32// PermanentlySet sets a terminal mode to [ModePermanentlySet].
33func (m Modes) PermanentlySet(modes ...Mode) {
34 for _, mode := range modes {
35 m[mode] = ModePermanentlySet
36 }
37}
38
39// Reset sets a terminal mode to [ModeReset].
40func (m Modes) Reset(modes ...Mode) {
41 for _, mode := range modes {
42 m[mode] = ModeReset
43 }
44}
45
46// PermanentlyReset sets a terminal mode to [ModePermanentlyReset].
47func (m Modes) PermanentlyReset(modes ...Mode) {
48 for _, mode := range modes {
49 m[mode] = ModePermanentlyReset
50 }
51}
52
53// IsSet returns true if the mode is set to [ModeSet] or [ModePermanentlySet].
54func (m Modes) IsSet(mode Mode) bool {
55 return m[mode].IsSet()
56}
57
58// IsPermanentlySet returns true if the mode is set to [ModePermanentlySet].
59func (m Modes) IsPermanentlySet(mode Mode) bool {
60 return m[mode].IsPermanentlySet()
61}
62
63// IsReset returns true if the mode is set to [ModeReset] or [ModePermanentlyReset].
64func (m Modes) IsReset(mode Mode) bool {
65 return m[mode].IsReset()
66}
67
68// IsPermanentlyReset returns true if the mode is set to [ModePermanentlyReset].
69func (m Modes) IsPermanentlyReset(mode Mode) bool {
70 return m[mode].IsPermanentlyReset()
71}
vendor/github.com/charmbracelet/x/ansi/mouse.go added +172
@@ -0,0 +1,172 @@
1package ansi
2
3import (
4 "fmt"
5)
6
7// MouseButton represents the button that was pressed during a mouse message.
8type MouseButton byte
9
10// Mouse event buttons
11//
12// This is based on X11 mouse button codes.
13//
14// 1 = left button
15// 2 = middle button (pressing the scroll wheel)
16// 3 = right button
17// 4 = turn scroll wheel up
18// 5 = turn scroll wheel down
19// 6 = push scroll wheel left
20// 7 = push scroll wheel right
21// 8 = 4th button (aka browser backward button)
22// 9 = 5th button (aka browser forward button)
23// 10
24// 11
25//
26// Other buttons are not supported.
27const (
28 MouseNone MouseButton = iota
29 MouseButton1
30 MouseButton2
31 MouseButton3
32 MouseButton4
33 MouseButton5
34 MouseButton6
35 MouseButton7
36 MouseButton8
37 MouseButton9
38 MouseButton10
39 MouseButton11
40
41 MouseLeft = MouseButton1
42 MouseMiddle = MouseButton2
43 MouseRight = MouseButton3
44 MouseWheelUp = MouseButton4
45 MouseWheelDown = MouseButton5
46 MouseWheelLeft = MouseButton6
47 MouseWheelRight = MouseButton7
48 MouseBackward = MouseButton8
49 MouseForward = MouseButton9
50 MouseRelease = MouseNone
51)
52
53var mouseButtons = map[MouseButton]string{
54 MouseNone: "none",
55 MouseLeft: "left",
56 MouseMiddle: "middle",
57 MouseRight: "right",
58 MouseWheelUp: "wheelup",
59 MouseWheelDown: "wheeldown",
60 MouseWheelLeft: "wheelleft",
61 MouseWheelRight: "wheelright",
62 MouseBackward: "backward",
63 MouseForward: "forward",
64 MouseButton10: "button10",
65 MouseButton11: "button11",
66}
67
68// String returns a string representation of the mouse button.
69func (b MouseButton) String() string {
70 return mouseButtons[b]
71}
72
73// EncodeMouseButton returns a byte representing a mouse button.
74// The button is a bitmask of the following leftmost values:
75//
76// - The first two bits are the button number:
77// 0 = left button, wheel up, or button no. 8 aka (backwards)
78// 1 = middle button, wheel down, or button no. 9 aka (forwards)
79// 2 = right button, wheel left, or button no. 10
80// 3 = release event, wheel right, or button no. 11
81//
82// - The third bit indicates whether the shift key was pressed.
83//
84// - The fourth bit indicates the alt key was pressed.
85//
86// - The fifth bit indicates the control key was pressed.
87//
88// - The sixth bit indicates motion events. Combined with button number 3, i.e.
89// release event, it represents a drag event.
90//
91// - The seventh bit indicates a wheel event.
92//
93// - The eighth bit indicates additional buttons.
94//
95// If button is [MouseNone], and motion is false, this returns a release event.
96// If button is undefined, this function returns 0xff.
97func EncodeMouseButton(b MouseButton, motion, shift, alt, ctrl bool) (m byte) {
98 // mouse bit shifts
99 const (
100 bitShift = 0b0000_0100
101 bitAlt = 0b0000_1000
102 bitCtrl = 0b0001_0000
103 bitMotion = 0b0010_0000
104 bitWheel = 0b0100_0000
105 bitAdd = 0b1000_0000 // additional buttons 8-11
106
107 bitsMask = 0b0000_0011
108 )
109
110 if b == MouseNone {
111 m = bitsMask
112 } else if b >= MouseLeft && b <= MouseRight {
113 m = byte(b - MouseLeft)
114 } else if b >= MouseWheelUp && b <= MouseWheelRight {
115 m = byte(b - MouseWheelUp)
116 m |= bitWheel
117 } else if b >= MouseBackward && b <= MouseButton11 {
118 m = byte(b - MouseBackward)
119 m |= bitAdd
120 } else {
121 m = 0xff // invalid button
122 }
123
124 if shift {
125 m |= bitShift
126 }
127 if alt {
128 m |= bitAlt
129 }
130 if ctrl {
131 m |= bitCtrl
132 }
133 if motion {
134 m |= bitMotion
135 }
136
137 return
138}
139
140// x10Offset is the offset for X10 mouse events.
141// See https://invisible-island.net/xterm/ctlseqs/ctlseqs.html#Mouse%20Tracking
142const x10Offset = 32
143
144// MouseX10 returns an escape sequence representing a mouse event in X10 mode.
145// Note that this requires the terminal support X10 mouse modes.
146//
147// CSI M Cb Cx Cy
148//
149// See: https://invisible-island.net/xterm/ctlseqs/ctlseqs.html#Mouse%20Tracking
150func MouseX10(b byte, x, y int) string {
151 return "\x1b[M" + string(b+x10Offset) + string(byte(x)+x10Offset+1) + string(byte(y)+x10Offset+1)
152}
153
154// MouseSgr returns an escape sequence representing a mouse event in SGR mode.
155//
156// CSI < Cb ; Cx ; Cy M
157// CSI < Cb ; Cx ; Cy m (release)
158//
159// See: https://invisible-island.net/xterm/ctlseqs/ctlseqs.html#Mouse%20Tracking
160func MouseSgr(b byte, x, y int, release bool) string {
161 s := 'M'
162 if release {
163 s = 'm'
164 }
165 if x < 0 {
166 x = -x
167 }
168 if y < 0 {
169 y = -y
170 }
171 return fmt.Sprintf("\x1b[<%d;%d;%d%c", b, x+1, y+1, s)
172}
vendor/github.com/charmbracelet/x/ansi/notification.go added +13
@@ -0,0 +1,13 @@
1package ansi
2
3// Notify sends a desktop notification using iTerm's OSC 9.
4//
5// OSC 9 ; Mc ST
6// OSC 9 ; Mc BEL
7//
8// Where Mc is the notification body.
9//
10// See: https://iterm2.com/documentation-escape-codes.html
11func Notify(s string) string {
12 return "\x1b]9;" + s + "\x07"
13}
vendor/github.com/charmbracelet/x/ansi/osc.go deleted −69
@@ -1,69 +0,0 @@
1package ansi
2
3import (
4 "bytes"
5 "strings"
6)
7
8// OscSequence represents an OSC sequence.
9//
10// The sequence starts with a OSC sequence, OSC (0x9D) in a 8-bit environment
11// or ESC ] (0x1B 0x5D) in a 7-bit environment, followed by positive integer identifier,
12// then by arbitrary data terminated by a ST (0x9C) in a 8-bit environment,
13// ESC \ (0x1B 0x5C) in a 7-bit environment, or BEL (0x07) for backwards compatibility.
14//
15// OSC Ps ; Pt ST
16// OSC Ps ; Pt BEL
17//
18// See ECMA-48 § 5.7.
19type OscSequence struct {
20 // Data contains the raw data of the sequence including the identifier
21 // command.
22 Data []byte
23
24 // Cmd contains the raw command of the sequence.
25 Cmd int
26}
27
28var _ Sequence = OscSequence{}
29
30// Command returns the command of the OSC sequence.
31func (s OscSequence) Command() int {
32 return s.Cmd
33}
34
35// Params returns the parameters of the OSC sequence split by ';'.
36// The first element is the identifier command.
37func (s OscSequence) Params() []string {
38 return strings.Split(string(s.Data), ";")
39}
40
41// Clone returns a copy of the OSC sequence.
42func (s OscSequence) Clone() Sequence {
43 return OscSequence{
44 Data: append([]byte(nil), s.Data...),
45 Cmd: s.Cmd,
46 }
47}
48
49// String returns the string representation of the OSC sequence.
50// To be more compatible with different terminal, this will always return a
51// 7-bit formatted sequence, terminated by BEL.
52func (s OscSequence) String() string {
53 return s.buffer().String()
54}
55
56// Bytes returns the byte representation of the OSC sequence.
57// To be more compatible with different terminal, this will always return a
58// 7-bit formatted sequence, terminated by BEL.
59func (s OscSequence) Bytes() []byte {
60 return s.buffer().Bytes()
61}
62
63func (s OscSequence) buffer() *bytes.Buffer {
64 var b bytes.Buffer
65 b.WriteString("\x1b]")
66 b.Write(s.Data)
67 b.WriteByte(BEL)
68 return &b
69}
vendor/github.com/charmbracelet/x/ansi/params.go deleted −45
@@ -1,45 +0,0 @@
1package ansi
2
3import (
4 "bytes"
5)
6
7// Params parses and returns a list of control sequence parameters.
8//
9// Parameters are positive integers separated by semicolons. Empty parameters
10// default to zero. Parameters can have sub-parameters separated by colons.
11//
12// Any non-parameter bytes are ignored. This includes bytes that are not in the
13// range of 0x30-0x3B.
14//
15// See ECMA-48 § 5.4.1.
16func Params(p []byte) [][]uint {
17 if len(p) == 0 {
18 return [][]uint{}
19 }
20
21 // Filter out non-parameter bytes i.e. non 0x30-0x3B.
22 p = bytes.TrimFunc(p, func(r rune) bool {
23 return r < 0x30 || r > 0x3B
24 })
25
26 parts := bytes.Split(p, []byte{';'})
27 params := make([][]uint, len(parts))
28 for i, part := range parts {
29 sparts := bytes.Split(part, []byte{':'})
30 params[i] = make([]uint, len(sparts))
31 for j, spart := range sparts {
32 params[i][j] = bytesToUint16(spart)
33 }
34 }
35
36 return params
37}
38
39func bytesToUint16(b []byte) uint {
40 var n uint
41 for _, c := range b {
42 n = n*10 + uint(c-'0')
43 }
44 return n
45}
vendor/github.com/charmbracelet/x/ansi/parser.go +215 −168
@@ -7,9 +7,6 @@ import (
77 "github.com/charmbracelet/x/ansi/parser"
88)
99
10// ParserDispatcher is a function that dispatches a sequence.
11type ParserDispatcher func(Sequence)
12
1310// Parser represents a DEC ANSI compatible sequence parser.
1411//
1512// It uses a state machine to parse ANSI escape sequences and control
@@ -20,137 +17,194 @@ type ParserDispatcher func(Sequence)
2017//
2118//go:generate go run ./gen.go
2219type Parser struct {
23 // Params contains the raw parameters of the sequence.
20 handler Handler
21
22 // params contains the raw parameters of the sequence.
2423 // These parameters used when constructing CSI and DCS sequences.
25 Params []int
24 params []int
2625
27 // Data contains the raw data of the sequence.
26 // data contains the raw data of the sequence.
2827 // These data used when constructing OSC, DCS, SOS, PM, and APC sequences.
29 Data []byte
28 data []byte
3029
31 // DataLen keeps track of the length of the data buffer.
32 // If DataLen is -1, the data buffer is unlimited and will grow as needed.
33 // Otherwise, DataLen is limited by the size of the Data buffer.
34 DataLen int
30 // dataLen keeps track of the length of the data buffer.
31 // If dataLen is -1, the data buffer is unlimited and will grow as needed.
32 // Otherwise, dataLen is limited by the size of the data buffer.
33 dataLen int
3534
36 // ParamsLen keeps track of the number of parameters.
37 // This is limited by the size of the Params buffer.
35 // paramsLen keeps track of the number of parameters.
36 // This is limited by the size of the params buffer.
3837 //
3938 // This is also used when collecting UTF-8 runes to keep track of the
4039 // number of rune bytes collected.
41 ParamsLen int
40 paramsLen int
4241
43 // Cmd contains the raw command along with the private marker and
42 // cmd contains the raw command along with the private prefix and
4443 // intermediate bytes of the sequence.
4544 // The first lower byte contains the command byte, the next byte contains
46 // the private marker, and the next byte contains the intermediate byte.
45 // the private prefix, and the next byte contains the intermediate byte.
4746 //
4847 // This is also used when collecting UTF-8 runes treating it as a slice of
4948 // 4 bytes.
50 Cmd int
49 cmd int
50
51 // state is the current state of the parser.
52 state byte
53}
54
55// NewParser returns a new parser with the default settings.
56// The [Parser] uses a default size of 32 for the parameters and 64KB for the
57// data buffer. Use [Parser.SetParamsSize] and [Parser.SetDataSize] to set the
58// size of the parameters and data buffer respectively.
59func NewParser() *Parser {
60 p := new(Parser)
61 p.SetParamsSize(parser.MaxParamsSize)
62 p.SetDataSize(1024 * 64) // 64KB data buffer
63 return p
64}
5165
52 // State is the current state of the parser.
53 State byte
66// SetParamsSize sets the size of the parameters buffer.
67// This is used when constructing CSI and DCS sequences.
68func (p *Parser) SetParamsSize(size int) {
69 p.params = make([]int, size)
5470}
5571
56// NewParser returns a new parser with the given sizes allocated.
57// If dataSize is zero, the underlying data buffer will be unlimited and will
72// SetDataSize sets the size of the data buffer.
73// This is used when constructing OSC, DCS, SOS, PM, and APC sequences.
74// If size is less than or equal to 0, the data buffer is unlimited and will
5875// grow as needed.
59func NewParser(paramsSize, dataSize int) *Parser {
60 s := new(Parser)
61 if dataSize <= 0 {
62 dataSize = 0
63 s.DataLen = -1
76func (p *Parser) SetDataSize(size int) {
77 if size <= 0 {
78 size = 0
79 p.dataLen = -1
6480 }
65 s.Params = make([]int, paramsSize)
66 s.Data = make([]byte, dataSize)
67 return s
81 p.data = make([]byte, size)
82}
83
84// Params returns the list of parsed packed parameters.
85func (p *Parser) Params() Params {
86 return unsafe.Slice((*Param)(unsafe.Pointer(&p.params[0])), p.paramsLen)
87}
88
89// Param returns the parameter at the given index and falls back to the default
90// value if the parameter is missing. If the index is out of bounds, it returns
91// the default value and false.
92func (p *Parser) Param(i, def int) (int, bool) {
93 if i < 0 || i >= p.paramsLen {
94 return def, false
95 }
96 return Param(p.params[i]).Param(def), true
97}
98
99// Command returns the packed command of the last dispatched sequence. Use
100// [Cmd] to unpack the command.
101func (p *Parser) Command() int {
102 return p.cmd
103}
104
105// Rune returns the last dispatched sequence as a rune.
106func (p *Parser) Rune() rune {
107 rw := utf8ByteLen(byte(p.cmd & 0xff))
108 if rw == -1 {
109 return utf8.RuneError
110 }
111 r, _ := utf8.DecodeRune((*[utf8.UTFMax]byte)(unsafe.Pointer(&p.cmd))[:rw])
112 return r
113}
114
115// Control returns the last dispatched sequence as a control code.
116func (p *Parser) Control() byte {
117 return byte(p.cmd & 0xff)
118}
119
120// Data returns the raw data of the last dispatched sequence.
121func (p *Parser) Data() []byte {
122 return p.data[:p.dataLen]
68123}
69124
70125// Reset resets the parser to its initial state.
71126func (p *Parser) Reset() {
72127 p.clear()
73 p.State = parser.GroundState
128 p.state = parser.GroundState
74129}
75130
76131// clear clears the parser parameters and command.
77132func (p *Parser) clear() {
78 if len(p.Params) > 0 {
79 p.Params[0] = parser.MissingParam
133 if len(p.params) > 0 {
134 p.params[0] = parser.MissingParam
80135 }
81 p.ParamsLen = 0
82 p.Cmd = 0
136 p.paramsLen = 0
137 p.cmd = 0
83138}
84139
85// clearCmd clears the parser command, params len and data len.
86func (p *Parser) clearCmd() {
87 p.Cmd = 0
88 p.ParamsLen = 0
89 p.DataLen = 0
140// State returns the current state of the parser.
141func (p *Parser) State() parser.State {
142 return p.state
90143}
91144
92145// StateName returns the name of the current state.
93146func (p *Parser) StateName() string {
94 return parser.StateNames[p.State]
147 return parser.StateNames[p.state]
95148}
96149
97150// Parse parses the given dispatcher and byte buffer.
98func (p *Parser) Parse(dispatcher ParserDispatcher, b []byte) {
151// Deprecated: Loop over the buffer and call [Parser.Advance] instead.
152func (p *Parser) Parse(b []byte) {
99153 for i := 0; i < len(b); i++ {
100 p.Advance(dispatcher, b[i], i < len(b)-1)
154 p.Advance(b[i])
101155 }
102156}
103157
104// Advance advances the parser with the given dispatcher and byte.
105func (p *Parser) Advance(dispatcher ParserDispatcher, b byte, more bool) parser.Action {
106 switch p.State {
158// Advance advances the parser using the given byte. It returns the action
159// performed by the parser.
160func (p *Parser) Advance(b byte) parser.Action {
161 switch p.state {
107162 case parser.Utf8State:
108163 // We handle UTF-8 here.
109 return p.advanceUtf8(dispatcher, b)
164 return p.advanceUtf8(b)
110165 default:
111 return p.advance(dispatcher, b, more)
166 return p.advance(b)
112167 }
113168}
114169
115170func (p *Parser) collectRune(b byte) {
116 if p.ParamsLen >= utf8.UTFMax {
171 if p.paramsLen >= utf8.UTFMax {
117172 return
118173 }
119174
120 shift := p.ParamsLen * 8
121 p.Cmd &^= 0xff << shift
122 p.Cmd |= int(b) << shift
123 p.ParamsLen++
175 shift := p.paramsLen * 8
176 p.cmd &^= 0xff << shift
177 p.cmd |= int(b) << shift
178 p.paramsLen++
124179}
125180
126func (p *Parser) advanceUtf8(dispatcher ParserDispatcher, b byte) parser.Action {
181func (p *Parser) advanceUtf8(b byte) parser.Action {
127182 // Collect UTF-8 rune bytes.
128183 p.collectRune(b)
129 rw := utf8ByteLen(byte(p.Cmd & 0xff))
184 rw := utf8ByteLen(byte(p.cmd & 0xff))
130185 if rw == -1 {
131186 // We panic here because the first byte comes from the state machine,
132187 // if this panics, it means there is a bug in the state machine!
133188 panic("invalid rune") // unreachable
134189 }
135190
136 if p.ParamsLen < rw {
191 if p.paramsLen < rw {
137192 return parser.CollectAction
138193 }
139194
140195 // We have enough bytes to decode the rune using unsafe
141 r, _ := utf8.DecodeRune((*[utf8.UTFMax]byte)(unsafe.Pointer(&p.Cmd))[:rw])
142 if dispatcher != nil {
143 dispatcher(Rune(r))
196 if p.handler.Print != nil {
197 p.handler.Print(p.Rune())
144198 }
145199
146 p.State = parser.GroundState
147 p.ParamsLen = 0
200 p.state = parser.GroundState
201 p.paramsLen = 0
148202
149203 return parser.PrintAction
150204}
151205
152func (p *Parser) advance(d ParserDispatcher, b byte, more bool) parser.Action {
153 state, action := parser.Table.Transition(p.State, b)
206func (p *Parser) advance(b byte) parser.Action {
207 state, action := parser.Table.Transition(p.state, b)
154208
155209 // We need to clear the parser state if the state changes from EscapeState.
156210 // This is because when we enter the EscapeState, we don't get a chance to
@@ -158,59 +212,53 @@ func (p *Parser) advance(d ParserDispatcher, b byte, more bool) parser.Action {
158212 // ST (\x1b\\ or \x9c), we dispatch the current sequence and transition to
159213 // EscapeState. However, the parser state is not cleared in this case and
160214 // we need to clear it here before dispatching the esc sequence.
161 if p.State != state {
162 if p.State == parser.EscapeState {
163 p.performAction(d, parser.ClearAction, state, b)
215 if p.state != state {
216 if p.state == parser.EscapeState {
217 p.performAction(parser.ClearAction, state, b)
164218 }
165219 if action == parser.PutAction &&
166 p.State == parser.DcsEntryState && state == parser.DcsStringState {
220 p.state == parser.DcsEntryState && state == parser.DcsStringState {
167221 // XXX: This is a special case where we need to start collecting
168222 // non-string parameterized data i.e. doesn't follow the ECMA-48 §
169223 // 5.4.1 string parameters format.
170 p.performAction(d, parser.StartAction, state, 0)
224 p.performAction(parser.StartAction, state, 0)
171225 }
172226 }
173227
174228 // Handle special cases
175229 switch {
176 case b == ESC && p.State == parser.EscapeState:
230 case b == ESC && p.state == parser.EscapeState:
177231 // Two ESCs in a row
178 p.performAction(d, parser.ExecuteAction, state, b)
179 if !more {
180 // Two ESCs at the end of the buffer
181 p.performAction(d, parser.ExecuteAction, state, b)
182 }
183 case b == ESC && !more:
184 // Last byte is an ESC
185 p.performAction(d, parser.ExecuteAction, state, b)
186 case p.State == parser.EscapeState && b == 'P' && !more:
187 // ESC P (DCS) at the end of the buffer
188 p.performAction(d, parser.DispatchAction, state, b)
189 case p.State == parser.EscapeState && b == 'X' && !more:
190 // ESC X (SOS) at the end of the buffer
191 p.performAction(d, parser.DispatchAction, state, b)
192 case p.State == parser.EscapeState && b == '[' && !more:
193 // ESC [ (CSI) at the end of the buffer
194 p.performAction(d, parser.DispatchAction, state, b)
195 case p.State == parser.EscapeState && b == ']' && !more:
196 // ESC ] (OSC) at the end of the buffer
197 p.performAction(d, parser.DispatchAction, state, b)
198 case p.State == parser.EscapeState && b == '^' && !more:
199 // ESC ^ (PM) at the end of the buffer
200 p.performAction(d, parser.DispatchAction, state, b)
201 case p.State == parser.EscapeState && b == '_' && !more:
202 // ESC _ (APC) at the end of the buffer
203 p.performAction(d, parser.DispatchAction, state, b)
232 p.performAction(parser.ExecuteAction, state, b)
204233 default:
205 p.performAction(d, action, state, b)
234 p.performAction(action, state, b)
206235 }
207236
208 p.State = state
237 p.state = state
209238
210239 return action
211240}
212241
213func (p *Parser) performAction(dispatcher ParserDispatcher, action parser.Action, state parser.State, b byte) {
242func (p *Parser) parseStringCmd() {
243 // Try to parse the command
244 datalen := len(p.data)
245 if p.dataLen >= 0 {
246 datalen = p.dataLen
247 }
248 for i := 0; i < datalen; i++ {
249 d := p.data[i]
250 if d < '0' || d > '9' {
251 break
252 }
253 if p.cmd == parser.MissingCommand {
254 p.cmd = 0
255 }
256 p.cmd *= 10
257 p.cmd += int(d - '0')
258 }
259}
260
261func (p *Parser) performAction(action parser.Action, state parser.State, b byte) {
214262 switch action {
215263 case parser.IgnoreAction:
216264 break
@@ -219,140 +267,139 @@ func (p *Parser) performAction(dispatcher ParserDispatcher, action parser.Action
219267 p.clear()
220268
221269 case parser.PrintAction:
222 if dispatcher != nil {
223 dispatcher(Rune(b))
270 p.cmd = int(b)
271 if p.handler.Print != nil {
272 p.handler.Print(rune(b))
224273 }
225274
226275 case parser.ExecuteAction:
227 if dispatcher != nil {
228 dispatcher(ControlCode(b))
276 p.cmd = int(b)
277 if p.handler.Execute != nil {
278 p.handler.Execute(b)
229279 }
230280
231 case parser.MarkerAction:
232 // Collect private marker
233 // we only store the last marker
234 p.Cmd &^= 0xff << parser.MarkerShift
235 p.Cmd |= int(b) << parser.MarkerShift
281 case parser.PrefixAction:
282 // Collect private prefix
283 // we only store the last prefix
284 p.cmd &^= 0xff << parser.PrefixShift
285 p.cmd |= int(b) << parser.PrefixShift
236286
237287 case parser.CollectAction:
238288 if state == parser.Utf8State {
239289 // Reset the UTF-8 counter
240 p.ParamsLen = 0
290 p.paramsLen = 0
241291 p.collectRune(b)
242292 } else {
243293 // Collect intermediate bytes
244294 // we only store the last intermediate byte
245 p.Cmd &^= 0xff << parser.IntermedShift
246 p.Cmd |= int(b) << parser.IntermedShift
295 p.cmd &^= 0xff << parser.IntermedShift
296 p.cmd |= int(b) << parser.IntermedShift
247297 }
248298
249299 case parser.ParamAction:
250300 // Collect parameters
251 if p.ParamsLen >= len(p.Params) {
301 if p.paramsLen >= len(p.params) {
252302 break
253303 }
254304
255305 if b >= '0' && b <= '9' {
256 if p.Params[p.ParamsLen] == parser.MissingParam {
257 p.Params[p.ParamsLen] = 0
306 if p.params[p.paramsLen] == parser.MissingParam {
307 p.params[p.paramsLen] = 0
258308 }
259309
260 p.Params[p.ParamsLen] *= 10
261 p.Params[p.ParamsLen] += int(b - '0')
310 p.params[p.paramsLen] *= 10
311 p.params[p.paramsLen] += int(b - '0')
262312 }
263313
264314 if b == ':' {
265 p.Params[p.ParamsLen] |= parser.HasMoreFlag
315 p.params[p.paramsLen] |= parser.HasMoreFlag
266316 }
267317
268318 if b == ';' || b == ':' {
269 p.ParamsLen++
270 if p.ParamsLen < len(p.Params) {
271 p.Params[p.ParamsLen] = parser.MissingParam
319 p.paramsLen++
320 if p.paramsLen < len(p.params) {
321 p.params[p.paramsLen] = parser.MissingParam
272322 }
273323 }
274324
275325 case parser.StartAction:
276 if p.DataLen < 0 && p.Data != nil {
277 p.Data = p.Data[:0]
326 if p.dataLen < 0 && p.data != nil {
327 p.data = p.data[:0]
278328 } else {
279 p.DataLen = 0
329 p.dataLen = 0
280330 }
281 if p.State >= parser.DcsEntryState && p.State <= parser.DcsStringState {
331 if p.state >= parser.DcsEntryState && p.state <= parser.DcsStringState {
282332 // Collect the command byte for DCS
283 p.Cmd |= int(b)
333 p.cmd |= int(b)
284334 } else {
285 p.Cmd = parser.MissingCommand
335 p.cmd = parser.MissingCommand
286336 }
287337
288338 case parser.PutAction:
289 switch p.State {
339 switch p.state {
290340 case parser.OscStringState:
291 if b == ';' && p.Cmd == parser.MissingCommand {
292 // Try to parse the command
293 datalen := len(p.Data)
294 if p.DataLen >= 0 {
295 datalen = p.DataLen
296 }
297 for i := 0; i < datalen; i++ {
298 d := p.Data[i]
299 if d < '0' || d > '9' {
300 break
301 }
302 if p.Cmd == parser.MissingCommand {
303 p.Cmd = 0
304 }
305 p.Cmd *= 10
306 p.Cmd += int(d - '0')
307 }
341 if b == ';' && p.cmd == parser.MissingCommand {
342 p.parseStringCmd()
308343 }
309344 }
310345
311 if p.DataLen < 0 {
312 p.Data = append(p.Data, b)
346 if p.dataLen < 0 {
347 p.data = append(p.data, b)
313348 } else {
314 if p.DataLen < len(p.Data) {
315 p.Data[p.DataLen] = b
316 p.DataLen++
349 if p.dataLen < len(p.data) {
350 p.data[p.dataLen] = b
351 p.dataLen++
317352 }
318353 }
319354
320355 case parser.DispatchAction:
321356 // Increment the last parameter
322 if p.ParamsLen > 0 && p.ParamsLen < len(p.Params)-1 ||
323 p.ParamsLen == 0 && len(p.Params) > 0 && p.Params[0] != parser.MissingParam {
324 p.ParamsLen++
357 if p.paramsLen > 0 && p.paramsLen < len(p.params)-1 ||
358 p.paramsLen == 0 && len(p.params) > 0 && p.params[0] != parser.MissingParam {
359 p.paramsLen++
325360 }
326361
327 if dispatcher == nil {
328 break
362 if p.state == parser.OscStringState && p.cmd == parser.MissingCommand {
363 // Ensure we have a command for OSC
364 p.parseStringCmd()
329365 }
330366
331 var seq Sequence
332 data := p.Data
333 if p.DataLen >= 0 {
334 data = data[:p.DataLen]
367 data := p.data
368 if p.dataLen >= 0 {
369 data = data[:p.dataLen]
335370 }
336 switch p.State {
371 switch p.state {
337372 case parser.CsiEntryState, parser.CsiParamState, parser.CsiIntermediateState:
338 p.Cmd |= int(b)
339 seq = CsiSequence{Cmd: p.Cmd, Params: p.Params[:p.ParamsLen]}
373 p.cmd |= int(b)
374 if p.handler.HandleCsi != nil {
375 p.handler.HandleCsi(Cmd(p.cmd), p.Params())
376 }
340377 case parser.EscapeState, parser.EscapeIntermediateState:
341 p.Cmd |= int(b)
342 seq = EscSequence(p.Cmd)
378 p.cmd |= int(b)
379 if p.handler.HandleEsc != nil {
380 p.handler.HandleEsc(Cmd(p.cmd))
381 }
343382 case parser.DcsEntryState, parser.DcsParamState, parser.DcsIntermediateState, parser.DcsStringState:
344 seq = DcsSequence{Cmd: p.Cmd, Params: p.Params[:p.ParamsLen], Data: data}
383 if p.handler.HandleDcs != nil {
384 p.handler.HandleDcs(Cmd(p.cmd), p.Params(), data)
385 }
345386 case parser.OscStringState:
346 seq = OscSequence{Cmd: p.Cmd, Data: data}
387 if p.handler.HandleOsc != nil {
388 p.handler.HandleOsc(p.cmd, data)
389 }
347390 case parser.SosStringState:
348 seq = SosSequence{Data: data}
391 if p.handler.HandleSos != nil {
392 p.handler.HandleSos(data)
393 }
349394 case parser.PmStringState:
350 seq = PmSequence{Data: data}
395 if p.handler.HandlePm != nil {
396 p.handler.HandlePm(data)
397 }
351398 case parser.ApcStringState:
352 seq = ApcSequence{Data: data}
399 if p.handler.HandleApc != nil {
400 p.handler.HandleApc(data)
401 }
353402 }
354
355 dispatcher(seq)
356403 }
357404}
358405
vendor/github.com/charmbracelet/x/ansi/parser/const.go +2 −2
@@ -8,7 +8,7 @@ const (
88 NoneAction Action = iota
99 ClearAction
1010 CollectAction
11 MarkerAction
11 PrefixAction
1212 DispatchAction
1313 ExecuteAction
1414 StartAction // Start of a data string
@@ -24,7 +24,7 @@ var ActionNames = []string{
2424 "NoneAction",
2525 "ClearAction",
2626 "CollectAction",
27 "MarkerAction",
27 "PrefixAction",
2828 "DispatchAction",
2929 "ExecuteAction",
3030 "StartAction",
vendor/github.com/charmbracelet/x/ansi/parser/seq.go +8 −8
@@ -4,9 +4,9 @@ import "math"
44
55// Shift and masks for sequence parameters and intermediates.
66const (
7 MarkerShift = 8
7 PrefixShift = 8
88 IntermedShift = 16
9 CommandMask = 0xff
9 FinalMask = 0xff
1010 HasMoreFlag = math.MinInt32
1111 ParamMask = ^HasMoreFlag
1212 MissingParam = ParamMask
@@ -22,12 +22,12 @@ const (
2222 DefaultParamValue = 0
2323)
2424
25// Marker returns the marker byte of the sequence.
25// Prefix returns the prefix byte of the sequence.
2626// This is always gonna be one of the following '<' '=' '>' '?' and in the
2727// range of 0x3C-0x3F.
28// Zero is returned if the sequence does not have a marker.
29func Marker(cmd int) int {
30 return (cmd >> MarkerShift) & CommandMask
28// Zero is returned if the sequence does not have a prefix.
29func Prefix(cmd int) int {
30 return (cmd >> PrefixShift) & FinalMask
3131}
3232
3333// Intermediate returns the intermediate byte of the sequence.
@@ -36,12 +36,12 @@ func Marker(cmd int) int {
3636// ',', '-', '.', '/'.
3737// Zero is returned if the sequence does not have an intermediate byte.
3838func Intermediate(cmd int) int {
39 return (cmd >> IntermedShift) & CommandMask
39 return (cmd >> IntermedShift) & FinalMask
4040}
4141
4242// Command returns the command byte of the CSI sequence.
4343func Command(cmd int) int {
44 return cmd & CommandMask
44 return cmd & FinalMask
4545}
4646
4747// Param returns the parameter at the given index.
vendor/github.com/charmbracelet/x/ansi/parser/transition_table.go +2 −2
@@ -178,7 +178,7 @@ func GenerateTransitionTable() TransitionTable {
178178 table.AddRange(0x20, 0x2F, DcsEntryState, CollectAction, DcsIntermediateState)
179179 // Dcs_entry -> Dcs_param
180180 table.AddRange(0x30, 0x3B, DcsEntryState, ParamAction, DcsParamState)
181 table.AddRange(0x3C, 0x3F, DcsEntryState, MarkerAction, DcsParamState)
181 table.AddRange(0x3C, 0x3F, DcsEntryState, PrefixAction, DcsParamState)
182182 // Dcs_entry -> Dcs_passthrough
183183 table.AddRange(0x08, 0x0D, DcsEntryState, PutAction, DcsStringState) // Follows ECMA-48 § 8.3.27
184184 // XXX: allows passing ESC (not a ECMA-48 standard) this to allow for
@@ -254,7 +254,7 @@ func GenerateTransitionTable() TransitionTable {
254254 table.AddRange(0x20, 0x2F, CsiEntryState, CollectAction, CsiIntermediateState)
255255 // Csi_entry -> Csi_param
256256 table.AddRange(0x30, 0x3B, CsiEntryState, ParamAction, CsiParamState)
257 table.AddRange(0x3C, 0x3F, CsiEntryState, MarkerAction, CsiParamState)
257 table.AddRange(0x3C, 0x3F, CsiEntryState, PrefixAction, CsiParamState)
258258
259259 // Osc_string
260260 table.AddRange(0x00, 0x06, OscStringState, IgnoreAction, OscStringState)
vendor/github.com/charmbracelet/x/ansi/parser_decode.go +206 −105
@@ -1,11 +1,10 @@
11package ansi
22
33import (
4 "bytes"
5 "strings"
64 "unicode/utf8"
75
86 "github.com/charmbracelet/x/ansi/parser"
7 "github.com/mattn/go-runewidth"
98 "github.com/rivo/uniseg"
109)
1110
@@ -16,7 +15,7 @@ type State = byte
1615// ANSI escape sequence states used by [DecodeSequence].
1716const (
1817 NormalState State = iota
19 MarkerState
18 PrefixState
2019 ParamsState
2120 IntermedState
2221 EscapeState
@@ -35,22 +34,22 @@ const (
3534//
3635// Passing a non-nil [*Parser] as the last argument will allow the decoder to
3736// collect sequence parameters, data, and commands. The parser cmd will have
38// the packed command value that contains intermediate and marker characters.
37// the packed command value that contains intermediate and prefix characters.
3938// In the case of a OSC sequence, the cmd will be the OSC command number. Use
40// [Cmd] and [Param] types to unpack command intermediates and markers as well
39// [Cmd] and [Param] types to unpack command intermediates and prefixes as well
4140// as parameters.
4241//
43// Zero [p.Cmd] means the CSI, DCS, or ESC sequence is invalid. Moreover, checking the
42// Zero [Cmd] means the CSI, DCS, or ESC sequence is invalid. Moreover, checking the
4443// validity of other data sequences, OSC, DCS, etc, will require checking for
4544// the returned sequence terminator bytes such as ST (ESC \\) and BEL).
4645//
47// We store the command byte in [p.Cmd] in the most significant byte, the
48// marker byte in the next byte, and the intermediate byte in the least
46// We store the command byte in [Cmd] in the most significant byte, the
47// prefix byte in the next byte, and the intermediate byte in the least
4948// significant byte. This is done to avoid using a struct to store the command
50// and its intermediates and markers. The command byte is always the least
51// significant byte i.e. [p.Cmd & 0xff]. Use the [Cmd] type to unpack the
52// command, intermediate, and marker bytes. Note that we only collect the last
53// marker character and intermediate byte.
49// and its intermediates and prefixes. The command byte is always the least
50// significant byte i.e. [Cmd & 0xff]. Use the [Cmd] type to unpack the
51// command, intermediate, and prefix bytes. Note that we only collect the last
52// prefix character and intermediate byte.
5453//
5554// The [p.Params] slice will contain the parameters of the sequence. Any
5655// sub-parameter will have the [parser.HasMoreFlag] set. Use the [Param] type
@@ -67,7 +66,63 @@ const (
6766// state = newState
6867// input = input[n:]
6968// }
69//
70// This function treats the text as a sequence of grapheme clusters.
7071func DecodeSequence[T string | []byte](b T, state byte, p *Parser) (seq T, width int, n int, newState byte) {
72 return decodeSequence(GraphemeWidth, b, state, p)
73}
74
75// DecodeSequenceWc decodes the first ANSI escape sequence or a printable
76// grapheme from the given data. It returns the sequence slice, the number of
77// bytes read, the cell width for each sequence, and the new state.
78//
79// The cell width will always be 0 for control and escape sequences, 1 for
80// ASCII printable characters, and the number of cells other Unicode characters
81// occupy. It uses the uniseg package to calculate the width of Unicode
82// graphemes and characters. This means it will always do grapheme clustering
83// (mode 2027).
84//
85// Passing a non-nil [*Parser] as the last argument will allow the decoder to
86// collect sequence parameters, data, and commands. The parser cmd will have
87// the packed command value that contains intermediate and prefix characters.
88// In the case of a OSC sequence, the cmd will be the OSC command number. Use
89// [Cmd] and [Param] types to unpack command intermediates and prefixes as well
90// as parameters.
91//
92// Zero [Cmd] means the CSI, DCS, or ESC sequence is invalid. Moreover, checking the
93// validity of other data sequences, OSC, DCS, etc, will require checking for
94// the returned sequence terminator bytes such as ST (ESC \\) and BEL).
95//
96// We store the command byte in [Cmd] in the most significant byte, the
97// prefix byte in the next byte, and the intermediate byte in the least
98// significant byte. This is done to avoid using a struct to store the command
99// and its intermediates and prefixes. The command byte is always the least
100// significant byte i.e. [Cmd & 0xff]. Use the [Cmd] type to unpack the
101// command, intermediate, and prefix bytes. Note that we only collect the last
102// prefix character and intermediate byte.
103//
104// The [p.Params] slice will contain the parameters of the sequence. Any
105// sub-parameter will have the [parser.HasMoreFlag] set. Use the [Param] type
106// to unpack the parameters.
107//
108// Example:
109//
110// var state byte // the initial state is always zero [NormalState]
111// p := NewParser(32, 1024) // create a new parser with a 32 params buffer and 1024 data buffer (optional)
112// input := []byte("\x1b[31mHello, World!\x1b[0m")
113// for len(input) > 0 {
114// seq, width, n, newState := DecodeSequenceWc(input, state, p)
115// log.Printf("seq: %q, width: %d", seq, width)
116// state = newState
117// input = input[n:]
118// }
119//
120// This function treats the text as a sequence of wide characters and runes.
121func DecodeSequenceWc[T string | []byte](b T, state byte, p *Parser) (seq T, width int, n int, newState byte) {
122 return decodeSequence(WcWidth, b, state, p)
123}
124
125func decodeSequence[T string | []byte](m Method, b T, state State, p *Parser) (seq T, width int, n int, newState byte) {
71126 for i := 0; i < len(b); i++ {
72127 c := b[i]
73128
@@ -76,39 +131,39 @@ func DecodeSequence[T string | []byte](b T, state byte, p *Parser) (seq T, width
76131 switch c {
77132 case ESC:
78133 if p != nil {
79 if len(p.Params) > 0 {
80 p.Params[0] = parser.MissingParam
134 if len(p.params) > 0 {
135 p.params[0] = parser.MissingParam
81136 }
82 p.Cmd = 0
83 p.ParamsLen = 0
84 p.DataLen = 0
137 p.cmd = 0
138 p.paramsLen = 0
139 p.dataLen = 0
85140 }
86141 state = EscapeState
87142 continue
88143 case CSI, DCS:
89144 if p != nil {
90 if len(p.Params) > 0 {
91 p.Params[0] = parser.MissingParam
145 if len(p.params) > 0 {
146 p.params[0] = parser.MissingParam
92147 }
93 p.Cmd = 0
94 p.ParamsLen = 0
95 p.DataLen = 0
148 p.cmd = 0
149 p.paramsLen = 0
150 p.dataLen = 0
96151 }
97 state = MarkerState
152 state = PrefixState
98153 continue
99154 case OSC, APC, SOS, PM:
100155 if p != nil {
101 p.Cmd = parser.MissingCommand
102 p.DataLen = 0
156 p.cmd = parser.MissingCommand
157 p.dataLen = 0
103158 }
104159 state = StringState
105160 continue
106161 }
107162
108163 if p != nil {
109 p.DataLen = 0
110 p.ParamsLen = 0
111 p.Cmd = 0
164 p.dataLen = 0
165 p.paramsLen = 0
166 p.cmd = 0
112167 }
113168 if c > US && c < DEL {
114169 // ASCII printable characters
@@ -122,18 +177,21 @@ func DecodeSequence[T string | []byte](b T, state byte, p *Parser) (seq T, width
122177
123178 if utf8.RuneStart(c) {
124179 seq, _, width, _ = FirstGraphemeCluster(b, -1)
180 if m == WcWidth {
181 width = runewidth.StringWidth(string(seq))
182 }
125183 i += len(seq)
126184 return b[:i], width, i, NormalState
127185 }
128186
129187 // Invalid UTF-8 sequence
130188 return b[:i], 0, i, NormalState
131 case MarkerState:
189 case PrefixState:
132190 if c >= '<' && c <= '?' {
133191 if p != nil {
134 // We only collect the last marker character.
135 p.Cmd &^= 0xff << parser.MarkerShift
136 p.Cmd |= int(c) << parser.MarkerShift
192 // We only collect the last prefix character.
193 p.cmd &^= 0xff << parser.PrefixShift
194 p.cmd |= int(c) << parser.PrefixShift
137195 }
138196 break
139197 }
@@ -143,27 +201,27 @@ func DecodeSequence[T string | []byte](b T, state byte, p *Parser) (seq T, width
143201 case ParamsState:
144202 if c >= '0' && c <= '9' {
145203 if p != nil {
146 if p.Params[p.ParamsLen] == parser.MissingParam {
147 p.Params[p.ParamsLen] = 0
204 if p.params[p.paramsLen] == parser.MissingParam {
205 p.params[p.paramsLen] = 0
148206 }
149207
150 p.Params[p.ParamsLen] *= 10
151 p.Params[p.ParamsLen] += int(c - '0')
208 p.params[p.paramsLen] *= 10
209 p.params[p.paramsLen] += int(c - '0')
152210 }
153211 break
154212 }
155213
156214 if c == ':' {
157215 if p != nil {
158 p.Params[p.ParamsLen] |= parser.HasMoreFlag
216 p.params[p.paramsLen] |= parser.HasMoreFlag
159217 }
160218 }
161219
162220 if c == ';' || c == ':' {
163221 if p != nil {
164 p.ParamsLen++
165 if p.ParamsLen < len(p.Params) {
166 p.Params[p.ParamsLen] = parser.MissingParam
222 p.paramsLen++
223 if p.paramsLen < len(p.params) {
224 p.params[p.paramsLen] = parser.MissingParam
167225 }
168226 }
169227 break
@@ -174,35 +232,36 @@ func DecodeSequence[T string | []byte](b T, state byte, p *Parser) (seq T, width
174232 case IntermedState:
175233 if c >= ' ' && c <= '/' {
176234 if p != nil {
177 p.Cmd &^= 0xff << parser.IntermedShift
178 p.Cmd |= int(c) << parser.IntermedShift
235 p.cmd &^= 0xff << parser.IntermedShift
236 p.cmd |= int(c) << parser.IntermedShift
179237 }
180238 break
181239 }
182240
183 state = NormalState
241 if p != nil {
242 // Increment the last parameter
243 if p.paramsLen > 0 && p.paramsLen < len(p.params)-1 ||
244 p.paramsLen == 0 && len(p.params) > 0 && p.params[0] != parser.MissingParam {
245 p.paramsLen++
246 }
247 }
248
184249 if c >= '@' && c <= '~' {
185250 if p != nil {
186 // Increment the last parameter
187 if p.ParamsLen > 0 && p.ParamsLen < len(p.Params)-1 ||
188 p.ParamsLen == 0 && len(p.Params) > 0 && p.Params[0] != parser.MissingParam {
189 p.ParamsLen++
190 }
191
192 p.Cmd &^= 0xff
193 p.Cmd |= int(c)
251 p.cmd &^= 0xff
252 p.cmd |= int(c)
194253 }
195254
196255 if HasDcsPrefix(b) {
197256 // Continue to collect DCS data
198257 if p != nil {
199 p.DataLen = 0
258 p.dataLen = 0
200259 }
201260 state = StringState
202261 continue
203262 }
204263
205 return b[:i+1], 0, i + 1, state
264 return b[:i+1], 0, i + 1, NormalState
206265 }
207266
208267 // Invalid CSI/DCS sequence
@@ -211,18 +270,18 @@ func DecodeSequence[T string | []byte](b T, state byte, p *Parser) (seq T, width
211270 switch c {
212271 case '[', 'P':
213272 if p != nil {
214 if len(p.Params) > 0 {
215 p.Params[0] = parser.MissingParam
273 if len(p.params) > 0 {
274 p.params[0] = parser.MissingParam
216275 }
217 p.ParamsLen = 0
218 p.Cmd = 0
276 p.paramsLen = 0
277 p.cmd = 0
219278 }
220 state = MarkerState
279 state = PrefixState
221280 continue
222281 case ']', 'X', '^', '_':
223282 if p != nil {
224 p.Cmd = parser.MissingCommand
225 p.DataLen = 0
283 p.cmd = parser.MissingCommand
284 p.dataLen = 0
226285 }
227286 state = StringState
228287 continue
@@ -230,14 +289,14 @@ func DecodeSequence[T string | []byte](b T, state byte, p *Parser) (seq T, width
230289
231290 if c >= ' ' && c <= '/' {
232291 if p != nil {
233 p.Cmd &^= 0xff << parser.IntermedShift
234 p.Cmd |= int(c) << parser.IntermedShift
292 p.cmd &^= 0xff << parser.IntermedShift
293 p.cmd |= int(c) << parser.IntermedShift
235294 }
236295 continue
237296 } else if c >= '0' && c <= '~' {
238297 if p != nil {
239 p.Cmd &^= 0xff
240 p.Cmd |= int(c)
298 p.cmd &^= 0xff
299 p.cmd |= int(c)
241300 }
242301 return b[:i+1], 0, i + 1, NormalState
243302 }
@@ -248,15 +307,31 @@ func DecodeSequence[T string | []byte](b T, state byte, p *Parser) (seq T, width
248307 switch c {
249308 case BEL:
250309 if HasOscPrefix(b) {
310 parseOscCmd(p)
251311 return b[:i+1], 0, i + 1, NormalState
252312 }
253313 case CAN, SUB:
314 if HasOscPrefix(b) {
315 // Ensure we parse the OSC command number
316 parseOscCmd(p)
317 }
318
254319 // Cancel the sequence
255320 return b[:i], 0, i, NormalState
256321 case ST:
322 if HasOscPrefix(b) {
323 // Ensure we parse the OSC command number
324 parseOscCmd(p)
325 }
326
257327 return b[:i+1], 0, i + 1, NormalState
258328 case ESC:
259329 if HasStPrefix(b[i:]) {
330 if HasOscPrefix(b) {
331 // Ensure we parse the OSC command number
332 parseOscCmd(p)
333 }
334
260335 // End of string 7-bit (ST)
261336 return b[:i+2], 0, i + 2, NormalState
262337 }
@@ -265,23 +340,13 @@ func DecodeSequence[T string | []byte](b T, state byte, p *Parser) (seq T, width
265340 return b[:i], 0, i, NormalState
266341 }
267342
268 if p != nil && p.DataLen < len(p.Data) {
269 p.Data[p.DataLen] = c
270 p.DataLen++
343 if p != nil && p.dataLen < len(p.data) {
344 p.data[p.dataLen] = c
345 p.dataLen++
271346
272347 // Parse the OSC command number
273 if c == ';' && p.Cmd == parser.MissingCommand && HasOscPrefix(b) {
274 for j := 0; j < p.DataLen; j++ {
275 d := p.Data[j]
276 if d < '0' || d > '9' {
277 break
278 }
279 if p.Cmd == parser.MissingCommand {
280 p.Cmd = 0
281 }
282 p.Cmd *= 10
283 p.Cmd += int(d - '0')
284 }
348 if c == ';' && HasOscPrefix(b) {
349 parseOscCmd(p)
285350 }
286351 }
287352 }
@@ -290,16 +355,21 @@ func DecodeSequence[T string | []byte](b T, state byte, p *Parser) (seq T, width
290355 return b, 0, len(b), state
291356}
292357
293// Index returns the index of the first occurrence of the given byte slice in
294// the data. It returns -1 if the byte slice is not found.
295func Index[T string | []byte](data, b T) int {
296 switch data := any(data).(type) {
297 case string:
298 return strings.Index(data, string(b))
299 case []byte:
300 return bytes.Index(data, []byte(b))
358func parseOscCmd(p *Parser) {
359 if p == nil || p.cmd != parser.MissingCommand {
360 return
361 }
362 for j := 0; j < p.dataLen; j++ {
363 d := p.data[j]
364 if d < '0' || d > '9' {
365 break
366 }
367 if p.cmd == parser.MissingCommand {
368 p.cmd = 0
369 }
370 p.cmd *= 10
371 p.cmd += int(d - '0')
301372 }
302 panic("unreachable")
303373}
304374
305375// Equal returns true if the given byte slices are equal.
@@ -380,30 +450,47 @@ func FirstGraphemeCluster[T string | []byte](b T, state int) (T, T, int, int) {
380450}
381451
382452// Cmd represents a sequence command. This is used to pack/unpack a sequence
383// command with its intermediate and marker characters. Those are commonly
453// command with its intermediate and prefix characters. Those are commonly
384454// found in CSI and DCS sequences.
385455type Cmd int
386456
387// Marker returns the marker byte of the CSI sequence.
457// Prefix returns the unpacked prefix byte of the CSI sequence.
388458// This is always gonna be one of the following '<' '=' '>' '?' and in the
389459// range of 0x3C-0x3F.
390// Zero is returned if the sequence does not have a marker.
391func (c Cmd) Marker() int {
392 return parser.Marker(int(c))
460// Zero is returned if the sequence does not have a prefix.
461func (c Cmd) Prefix() byte {
462 return byte(parser.Prefix(int(c)))
393463}
394464
395// Intermediate returns the intermediate byte of the CSI sequence.
465// Intermediate returns the unpacked intermediate byte of the CSI sequence.
396466// An intermediate byte is in the range of 0x20-0x2F. This includes these
397467// characters from ' ', '!', '"', '#', '$', '%', '&', ”', '(', ')', '*', '+',
398468// ',', '-', '.', '/'.
399469// Zero is returned if the sequence does not have an intermediate byte.
400func (c Cmd) Intermediate() int {
401 return parser.Intermediate(int(c))
470func (c Cmd) Intermediate() byte {
471 return byte(parser.Intermediate(int(c)))
402472}
403473
404// Command returns the command byte of the CSI sequence.
405func (c Cmd) Command() int {
406 return parser.Command(int(c))
474// Final returns the unpacked command byte of the CSI sequence.
475func (c Cmd) Final() byte {
476 return byte(parser.Command(int(c)))
477}
478
479// Command packs a command with the given prefix, intermediate, and final. A
480// zero byte means the sequence does not have a prefix or intermediate.
481//
482// Prefixes are in the range of 0x3C-0x3F that is one of `<=>?`.
483//
484// Intermediates are in the range of 0x20-0x2F that is anything in
485// `!"#$%&'()*+,-./`.
486//
487// Final bytes are in the range of 0x40-0x7E that is anything in the range
488// `@A–Z[\]^_`a–z{|}~`.
489func Command(prefix, inter, final byte) (c int) {
490 c = int(final)
491 c |= int(prefix) << parser.PrefixShift
492 c |= int(inter) << parser.IntermedShift
493 return
407494}
408495
409496// Param represents a sequence parameter. Sequence parameters with
@@ -411,13 +498,27 @@ func (c Cmd) Command() int {
411498// the parameters from a CSI and DCS sequences.
412499type Param int
413500
414// Param returns the parameter at the given index.
415// It returns -1 if the parameter does not exist.
416func (s Param) Param() int {
417 return int(s) & parser.ParamMask
501// Param returns the unpacked parameter at the given index.
502// It returns the default value if the parameter is missing.
503func (s Param) Param(def int) int {
504 p := int(s) & parser.ParamMask
505 if p == parser.MissingParam {
506 return def
507 }
508 return p
418509}
419510
420// HasMore returns true if the parameter has more sub-parameters.
511// HasMore unpacks the HasMoreFlag from the parameter.
421512func (s Param) HasMore() bool {
422 return int(s)&parser.HasMoreFlag != 0
513 return s&parser.HasMoreFlag != 0
514}
515
516// Parameter packs an escape code parameter with the given parameter and
517// whether this parameter has following sub-parameters.
518func Parameter(p int, hasMore bool) (s int) {
519 s = p & parser.ParamMask
520 if hasMore {
521 s |= parser.HasMoreFlag
522 }
523 return
423524}
vendor/github.com/charmbracelet/x/ansi/parser_handler.go added +60
@@ -0,0 +1,60 @@
1package ansi
2
3import "unsafe"
4
5// Params represents a list of packed parameters.
6type Params []Param
7
8// Param returns the parameter at the given index and if it is part of a
9// sub-parameters. It falls back to the default value if the parameter is
10// missing. If the index is out of bounds, it returns the default value and
11// false.
12func (p Params) Param(i, def int) (int, bool, bool) {
13 if i < 0 || i >= len(p) {
14 return def, false, false
15 }
16 return p[i].Param(def), p[i].HasMore(), true
17}
18
19// ForEach iterates over the parameters and calls the given function for each
20// parameter. If a parameter is part of a sub-parameter, it will be called with
21// hasMore set to true.
22// Use def to set a default value for missing parameters.
23func (p Params) ForEach(def int, f func(i, param int, hasMore bool)) {
24 for i := range p {
25 f(i, p[i].Param(def), p[i].HasMore())
26 }
27}
28
29// ToParams converts a list of integers to a list of parameters.
30func ToParams(params []int) Params {
31 return unsafe.Slice((*Param)(unsafe.Pointer(&params[0])), len(params))
32}
33
34// Handler handles actions performed by the parser.
35// It is used to handle ANSI escape sequences, control characters, and runes.
36type Handler struct {
37 // Print is called when a printable rune is encountered.
38 Print func(r rune)
39 // Execute is called when a control character is encountered.
40 Execute func(b byte)
41 // HandleCsi is called when a CSI sequence is encountered.
42 HandleCsi func(cmd Cmd, params Params)
43 // HandleEsc is called when an ESC sequence is encountered.
44 HandleEsc func(cmd Cmd)
45 // HandleDcs is called when a DCS sequence is encountered.
46 HandleDcs func(cmd Cmd, params Params, data []byte)
47 // HandleOsc is called when an OSC sequence is encountered.
48 HandleOsc func(cmd int, data []byte)
49 // HandlePm is called when a PM sequence is encountered.
50 HandlePm func(data []byte)
51 // HandleApc is called when an APC sequence is encountered.
52 HandleApc func(data []byte)
53 // HandleSos is called when a SOS sequence is encountered.
54 HandleSos func(data []byte)
55}
56
57// SetHandler sets the handler for the parser.
58func (p *Parser) SetHandler(h Handler) {
59 p.handler = h
60}
vendor/github.com/charmbracelet/x/ansi/parser_sync.go added +29
@@ -0,0 +1,29 @@
1package ansi
2
3import (
4 "sync"
5
6 "github.com/charmbracelet/x/ansi/parser"
7)
8
9var parserPool = sync.Pool{
10 New: func() any {
11 p := NewParser()
12 p.SetParamsSize(parser.MaxParamsSize)
13 p.SetDataSize(1024 * 1024 * 4) // 4MB of data buffer
14 return p
15 },
16}
17
18// GetParser returns a parser from a sync pool.
19func GetParser() *Parser {
20 return parserPool.Get().(*Parser)
21}
22
23// PutParser returns a parser to a sync pool. The parser is reset
24// automatically.
25func PutParser(p *Parser) {
26 p.Reset()
27 p.dataLen = 0
28 parserPool.Put(p)
29}
vendor/github.com/charmbracelet/x/ansi/paste.go added +7
@@ -0,0 +1,7 @@
1package ansi
2
3// BracketedPasteStart is the control sequence to enable bracketed paste mode.
4const BracketedPasteStart = "\x1b[200~"
5
6// BracketedPasteEnd is the control sequence to disable bracketed paste mode.
7const BracketedPasteEnd = "\x1b[201~"
vendor/github.com/charmbracelet/x/ansi/reset.go added +11
@@ -0,0 +1,11 @@
1package ansi
2
3// ResetInitialState (RIS) resets the terminal to its initial state.
4//
5// ESC c
6//
7// See: https://vt100.net/docs/vt510-rm/RIS.html
8const (
9 ResetInitialState = "\x1bc"
10 RIS = ResetInitialState
11)
vendor/github.com/charmbracelet/x/ansi/screen.go +301 −17
@@ -1,30 +1,44 @@
11package ansi
22
3import "strconv"
3import (
4 "strconv"
5 "strings"
6)
47
5// EraseDisplay (ED) clears the screen or parts of the screen. Possible values:
8// EraseDisplay (ED) clears the display or parts of the display. A screen is
9// the shown part of the terminal display excluding the scrollback buffer.
10// Possible values:
11//
12// Default is 0.
613//
714// 0: Clear from cursor to end of screen.
815// 1: Clear from cursor to beginning of the screen.
916// 2: Clear entire screen (and moves cursor to upper left on DOS).
10// 3: Clear entire screen and delete all lines saved in the scrollback buffer.
17// 3: Clear entire display which delete all lines saved in the scrollback buffer (xterm).
1118//
1219// CSI <n> J
1320//
1421// See: https://vt100.net/docs/vt510-rm/ED.html
1522func EraseDisplay(n int) string {
16 if n < 0 {
17 n = 0
23 var s string
24 if n > 0 {
25 s = strconv.Itoa(n)
1826 }
19 return "\x1b[" + strconv.Itoa(n) + "J"
27 return "\x1b[" + s + "J"
28}
29
30// ED is an alias for [EraseDisplay].
31func ED(n int) string {
32 return EraseDisplay(n)
2033}
2134
2235// EraseDisplay constants.
2336// These are the possible values for the EraseDisplay function.
2437const (
25 EraseDisplayRight = "\x1b[0J"
26 EraseDisplayLeft = "\x1b[1J"
27 EraseEntireDisplay = "\x1b[2J"
38 EraseScreenBelow = "\x1b[J"
39 EraseScreenAbove = "\x1b[1J"
40 EraseEntireScreen = "\x1b[2J"
41 EraseEntireDisplay = "\x1b[3J"
2842)
2943
3044// EraseLine (EL) clears the current line or parts of the line. Possible values:
@@ -39,16 +53,22 @@ const (
3953//
4054// See: https://vt100.net/docs/vt510-rm/EL.html
4155func EraseLine(n int) string {
42 if n < 0 {
43 n = 0
56 var s string
57 if n > 0 {
58 s = strconv.Itoa(n)
4459 }
45 return "\x1b[" + strconv.Itoa(n) + "K"
60 return "\x1b[" + s + "K"
61}
62
63// EL is an alias for [EraseLine].
64func EL(n int) string {
65 return EraseLine(n)
4666}
4767
4868// EraseLine constants.
4969// These are the possible values for the EraseLine function.
5070const (
51 EraseLineRight = "\x1b[0K"
71 EraseLineRight = "\x1b[K"
5272 EraseLineLeft = "\x1b[1K"
5373 EraseEntireLine = "\x1b[2K"
5474)
@@ -56,7 +76,7 @@ const (
5676// ScrollUp (SU) scrolls the screen up n lines. New lines are added at the
5777// bottom of the screen.
5878//
59// CSI <n> S
79// CSI Pn S
6080//
6181// See: https://vt100.net/docs/vt510-rm/SU.html
6282func ScrollUp(n int) string {
@@ -67,10 +87,20 @@ func ScrollUp(n int) string {
6787 return "\x1b[" + s + "S"
6888}
6989
90// PanDown is an alias for [ScrollUp].
91func PanDown(n int) string {
92 return ScrollUp(n)
93}
94
95// SU is an alias for [ScrollUp].
96func SU(n int) string {
97 return ScrollUp(n)
98}
99
70100// ScrollDown (SD) scrolls the screen down n lines. New lines are added at the
71101// top of the screen.
72102//
73// CSI <n> T
103// CSI Pn T
74104//
75105// See: https://vt100.net/docs/vt510-rm/SD.html
76106func ScrollDown(n int) string {
@@ -81,10 +111,20 @@ func ScrollDown(n int) string {
81111 return "\x1b[" + s + "T"
82112}
83113
114// PanUp is an alias for [ScrollDown].
115func PanUp(n int) string {
116 return ScrollDown(n)
117}
118
119// SD is an alias for [ScrollDown].
120func SD(n int) string {
121 return ScrollDown(n)
122}
123
84124// InsertLine (IL) inserts n blank lines at the current cursor position.
85125// Existing lines are moved down.
86126//
87// CSI <n> L
127// CSI Pn L
88128//
89129// See: https://vt100.net/docs/vt510-rm/IL.html
90130func InsertLine(n int) string {
@@ -95,10 +135,15 @@ func InsertLine(n int) string {
95135 return "\x1b[" + s + "L"
96136}
97137
138// IL is an alias for [InsertLine].
139func IL(n int) string {
140 return InsertLine(n)
141}
142
98143// DeleteLine (DL) deletes n lines at the current cursor position. Existing
99144// lines are moved up.
100145//
101// CSI <n> M
146// CSI Pn M
102147//
103148// See: https://vt100.net/docs/vt510-rm/DL.html
104149func DeleteLine(n int) string {
@@ -109,12 +154,67 @@ func DeleteLine(n int) string {
109154 return "\x1b[" + s + "M"
110155}
111156
157// DL is an alias for [DeleteLine].
158func DL(n int) string {
159 return DeleteLine(n)
160}
161
162// SetTopBottomMargins (DECSTBM) sets the top and bottom margins for the scrolling
163// region. The default is the entire screen.
164//
165// Default is 1 and the bottom of the screen.
166//
167// CSI Pt ; Pb r
168//
169// See: https://vt100.net/docs/vt510-rm/DECSTBM.html
170func SetTopBottomMargins(top, bot int) string {
171 var t, b string
172 if top > 0 {
173 t = strconv.Itoa(top)
174 }
175 if bot > 0 {
176 b = strconv.Itoa(bot)
177 }
178 return "\x1b[" + t + ";" + b + "r"
179}
180
181// DECSTBM is an alias for [SetTopBottomMargins].
182func DECSTBM(top, bot int) string {
183 return SetTopBottomMargins(top, bot)
184}
185
186// SetLeftRightMargins (DECSLRM) sets the left and right margins for the scrolling
187// region.
188//
189// Default is 1 and the right of the screen.
190//
191// CSI Pl ; Pr s
192//
193// See: https://vt100.net/docs/vt510-rm/DECSLRM.html
194func SetLeftRightMargins(left, right int) string {
195 var l, r string
196 if left > 0 {
197 l = strconv.Itoa(left)
198 }
199 if right > 0 {
200 r = strconv.Itoa(right)
201 }
202 return "\x1b[" + l + ";" + r + "s"
203}
204
205// DECSLRM is an alias for [SetLeftRightMargins].
206func DECSLRM(left, right int) string {
207 return SetLeftRightMargins(left, right)
208}
209
112210// SetScrollingRegion (DECSTBM) sets the top and bottom margins for the scrolling
113211// region. The default is the entire screen.
114212//
115213// CSI <top> ; <bottom> r
116214//
117215// See: https://vt100.net/docs/vt510-rm/DECSTBM.html
216//
217// Deprecated: use [SetTopBottomMargins] instead.
118218func SetScrollingRegion(t, b int) string {
119219 if t < 0 {
120220 t = 0
@@ -124,3 +224,187 @@ func SetScrollingRegion(t, b int) string {
124224 }
125225 return "\x1b[" + strconv.Itoa(t) + ";" + strconv.Itoa(b) + "r"
126226}
227
228// InsertCharacter (ICH) inserts n blank characters at the current cursor
229// position. Existing characters move to the right. Characters moved past the
230// right margin are lost. ICH has no effect outside the scrolling margins.
231//
232// Default is 1.
233//
234// CSI Pn @
235//
236// See: https://vt100.net/docs/vt510-rm/ICH.html
237func InsertCharacter(n int) string {
238 var s string
239 if n > 1 {
240 s = strconv.Itoa(n)
241 }
242 return "\x1b[" + s + "@"
243}
244
245// ICH is an alias for [InsertCharacter].
246func ICH(n int) string {
247 return InsertCharacter(n)
248}
249
250// DeleteCharacter (DCH) deletes n characters at the current cursor position.
251// As the characters are deleted, the remaining characters move to the left and
252// the cursor remains at the same position.
253//
254// Default is 1.
255//
256// CSI Pn P
257//
258// See: https://vt100.net/docs/vt510-rm/DCH.html
259func DeleteCharacter(n int) string {
260 var s string
261 if n > 1 {
262 s = strconv.Itoa(n)
263 }
264 return "\x1b[" + s + "P"
265}
266
267// DCH is an alias for [DeleteCharacter].
268func DCH(n int) string {
269 return DeleteCharacter(n)
270}
271
272// SetTabEvery8Columns (DECST8C) sets the tab stops at every 8 columns.
273//
274// CSI ? 5 W
275//
276// See: https://vt100.net/docs/vt510-rm/DECST8C.html
277const (
278 SetTabEvery8Columns = "\x1b[?5W"
279 DECST8C = SetTabEvery8Columns
280)
281
282// HorizontalTabSet (HTS) sets a horizontal tab stop at the current cursor
283// column.
284//
285// This is equivalent to [HTS].
286//
287// ESC H
288//
289// See: https://vt100.net/docs/vt510-rm/HTS.html
290const HorizontalTabSet = "\x1bH"
291
292// TabClear (TBC) clears tab stops.
293//
294// Default is 0.
295//
296// Possible values:
297// 0: Clear tab stop at the current column. (default)
298// 3: Clear all tab stops.
299//
300// CSI Pn g
301//
302// See: https://vt100.net/docs/vt510-rm/TBC.html
303func TabClear(n int) string {
304 var s string
305 if n > 0 {
306 s = strconv.Itoa(n)
307 }
308 return "\x1b[" + s + "g"
309}
310
311// TBC is an alias for [TabClear].
312func TBC(n int) string {
313 return TabClear(n)
314}
315
316// RequestPresentationStateReport (DECRQPSR) requests the terminal to send a
317// report of the presentation state. This includes the cursor information [DECCIR],
318// and tab stop [DECTABSR] reports.
319//
320// Default is 0.
321//
322// Possible values:
323// 0: Error, request ignored.
324// 1: Cursor information report [DECCIR].
325// 2: Tab stop report [DECTABSR].
326//
327// CSI Ps $ w
328//
329// See: https://vt100.net/docs/vt510-rm/DECRQPSR.html
330func RequestPresentationStateReport(n int) string {
331 var s string
332 if n > 0 {
333 s = strconv.Itoa(n)
334 }
335 return "\x1b[" + s + "$w"
336}
337
338// DECRQPSR is an alias for [RequestPresentationStateReport].
339func DECRQPSR(n int) string {
340 return RequestPresentationStateReport(n)
341}
342
343// TabStopReport (DECTABSR) is the response to a tab stop report request.
344// It reports the tab stops set in the terminal.
345//
346// The response is a list of tab stops separated by a slash (/) character.
347//
348// DCS 2 $ u D ... D ST
349//
350// Where D is a decimal number representing a tab stop.
351//
352// See: https://vt100.net/docs/vt510-rm/DECTABSR.html
353func TabStopReport(stops ...int) string {
354 var s []string
355 for _, v := range stops {
356 s = append(s, strconv.Itoa(v))
357 }
358 return "\x1bP2$u" + strings.Join(s, "/") + "\x1b\\"
359}
360
361// DECTABSR is an alias for [TabStopReport].
362func DECTABSR(stops ...int) string {
363 return TabStopReport(stops...)
364}
365
366// CursorInformationReport (DECCIR) is the response to a cursor information
367// report request. It reports the cursor position, visual attributes, and
368// character protection attributes. It also reports the status of origin mode
369// [DECOM] and the current active character set.
370//
371// The response is a list of values separated by a semicolon (;) character.
372//
373// DCS 1 $ u D ... D ST
374//
375// Where D is a decimal number representing a value.
376//
377// See: https://vt100.net/docs/vt510-rm/DECCIR.html
378func CursorInformationReport(values ...int) string {
379 var s []string
380 for _, v := range values {
381 s = append(s, strconv.Itoa(v))
382 }
383 return "\x1bP1$u" + strings.Join(s, ";") + "\x1b\\"
384}
385
386// DECCIR is an alias for [CursorInformationReport].
387func DECCIR(values ...int) string {
388 return CursorInformationReport(values...)
389}
390
391// RepeatPreviousCharacter (REP) repeats the previous character n times.
392// This is identical to typing the same character n times.
393//
394// Default is 1.
395//
396// CSI Pn b
397//
398// See: ECMA-48 § 8.3.103
399func RepeatPreviousCharacter(n int) string {
400 var s string
401 if n > 1 {
402 s = strconv.Itoa(n)
403 }
404 return "\x1b[" + s + "b"
405}
406
407// REP is an alias for [RepeatPreviousCharacter].
408func REP(n int) string {
409 return RepeatPreviousCharacter(n)
410}
vendor/github.com/charmbracelet/x/ansi/sequence.go deleted −199
@@ -1,199 +0,0 @@
1package ansi
2
3import (
4 "bytes"
5
6 "github.com/charmbracelet/x/ansi/parser"
7)
8
9// Sequence represents an ANSI sequence. This can be a control sequence, escape
10// sequence, a printable character, etc.
11type Sequence interface {
12 // String returns the string representation of the sequence.
13 String() string
14 // Bytes returns the byte representation of the sequence.
15 Bytes() []byte
16 // Clone returns a copy of the sequence.
17 Clone() Sequence
18}
19
20// Rune represents a printable character.
21type Rune rune
22
23var _ Sequence = Rune(0)
24
25// Bytes implements Sequence.
26func (r Rune) Bytes() []byte {
27 return []byte(string(r))
28}
29
30// String implements Sequence.
31func (r Rune) String() string {
32 return string(r)
33}
34
35// Clone implements Sequence.
36func (r Rune) Clone() Sequence {
37 return r
38}
39
40// ControlCode represents a control code character. This is a character that
41// is not printable and is used to control the terminal. This would be a
42// character in the C0 or C1 set in the range of 0x00-0x1F and 0x80-0x9F.
43type ControlCode byte
44
45var _ Sequence = ControlCode(0)
46
47// Bytes implements Sequence.
48func (c ControlCode) Bytes() []byte {
49 return []byte{byte(c)}
50}
51
52// String implements Sequence.
53func (c ControlCode) String() string {
54 return string(c)
55}
56
57// Clone implements Sequence.
58func (c ControlCode) Clone() Sequence {
59 return c
60}
61
62// EscSequence represents an escape sequence.
63type EscSequence int
64
65var _ Sequence = EscSequence(0)
66
67// buffer returns the buffer of the escape sequence.
68func (e EscSequence) buffer() *bytes.Buffer {
69 var b bytes.Buffer
70 b.WriteByte('\x1b')
71 if i := parser.Intermediate(int(e)); i != 0 {
72 b.WriteByte(byte(i))
73 }
74 b.WriteByte(byte(e.Command()))
75 return &b
76}
77
78// Bytes implements Sequence.
79func (e EscSequence) Bytes() []byte {
80 return e.buffer().Bytes()
81}
82
83// String implements Sequence.
84func (e EscSequence) String() string {
85 return e.buffer().String()
86}
87
88// Clone implements Sequence.
89func (e EscSequence) Clone() Sequence {
90 return e
91}
92
93// Command returns the command byte of the escape sequence.
94func (e EscSequence) Command() int {
95 return parser.Command(int(e))
96}
97
98// Intermediate returns the intermediate byte of the escape sequence.
99func (e EscSequence) Intermediate() int {
100 return parser.Intermediate(int(e))
101}
102
103// SosSequence represents a SOS sequence.
104type SosSequence struct {
105 // Data contains the raw data of the sequence.
106 Data []byte
107}
108
109var _ Sequence = &SosSequence{}
110
111// Clone implements Sequence.
112func (s SosSequence) Clone() Sequence {
113 return SosSequence{Data: append([]byte(nil), s.Data...)}
114}
115
116// Bytes implements Sequence.
117func (s SosSequence) Bytes() []byte {
118 return s.buffer().Bytes()
119}
120
121// String implements Sequence.
122func (s SosSequence) String() string {
123 return s.buffer().String()
124}
125
126func (s SosSequence) buffer() *bytes.Buffer {
127 var b bytes.Buffer
128 b.WriteByte('\x1b')
129 b.WriteByte('X')
130 b.Write(s.Data)
131 b.WriteString("\x1b\\")
132 return &b
133}
134
135// PmSequence represents a PM sequence.
136type PmSequence struct {
137 // Data contains the raw data of the sequence.
138 Data []byte
139}
140
141var _ Sequence = &PmSequence{}
142
143// Clone implements Sequence.
144func (s PmSequence) Clone() Sequence {
145 return PmSequence{Data: append([]byte(nil), s.Data...)}
146}
147
148// Bytes implements Sequence.
149func (s PmSequence) Bytes() []byte {
150 return s.buffer().Bytes()
151}
152
153// String implements Sequence.
154func (s PmSequence) String() string {
155 return s.buffer().String()
156}
157
158// buffer returns the buffer of the PM sequence.
159func (s PmSequence) buffer() *bytes.Buffer {
160 var b bytes.Buffer
161 b.WriteByte('\x1b')
162 b.WriteByte('^')
163 b.Write(s.Data)
164 b.WriteString("\x1b\\")
165 return &b
166}
167
168// ApcSequence represents an APC sequence.
169type ApcSequence struct {
170 // Data contains the raw data of the sequence.
171 Data []byte
172}
173
174var _ Sequence = &ApcSequence{}
175
176// Clone implements Sequence.
177func (s ApcSequence) Clone() Sequence {
178 return ApcSequence{Data: append([]byte(nil), s.Data...)}
179}
180
181// Bytes implements Sequence.
182func (s ApcSequence) Bytes() []byte {
183 return s.buffer().Bytes()
184}
185
186// String implements Sequence.
187func (s ApcSequence) String() string {
188 return s.buffer().String()
189}
190
191// buffer returns the buffer of the APC sequence.
192func (s ApcSequence) buffer() *bytes.Buffer {
193 var b bytes.Buffer
194 b.WriteByte('\x1b')
195 b.WriteByte('_')
196 b.Write(s.Data)
197 b.WriteString("\x1b\\")
198 return &b
199}
vendor/github.com/charmbracelet/x/ansi/sgr.go added +95
@@ -0,0 +1,95 @@
1package ansi
2
3import "strconv"
4
5// Select Graphic Rendition (SGR) is a command that sets display attributes.
6//
7// Default is 0.
8//
9// CSI Ps ; Ps ... m
10//
11// See: https://vt100.net/docs/vt510-rm/SGR.html
12func SelectGraphicRendition(ps ...Attr) string {
13 if len(ps) == 0 {
14 return ResetStyle
15 }
16
17 var s Style
18 for _, p := range ps {
19 attr, ok := attrStrings[p]
20 if ok {
21 s = append(s, attr)
22 } else {
23 if p < 0 {
24 p = 0
25 }
26 s = append(s, strconv.Itoa(p))
27 }
28 }
29
30 return s.String()
31}
32
33// SGR is an alias for [SelectGraphicRendition].
34func SGR(ps ...Attr) string {
35 return SelectGraphicRendition(ps...)
36}
37
38var attrStrings = map[int]string{
39 ResetAttr: "0",
40 BoldAttr: "1",
41 FaintAttr: "2",
42 ItalicAttr: "3",
43 UnderlineAttr: "4",
44 SlowBlinkAttr: "5",
45 RapidBlinkAttr: "6",
46 ReverseAttr: "7",
47 ConcealAttr: "8",
48 StrikethroughAttr: "9",
49 NoBoldAttr: "21",
50 NormalIntensityAttr: "22",
51 NoItalicAttr: "23",
52 NoUnderlineAttr: "24",
53 NoBlinkAttr: "25",
54 NoReverseAttr: "27",
55 NoConcealAttr: "28",
56 NoStrikethroughAttr: "29",
57 BlackForegroundColorAttr: "30",
58 RedForegroundColorAttr: "31",
59 GreenForegroundColorAttr: "32",
60 YellowForegroundColorAttr: "33",
61 BlueForegroundColorAttr: "34",
62 MagentaForegroundColorAttr: "35",
63 CyanForegroundColorAttr: "36",
64 WhiteForegroundColorAttr: "37",
65 ExtendedForegroundColorAttr: "38",
66 DefaultForegroundColorAttr: "39",
67 BlackBackgroundColorAttr: "40",
68 RedBackgroundColorAttr: "41",
69 GreenBackgroundColorAttr: "42",
70 YellowBackgroundColorAttr: "43",
71 BlueBackgroundColorAttr: "44",
72 MagentaBackgroundColorAttr: "45",
73 CyanBackgroundColorAttr: "46",
74 WhiteBackgroundColorAttr: "47",
75 ExtendedBackgroundColorAttr: "48",
76 DefaultBackgroundColorAttr: "49",
77 ExtendedUnderlineColorAttr: "58",
78 DefaultUnderlineColorAttr: "59",
79 BrightBlackForegroundColorAttr: "90",
80 BrightRedForegroundColorAttr: "91",
81 BrightGreenForegroundColorAttr: "92",
82 BrightYellowForegroundColorAttr: "93",
83 BrightBlueForegroundColorAttr: "94",
84 BrightMagentaForegroundColorAttr: "95",
85 BrightCyanForegroundColorAttr: "96",
86 BrightWhiteForegroundColorAttr: "97",
87 BrightBlackBackgroundColorAttr: "100",
88 BrightRedBackgroundColorAttr: "101",
89 BrightGreenBackgroundColorAttr: "102",
90 BrightYellowBackgroundColorAttr: "103",
91 BrightBlueBackgroundColorAttr: "104",
92 BrightMagentaBackgroundColorAttr: "105",
93 BrightCyanBackgroundColorAttr: "106",
94 BrightWhiteBackgroundColorAttr: "107",
95}
vendor/github.com/charmbracelet/x/ansi/status.go added +144
@@ -0,0 +1,144 @@
1package ansi
2
3import (
4 "strconv"
5 "strings"
6)
7
8// StatusReport represents a terminal status report.
9type StatusReport interface {
10 // StatusReport returns the status report identifier.
11 StatusReport() int
12}
13
14// ANSIReport represents an ANSI terminal status report.
15type ANSIStatusReport int //nolint:revive
16
17// Report returns the status report identifier.
18func (s ANSIStatusReport) StatusReport() int {
19 return int(s)
20}
21
22// DECStatusReport represents a DEC terminal status report.
23type DECStatusReport int
24
25// Status returns the status report identifier.
26func (s DECStatusReport) StatusReport() int {
27 return int(s)
28}
29
30// DeviceStatusReport (DSR) is a control sequence that reports the terminal's
31// status.
32// The terminal responds with a DSR sequence.
33//
34// CSI Ps n
35// CSI ? Ps n
36//
37// If one of the statuses is a [DECStatus], the sequence will use the DEC
38// format.
39//
40// See also https://vt100.net/docs/vt510-rm/DSR.html
41func DeviceStatusReport(statues ...StatusReport) string {
42 var dec bool
43 list := make([]string, len(statues))
44 seq := "\x1b["
45 for i, status := range statues {
46 list[i] = strconv.Itoa(status.StatusReport())
47 switch status.(type) {
48 case DECStatusReport:
49 dec = true
50 }
51 }
52 if dec {
53 seq += "?"
54 }
55 return seq + strings.Join(list, ";") + "n"
56}
57
58// DSR is an alias for [DeviceStatusReport].
59func DSR(status StatusReport) string {
60 return DeviceStatusReport(status)
61}
62
63// RequestCursorPositionReport is an escape sequence that requests the current
64// cursor position.
65//
66// CSI 6 n
67//
68// The terminal will report the cursor position as a CSI sequence in the
69// following format:
70//
71// CSI Pl ; Pc R
72//
73// Where Pl is the line number and Pc is the column number.
74// See: https://vt100.net/docs/vt510-rm/CPR.html
75const RequestCursorPositionReport = "\x1b[6n"
76
77// RequestExtendedCursorPositionReport (DECXCPR) is a sequence for requesting
78// the cursor position report including the current page number.
79//
80// CSI ? 6 n
81//
82// The terminal will report the cursor position as a CSI sequence in the
83// following format:
84//
85// CSI ? Pl ; Pc ; Pp R
86//
87// Where Pl is the line number, Pc is the column number, and Pp is the page
88// number.
89// See: https://vt100.net/docs/vt510-rm/DECXCPR.html
90const RequestExtendedCursorPositionReport = "\x1b[?6n"
91
92// CursorPositionReport (CPR) is a control sequence that reports the cursor's
93// position.
94//
95// CSI Pl ; Pc R
96//
97// Where Pl is the line number and Pc is the column number.
98//
99// See also https://vt100.net/docs/vt510-rm/CPR.html
100func CursorPositionReport(line, column int) string {
101 if line < 1 {
102 line = 1
103 }
104 if column < 1 {
105 column = 1
106 }
107 return "\x1b[" + strconv.Itoa(line) + ";" + strconv.Itoa(column) + "R"
108}
109
110// CPR is an alias for [CursorPositionReport].
111func CPR(line, column int) string {
112 return CursorPositionReport(line, column)
113}
114
115// ExtendedCursorPositionReport (DECXCPR) is a control sequence that reports the
116// cursor's position along with the page number (optional).
117//
118// CSI ? Pl ; Pc R
119// CSI ? Pl ; Pc ; Pv R
120//
121// Where Pl is the line number, Pc is the column number, and Pv is the page
122// number.
123//
124// If the page number is zero or negative, the returned sequence won't include
125// the page number.
126//
127// See also https://vt100.net/docs/vt510-rm/DECXCPR.html
128func ExtendedCursorPositionReport(line, column, page int) string {
129 if line < 1 {
130 line = 1
131 }
132 if column < 1 {
133 column = 1
134 }
135 if page < 1 {
136 return "\x1b[?" + strconv.Itoa(line) + ";" + strconv.Itoa(column) + "R"
137 }
138 return "\x1b[?" + strconv.Itoa(line) + ";" + strconv.Itoa(column) + ";" + strconv.Itoa(page) + "R"
139}
140
141// DECXCPR is an alias for [ExtendedCursorPositionReport].
142func DECXCPR(line, column, page int) string {
143 return ExtendedCursorPositionReport(line, column, page)
144}
vendor/github.com/charmbracelet/x/ansi/style.go +443 −79
@@ -12,10 +12,10 @@ import (
1212const ResetStyle = "\x1b[m"
1313
1414// Attr is a SGR (Select Graphic Rendition) style attribute.
15type Attr = string
15type Attr = int
1616
1717// Style represents an ANSI SGR (Select Graphic Rendition) style.
18type Style []Attr
18type Style []string
1919
2020// String returns the ANSI SGR (Select Graphic Rendition) style sequence for
2121// the given style.
@@ -36,186 +36,357 @@ func (s Style) Styled(str string) string {
3636
3737// Reset appends the reset style attribute to the style.
3838func (s Style) Reset() Style {
39 return append(s, ResetAttr)
39 return append(s, resetAttr)
4040}
4141
4242// Bold appends the bold style attribute to the style.
4343func (s Style) Bold() Style {
44 return append(s, BoldAttr)
44 return append(s, boldAttr)
4545}
4646
4747// Faint appends the faint style attribute to the style.
4848func (s Style) Faint() Style {
49 return append(s, FaintAttr)
49 return append(s, faintAttr)
5050}
5151
5252// Italic appends the italic style attribute to the style.
5353func (s Style) Italic() Style {
54 return append(s, ItalicAttr)
54 return append(s, italicAttr)
5555}
5656
5757// Underline appends the underline style attribute to the style.
5858func (s Style) Underline() Style {
59 return append(s, UnderlineAttr)
59 return append(s, underlineAttr)
60}
61
62// UnderlineStyle appends the underline style attribute to the style.
63func (s Style) UnderlineStyle(u UnderlineStyle) Style {
64 switch u {
65 case NoUnderlineStyle:
66 return s.NoUnderline()
67 case SingleUnderlineStyle:
68 return s.Underline()
69 case DoubleUnderlineStyle:
70 return append(s, doubleUnderlineStyle)
71 case CurlyUnderlineStyle:
72 return append(s, curlyUnderlineStyle)
73 case DottedUnderlineStyle:
74 return append(s, dottedUnderlineStyle)
75 case DashedUnderlineStyle:
76 return append(s, dashedUnderlineStyle)
77 }
78 return s
6079}
6180
6281// DoubleUnderline appends the double underline style attribute to the style.
82// This is a convenience method for UnderlineStyle(DoubleUnderlineStyle).
6383func (s Style) DoubleUnderline() Style {
64 return append(s, DoubleUnderlineAttr)
84 return s.UnderlineStyle(DoubleUnderlineStyle)
6585}
6686
6787// CurlyUnderline appends the curly underline style attribute to the style.
88// This is a convenience method for UnderlineStyle(CurlyUnderlineStyle).
6889func (s Style) CurlyUnderline() Style {
69 return append(s, CurlyUnderlineAttr)
90 return s.UnderlineStyle(CurlyUnderlineStyle)
7091}
7192
7293// DottedUnderline appends the dotted underline style attribute to the style.
94// This is a convenience method for UnderlineStyle(DottedUnderlineStyle).
7395func (s Style) DottedUnderline() Style {
74 return append(s, DottedUnderlineAttr)
96 return s.UnderlineStyle(DottedUnderlineStyle)
7597}
7698
7799// DashedUnderline appends the dashed underline style attribute to the style.
100// This is a convenience method for UnderlineStyle(DashedUnderlineStyle).
78101func (s Style) DashedUnderline() Style {
79 return append(s, DashedUnderlineAttr)
102 return s.UnderlineStyle(DashedUnderlineStyle)
80103}
81104
82105// SlowBlink appends the slow blink style attribute to the style.
83106func (s Style) SlowBlink() Style {
84 return append(s, SlowBlinkAttr)
107 return append(s, slowBlinkAttr)
85108}
86109
87110// RapidBlink appends the rapid blink style attribute to the style.
88111func (s Style) RapidBlink() Style {
89 return append(s, RapidBlinkAttr)
112 return append(s, rapidBlinkAttr)
90113}
91114
92115// Reverse appends the reverse style attribute to the style.
93116func (s Style) Reverse() Style {
94 return append(s, ReverseAttr)
117 return append(s, reverseAttr)
95118}
96119
97120// Conceal appends the conceal style attribute to the style.
98121func (s Style) Conceal() Style {
99 return append(s, ConcealAttr)
122 return append(s, concealAttr)
100123}
101124
102125// Strikethrough appends the strikethrough style attribute to the style.
103126func (s Style) Strikethrough() Style {
104 return append(s, StrikethroughAttr)
127 return append(s, strikethroughAttr)
105128}
106129
107130// NoBold appends the no bold style attribute to the style.
108131func (s Style) NoBold() Style {
109 return append(s, NoBoldAttr)
132 return append(s, noBoldAttr)
110133}
111134
112135// NormalIntensity appends the normal intensity style attribute to the style.
113136func (s Style) NormalIntensity() Style {
114 return append(s, NormalIntensityAttr)
137 return append(s, normalIntensityAttr)
115138}
116139
117140// NoItalic appends the no italic style attribute to the style.
118141func (s Style) NoItalic() Style {
119 return append(s, NoItalicAttr)
142 return append(s, noItalicAttr)
120143}
121144
122145// NoUnderline appends the no underline style attribute to the style.
123146func (s Style) NoUnderline() Style {
124 return append(s, NoUnderlineAttr)
147 return append(s, noUnderlineAttr)
125148}
126149
127150// NoBlink appends the no blink style attribute to the style.
128151func (s Style) NoBlink() Style {
129 return append(s, NoBlinkAttr)
152 return append(s, noBlinkAttr)
130153}
131154
132155// NoReverse appends the no reverse style attribute to the style.
133156func (s Style) NoReverse() Style {
134 return append(s, NoReverseAttr)
157 return append(s, noReverseAttr)
135158}
136159
137160// NoConceal appends the no conceal style attribute to the style.
138161func (s Style) NoConceal() Style {
139 return append(s, NoConcealAttr)
162 return append(s, noConcealAttr)
140163}
141164
142165// NoStrikethrough appends the no strikethrough style attribute to the style.
143166func (s Style) NoStrikethrough() Style {
144 return append(s, NoStrikethroughAttr)
167 return append(s, noStrikethroughAttr)
145168}
146169
147170// DefaultForegroundColor appends the default foreground color style attribute to the style.
148171func (s Style) DefaultForegroundColor() Style {
149 return append(s, DefaultForegroundColorAttr)
172 return append(s, defaultForegroundColorAttr)
150173}
151174
152175// DefaultBackgroundColor appends the default background color style attribute to the style.
153176func (s Style) DefaultBackgroundColor() Style {
154 return append(s, DefaultBackgroundColorAttr)
177 return append(s, defaultBackgroundColorAttr)
155178}
156179
157180// DefaultUnderlineColor appends the default underline color style attribute to the style.
158181func (s Style) DefaultUnderlineColor() Style {
159 return append(s, DefaultUnderlineColorAttr)
182 return append(s, defaultUnderlineColorAttr)
160183}
161184
162185// ForegroundColor appends the foreground color style attribute to the style.
163186func (s Style) ForegroundColor(c Color) Style {
164 return append(s, ForegroundColorAttr(c))
187 return append(s, foregroundColorString(c))
165188}
166189
167190// BackgroundColor appends the background color style attribute to the style.
168191func (s Style) BackgroundColor(c Color) Style {
169 return append(s, BackgroundColorAttr(c))
192 return append(s, backgroundColorString(c))
170193}
171194
172195// UnderlineColor appends the underline color style attribute to the style.
173196func (s Style) UnderlineColor(c Color) Style {
174 return append(s, UnderlineColorAttr(c))
197 return append(s, underlineColorString(c))
175198}
176199
200// UnderlineStyle represents an ANSI SGR (Select Graphic Rendition) underline
201// style.
202type UnderlineStyle = byte
203
204const (
205 doubleUnderlineStyle = "4:2"
206 curlyUnderlineStyle = "4:3"
207 dottedUnderlineStyle = "4:4"
208 dashedUnderlineStyle = "4:5"
209)
210
211const (
212 // NoUnderlineStyle is the default underline style.
213 NoUnderlineStyle UnderlineStyle = iota
214 // SingleUnderlineStyle is a single underline style.
215 SingleUnderlineStyle
216 // DoubleUnderlineStyle is a double underline style.
217 DoubleUnderlineStyle
218 // CurlyUnderlineStyle is a curly underline style.
219 CurlyUnderlineStyle
220 // DottedUnderlineStyle is a dotted underline style.
221 DottedUnderlineStyle
222 // DashedUnderlineStyle is a dashed underline style.
223 DashedUnderlineStyle
224)
225
177226// SGR (Select Graphic Rendition) style attributes.
178227// See: https://en.wikipedia.org/wiki/ANSI_escape_code#SGR_(Select_Graphic_Rendition)_parameters
179228const (
180 ResetAttr Attr = "0"
181 BoldAttr Attr = "1"
182 FaintAttr Attr = "2"
183 ItalicAttr Attr = "3"
184 UnderlineAttr Attr = "4"
185 DoubleUnderlineAttr Attr = "4:2"
186 CurlyUnderlineAttr Attr = "4:3"
187 DottedUnderlineAttr Attr = "4:4"
188 DashedUnderlineAttr Attr = "4:5"
189 SlowBlinkAttr Attr = "5"
190 RapidBlinkAttr Attr = "6"
191 ReverseAttr Attr = "7"
192 ConcealAttr Attr = "8"
193 StrikethroughAttr Attr = "9"
194 NoBoldAttr Attr = "21" // Some terminals treat this as double underline.
195 NormalIntensityAttr Attr = "22"
196 NoItalicAttr Attr = "23"
197 NoUnderlineAttr Attr = "24"
198 NoBlinkAttr Attr = "25"
199 NoReverseAttr Attr = "27"
200 NoConcealAttr Attr = "28"
201 NoStrikethroughAttr Attr = "29"
202 DefaultForegroundColorAttr Attr = "39"
203 DefaultBackgroundColorAttr Attr = "49"
204 DefaultUnderlineColorAttr Attr = "59"
229 ResetAttr Attr = 0
230 BoldAttr Attr = 1
231 FaintAttr Attr = 2
232 ItalicAttr Attr = 3
233 UnderlineAttr Attr = 4
234 SlowBlinkAttr Attr = 5
235 RapidBlinkAttr Attr = 6
236 ReverseAttr Attr = 7
237 ConcealAttr Attr = 8
238 StrikethroughAttr Attr = 9
239 NoBoldAttr Attr = 21 // Some terminals treat this as double underline.
240 NormalIntensityAttr Attr = 22
241 NoItalicAttr Attr = 23
242 NoUnderlineAttr Attr = 24
243 NoBlinkAttr Attr = 25
244 NoReverseAttr Attr = 27
245 NoConcealAttr Attr = 28
246 NoStrikethroughAttr Attr = 29
247 BlackForegroundColorAttr Attr = 30
248 RedForegroundColorAttr Attr = 31
249 GreenForegroundColorAttr Attr = 32
250 YellowForegroundColorAttr Attr = 33
251 BlueForegroundColorAttr Attr = 34
252 MagentaForegroundColorAttr Attr = 35
253 CyanForegroundColorAttr Attr = 36
254 WhiteForegroundColorAttr Attr = 37
255 ExtendedForegroundColorAttr Attr = 38
256 DefaultForegroundColorAttr Attr = 39
257 BlackBackgroundColorAttr Attr = 40
258 RedBackgroundColorAttr Attr = 41
259 GreenBackgroundColorAttr Attr = 42
260 YellowBackgroundColorAttr Attr = 43
261 BlueBackgroundColorAttr Attr = 44
262 MagentaBackgroundColorAttr Attr = 45
263 CyanBackgroundColorAttr Attr = 46
264 WhiteBackgroundColorAttr Attr = 47
265 ExtendedBackgroundColorAttr Attr = 48
266 DefaultBackgroundColorAttr Attr = 49
267 ExtendedUnderlineColorAttr Attr = 58
268 DefaultUnderlineColorAttr Attr = 59
269 BrightBlackForegroundColorAttr Attr = 90
270 BrightRedForegroundColorAttr Attr = 91
271 BrightGreenForegroundColorAttr Attr = 92
272 BrightYellowForegroundColorAttr Attr = 93
273 BrightBlueForegroundColorAttr Attr = 94
274 BrightMagentaForegroundColorAttr Attr = 95
275 BrightCyanForegroundColorAttr Attr = 96
276 BrightWhiteForegroundColorAttr Attr = 97
277 BrightBlackBackgroundColorAttr Attr = 100
278 BrightRedBackgroundColorAttr Attr = 101
279 BrightGreenBackgroundColorAttr Attr = 102
280 BrightYellowBackgroundColorAttr Attr = 103
281 BrightBlueBackgroundColorAttr Attr = 104
282 BrightMagentaBackgroundColorAttr Attr = 105
283 BrightCyanBackgroundColorAttr Attr = 106
284 BrightWhiteBackgroundColorAttr Attr = 107
285
286 RGBColorIntroducerAttr Attr = 2
287 ExtendedColorIntroducerAttr Attr = 5
205288)
206289
207// ForegroundColorAttr returns the style SGR attribute for the given foreground
208// color.
290const (
291 resetAttr = "0"
292 boldAttr = "1"
293 faintAttr = "2"
294 italicAttr = "3"
295 underlineAttr = "4"
296 slowBlinkAttr = "5"
297 rapidBlinkAttr = "6"
298 reverseAttr = "7"
299 concealAttr = "8"
300 strikethroughAttr = "9"
301 noBoldAttr = "21"
302 normalIntensityAttr = "22"
303 noItalicAttr = "23"
304 noUnderlineAttr = "24"
305 noBlinkAttr = "25"
306 noReverseAttr = "27"
307 noConcealAttr = "28"
308 noStrikethroughAttr = "29"
309 blackForegroundColorAttr = "30"
310 redForegroundColorAttr = "31"
311 greenForegroundColorAttr = "32"
312 yellowForegroundColorAttr = "33"
313 blueForegroundColorAttr = "34"
314 magentaForegroundColorAttr = "35"
315 cyanForegroundColorAttr = "36"
316 whiteForegroundColorAttr = "37"
317 extendedForegroundColorAttr = "38"
318 defaultForegroundColorAttr = "39"
319 blackBackgroundColorAttr = "40"
320 redBackgroundColorAttr = "41"
321 greenBackgroundColorAttr = "42"
322 yellowBackgroundColorAttr = "43"
323 blueBackgroundColorAttr = "44"
324 magentaBackgroundColorAttr = "45"
325 cyanBackgroundColorAttr = "46"
326 whiteBackgroundColorAttr = "47"
327 extendedBackgroundColorAttr = "48"
328 defaultBackgroundColorAttr = "49"
329 extendedUnderlineColorAttr = "58"
330 defaultUnderlineColorAttr = "59"
331 brightBlackForegroundColorAttr = "90"
332 brightRedForegroundColorAttr = "91"
333 brightGreenForegroundColorAttr = "92"
334 brightYellowForegroundColorAttr = "93"
335 brightBlueForegroundColorAttr = "94"
336 brightMagentaForegroundColorAttr = "95"
337 brightCyanForegroundColorAttr = "96"
338 brightWhiteForegroundColorAttr = "97"
339 brightBlackBackgroundColorAttr = "100"
340 brightRedBackgroundColorAttr = "101"
341 brightGreenBackgroundColorAttr = "102"
342 brightYellowBackgroundColorAttr = "103"
343 brightBlueBackgroundColorAttr = "104"
344 brightMagentaBackgroundColorAttr = "105"
345 brightCyanBackgroundColorAttr = "106"
346 brightWhiteBackgroundColorAttr = "107"
347)
348
349// foregroundColorString returns the style SGR attribute for the given
350// foreground color.
209351// See: https://en.wikipedia.org/wiki/ANSI_escape_code#SGR_(Select_Graphic_Rendition)_parameters
210func ForegroundColorAttr(c Color) Attr {
352func foregroundColorString(c Color) string {
211353 switch c := c.(type) {
212354 case BasicColor:
213355 // 3-bit or 4-bit ANSI foreground
214356 // "3<n>" or "9<n>" where n is the color number from 0 to 7
215 if c < 8 {
216 return "3" + string('0'+c)
217 } else if c < 16 {
218 return "9" + string('0'+c-8)
357 switch c {
358 case Black:
359 return blackForegroundColorAttr
360 case Red:
361 return redForegroundColorAttr
362 case Green:
363 return greenForegroundColorAttr
364 case Yellow:
365 return yellowForegroundColorAttr
366 case Blue:
367 return blueForegroundColorAttr
368 case Magenta:
369 return magentaForegroundColorAttr
370 case Cyan:
371 return cyanForegroundColorAttr
372 case White:
373 return whiteForegroundColorAttr
374 case BrightBlack:
375 return brightBlackForegroundColorAttr
376 case BrightRed:
377 return brightRedForegroundColorAttr
378 case BrightGreen:
379 return brightGreenForegroundColorAttr
380 case BrightYellow:
381 return brightYellowForegroundColorAttr
382 case BrightBlue:
383 return brightBlueForegroundColorAttr
384 case BrightMagenta:
385 return brightMagentaForegroundColorAttr
386 case BrightCyan:
387 return brightCyanForegroundColorAttr
388 case BrightWhite:
389 return brightWhiteForegroundColorAttr
219390 }
220391 case ExtendedColor:
221392 // 256-color ANSI foreground
@@ -230,21 +401,50 @@ func ForegroundColorAttr(c Color) Attr {
230401 strconv.FormatUint(uint64(shift(g)), 10) + ";" +
231402 strconv.FormatUint(uint64(shift(b)), 10)
232403 }
233 return DefaultForegroundColorAttr
404 return defaultForegroundColorAttr
234405}
235406
236// BackgroundColorAttr returns the style SGR attribute for the given background
237// color.
407// backgroundColorString returns the style SGR attribute for the given
408// background color.
238409// See: https://en.wikipedia.org/wiki/ANSI_escape_code#SGR_(Select_Graphic_Rendition)_parameters
239func BackgroundColorAttr(c Color) Attr {
410func backgroundColorString(c Color) string {
240411 switch c := c.(type) {
241412 case BasicColor:
242413 // 3-bit or 4-bit ANSI foreground
243414 // "4<n>" or "10<n>" where n is the color number from 0 to 7
244 if c < 8 {
245 return "4" + string('0'+c)
246 } else {
247 return "10" + string('0'+c-8)
415 switch c {
416 case Black:
417 return blackBackgroundColorAttr
418 case Red:
419 return redBackgroundColorAttr
420 case Green:
421 return greenBackgroundColorAttr
422 case Yellow:
423 return yellowBackgroundColorAttr
424 case Blue:
425 return blueBackgroundColorAttr
426 case Magenta:
427 return magentaBackgroundColorAttr
428 case Cyan:
429 return cyanBackgroundColorAttr
430 case White:
431 return whiteBackgroundColorAttr
432 case BrightBlack:
433 return brightBlackBackgroundColorAttr
434 case BrightRed:
435 return brightRedBackgroundColorAttr
436 case BrightGreen:
437 return brightGreenBackgroundColorAttr
438 case BrightYellow:
439 return brightYellowBackgroundColorAttr
440 case BrightBlue:
441 return brightBlueBackgroundColorAttr
442 case BrightMagenta:
443 return brightMagentaBackgroundColorAttr
444 case BrightCyan:
445 return brightCyanBackgroundColorAttr
446 case BrightWhite:
447 return brightWhiteBackgroundColorAttr
248448 }
249449 case ExtendedColor:
250450 // 256-color ANSI foreground
@@ -259,13 +459,13 @@ func BackgroundColorAttr(c Color) Attr {
259459 strconv.FormatUint(uint64(shift(g)), 10) + ";" +
260460 strconv.FormatUint(uint64(shift(b)), 10)
261461 }
262 return DefaultBackgroundColorAttr
462 return defaultBackgroundColorAttr
263463}
264464
265// UnderlineColorAttr returns the style SGR attribute for the given underline
465// underlineColorString returns the style SGR attribute for the given underline
266466// color.
267467// See: https://en.wikipedia.org/wiki/ANSI_escape_code#SGR_(Select_Graphic_Rendition)_parameters
268func UnderlineColorAttr(c Color) Attr {
468func underlineColorString(c Color) string {
269469 switch c := c.(type) {
270470 // NOTE: we can't use 3-bit and 4-bit ANSI color codes with underline
271471 // color, use 256-color instead.
@@ -285,12 +485,176 @@ func UnderlineColorAttr(c Color) Attr {
285485 strconv.FormatUint(uint64(shift(g)), 10) + ";" +
286486 strconv.FormatUint(uint64(shift(b)), 10)
287487 }
288 return DefaultUnderlineColorAttr
289}
488 return defaultUnderlineColorAttr
489}
490
491// ReadStyleColor decodes a color from a slice of parameters. It returns the
492// number of parameters read and the color. This function is used to read SGR
493// color parameters following the ITU T.416 standard.
494//
495// It supports reading the following color types:
496// - 0: implementation defined
497// - 1: transparent
498// - 2: RGB direct color
499// - 3: CMY direct color
500// - 4: CMYK direct color
501// - 5: indexed color
502// - 6: RGBA direct color (WezTerm extension)
503//
504// The parameters can be separated by semicolons (;) or colons (:). Mixing
505// separators is not allowed.
506//
507// The specs supports defining a color space id, a color tolerance value, and a
508// tolerance color space id. However, these values have no effect on the
509// returned color and will be ignored.
510//
511// This implementation includes a few modifications to the specs:
512// 1. Support for legacy color values separated by semicolons (;) with respect to RGB, and indexed colors
513// 2. Support ignoring and omitting the color space id (second parameter) with respect to RGB colors
514// 3. Support ignoring and omitting the 6th parameter with respect to RGB and CMY colors
515// 4. Support reading RGBA colors
516func ReadStyleColor(params Params, co *color.Color) (n int) {
517 if len(params) < 2 { // Need at least SGR type and color type
518 return 0
519 }
520
521 // First parameter indicates one of 38, 48, or 58 (foreground, background, or underline)
522 s := params[0]
523 p := params[1]
524 colorType := p.Param(0)
525 n = 2
526
527 paramsfn := func() (p1, p2, p3, p4 int) {
528 // Where should we start reading the color?
529 switch {
530 case s.HasMore() && p.HasMore() && len(params) > 8 && params[2].HasMore() && params[3].HasMore() && params[4].HasMore() && params[5].HasMore() && params[6].HasMore() && params[7].HasMore():
531 // We have color space id, a 6th parameter, a tolerance value, and a tolerance color space
532 n += 7
533 return params[3].Param(0), params[4].Param(0), params[5].Param(0), params[6].Param(0)
534 case s.HasMore() && p.HasMore() && len(params) > 7 && params[2].HasMore() && params[3].HasMore() && params[4].HasMore() && params[5].HasMore() && params[6].HasMore():
535 // We have color space id, a 6th parameter, and a tolerance value
536 n += 6
537 return params[3].Param(0), params[4].Param(0), params[5].Param(0), params[6].Param(0)
538 case s.HasMore() && p.HasMore() && len(params) > 6 && params[2].HasMore() && params[3].HasMore() && params[4].HasMore() && params[5].HasMore():
539 // We have color space id and a 6th parameter
540 // 48 : 4 : : 1 : 2 : 3 :4
541 n += 5
542 return params[3].Param(0), params[4].Param(0), params[5].Param(0), params[6].Param(0)
543 case s.HasMore() && p.HasMore() && len(params) > 5 && params[2].HasMore() && params[3].HasMore() && params[4].HasMore() && !params[5].HasMore():
544 // We have color space
545 // 48 : 3 : : 1 : 2 : 3
546 n += 4
547 return params[3].Param(0), params[4].Param(0), params[5].Param(0), -1
548 case s.HasMore() && p.HasMore() && p.Param(0) == 2 && params[2].HasMore() && params[3].HasMore() && !params[4].HasMore():
549 // We have color values separated by colons (:)
550 // 48 : 2 : 1 : 2 : 3
551 fallthrough
552 case !s.HasMore() && !p.HasMore() && p.Param(0) == 2 && !params[2].HasMore() && !params[3].HasMore() && !params[4].HasMore():
553 // Support legacy color values separated by semicolons (;)
554 // 48 ; 2 ; 1 ; 2 ; 3
555 n += 3
556 return params[2].Param(0), params[3].Param(0), params[4].Param(0), -1
557 }
558 // Ambiguous SGR color
559 return -1, -1, -1, -1
560 }
561
562 switch colorType {
563 case 0: // implementation defined
564 return 2
565 case 1: // transparent
566 *co = color.Transparent
567 return 2
568 case 2: // RGB direct color
569 if len(params) < 5 {
570 return 0
571 }
572
573 r, g, b, _ := paramsfn()
574 if r == -1 || g == -1 || b == -1 {
575 return 0
576 }
577
578 *co = color.RGBA{
579 R: uint8(r), //nolint:gosec
580 G: uint8(g), //nolint:gosec
581 B: uint8(b), //nolint:gosec
582 A: 0xff,
583 }
584 return
585
586 case 3: // CMY direct color
587 if len(params) < 5 {
588 return 0
589 }
590
591 c, m, y, _ := paramsfn()
592 if c == -1 || m == -1 || y == -1 {
593 return 0
594 }
595
596 *co = color.CMYK{
597 C: uint8(c), //nolint:gosec
598 M: uint8(m), //nolint:gosec
599 Y: uint8(y), //nolint:gosec
600 K: 0,
601 }
602 return
603
604 case 4: // CMYK direct color
605 if len(params) < 6 {
606 return 0
607 }
608
609 c, m, y, k := paramsfn()
610 if c == -1 || m == -1 || y == -1 || k == -1 {
611 return 0
612 }
613
614 *co = color.CMYK{
615 C: uint8(c), //nolint:gosec
616 M: uint8(m), //nolint:gosec
617 Y: uint8(y), //nolint:gosec
618 K: uint8(k), //nolint:gosec
619 }
620 return
621
622 case 5: // indexed color
623 if len(params) < 3 {
624 return 0
625 }
626 switch {
627 case s.HasMore() && p.HasMore() && !params[2].HasMore():
628 // Colon separated indexed color
629 // 38 : 5 : 234
630 case !s.HasMore() && !p.HasMore() && !params[2].HasMore():
631 // Legacy semicolon indexed color
632 // 38 ; 5 ; 234
633 default:
634 return 0
635 }
636 *co = ExtendedColor(params[2].Param(0)) //nolint:gosec
637 return 3
638
639 case 6: // RGBA direct color
640 if len(params) < 6 {
641 return 0
642 }
643
644 r, g, b, a := paramsfn()
645 if r == -1 || g == -1 || b == -1 || a == -1 {
646 return 0
647 }
648
649 *co = color.RGBA{
650 R: uint8(r), //nolint:gosec
651 G: uint8(g), //nolint:gosec
652 B: uint8(b), //nolint:gosec
653 A: uint8(a), //nolint:gosec
654 }
655 return
290656
291func shift(v uint32) uint32 {
292 if v > 0xff {
293 return v >> 8
657 default:
658 return 0
294659 }
295 return v
296660}
vendor/github.com/charmbracelet/x/ansi/termcap.go +11 −1
@@ -14,7 +14,7 @@ import (
1414//
1515// See: https://man7.org/linux/man-pages/man5/terminfo.5.html
1616// See: https://invisible-island.net/xterm/ctlseqs/ctlseqs.html#h3-Operating-System-Commands
17func RequestTermcap(caps ...string) string {
17func XTGETTCAP(caps ...string) string {
1818 if len(caps) == 0 {
1919 return ""
2020 }
@@ -29,3 +29,13 @@ func RequestTermcap(caps ...string) string {
2929
3030 return s + "\x1b\\"
3131}
32
33// RequestTermcap is an alias for [XTGETTCAP].
34func RequestTermcap(caps ...string) string {
35 return XTGETTCAP(caps...)
36}
37
38// RequestTerminfo is an alias for [XTGETTCAP].
39func RequestTerminfo(caps ...string) string {
40 return XTGETTCAP(caps...)
41}
vendor/github.com/charmbracelet/x/ansi/truncate.go +179 −4
@@ -4,14 +4,65 @@ import (
44 "bytes"
55
66 "github.com/charmbracelet/x/ansi/parser"
7 "github.com/mattn/go-runewidth"
78 "github.com/rivo/uniseg"
89)
910
10// Truncate truncates a string to a given length, adding a tail to the
11// end if the string is longer than the given length.
12// This function is aware of ANSI escape codes and will not break them, and
13// accounts for wide-characters (such as East Asians and emojis).
11// Cut the string, without adding any prefix or tail strings. This function is
12// aware of ANSI escape codes and will not break them, and accounts for
13// wide-characters (such as East-Asian characters and emojis). Note that the
14// [left] parameter is inclusive, while [right] isn't.
15// This treats the text as a sequence of graphemes.
16func Cut(s string, left, right int) string {
17 return cut(GraphemeWidth, s, left, right)
18}
19
20// CutWc the string, without adding any prefix or tail strings. This function is
21// aware of ANSI escape codes and will not break them, and accounts for
22// wide-characters (such as East-Asian characters and emojis). Note that the
23// [left] parameter is inclusive, while [right] isn't.
24// This treats the text as a sequence of wide characters and runes.
25func CutWc(s string, left, right int) string {
26 return cut(WcWidth, s, left, right)
27}
28
29func cut(m Method, s string, left, right int) string {
30 if right <= left {
31 return ""
32 }
33
34 truncate := Truncate
35 truncateLeft := TruncateLeft
36 if m == WcWidth {
37 truncate = TruncateWc
38 truncateLeft = TruncateWc
39 }
40
41 if left == 0 {
42 return truncate(s, right, "")
43 }
44 return truncateLeft(Truncate(s, right, ""), left, "")
45}
46
47// Truncate truncates a string to a given length, adding a tail to the end if
48// the string is longer than the given length. This function is aware of ANSI
49// escape codes and will not break them, and accounts for wide-characters (such
50// as East-Asian characters and emojis).
51// This treats the text as a sequence of graphemes.
1452func Truncate(s string, length int, tail string) string {
53 return truncate(GraphemeWidth, s, length, tail)
54}
55
56// TruncateWc truncates a string to a given length, adding a tail to the end if
57// the string is longer than the given length. This function is aware of ANSI
58// escape codes and will not break them, and accounts for wide-characters (such
59// as East-Asian characters and emojis).
60// This treats the text as a sequence of wide characters and runes.
61func TruncateWc(s string, length int, tail string) string {
62 return truncate(WcWidth, s, length, tail)
63}
64
65func truncate(m Method, s string, length int, tail string) string {
1566 if sw := StringWidth(s); sw <= length {
1667 return s
1768 }
@@ -33,6 +84,7 @@ func Truncate(s string, length int, tail string) string {
3384 // Here we iterate over the bytes of the string and collect printable
3485 // characters and runes. We also keep track of the width of the string
3586 // in cells.
87 //
3688 // Once we reach the given length, we start ignoring characters and only
3789 // collect ANSI escape codes until we reach the end of string.
3890 for i < len(b) {
@@ -41,6 +93,9 @@ func Truncate(s string, length int, tail string) string {
4193 // This action happens when we transition to the Utf8State.
4294 var width int
4395 cluster, _, width, _ = uniseg.FirstGraphemeCluster(b[i:], -1)
96 if m == WcWidth {
97 width = runewidth.StringWidth(string(cluster))
98 }
4499
45100 // increment the index by the length of the cluster
46101 i += len(cluster)
@@ -105,3 +160,123 @@ func Truncate(s string, length int, tail string) string {
105160
106161 return buf.String()
107162}
163
164// TruncateLeft truncates a string from the left side by removing n characters,
165// adding a prefix to the beginning if the string is longer than n.
166// This function is aware of ANSI escape codes and will not break them, and
167// accounts for wide-characters (such as East-Asian characters and emojis).
168// This treats the text as a sequence of graphemes.
169func TruncateLeft(s string, n int, prefix string) string {
170 return truncateLeft(GraphemeWidth, s, n, prefix)
171}
172
173// TruncateLeftWc truncates a string from the left side by removing n characters,
174// adding a prefix to the beginning if the string is longer than n.
175// This function is aware of ANSI escape codes and will not break them, and
176// accounts for wide-characters (such as East-Asian characters and emojis).
177// This treats the text as a sequence of wide characters and runes.
178func TruncateLeftWc(s string, n int, prefix string) string {
179 return truncateLeft(WcWidth, s, n, prefix)
180}
181
182func truncateLeft(m Method, s string, n int, prefix string) string {
183 if n <= 0 {
184 return s
185 }
186
187 var cluster []byte
188 var buf bytes.Buffer
189 curWidth := 0
190 ignoring := true
191 pstate := parser.GroundState
192 b := []byte(s)
193 i := 0
194
195 for i < len(b) {
196 if !ignoring {
197 buf.Write(b[i:])
198 break
199 }
200
201 state, action := parser.Table.Transition(pstate, b[i])
202 if state == parser.Utf8State {
203 var width int
204 cluster, _, width, _ = uniseg.FirstGraphemeCluster(b[i:], -1)
205 if m == WcWidth {
206 width = runewidth.StringWidth(string(cluster))
207 }
208
209 i += len(cluster)
210 curWidth += width
211
212 if curWidth > n && ignoring {
213 ignoring = false
214 buf.WriteString(prefix)
215 }
216
217 if ignoring {
218 continue
219 }
220
221 if curWidth > n {
222 buf.Write(cluster)
223 }
224
225 pstate = parser.GroundState
226 continue
227 }
228
229 switch action {
230 case parser.PrintAction:
231 curWidth++
232
233 if curWidth > n && ignoring {
234 ignoring = false
235 buf.WriteString(prefix)
236 }
237
238 if ignoring {
239 i++
240 continue
241 }
242
243 fallthrough
244 default:
245 buf.WriteByte(b[i])
246 i++
247 }
248
249 pstate = state
250 if curWidth > n && ignoring {
251 ignoring = false
252 buf.WriteString(prefix)
253 }
254 }
255
256 return buf.String()
257}
258
259// ByteToGraphemeRange takes start and stop byte positions and converts them to
260// grapheme-aware char positions.
261// You can use this with [Truncate], [TruncateLeft], and [Cut].
262func ByteToGraphemeRange(str string, byteStart, byteStop int) (charStart, charStop int) {
263 bytePos, charPos := 0, 0
264 gr := uniseg.NewGraphemes(str)
265 for byteStart > bytePos {
266 if !gr.Next() {
267 break
268 }
269 bytePos += len(gr.Str())
270 charPos += max(1, gr.Width())
271 }
272 charStart = charPos
273 for byteStop > bytePos {
274 if !gr.Next() {
275 break
276 }
277 bytePos += len(gr.Str())
278 charPos += max(1, gr.Width())
279 }
280 charStop = charPos
281 return
282}
vendor/github.com/charmbracelet/x/ansi/util.go +77
@@ -3,6 +3,10 @@ package ansi
33import (
44 "fmt"
55 "image/color"
6 "strconv"
7 "strings"
8
9 "github.com/lucasb-eyer/go-colorful"
610)
711
812// colorToHexString returns a hex string representation of a color.
@@ -27,3 +31,76 @@ func colorToHexString(c color.Color) string {
2731func rgbToHex(r, g, b uint32) uint32 {
2832 return r<<16 + g<<8 + b
2933}
34
35type shiftable interface {
36 ~uint | ~uint16 | ~uint32 | ~uint64
37}
38
39func shift[T shiftable](x T) T {
40 if x > 0xff {
41 x >>= 8
42 }
43 return x
44}
45
46// XParseColor is a helper function that parses a string into a color.Color. It
47// provides a similar interface to the XParseColor function in Xlib. It
48// supports the following formats:
49//
50// - #RGB
51// - #RRGGBB
52// - rgb:RRRR/GGGG/BBBB
53// - rgba:RRRR/GGGG/BBBB/AAAA
54//
55// If the string is not a valid color, nil is returned.
56//
57// See: https://linux.die.net/man/3/xparsecolor
58func XParseColor(s string) color.Color {
59 switch {
60 case strings.HasPrefix(s, "#"):
61 c, err := colorful.Hex(s)
62 if err != nil {
63 return nil
64 }
65
66 return c
67 case strings.HasPrefix(s, "rgb:"):
68 parts := strings.Split(s[4:], "/")
69 if len(parts) != 3 {
70 return nil
71 }
72
73 r, _ := strconv.ParseUint(parts[0], 16, 32)
74 g, _ := strconv.ParseUint(parts[1], 16, 32)
75 b, _ := strconv.ParseUint(parts[2], 16, 32)
76
77 return color.RGBA{uint8(shift(r)), uint8(shift(g)), uint8(shift(b)), 255} //nolint:gosec
78 case strings.HasPrefix(s, "rgba:"):
79 parts := strings.Split(s[5:], "/")
80 if len(parts) != 4 {
81 return nil
82 }
83
84 r, _ := strconv.ParseUint(parts[0], 16, 32)
85 g, _ := strconv.ParseUint(parts[1], 16, 32)
86 b, _ := strconv.ParseUint(parts[2], 16, 32)
87 a, _ := strconv.ParseUint(parts[3], 16, 32)
88
89 return color.RGBA{uint8(shift(r)), uint8(shift(g)), uint8(shift(b)), uint8(shift(a))} //nolint:gosec
90 }
91 return nil
92}
93
94type ordered interface {
95 ~int | ~int8 | ~int16 | ~int32 | ~int64 |
96 ~uint | ~uint8 | ~uint16 | ~uint32 | ~uint64 | ~uintptr |
97 ~float32 | ~float64 |
98 ~string
99}
100
101func max[T ordered](a, b T) T { //nolint:predeclared
102 if a > b {
103 return a
104 }
105 return b
106}
vendor/github.com/charmbracelet/x/ansi/width.go +18
@@ -4,6 +4,7 @@ import (
44 "bytes"
55
66 "github.com/charmbracelet/x/ansi/parser"
7 "github.com/mattn/go-runewidth"
78 "github.com/rivo/uniseg"
89)
910
@@ -62,7 +63,21 @@ func Strip(s string) string {
6263// cells that the string will occupy when printed in a terminal. ANSI escape
6364// codes are ignored and wide characters (such as East Asians and emojis) are
6465// accounted for.
66// This treats the text as a sequence of grapheme clusters.
6567func StringWidth(s string) int {
68 return stringWidth(GraphemeWidth, s)
69}
70
71// StringWidthWc returns the width of a string in cells. This is the number of
72// cells that the string will occupy when printed in a terminal. ANSI escape
73// codes are ignored and wide characters (such as East Asians and emojis) are
74// accounted for.
75// This treats the text as a sequence of wide characters and runes.
76func StringWidthWc(s string) int {
77 return stringWidth(WcWidth, s)
78}
79
80func stringWidth(m Method, s string) int {
6681 if s == "" {
6782 return 0
6883 }
@@ -78,6 +93,9 @@ func StringWidth(s string) int {
7893 if state == parser.Utf8State {
7994 var w int
8095 cluster, _, w, _ = uniseg.FirstGraphemeClusterInString(s[i:], -1)
96 if m == WcWidth {
97 w = runewidth.StringWidth(cluster)
98 }
8199 width += w
82100 i += len(cluster) - 1
83101 pstate = parser.GroundState
vendor/github.com/charmbracelet/x/ansi/winop.go added +53
@@ -0,0 +1,53 @@
1package ansi
2
3import (
4 "strconv"
5 "strings"
6)
7
8const (
9 // ResizeWindowWinOp is a window operation that resizes the terminal
10 // window.
11 ResizeWindowWinOp = 4
12
13 // RequestWindowSizeWinOp is a window operation that requests a report of
14 // the size of the terminal window in pixels. The response is in the form:
15 // CSI 4 ; height ; width t
16 RequestWindowSizeWinOp = 14
17
18 // RequestCellSizeWinOp is a window operation that requests a report of
19 // the size of the terminal cell size in pixels. The response is in the form:
20 // CSI 6 ; height ; width t
21 RequestCellSizeWinOp = 16
22)
23
24// WindowOp (XTWINOPS) is a sequence that manipulates the terminal window.
25//
26// CSI Ps ; Ps ; Ps t
27//
28// Ps is a semicolon-separated list of parameters.
29// See https://invisible-island.net/xterm/ctlseqs/ctlseqs.html#h4-Functions-using-CSI-_-ordered-by-the-final-character-lparen-s-rparen:CSI-Ps;Ps;Ps-t.1EB0
30func WindowOp(p int, ps ...int) string {
31 if p <= 0 {
32 return ""
33 }
34
35 if len(ps) == 0 {
36 return "\x1b[" + strconv.Itoa(p) + "t"
37 }
38
39 params := make([]string, 0, len(ps)+1)
40 params = append(params, strconv.Itoa(p))
41 for _, p := range ps {
42 if p >= 0 {
43 params = append(params, strconv.Itoa(p))
44 }
45 }
46
47 return "\x1b[" + strings.Join(params, ";") + "t"
48}
49
50// XTWINOPS is an alias for [WindowOp].
51func XTWINOPS(p int, ps ...int) string {
52 return WindowOp(p, ps...)
53}
vendor/github.com/charmbracelet/x/ansi/wrap.go +78 −6
@@ -6,6 +6,7 @@ import (
66 "unicode/utf8"
77
88 "github.com/charmbracelet/x/ansi/parser"
9 "github.com/mattn/go-runewidth"
910 "github.com/rivo/uniseg"
1011)
1112
@@ -17,7 +18,22 @@ const nbsp = 0xA0
1718// wide-characters in the string.
1819// When preserveSpace is true, spaces at the beginning of a line will be
1920// preserved.
21// This treats the text as a sequence of graphemes.
2022func Hardwrap(s string, limit int, preserveSpace bool) string {
23 return hardwrap(GraphemeWidth, s, limit, preserveSpace)
24}
25
26// HardwrapWc wraps a string or a block of text to a given line length, breaking
27// word boundaries. This will preserve ANSI escape codes and will account for
28// wide-characters in the string.
29// When preserveSpace is true, spaces at the beginning of a line will be
30// preserved.
31// This treats the text as a sequence of wide characters and runes.
32func HardwrapWc(s string, limit int, preserveSpace bool) string {
33 return hardwrap(WcWidth, s, limit, preserveSpace)
34}
35
36func hardwrap(m Method, s string, limit int, preserveSpace bool) string {
2137 if limit < 1 {
2238 return s
2339 }
@@ -42,6 +58,9 @@ func Hardwrap(s string, limit int, preserveSpace bool) string {
4258 if state == parser.Utf8State {
4359 var width int
4460 cluster, _, width, _ = uniseg.FirstGraphemeCluster(b[i:], -1)
61 if m == WcWidth {
62 width = runewidth.StringWidth(string(cluster))
63 }
4564 i += len(cluster)
4665
4766 if curWidth+width > limit {
@@ -83,7 +102,9 @@ func Hardwrap(s string, limit int, preserveSpace bool) string {
83102 }
84103
85104 buf.WriteByte(b[i])
86 curWidth++
105 if action == parser.PrintAction {
106 curWidth++
107 }
87108 default:
88109 buf.WriteByte(b[i])
89110 }
@@ -106,7 +127,27 @@ func Hardwrap(s string, limit int, preserveSpace bool) string {
106127// breakpoint.
107128//
108129// Note: breakpoints must be a string of 1-cell wide rune characters.
130//
131// This treats the text as a sequence of graphemes.
109132func Wordwrap(s string, limit int, breakpoints string) string {
133 return wordwrap(GraphemeWidth, s, limit, breakpoints)
134}
135
136// WordwrapWc wraps a string or a block of text to a given line length, not
137// breaking word boundaries. This will preserve ANSI escape codes and will
138// account for wide-characters in the string.
139// The breakpoints string is a list of characters that are considered
140// breakpoints for word wrapping. A hyphen (-) is always considered a
141// breakpoint.
142//
143// Note: breakpoints must be a string of 1-cell wide rune characters.
144//
145// This treats the text as a sequence of wide characters and runes.
146func WordwrapWc(s string, limit int, breakpoints string) string {
147 return wordwrap(WcWidth, s, limit, breakpoints)
148}
149
150func wordwrap(m Method, s string, limit int, breakpoints string) string {
110151 if limit < 1 {
111152 return s
112153 }
@@ -152,6 +193,9 @@ func Wordwrap(s string, limit int, breakpoints string) string {
152193 if state == parser.Utf8State {
153194 var width int
154195 cluster, _, width, _ = uniseg.FirstGraphemeCluster(b[i:], -1)
196 if m == WcWidth {
197 width = runewidth.StringWidth(string(cluster))
198 }
155199 i += len(cluster)
156200
157201 r, _ := utf8.DecodeRune(cluster)
@@ -234,7 +278,26 @@ func Wordwrap(s string, limit int, breakpoints string) string {
234278// (-) is always considered a breakpoint.
235279//
236280// Note: breakpoints must be a string of 1-cell wide rune characters.
281//
282// This treats the text as a sequence of graphemes.
237283func Wrap(s string, limit int, breakpoints string) string {
284 return wrap(GraphemeWidth, s, limit, breakpoints)
285}
286
287// WrapWc wraps a string or a block of text to a given line length, breaking word
288// boundaries if necessary. This will preserve ANSI escape codes and will
289// account for wide-characters in the string. The breakpoints string is a list
290// of characters that are considered breakpoints for word wrapping. A hyphen
291// (-) is always considered a breakpoint.
292//
293// Note: breakpoints must be a string of 1-cell wide rune characters.
294//
295// This treats the text as a sequence of wide characters and runes.
296func WrapWc(s string, limit int, breakpoints string) string {
297 return wrap(WcWidth, s, limit, breakpoints)
298}
299
300func wrap(m Method, s string, limit int, breakpoints string) string {
238301 if limit < 1 {
239302 return s
240303 }
@@ -280,6 +343,9 @@ func Wrap(s string, limit int, breakpoints string) string {
280343 if state == parser.Utf8State {
281344 var width int
282345 cluster, _, width, _ = uniseg.FirstGraphemeCluster(b[i:], -1)
346 if m == WcWidth {
347 width = runewidth.StringWidth(string(cluster))
348 }
283349 i += len(cluster)
284350
285351 r, _ := utf8.DecodeRune(cluster)
@@ -349,6 +415,9 @@ func Wrap(s string, limit int, breakpoints string) string {
349415 curWidth++
350416 }
351417 default:
418 if curWidth == limit {
419 addNewline()
420 }
352421 word.WriteRune(r)
353422 wordLen++
354423
@@ -373,14 +442,17 @@ func Wrap(s string, limit int, breakpoints string) string {
373442 i++
374443 }
375444
376 if word.Len() != 0 {
377 // Preserve ANSI wrapped spaces at the end of string
445 if wordLen == 0 {
378446 if curWidth+space.Len() > limit {
379 buf.WriteByte('\n')
447 curWidth = 0
448 } else {
449 // preserve whitespaces
450 buf.Write(space.Bytes())
380451 }
381 addSpace()
452 space.Reset()
382453 }
383 buf.Write(word.Bytes())
454
455 addWord()
384456
385457 return buf.String()
386458}
vendor/github.com/charmbracelet/x/ansi/xterm.go +88
@@ -2,6 +2,84 @@ package ansi
22
33import "strconv"
44
5// KeyModifierOptions (XTMODKEYS) sets/resets xterm key modifier options.
6//
7// Default is 0.
8//
9// CSI > Pp m
10// CSI > Pp ; Pv m
11//
12// If Pv is omitted, the resource is reset to its initial value.
13//
14// See: https://invisible-island.net/xterm/ctlseqs/ctlseqs.html#h3-Functions-using-CSI-_-ordered-by-the-final-character_s_
15func KeyModifierOptions(p int, vs ...int) string {
16 var pp, pv string
17 if p > 0 {
18 pp = strconv.Itoa(p)
19 }
20
21 if len(vs) == 0 {
22 return "\x1b[>" + strconv.Itoa(p) + "m"
23 }
24
25 v := vs[0]
26 if v > 0 {
27 pv = strconv.Itoa(v)
28 return "\x1b[>" + pp + ";" + pv + "m"
29 }
30
31 return "\x1b[>" + pp + "m"
32}
33
34// XTMODKEYS is an alias for [KeyModifierOptions].
35func XTMODKEYS(p int, vs ...int) string {
36 return KeyModifierOptions(p, vs...)
37}
38
39// SetKeyModifierOptions sets xterm key modifier options.
40// This is an alias for [KeyModifierOptions].
41func SetKeyModifierOptions(pp int, pv int) string {
42 return KeyModifierOptions(pp, pv)
43}
44
45// ResetKeyModifierOptions resets xterm key modifier options.
46// This is an alias for [KeyModifierOptions].
47func ResetKeyModifierOptions(pp int) string {
48 return KeyModifierOptions(pp)
49}
50
51// QueryKeyModifierOptions (XTQMODKEYS) requests xterm key modifier options.
52//
53// Default is 0.
54//
55// CSI ? Pp m
56//
57// See: https://invisible-island.net/xterm/ctlseqs/ctlseqs.html#h3-Functions-using-CSI-_-ordered-by-the-final-character_s_
58func QueryKeyModifierOptions(pp int) string {
59 var p string
60 if pp > 0 {
61 p = strconv.Itoa(pp)
62 }
63 return "\x1b[?" + p + "m"
64}
65
66// XTQMODKEYS is an alias for [QueryKeyModifierOptions].
67func XTQMODKEYS(pp int) string {
68 return QueryKeyModifierOptions(pp)
69}
70
71// Modify Other Keys (modifyOtherKeys) is an xterm feature that allows the
72// terminal to modify the behavior of certain keys to send different escape
73// sequences when pressed.
74//
75// See: https://invisible-island.net/xterm/manpage/xterm.html#VT100-Widget-Resources:modifyOtherKeys
76const (
77 SetModifyOtherKeys1 = "\x1b[>4;1m"
78 SetModifyOtherKeys2 = "\x1b[>4;2m"
79 ResetModifyOtherKeys = "\x1b[>4m"
80 QueryModifyOtherKeys = "\x1b[?4m"
81)
82
583// ModifyOtherKeys returns a sequence that sets XTerm modifyOtherKeys mode.
684// The mode argument specifies the mode to set.
785//
@@ -13,6 +91,8 @@ import "strconv"
1391//
1492// See: https://invisible-island.net/xterm/ctlseqs/ctlseqs.html#h3-Functions-using-CSI-_-ordered-by-the-final-character_s_
1593// See: https://invisible-island.net/xterm/manpage/xterm.html#VT100-Widget-Resources:modifyOtherKeys
94//
95// Deprecated: use [SetModifyOtherKeys1] or [SetModifyOtherKeys2] instead.
1696func ModifyOtherKeys(mode int) string {
1797 return "\x1b[>4;" + strconv.Itoa(mode) + "m"
1898}
@@ -23,6 +103,8 @@ func ModifyOtherKeys(mode int) string {
23103//
24104// See: https://invisible-island.net/xterm/ctlseqs/ctlseqs.html#h3-Functions-using-CSI-_-ordered-by-the-final-character_s_
25105// See: https://invisible-island.net/xterm/manpage/xterm.html#VT100-Widget-Resources:modifyOtherKeys
106//
107// Deprecated: use [ResetModifyOtherKeys] instead.
26108const DisableModifyOtherKeys = "\x1b[>4;0m"
27109
28110// EnableModifyOtherKeys1 enables the modifyOtherKeys mode 1.
@@ -31,6 +113,8 @@ const DisableModifyOtherKeys = "\x1b[>4;0m"
31113//
32114// See: https://invisible-island.net/xterm/ctlseqs/ctlseqs.html#h3-Functions-using-CSI-_-ordered-by-the-final-character_s_
33115// See: https://invisible-island.net/xterm/manpage/xterm.html#VT100-Widget-Resources:modifyOtherKeys
116//
117// Deprecated: use [SetModifyOtherKeys1] instead.
34118const EnableModifyOtherKeys1 = "\x1b[>4;1m"
35119
36120// EnableModifyOtherKeys2 enables the modifyOtherKeys mode 2.
@@ -39,6 +123,8 @@ const EnableModifyOtherKeys1 = "\x1b[>4;1m"
39123//
40124// See: https://invisible-island.net/xterm/ctlseqs/ctlseqs.html#h3-Functions-using-CSI-_-ordered-by-the-final-character_s_
41125// See: https://invisible-island.net/xterm/manpage/xterm.html#VT100-Widget-Resources:modifyOtherKeys
126//
127// Deprecated: use [SetModifyOtherKeys2] instead.
42128const EnableModifyOtherKeys2 = "\x1b[>4;2m"
43129
44130// RequestModifyOtherKeys requests the modifyOtherKeys mode.
@@ -47,4 +133,6 @@ const EnableModifyOtherKeys2 = "\x1b[>4;2m"
47133//
48134// See: https://invisible-island.net/xterm/ctlseqs/ctlseqs.html#h3-Functions-using-CSI-_-ordered-by-the-final-character_s_
49135// See: https://invisible-island.net/xterm/manpage/xterm.html#VT100-Widget-Resources:modifyOtherKeys
136//
137// Deprecated: use [QueryModifyOtherKeys] instead.
50138const RequestModifyOtherKeys = "\x1b[?4m"
vendor/github.com/charmbracelet/x/term/term_windows.go +1
@@ -25,6 +25,7 @@ func makeRaw(fd uintptr) (*State, error) {
2525 return nil, err
2626 }
2727 raw := st &^ (windows.ENABLE_ECHO_INPUT | windows.ENABLE_PROCESSED_INPUT | windows.ENABLE_LINE_INPUT | windows.ENABLE_PROCESSED_OUTPUT)
28 raw |= windows.ENABLE_VIRTUAL_TERMINAL_INPUT
2829 if err := windows.SetConsoleMode(windows.Handle(fd), raw); err != nil {
2930 return nil, err
3031 }
vendor/github.com/mattn/go-runewidth/runewidth_table.go +167 −156
@@ -4,20 +4,21 @@ package runewidth
44
55var combining = table{
66 {0x0300, 0x036F}, {0x0483, 0x0489}, {0x07EB, 0x07F3},
7 {0x0C00, 0x0C00}, {0x0C04, 0x0C04}, {0x0D00, 0x0D01},
8 {0x135D, 0x135F}, {0x1A7F, 0x1A7F}, {0x1AB0, 0x1AC0},
9 {0x1B6B, 0x1B73}, {0x1DC0, 0x1DF9}, {0x1DFB, 0x1DFF},
7 {0x0C00, 0x0C00}, {0x0C04, 0x0C04}, {0x0CF3, 0x0CF3},
8 {0x0D00, 0x0D01}, {0x135D, 0x135F}, {0x1A7F, 0x1A7F},
9 {0x1AB0, 0x1ACE}, {0x1B6B, 0x1B73}, {0x1DC0, 0x1DFF},
1010 {0x20D0, 0x20F0}, {0x2CEF, 0x2CF1}, {0x2DE0, 0x2DFF},
1111 {0x3099, 0x309A}, {0xA66F, 0xA672}, {0xA674, 0xA67D},
1212 {0xA69E, 0xA69F}, {0xA6F0, 0xA6F1}, {0xA8E0, 0xA8F1},
1313 {0xFE20, 0xFE2F}, {0x101FD, 0x101FD}, {0x10376, 0x1037A},
14 {0x10EAB, 0x10EAC}, {0x10F46, 0x10F50}, {0x11300, 0x11301},
15 {0x1133B, 0x1133C}, {0x11366, 0x1136C}, {0x11370, 0x11374},
16 {0x16AF0, 0x16AF4}, {0x1D165, 0x1D169}, {0x1D16D, 0x1D172},
14 {0x10EAB, 0x10EAC}, {0x10F46, 0x10F50}, {0x10F82, 0x10F85},
15 {0x11300, 0x11301}, {0x1133B, 0x1133C}, {0x11366, 0x1136C},
16 {0x11370, 0x11374}, {0x16AF0, 0x16AF4}, {0x1CF00, 0x1CF2D},
17 {0x1CF30, 0x1CF46}, {0x1D165, 0x1D169}, {0x1D16D, 0x1D172},
1718 {0x1D17B, 0x1D182}, {0x1D185, 0x1D18B}, {0x1D1AA, 0x1D1AD},
1819 {0x1D242, 0x1D244}, {0x1E000, 0x1E006}, {0x1E008, 0x1E018},
1920 {0x1E01B, 0x1E021}, {0x1E023, 0x1E024}, {0x1E026, 0x1E02A},
20 {0x1E8D0, 0x1E8D6},
21 {0x1E08F, 0x1E08F}, {0x1E8D0, 0x1E8D6},
2122}
2223
2324var doublewidth = table{
@@ -33,33 +34,34 @@ var doublewidth = table{
3334 {0x2753, 0x2755}, {0x2757, 0x2757}, {0x2795, 0x2797},
3435 {0x27B0, 0x27B0}, {0x27BF, 0x27BF}, {0x2B1B, 0x2B1C},
3536 {0x2B50, 0x2B50}, {0x2B55, 0x2B55}, {0x2E80, 0x2E99},
36 {0x2E9B, 0x2EF3}, {0x2F00, 0x2FD5}, {0x2FF0, 0x2FFB},
37 {0x3000, 0x303E}, {0x3041, 0x3096}, {0x3099, 0x30FF},
38 {0x3105, 0x312F}, {0x3131, 0x318E}, {0x3190, 0x31E3},
39 {0x31F0, 0x321E}, {0x3220, 0x3247}, {0x3250, 0x4DBF},
40 {0x4E00, 0xA48C}, {0xA490, 0xA4C6}, {0xA960, 0xA97C},
41 {0xAC00, 0xD7A3}, {0xF900, 0xFAFF}, {0xFE10, 0xFE19},
42 {0xFE30, 0xFE52}, {0xFE54, 0xFE66}, {0xFE68, 0xFE6B},
43 {0xFF01, 0xFF60}, {0xFFE0, 0xFFE6}, {0x16FE0, 0x16FE4},
44 {0x16FF0, 0x16FF1}, {0x17000, 0x187F7}, {0x18800, 0x18CD5},
45 {0x18D00, 0x18D08}, {0x1B000, 0x1B11E}, {0x1B150, 0x1B152},
46 {0x1B164, 0x1B167}, {0x1B170, 0x1B2FB}, {0x1F004, 0x1F004},
47 {0x1F0CF, 0x1F0CF}, {0x1F18E, 0x1F18E}, {0x1F191, 0x1F19A},
48 {0x1F200, 0x1F202}, {0x1F210, 0x1F23B}, {0x1F240, 0x1F248},
49 {0x1F250, 0x1F251}, {0x1F260, 0x1F265}, {0x1F300, 0x1F320},
50 {0x1F32D, 0x1F335}, {0x1F337, 0x1F37C}, {0x1F37E, 0x1F393},
51 {0x1F3A0, 0x1F3CA}, {0x1F3CF, 0x1F3D3}, {0x1F3E0, 0x1F3F0},
52 {0x1F3F4, 0x1F3F4}, {0x1F3F8, 0x1F43E}, {0x1F440, 0x1F440},
53 {0x1F442, 0x1F4FC}, {0x1F4FF, 0x1F53D}, {0x1F54B, 0x1F54E},
54 {0x1F550, 0x1F567}, {0x1F57A, 0x1F57A}, {0x1F595, 0x1F596},
55 {0x1F5A4, 0x1F5A4}, {0x1F5FB, 0x1F64F}, {0x1F680, 0x1F6C5},
56 {0x1F6CC, 0x1F6CC}, {0x1F6D0, 0x1F6D2}, {0x1F6D5, 0x1F6D7},
57 {0x1F6EB, 0x1F6EC}, {0x1F6F4, 0x1F6FC}, {0x1F7E0, 0x1F7EB},
58 {0x1F90C, 0x1F93A}, {0x1F93C, 0x1F945}, {0x1F947, 0x1F978},
59 {0x1F97A, 0x1F9CB}, {0x1F9CD, 0x1F9FF}, {0x1FA70, 0x1FA74},
60 {0x1FA78, 0x1FA7A}, {0x1FA80, 0x1FA86}, {0x1FA90, 0x1FAA8},
61 {0x1FAB0, 0x1FAB6}, {0x1FAC0, 0x1FAC2}, {0x1FAD0, 0x1FAD6},
62 {0x20000, 0x2FFFD}, {0x30000, 0x3FFFD},
37 {0x2E9B, 0x2EF3}, {0x2F00, 0x2FD5}, {0x2FF0, 0x303E},
38 {0x3041, 0x3096}, {0x3099, 0x30FF}, {0x3105, 0x312F},
39 {0x3131, 0x318E}, {0x3190, 0x31E3}, {0x31EF, 0x321E},
40 {0x3220, 0x3247}, {0x3250, 0x4DBF}, {0x4E00, 0xA48C},
41 {0xA490, 0xA4C6}, {0xA960, 0xA97C}, {0xAC00, 0xD7A3},
42 {0xF900, 0xFAFF}, {0xFE10, 0xFE19}, {0xFE30, 0xFE52},
43 {0xFE54, 0xFE66}, {0xFE68, 0xFE6B}, {0xFF01, 0xFF60},
44 {0xFFE0, 0xFFE6}, {0x16FE0, 0x16FE4}, {0x16FF0, 0x16FF1},
45 {0x17000, 0x187F7}, {0x18800, 0x18CD5}, {0x18D00, 0x18D08},
46 {0x1AFF0, 0x1AFF3}, {0x1AFF5, 0x1AFFB}, {0x1AFFD, 0x1AFFE},
47 {0x1B000, 0x1B122}, {0x1B132, 0x1B132}, {0x1B150, 0x1B152},
48 {0x1B155, 0x1B155}, {0x1B164, 0x1B167}, {0x1B170, 0x1B2FB},
49 {0x1F004, 0x1F004}, {0x1F0CF, 0x1F0CF}, {0x1F18E, 0x1F18E},
50 {0x1F191, 0x1F19A}, {0x1F200, 0x1F202}, {0x1F210, 0x1F23B},
51 {0x1F240, 0x1F248}, {0x1F250, 0x1F251}, {0x1F260, 0x1F265},
52 {0x1F300, 0x1F320}, {0x1F32D, 0x1F335}, {0x1F337, 0x1F37C},
53 {0x1F37E, 0x1F393}, {0x1F3A0, 0x1F3CA}, {0x1F3CF, 0x1F3D3},
54 {0x1F3E0, 0x1F3F0}, {0x1F3F4, 0x1F3F4}, {0x1F3F8, 0x1F43E},
55 {0x1F440, 0x1F440}, {0x1F442, 0x1F4FC}, {0x1F4FF, 0x1F53D},
56 {0x1F54B, 0x1F54E}, {0x1F550, 0x1F567}, {0x1F57A, 0x1F57A},
57 {0x1F595, 0x1F596}, {0x1F5A4, 0x1F5A4}, {0x1F5FB, 0x1F64F},
58 {0x1F680, 0x1F6C5}, {0x1F6CC, 0x1F6CC}, {0x1F6D0, 0x1F6D2},
59 {0x1F6D5, 0x1F6D7}, {0x1F6DC, 0x1F6DF}, {0x1F6EB, 0x1F6EC},
60 {0x1F6F4, 0x1F6FC}, {0x1F7E0, 0x1F7EB}, {0x1F7F0, 0x1F7F0},
61 {0x1F90C, 0x1F93A}, {0x1F93C, 0x1F945}, {0x1F947, 0x1F9FF},
62 {0x1FA70, 0x1FA7C}, {0x1FA80, 0x1FA88}, {0x1FA90, 0x1FABD},
63 {0x1FABF, 0x1FAC5}, {0x1FACE, 0x1FADB}, {0x1FAE0, 0x1FAE8},
64 {0x1FAF0, 0x1FAF8}, {0x20000, 0x2FFFD}, {0x30000, 0x3FFFD},
6365}
6466
6567var ambiguous = table{
@@ -154,43 +156,43 @@ var neutral = table{
154156 {0x0402, 0x040F}, {0x0450, 0x0450}, {0x0452, 0x052F},
155157 {0x0531, 0x0556}, {0x0559, 0x058A}, {0x058D, 0x058F},
156158 {0x0591, 0x05C7}, {0x05D0, 0x05EA}, {0x05EF, 0x05F4},
157 {0x0600, 0x061C}, {0x061E, 0x070D}, {0x070F, 0x074A},
158 {0x074D, 0x07B1}, {0x07C0, 0x07FA}, {0x07FD, 0x082D},
159 {0x0830, 0x083E}, {0x0840, 0x085B}, {0x085E, 0x085E},
160 {0x0860, 0x086A}, {0x08A0, 0x08B4}, {0x08B6, 0x08C7},
161 {0x08D3, 0x0983}, {0x0985, 0x098C}, {0x098F, 0x0990},
162 {0x0993, 0x09A8}, {0x09AA, 0x09B0}, {0x09B2, 0x09B2},
163 {0x09B6, 0x09B9}, {0x09BC, 0x09C4}, {0x09C7, 0x09C8},
164 {0x09CB, 0x09CE}, {0x09D7, 0x09D7}, {0x09DC, 0x09DD},
165 {0x09DF, 0x09E3}, {0x09E6, 0x09FE}, {0x0A01, 0x0A03},
166 {0x0A05, 0x0A0A}, {0x0A0F, 0x0A10}, {0x0A13, 0x0A28},
167 {0x0A2A, 0x0A30}, {0x0A32, 0x0A33}, {0x0A35, 0x0A36},
168 {0x0A38, 0x0A39}, {0x0A3C, 0x0A3C}, {0x0A3E, 0x0A42},
169 {0x0A47, 0x0A48}, {0x0A4B, 0x0A4D}, {0x0A51, 0x0A51},
170 {0x0A59, 0x0A5C}, {0x0A5E, 0x0A5E}, {0x0A66, 0x0A76},
171 {0x0A81, 0x0A83}, {0x0A85, 0x0A8D}, {0x0A8F, 0x0A91},
172 {0x0A93, 0x0AA8}, {0x0AAA, 0x0AB0}, {0x0AB2, 0x0AB3},
173 {0x0AB5, 0x0AB9}, {0x0ABC, 0x0AC5}, {0x0AC7, 0x0AC9},
174 {0x0ACB, 0x0ACD}, {0x0AD0, 0x0AD0}, {0x0AE0, 0x0AE3},
175 {0x0AE6, 0x0AF1}, {0x0AF9, 0x0AFF}, {0x0B01, 0x0B03},
176 {0x0B05, 0x0B0C}, {0x0B0F, 0x0B10}, {0x0B13, 0x0B28},
177 {0x0B2A, 0x0B30}, {0x0B32, 0x0B33}, {0x0B35, 0x0B39},
178 {0x0B3C, 0x0B44}, {0x0B47, 0x0B48}, {0x0B4B, 0x0B4D},
179 {0x0B55, 0x0B57}, {0x0B5C, 0x0B5D}, {0x0B5F, 0x0B63},
180 {0x0B66, 0x0B77}, {0x0B82, 0x0B83}, {0x0B85, 0x0B8A},
181 {0x0B8E, 0x0B90}, {0x0B92, 0x0B95}, {0x0B99, 0x0B9A},
182 {0x0B9C, 0x0B9C}, {0x0B9E, 0x0B9F}, {0x0BA3, 0x0BA4},
183 {0x0BA8, 0x0BAA}, {0x0BAE, 0x0BB9}, {0x0BBE, 0x0BC2},
184 {0x0BC6, 0x0BC8}, {0x0BCA, 0x0BCD}, {0x0BD0, 0x0BD0},
185 {0x0BD7, 0x0BD7}, {0x0BE6, 0x0BFA}, {0x0C00, 0x0C0C},
186 {0x0C0E, 0x0C10}, {0x0C12, 0x0C28}, {0x0C2A, 0x0C39},
187 {0x0C3D, 0x0C44}, {0x0C46, 0x0C48}, {0x0C4A, 0x0C4D},
188 {0x0C55, 0x0C56}, {0x0C58, 0x0C5A}, {0x0C60, 0x0C63},
159 {0x0600, 0x070D}, {0x070F, 0x074A}, {0x074D, 0x07B1},
160 {0x07C0, 0x07FA}, {0x07FD, 0x082D}, {0x0830, 0x083E},
161 {0x0840, 0x085B}, {0x085E, 0x085E}, {0x0860, 0x086A},
162 {0x0870, 0x088E}, {0x0890, 0x0891}, {0x0898, 0x0983},
163 {0x0985, 0x098C}, {0x098F, 0x0990}, {0x0993, 0x09A8},
164 {0x09AA, 0x09B0}, {0x09B2, 0x09B2}, {0x09B6, 0x09B9},
165 {0x09BC, 0x09C4}, {0x09C7, 0x09C8}, {0x09CB, 0x09CE},
166 {0x09D7, 0x09D7}, {0x09DC, 0x09DD}, {0x09DF, 0x09E3},
167 {0x09E6, 0x09FE}, {0x0A01, 0x0A03}, {0x0A05, 0x0A0A},
168 {0x0A0F, 0x0A10}, {0x0A13, 0x0A28}, {0x0A2A, 0x0A30},
169 {0x0A32, 0x0A33}, {0x0A35, 0x0A36}, {0x0A38, 0x0A39},
170 {0x0A3C, 0x0A3C}, {0x0A3E, 0x0A42}, {0x0A47, 0x0A48},
171 {0x0A4B, 0x0A4D}, {0x0A51, 0x0A51}, {0x0A59, 0x0A5C},
172 {0x0A5E, 0x0A5E}, {0x0A66, 0x0A76}, {0x0A81, 0x0A83},
173 {0x0A85, 0x0A8D}, {0x0A8F, 0x0A91}, {0x0A93, 0x0AA8},
174 {0x0AAA, 0x0AB0}, {0x0AB2, 0x0AB3}, {0x0AB5, 0x0AB9},
175 {0x0ABC, 0x0AC5}, {0x0AC7, 0x0AC9}, {0x0ACB, 0x0ACD},
176 {0x0AD0, 0x0AD0}, {0x0AE0, 0x0AE3}, {0x0AE6, 0x0AF1},
177 {0x0AF9, 0x0AFF}, {0x0B01, 0x0B03}, {0x0B05, 0x0B0C},
178 {0x0B0F, 0x0B10}, {0x0B13, 0x0B28}, {0x0B2A, 0x0B30},
179 {0x0B32, 0x0B33}, {0x0B35, 0x0B39}, {0x0B3C, 0x0B44},
180 {0x0B47, 0x0B48}, {0x0B4B, 0x0B4D}, {0x0B55, 0x0B57},
181 {0x0B5C, 0x0B5D}, {0x0B5F, 0x0B63}, {0x0B66, 0x0B77},
182 {0x0B82, 0x0B83}, {0x0B85, 0x0B8A}, {0x0B8E, 0x0B90},
183 {0x0B92, 0x0B95}, {0x0B99, 0x0B9A}, {0x0B9C, 0x0B9C},
184 {0x0B9E, 0x0B9F}, {0x0BA3, 0x0BA4}, {0x0BA8, 0x0BAA},
185 {0x0BAE, 0x0BB9}, {0x0BBE, 0x0BC2}, {0x0BC6, 0x0BC8},
186 {0x0BCA, 0x0BCD}, {0x0BD0, 0x0BD0}, {0x0BD7, 0x0BD7},
187 {0x0BE6, 0x0BFA}, {0x0C00, 0x0C0C}, {0x0C0E, 0x0C10},
188 {0x0C12, 0x0C28}, {0x0C2A, 0x0C39}, {0x0C3C, 0x0C44},
189 {0x0C46, 0x0C48}, {0x0C4A, 0x0C4D}, {0x0C55, 0x0C56},
190 {0x0C58, 0x0C5A}, {0x0C5D, 0x0C5D}, {0x0C60, 0x0C63},
189191 {0x0C66, 0x0C6F}, {0x0C77, 0x0C8C}, {0x0C8E, 0x0C90},
190192 {0x0C92, 0x0CA8}, {0x0CAA, 0x0CB3}, {0x0CB5, 0x0CB9},
191193 {0x0CBC, 0x0CC4}, {0x0CC6, 0x0CC8}, {0x0CCA, 0x0CCD},
192 {0x0CD5, 0x0CD6}, {0x0CDE, 0x0CDE}, {0x0CE0, 0x0CE3},
193 {0x0CE6, 0x0CEF}, {0x0CF1, 0x0CF2}, {0x0D00, 0x0D0C},
194 {0x0CD5, 0x0CD6}, {0x0CDD, 0x0CDE}, {0x0CE0, 0x0CE3},
195 {0x0CE6, 0x0CEF}, {0x0CF1, 0x0CF3}, {0x0D00, 0x0D0C},
194196 {0x0D0E, 0x0D10}, {0x0D12, 0x0D44}, {0x0D46, 0x0D48},
195197 {0x0D4A, 0x0D4F}, {0x0D54, 0x0D63}, {0x0D66, 0x0D7F},
196198 {0x0D81, 0x0D83}, {0x0D85, 0x0D96}, {0x0D9A, 0x0DB1},
@@ -200,7 +202,7 @@ var neutral = table{
200202 {0x0E01, 0x0E3A}, {0x0E3F, 0x0E5B}, {0x0E81, 0x0E82},
201203 {0x0E84, 0x0E84}, {0x0E86, 0x0E8A}, {0x0E8C, 0x0EA3},
202204 {0x0EA5, 0x0EA5}, {0x0EA7, 0x0EBD}, {0x0EC0, 0x0EC4},
203 {0x0EC6, 0x0EC6}, {0x0EC8, 0x0ECD}, {0x0ED0, 0x0ED9},
205 {0x0EC6, 0x0EC6}, {0x0EC8, 0x0ECE}, {0x0ED0, 0x0ED9},
204206 {0x0EDC, 0x0EDF}, {0x0F00, 0x0F47}, {0x0F49, 0x0F6C},
205207 {0x0F71, 0x0F97}, {0x0F99, 0x0FBC}, {0x0FBE, 0x0FCC},
206208 {0x0FCE, 0x0FDA}, {0x1000, 0x10C5}, {0x10C7, 0x10C7},
@@ -212,20 +214,19 @@ var neutral = table{
212214 {0x12D8, 0x1310}, {0x1312, 0x1315}, {0x1318, 0x135A},
213215 {0x135D, 0x137C}, {0x1380, 0x1399}, {0x13A0, 0x13F5},
214216 {0x13F8, 0x13FD}, {0x1400, 0x169C}, {0x16A0, 0x16F8},
215 {0x1700, 0x170C}, {0x170E, 0x1714}, {0x1720, 0x1736},
216 {0x1740, 0x1753}, {0x1760, 0x176C}, {0x176E, 0x1770},
217 {0x1772, 0x1773}, {0x1780, 0x17DD}, {0x17E0, 0x17E9},
218 {0x17F0, 0x17F9}, {0x1800, 0x180E}, {0x1810, 0x1819},
219 {0x1820, 0x1878}, {0x1880, 0x18AA}, {0x18B0, 0x18F5},
220 {0x1900, 0x191E}, {0x1920, 0x192B}, {0x1930, 0x193B},
221 {0x1940, 0x1940}, {0x1944, 0x196D}, {0x1970, 0x1974},
222 {0x1980, 0x19AB}, {0x19B0, 0x19C9}, {0x19D0, 0x19DA},
223 {0x19DE, 0x1A1B}, {0x1A1E, 0x1A5E}, {0x1A60, 0x1A7C},
224 {0x1A7F, 0x1A89}, {0x1A90, 0x1A99}, {0x1AA0, 0x1AAD},
225 {0x1AB0, 0x1AC0}, {0x1B00, 0x1B4B}, {0x1B50, 0x1B7C},
226 {0x1B80, 0x1BF3}, {0x1BFC, 0x1C37}, {0x1C3B, 0x1C49},
227 {0x1C4D, 0x1C88}, {0x1C90, 0x1CBA}, {0x1CBD, 0x1CC7},
228 {0x1CD0, 0x1CFA}, {0x1D00, 0x1DF9}, {0x1DFB, 0x1F15},
217 {0x1700, 0x1715}, {0x171F, 0x1736}, {0x1740, 0x1753},
218 {0x1760, 0x176C}, {0x176E, 0x1770}, {0x1772, 0x1773},
219 {0x1780, 0x17DD}, {0x17E0, 0x17E9}, {0x17F0, 0x17F9},
220 {0x1800, 0x1819}, {0x1820, 0x1878}, {0x1880, 0x18AA},
221 {0x18B0, 0x18F5}, {0x1900, 0x191E}, {0x1920, 0x192B},
222 {0x1930, 0x193B}, {0x1940, 0x1940}, {0x1944, 0x196D},
223 {0x1970, 0x1974}, {0x1980, 0x19AB}, {0x19B0, 0x19C9},
224 {0x19D0, 0x19DA}, {0x19DE, 0x1A1B}, {0x1A1E, 0x1A5E},
225 {0x1A60, 0x1A7C}, {0x1A7F, 0x1A89}, {0x1A90, 0x1A99},
226 {0x1AA0, 0x1AAD}, {0x1AB0, 0x1ACE}, {0x1B00, 0x1B4C},
227 {0x1B50, 0x1B7E}, {0x1B80, 0x1BF3}, {0x1BFC, 0x1C37},
228 {0x1C3B, 0x1C49}, {0x1C4D, 0x1C88}, {0x1C90, 0x1CBA},
229 {0x1CBD, 0x1CC7}, {0x1CD0, 0x1CFA}, {0x1D00, 0x1F15},
229230 {0x1F18, 0x1F1D}, {0x1F20, 0x1F45}, {0x1F48, 0x1F4D},
230231 {0x1F50, 0x1F57}, {0x1F59, 0x1F59}, {0x1F5B, 0x1F5B},
231232 {0x1F5D, 0x1F5D}, {0x1F5F, 0x1F7D}, {0x1F80, 0x1FB4},
@@ -237,7 +238,7 @@ var neutral = table{
237238 {0x2036, 0x203A}, {0x203C, 0x203D}, {0x203F, 0x2064},
238239 {0x2066, 0x2071}, {0x2075, 0x207E}, {0x2080, 0x2080},
239240 {0x2085, 0x208E}, {0x2090, 0x209C}, {0x20A0, 0x20A8},
240 {0x20AA, 0x20AB}, {0x20AD, 0x20BF}, {0x20D0, 0x20F0},
241 {0x20AA, 0x20AB}, {0x20AD, 0x20C0}, {0x20D0, 0x20F0},
241242 {0x2100, 0x2102}, {0x2104, 0x2104}, {0x2106, 0x2108},
242243 {0x210A, 0x2112}, {0x2114, 0x2115}, {0x2117, 0x2120},
243244 {0x2123, 0x2125}, {0x2127, 0x212A}, {0x212C, 0x2152},
@@ -275,15 +276,15 @@ var neutral = table{
275276 {0x2780, 0x2794}, {0x2798, 0x27AF}, {0x27B1, 0x27BE},
276277 {0x27C0, 0x27E5}, {0x27EE, 0x2984}, {0x2987, 0x2B1A},
277278 {0x2B1D, 0x2B4F}, {0x2B51, 0x2B54}, {0x2B5A, 0x2B73},
278 {0x2B76, 0x2B95}, {0x2B97, 0x2C2E}, {0x2C30, 0x2C5E},
279 {0x2C60, 0x2CF3}, {0x2CF9, 0x2D25}, {0x2D27, 0x2D27},
280 {0x2D2D, 0x2D2D}, {0x2D30, 0x2D67}, {0x2D6F, 0x2D70},
281 {0x2D7F, 0x2D96}, {0x2DA0, 0x2DA6}, {0x2DA8, 0x2DAE},
282 {0x2DB0, 0x2DB6}, {0x2DB8, 0x2DBE}, {0x2DC0, 0x2DC6},
283 {0x2DC8, 0x2DCE}, {0x2DD0, 0x2DD6}, {0x2DD8, 0x2DDE},
284 {0x2DE0, 0x2E52}, {0x303F, 0x303F}, {0x4DC0, 0x4DFF},
285 {0xA4D0, 0xA62B}, {0xA640, 0xA6F7}, {0xA700, 0xA7BF},
286 {0xA7C2, 0xA7CA}, {0xA7F5, 0xA82C}, {0xA830, 0xA839},
279 {0x2B76, 0x2B95}, {0x2B97, 0x2CF3}, {0x2CF9, 0x2D25},
280 {0x2D27, 0x2D27}, {0x2D2D, 0x2D2D}, {0x2D30, 0x2D67},
281 {0x2D6F, 0x2D70}, {0x2D7F, 0x2D96}, {0x2DA0, 0x2DA6},
282 {0x2DA8, 0x2DAE}, {0x2DB0, 0x2DB6}, {0x2DB8, 0x2DBE},
283 {0x2DC0, 0x2DC6}, {0x2DC8, 0x2DCE}, {0x2DD0, 0x2DD6},
284 {0x2DD8, 0x2DDE}, {0x2DE0, 0x2E5D}, {0x303F, 0x303F},
285 {0x4DC0, 0x4DFF}, {0xA4D0, 0xA62B}, {0xA640, 0xA6F7},
286 {0xA700, 0xA7CA}, {0xA7D0, 0xA7D1}, {0xA7D3, 0xA7D3},
287 {0xA7D5, 0xA7D9}, {0xA7F2, 0xA82C}, {0xA830, 0xA839},
287288 {0xA840, 0xA877}, {0xA880, 0xA8C5}, {0xA8CE, 0xA8D9},
288289 {0xA8E0, 0xA953}, {0xA95F, 0xA95F}, {0xA980, 0xA9CD},
289290 {0xA9CF, 0xA9D9}, {0xA9DE, 0xA9FE}, {0xAA00, 0xAA36},
@@ -294,8 +295,8 @@ var neutral = table{
294295 {0xD7B0, 0xD7C6}, {0xD7CB, 0xD7FB}, {0xD800, 0xDFFF},
295296 {0xFB00, 0xFB06}, {0xFB13, 0xFB17}, {0xFB1D, 0xFB36},
296297 {0xFB38, 0xFB3C}, {0xFB3E, 0xFB3E}, {0xFB40, 0xFB41},
297 {0xFB43, 0xFB44}, {0xFB46, 0xFBC1}, {0xFBD3, 0xFD3F},
298 {0xFD50, 0xFD8F}, {0xFD92, 0xFDC7}, {0xFDF0, 0xFDFD},
298 {0xFB43, 0xFB44}, {0xFB46, 0xFBC2}, {0xFBD3, 0xFD8F},
299 {0xFD92, 0xFDC7}, {0xFDCF, 0xFDCF}, {0xFDF0, 0xFDFF},
299300 {0xFE20, 0xFE2F}, {0xFE70, 0xFE74}, {0xFE76, 0xFEFC},
300301 {0xFEFF, 0xFEFF}, {0xFFF9, 0xFFFC}, {0x10000, 0x1000B},
301302 {0x1000D, 0x10026}, {0x10028, 0x1003A}, {0x1003C, 0x1003D},
@@ -307,44 +308,48 @@ var neutral = table{
307308 {0x10380, 0x1039D}, {0x1039F, 0x103C3}, {0x103C8, 0x103D5},
308309 {0x10400, 0x1049D}, {0x104A0, 0x104A9}, {0x104B0, 0x104D3},
309310 {0x104D8, 0x104FB}, {0x10500, 0x10527}, {0x10530, 0x10563},
310 {0x1056F, 0x1056F}, {0x10600, 0x10736}, {0x10740, 0x10755},
311 {0x10760, 0x10767}, {0x10800, 0x10805}, {0x10808, 0x10808},
312 {0x1080A, 0x10835}, {0x10837, 0x10838}, {0x1083C, 0x1083C},
313 {0x1083F, 0x10855}, {0x10857, 0x1089E}, {0x108A7, 0x108AF},
314 {0x108E0, 0x108F2}, {0x108F4, 0x108F5}, {0x108FB, 0x1091B},
315 {0x1091F, 0x10939}, {0x1093F, 0x1093F}, {0x10980, 0x109B7},
316 {0x109BC, 0x109CF}, {0x109D2, 0x10A03}, {0x10A05, 0x10A06},
317 {0x10A0C, 0x10A13}, {0x10A15, 0x10A17}, {0x10A19, 0x10A35},
318 {0x10A38, 0x10A3A}, {0x10A3F, 0x10A48}, {0x10A50, 0x10A58},
319 {0x10A60, 0x10A9F}, {0x10AC0, 0x10AE6}, {0x10AEB, 0x10AF6},
320 {0x10B00, 0x10B35}, {0x10B39, 0x10B55}, {0x10B58, 0x10B72},
321 {0x10B78, 0x10B91}, {0x10B99, 0x10B9C}, {0x10BA9, 0x10BAF},
322 {0x10C00, 0x10C48}, {0x10C80, 0x10CB2}, {0x10CC0, 0x10CF2},
323 {0x10CFA, 0x10D27}, {0x10D30, 0x10D39}, {0x10E60, 0x10E7E},
324 {0x10E80, 0x10EA9}, {0x10EAB, 0x10EAD}, {0x10EB0, 0x10EB1},
325 {0x10F00, 0x10F27}, {0x10F30, 0x10F59}, {0x10FB0, 0x10FCB},
326 {0x10FE0, 0x10FF6}, {0x11000, 0x1104D}, {0x11052, 0x1106F},
327 {0x1107F, 0x110C1}, {0x110CD, 0x110CD}, {0x110D0, 0x110E8},
328 {0x110F0, 0x110F9}, {0x11100, 0x11134}, {0x11136, 0x11147},
329 {0x11150, 0x11176}, {0x11180, 0x111DF}, {0x111E1, 0x111F4},
330 {0x11200, 0x11211}, {0x11213, 0x1123E}, {0x11280, 0x11286},
331 {0x11288, 0x11288}, {0x1128A, 0x1128D}, {0x1128F, 0x1129D},
332 {0x1129F, 0x112A9}, {0x112B0, 0x112EA}, {0x112F0, 0x112F9},
333 {0x11300, 0x11303}, {0x11305, 0x1130C}, {0x1130F, 0x11310},
334 {0x11313, 0x11328}, {0x1132A, 0x11330}, {0x11332, 0x11333},
335 {0x11335, 0x11339}, {0x1133B, 0x11344}, {0x11347, 0x11348},
336 {0x1134B, 0x1134D}, {0x11350, 0x11350}, {0x11357, 0x11357},
337 {0x1135D, 0x11363}, {0x11366, 0x1136C}, {0x11370, 0x11374},
338 {0x11400, 0x1145B}, {0x1145D, 0x11461}, {0x11480, 0x114C7},
339 {0x114D0, 0x114D9}, {0x11580, 0x115B5}, {0x115B8, 0x115DD},
340 {0x11600, 0x11644}, {0x11650, 0x11659}, {0x11660, 0x1166C},
341 {0x11680, 0x116B8}, {0x116C0, 0x116C9}, {0x11700, 0x1171A},
342 {0x1171D, 0x1172B}, {0x11730, 0x1173F}, {0x11800, 0x1183B},
343 {0x118A0, 0x118F2}, {0x118FF, 0x11906}, {0x11909, 0x11909},
344 {0x1190C, 0x11913}, {0x11915, 0x11916}, {0x11918, 0x11935},
345 {0x11937, 0x11938}, {0x1193B, 0x11946}, {0x11950, 0x11959},
346 {0x119A0, 0x119A7}, {0x119AA, 0x119D7}, {0x119DA, 0x119E4},
347 {0x11A00, 0x11A47}, {0x11A50, 0x11AA2}, {0x11AC0, 0x11AF8},
311 {0x1056F, 0x1057A}, {0x1057C, 0x1058A}, {0x1058C, 0x10592},
312 {0x10594, 0x10595}, {0x10597, 0x105A1}, {0x105A3, 0x105B1},
313 {0x105B3, 0x105B9}, {0x105BB, 0x105BC}, {0x10600, 0x10736},
314 {0x10740, 0x10755}, {0x10760, 0x10767}, {0x10780, 0x10785},
315 {0x10787, 0x107B0}, {0x107B2, 0x107BA}, {0x10800, 0x10805},
316 {0x10808, 0x10808}, {0x1080A, 0x10835}, {0x10837, 0x10838},
317 {0x1083C, 0x1083C}, {0x1083F, 0x10855}, {0x10857, 0x1089E},
318 {0x108A7, 0x108AF}, {0x108E0, 0x108F2}, {0x108F4, 0x108F5},
319 {0x108FB, 0x1091B}, {0x1091F, 0x10939}, {0x1093F, 0x1093F},
320 {0x10980, 0x109B7}, {0x109BC, 0x109CF}, {0x109D2, 0x10A03},
321 {0x10A05, 0x10A06}, {0x10A0C, 0x10A13}, {0x10A15, 0x10A17},
322 {0x10A19, 0x10A35}, {0x10A38, 0x10A3A}, {0x10A3F, 0x10A48},
323 {0x10A50, 0x10A58}, {0x10A60, 0x10A9F}, {0x10AC0, 0x10AE6},
324 {0x10AEB, 0x10AF6}, {0x10B00, 0x10B35}, {0x10B39, 0x10B55},
325 {0x10B58, 0x10B72}, {0x10B78, 0x10B91}, {0x10B99, 0x10B9C},
326 {0x10BA9, 0x10BAF}, {0x10C00, 0x10C48}, {0x10C80, 0x10CB2},
327 {0x10CC0, 0x10CF2}, {0x10CFA, 0x10D27}, {0x10D30, 0x10D39},
328 {0x10E60, 0x10E7E}, {0x10E80, 0x10EA9}, {0x10EAB, 0x10EAD},
329 {0x10EB0, 0x10EB1}, {0x10EFD, 0x10F27}, {0x10F30, 0x10F59},
330 {0x10F70, 0x10F89}, {0x10FB0, 0x10FCB}, {0x10FE0, 0x10FF6},
331 {0x11000, 0x1104D}, {0x11052, 0x11075}, {0x1107F, 0x110C2},
332 {0x110CD, 0x110CD}, {0x110D0, 0x110E8}, {0x110F0, 0x110F9},
333 {0x11100, 0x11134}, {0x11136, 0x11147}, {0x11150, 0x11176},
334 {0x11180, 0x111DF}, {0x111E1, 0x111F4}, {0x11200, 0x11211},
335 {0x11213, 0x11241}, {0x11280, 0x11286}, {0x11288, 0x11288},
336 {0x1128A, 0x1128D}, {0x1128F, 0x1129D}, {0x1129F, 0x112A9},
337 {0x112B0, 0x112EA}, {0x112F0, 0x112F9}, {0x11300, 0x11303},
338 {0x11305, 0x1130C}, {0x1130F, 0x11310}, {0x11313, 0x11328},
339 {0x1132A, 0x11330}, {0x11332, 0x11333}, {0x11335, 0x11339},
340 {0x1133B, 0x11344}, {0x11347, 0x11348}, {0x1134B, 0x1134D},
341 {0x11350, 0x11350}, {0x11357, 0x11357}, {0x1135D, 0x11363},
342 {0x11366, 0x1136C}, {0x11370, 0x11374}, {0x11400, 0x1145B},
343 {0x1145D, 0x11461}, {0x11480, 0x114C7}, {0x114D0, 0x114D9},
344 {0x11580, 0x115B5}, {0x115B8, 0x115DD}, {0x11600, 0x11644},
345 {0x11650, 0x11659}, {0x11660, 0x1166C}, {0x11680, 0x116B9},
346 {0x116C0, 0x116C9}, {0x11700, 0x1171A}, {0x1171D, 0x1172B},
347 {0x11730, 0x11746}, {0x11800, 0x1183B}, {0x118A0, 0x118F2},
348 {0x118FF, 0x11906}, {0x11909, 0x11909}, {0x1190C, 0x11913},
349 {0x11915, 0x11916}, {0x11918, 0x11935}, {0x11937, 0x11938},
350 {0x1193B, 0x11946}, {0x11950, 0x11959}, {0x119A0, 0x119A7},
351 {0x119AA, 0x119D7}, {0x119DA, 0x119E4}, {0x11A00, 0x11A47},
352 {0x11A50, 0x11AA2}, {0x11AB0, 0x11AF8}, {0x11B00, 0x11B09},
348353 {0x11C00, 0x11C08}, {0x11C0A, 0x11C36}, {0x11C38, 0x11C45},
349354 {0x11C50, 0x11C6C}, {0x11C70, 0x11C8F}, {0x11C92, 0x11CA7},
350355 {0x11CA9, 0x11CB6}, {0x11D00, 0x11D06}, {0x11D08, 0x11D09},
@@ -352,30 +357,36 @@ var neutral = table{
352357 {0x11D3F, 0x11D47}, {0x11D50, 0x11D59}, {0x11D60, 0x11D65},
353358 {0x11D67, 0x11D68}, {0x11D6A, 0x11D8E}, {0x11D90, 0x11D91},
354359 {0x11D93, 0x11D98}, {0x11DA0, 0x11DA9}, {0x11EE0, 0x11EF8},
360 {0x11F00, 0x11F10}, {0x11F12, 0x11F3A}, {0x11F3E, 0x11F59},
355361 {0x11FB0, 0x11FB0}, {0x11FC0, 0x11FF1}, {0x11FFF, 0x12399},
356362 {0x12400, 0x1246E}, {0x12470, 0x12474}, {0x12480, 0x12543},
357 {0x13000, 0x1342E}, {0x13430, 0x13438}, {0x14400, 0x14646},
363 {0x12F90, 0x12FF2}, {0x13000, 0x13455}, {0x14400, 0x14646},
358364 {0x16800, 0x16A38}, {0x16A40, 0x16A5E}, {0x16A60, 0x16A69},
359 {0x16A6E, 0x16A6F}, {0x16AD0, 0x16AED}, {0x16AF0, 0x16AF5},
360 {0x16B00, 0x16B45}, {0x16B50, 0x16B59}, {0x16B5B, 0x16B61},
361 {0x16B63, 0x16B77}, {0x16B7D, 0x16B8F}, {0x16E40, 0x16E9A},
362 {0x16F00, 0x16F4A}, {0x16F4F, 0x16F87}, {0x16F8F, 0x16F9F},
363 {0x1BC00, 0x1BC6A}, {0x1BC70, 0x1BC7C}, {0x1BC80, 0x1BC88},
364 {0x1BC90, 0x1BC99}, {0x1BC9C, 0x1BCA3}, {0x1D000, 0x1D0F5},
365 {0x1D100, 0x1D126}, {0x1D129, 0x1D1E8}, {0x1D200, 0x1D245},
366 {0x1D2E0, 0x1D2F3}, {0x1D300, 0x1D356}, {0x1D360, 0x1D378},
367 {0x1D400, 0x1D454}, {0x1D456, 0x1D49C}, {0x1D49E, 0x1D49F},
368 {0x1D4A2, 0x1D4A2}, {0x1D4A5, 0x1D4A6}, {0x1D4A9, 0x1D4AC},
369 {0x1D4AE, 0x1D4B9}, {0x1D4BB, 0x1D4BB}, {0x1D4BD, 0x1D4C3},
370 {0x1D4C5, 0x1D505}, {0x1D507, 0x1D50A}, {0x1D50D, 0x1D514},
371 {0x1D516, 0x1D51C}, {0x1D51E, 0x1D539}, {0x1D53B, 0x1D53E},
372 {0x1D540, 0x1D544}, {0x1D546, 0x1D546}, {0x1D54A, 0x1D550},
373 {0x1D552, 0x1D6A5}, {0x1D6A8, 0x1D7CB}, {0x1D7CE, 0x1DA8B},
374 {0x1DA9B, 0x1DA9F}, {0x1DAA1, 0x1DAAF}, {0x1E000, 0x1E006},
375 {0x1E008, 0x1E018}, {0x1E01B, 0x1E021}, {0x1E023, 0x1E024},
376 {0x1E026, 0x1E02A}, {0x1E100, 0x1E12C}, {0x1E130, 0x1E13D},
377 {0x1E140, 0x1E149}, {0x1E14E, 0x1E14F}, {0x1E2C0, 0x1E2F9},
378 {0x1E2FF, 0x1E2FF}, {0x1E800, 0x1E8C4}, {0x1E8C7, 0x1E8D6},
365 {0x16A6E, 0x16ABE}, {0x16AC0, 0x16AC9}, {0x16AD0, 0x16AED},
366 {0x16AF0, 0x16AF5}, {0x16B00, 0x16B45}, {0x16B50, 0x16B59},
367 {0x16B5B, 0x16B61}, {0x16B63, 0x16B77}, {0x16B7D, 0x16B8F},
368 {0x16E40, 0x16E9A}, {0x16F00, 0x16F4A}, {0x16F4F, 0x16F87},
369 {0x16F8F, 0x16F9F}, {0x1BC00, 0x1BC6A}, {0x1BC70, 0x1BC7C},
370 {0x1BC80, 0x1BC88}, {0x1BC90, 0x1BC99}, {0x1BC9C, 0x1BCA3},
371 {0x1CF00, 0x1CF2D}, {0x1CF30, 0x1CF46}, {0x1CF50, 0x1CFC3},
372 {0x1D000, 0x1D0F5}, {0x1D100, 0x1D126}, {0x1D129, 0x1D1EA},
373 {0x1D200, 0x1D245}, {0x1D2C0, 0x1D2D3}, {0x1D2E0, 0x1D2F3},
374 {0x1D300, 0x1D356}, {0x1D360, 0x1D378}, {0x1D400, 0x1D454},
375 {0x1D456, 0x1D49C}, {0x1D49E, 0x1D49F}, {0x1D4A2, 0x1D4A2},
376 {0x1D4A5, 0x1D4A6}, {0x1D4A9, 0x1D4AC}, {0x1D4AE, 0x1D4B9},
377 {0x1D4BB, 0x1D4BB}, {0x1D4BD, 0x1D4C3}, {0x1D4C5, 0x1D505},
378 {0x1D507, 0x1D50A}, {0x1D50D, 0x1D514}, {0x1D516, 0x1D51C},
379 {0x1D51E, 0x1D539}, {0x1D53B, 0x1D53E}, {0x1D540, 0x1D544},
380 {0x1D546, 0x1D546}, {0x1D54A, 0x1D550}, {0x1D552, 0x1D6A5},
381 {0x1D6A8, 0x1D7CB}, {0x1D7CE, 0x1DA8B}, {0x1DA9B, 0x1DA9F},
382 {0x1DAA1, 0x1DAAF}, {0x1DF00, 0x1DF1E}, {0x1DF25, 0x1DF2A},
383 {0x1E000, 0x1E006}, {0x1E008, 0x1E018}, {0x1E01B, 0x1E021},
384 {0x1E023, 0x1E024}, {0x1E026, 0x1E02A}, {0x1E030, 0x1E06D},
385 {0x1E08F, 0x1E08F}, {0x1E100, 0x1E12C}, {0x1E130, 0x1E13D},
386 {0x1E140, 0x1E149}, {0x1E14E, 0x1E14F}, {0x1E290, 0x1E2AE},
387 {0x1E2C0, 0x1E2F9}, {0x1E2FF, 0x1E2FF}, {0x1E4D0, 0x1E4F9},
388 {0x1E7E0, 0x1E7E6}, {0x1E7E8, 0x1E7EB}, {0x1E7ED, 0x1E7EE},
389 {0x1E7F0, 0x1E7FE}, {0x1E800, 0x1E8C4}, {0x1E8C7, 0x1E8D6},
379390 {0x1E900, 0x1E94B}, {0x1E950, 0x1E959}, {0x1E95E, 0x1E95F},
380391 {0x1EC71, 0x1ECB4}, {0x1ED01, 0x1ED3D}, {0x1EE00, 0x1EE03},
381392 {0x1EE05, 0x1EE1F}, {0x1EE21, 0x1EE22}, {0x1EE24, 0x1EE24},
@@ -400,8 +411,8 @@ var neutral = table{
400411 {0x1F54F, 0x1F54F}, {0x1F568, 0x1F579}, {0x1F57B, 0x1F594},
401412 {0x1F597, 0x1F5A3}, {0x1F5A5, 0x1F5FA}, {0x1F650, 0x1F67F},
402413 {0x1F6C6, 0x1F6CB}, {0x1F6CD, 0x1F6CF}, {0x1F6D3, 0x1F6D4},
403 {0x1F6E0, 0x1F6EA}, {0x1F6F0, 0x1F6F3}, {0x1F700, 0x1F773},
404 {0x1F780, 0x1F7D8}, {0x1F800, 0x1F80B}, {0x1F810, 0x1F847},
414 {0x1F6E0, 0x1F6EA}, {0x1F6F0, 0x1F6F3}, {0x1F700, 0x1F776},
415 {0x1F77B, 0x1F7D9}, {0x1F800, 0x1F80B}, {0x1F810, 0x1F847},
405416 {0x1F850, 0x1F859}, {0x1F860, 0x1F887}, {0x1F890, 0x1F8AD},
406417 {0x1F8B0, 0x1F8B1}, {0x1F900, 0x1F90B}, {0x1F93B, 0x1F93B},
407418 {0x1F946, 0x1F946}, {0x1FA00, 0x1FA53}, {0x1FA60, 0x1FA6D},
vendor/github.com/hugolgst/rich-go/LICENSE → vendor/github.com/wraient/rich-go/LICENSE renamed
vendor/github.com/hugolgst/rich-go/client/client.go → vendor/github.com/wraient/rich-go/client/client.go renamed +1 −1
@@ -6,7 +6,7 @@ import (
66 "fmt"
77 "os"
88
9 "github.com/hugolgst/rich-go/ipc"
9 "github.com/wraient/rich-go/ipc"
1010)
1111
1212var logged bool
vendor/github.com/hugolgst/rich-go/client/inputMapper.go → vendor/github.com/wraient/rich-go/client/inputMapper.go renamed +16
@@ -4,12 +4,28 @@ import (
44 "time"
55)
66
7// ActivityType represents the type of Discord rich presence activity
8type ActivityType int
9
10const (
11 // ActivityTypePlaying represents "Playing ..." status
12 ActivityTypePlaying ActivityType = 0
13 // ActivityTypeListening represents "Listening to ..." status
14 ActivityTypeListening ActivityType = 2
15 // ActivityTypeWatching represents "Watching ..." status
16 ActivityTypeWatching ActivityType = 3
17 // ActivityTypeCompeting represents "Competing in ..." status
18 ActivityTypeCompeting ActivityType = 5
19)
20
721// Activity holds the data for discord rich presence
822type Activity struct {
923 // What the player is currently doing
1024 Details string
1125 // The user's current party status
1226 State string
27 // The activity type, defaults to Playing if not specified
28 Type ActivityType
1329 // The id for a large asset of the activity, usually a snowflake
1430 LargeImage string
1531 // Text displayed when hovering over the large image of the activity
vendor/github.com/hugolgst/rich-go/client/types.go → vendor/github.com/wraient/rich-go/client/types.go renamed +1
@@ -19,6 +19,7 @@ type Args struct {
1919type PayloadActivity struct {
2020 Details string `json:"details,omitempty"`
2121 State string `json:"state,omitempty"`
22 Type ActivityType `json:"type,omitempty"`
2223 Assets PayloadAssets `json:"assets,omitempty"`
2324 Party *PayloadParty `json:"party,omitempty"`
2425 Timestamps *PayloadTimestamps `json:"timestamps,omitempty"`
vendor/github.com/hugolgst/rich-go/ipc/ipc.go → vendor/github.com/wraient/rich-go/ipc/ipc.go renamed
vendor/github.com/hugolgst/rich-go/ipc/ipc_notwin.go → vendor/github.com/wraient/rich-go/ipc/ipc_notwin.go renamed +1
@@ -1,3 +1,4 @@
1//go:build !windows
12// +build !windows
23
34package ipc
vendor/github.com/hugolgst/rich-go/ipc/ipc_windows.go → vendor/github.com/wraient/rich-go/ipc/ipc_windows.go renamed +3 −1
@@ -1,10 +1,12 @@
1//go:build windows
12// +build windows
23
34package ipc
45
56import (
6 npipe "gopkg.in/natefinch/npipe.v2"
77 "time"
8
9 npipe "gopkg.in/natefinch/npipe.v2"
810)
911
1012// OpenSocket opens the discord-ipc-0 named pipe
vendor/golang.org/x/sync/errgroup/errgroup.go +1
@@ -118,6 +118,7 @@ func (g *Group) TryGo(f func() error) bool {
118118
119119// SetLimit limits the number of active goroutines in this group to at most n.
120120// A negative value indicates no limit.
121// A limit of zero will prevent any new goroutines from being added.
121122//
122123// Any subsequent call to the Go method will block until it can add an active
123124// goroutine without exceeding the configured limit.
vendor/golang.org/x/sys/unix/auxv.go added +36
@@ -0,0 +1,36 @@
1// Copyright 2025 The Go Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style
3// license that can be found in the LICENSE file.
4
5//go:build go1.21 && (aix || darwin || dragonfly || freebsd || linux || netbsd || openbsd || solaris || zos)
6
7package unix
8
9import (
10 "syscall"
11 "unsafe"
12)
13
14//go:linkname runtime_getAuxv runtime.getAuxv
15func runtime_getAuxv() []uintptr
16
17// Auxv returns the ELF auxiliary vector as a sequence of key/value pairs.
18// The returned slice is always a fresh copy, owned by the caller.
19// It returns an error on non-ELF platforms, or if the auxiliary vector cannot be accessed,
20// which happens in some locked-down environments and build modes.
21func Auxv() ([][2]uintptr, error) {
22 vec := runtime_getAuxv()
23 vecLen := len(vec)
24
25 if vecLen == 0 {
26 return nil, syscall.ENOENT
27 }
28
29 if vecLen%2 != 0 {
30 return nil, syscall.EINVAL
31 }
32
33 result := make([]uintptr, vecLen)
34 copy(result, vec)
35 return unsafe.Slice((*[2]uintptr)(unsafe.Pointer(&result[0])), vecLen/2), nil
36}
vendor/golang.org/x/sys/unix/auxv_unsupported.go added +13
@@ -0,0 +1,13 @@
1// Copyright 2025 The Go Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style
3// license that can be found in the LICENSE file.
4
5//go:build !go1.21 && (aix || darwin || dragonfly || freebsd || linux || netbsd || openbsd || solaris || zos)
6
7package unix
8
9import "syscall"
10
11func Auxv() ([][2]uintptr, error) {
12 return nil, syscall.ENOTSUP
13}
vendor/golang.org/x/sys/unix/ioctl_linux.go +96
@@ -58,6 +58,102 @@ func IoctlGetEthtoolDrvinfo(fd int, ifname string) (*EthtoolDrvinfo, error) {
5858 return &value, err
5959}
6060
61// IoctlGetEthtoolTsInfo fetches ethtool timestamping and PHC
62// association for the network device specified by ifname.
63func IoctlGetEthtoolTsInfo(fd int, ifname string) (*EthtoolTsInfo, error) {
64 ifr, err := NewIfreq(ifname)
65 if err != nil {
66 return nil, err
67 }
68
69 value := EthtoolTsInfo{Cmd: ETHTOOL_GET_TS_INFO}
70 ifrd := ifr.withData(unsafe.Pointer(&value))
71
72 err = ioctlIfreqData(fd, SIOCETHTOOL, &ifrd)
73 return &value, err
74}
75
76// IoctlGetHwTstamp retrieves the hardware timestamping configuration
77// for the network device specified by ifname.
78func IoctlGetHwTstamp(fd int, ifname string) (*HwTstampConfig, error) {
79 ifr, err := NewIfreq(ifname)
80 if err != nil {
81 return nil, err
82 }
83
84 value := HwTstampConfig{}
85 ifrd := ifr.withData(unsafe.Pointer(&value))
86
87 err = ioctlIfreqData(fd, SIOCGHWTSTAMP, &ifrd)
88 return &value, err
89}
90
91// IoctlSetHwTstamp updates the hardware timestamping configuration for
92// the network device specified by ifname.
93func IoctlSetHwTstamp(fd int, ifname string, cfg *HwTstampConfig) error {
94 ifr, err := NewIfreq(ifname)
95 if err != nil {
96 return err
97 }
98 ifrd := ifr.withData(unsafe.Pointer(cfg))
99 return ioctlIfreqData(fd, SIOCSHWTSTAMP, &ifrd)
100}
101
102// FdToClockID derives the clock ID from the file descriptor number
103// - see clock_gettime(3), FD_TO_CLOCKID macros. The resulting ID is
104// suitable for system calls like ClockGettime.
105func FdToClockID(fd int) int32 { return int32((int(^fd) << 3) | 3) }
106
107// IoctlPtpClockGetcaps returns the description of a given PTP device.
108func IoctlPtpClockGetcaps(fd int) (*PtpClockCaps, error) {
109 var value PtpClockCaps
110 err := ioctlPtr(fd, PTP_CLOCK_GETCAPS2, unsafe.Pointer(&value))
111 return &value, err
112}
113
114// IoctlPtpSysOffsetPrecise returns a description of the clock
115// offset compared to the system clock.
116func IoctlPtpSysOffsetPrecise(fd int) (*PtpSysOffsetPrecise, error) {
117 var value PtpSysOffsetPrecise
118 err := ioctlPtr(fd, PTP_SYS_OFFSET_PRECISE2, unsafe.Pointer(&value))
119 return &value, err
120}
121
122// IoctlPtpSysOffsetExtended returns an extended description of the
123// clock offset compared to the system clock. The samples parameter
124// specifies the desired number of measurements.
125func IoctlPtpSysOffsetExtended(fd int, samples uint) (*PtpSysOffsetExtended, error) {
126 value := PtpSysOffsetExtended{Samples: uint32(samples)}
127 err := ioctlPtr(fd, PTP_SYS_OFFSET_EXTENDED2, unsafe.Pointer(&value))
128 return &value, err
129}
130
131// IoctlPtpPinGetfunc returns the configuration of the specified
132// I/O pin on given PTP device.
133func IoctlPtpPinGetfunc(fd int, index uint) (*PtpPinDesc, error) {
134 value := PtpPinDesc{Index: uint32(index)}
135 err := ioctlPtr(fd, PTP_PIN_GETFUNC2, unsafe.Pointer(&value))
136 return &value, err
137}
138
139// IoctlPtpPinSetfunc updates configuration of the specified PTP
140// I/O pin.
141func IoctlPtpPinSetfunc(fd int, pd *PtpPinDesc) error {
142 return ioctlPtr(fd, PTP_PIN_SETFUNC2, unsafe.Pointer(pd))
143}
144
145// IoctlPtpPeroutRequest configures the periodic output mode of the
146// PTP I/O pins.
147func IoctlPtpPeroutRequest(fd int, r *PtpPeroutRequest) error {
148 return ioctlPtr(fd, PTP_PEROUT_REQUEST2, unsafe.Pointer(r))
149}
150
151// IoctlPtpExttsRequest configures the external timestamping mode
152// of the PTP I/O pins.
153func IoctlPtpExttsRequest(fd int, r *PtpExttsRequest) error {
154 return ioctlPtr(fd, PTP_EXTTS_REQUEST2, unsafe.Pointer(r))
155}
156
61157// IoctlGetWatchdogInfo fetches information about a watchdog device from the
62158// Linux watchdog API. For more information, see:
63159// https://www.kernel.org/doc/html/latest/watchdog/watchdog-api.html.
vendor/golang.org/x/sys/unix/mkerrors.sh +15 −2
@@ -158,6 +158,16 @@ includes_Linux='
158158#endif
159159#define _GNU_SOURCE
160160
161// See the description in unix/linux/types.go
162#if defined(__ARM_EABI__) || \
163 (defined(__mips__) && (_MIPS_SIM == _ABIO32)) || \
164 (defined(__powerpc__) && (!defined(__powerpc64__)))
165# ifdef _TIME_BITS
166# undef _TIME_BITS
167# endif
168# define _TIME_BITS 32
169#endif
170
161171// <sys/ioctl.h> is broken on powerpc64, as it fails to include definitions of
162172// these structures. We just include them copied from <bits/termios.h>.
163173#if defined(__powerpc__)
@@ -256,6 +266,7 @@ struct ltchars {
256266#include <linux/nsfs.h>
257267#include <linux/perf_event.h>
258268#include <linux/pps.h>
269#include <linux/ptp_clock.h>
259270#include <linux/ptrace.h>
260271#include <linux/random.h>
261272#include <linux/reboot.h>
@@ -527,6 +538,7 @@ ccflags="$@"
527538 $2 ~ /^(AF|SOCK|SO|SOL|IPPROTO|IP|IPV6|TCP|MCAST|EVFILT|NOTE|SHUT|PROT|MAP|MREMAP|MFD|T?PACKET|MSG|SCM|MCL|DT|MADV|PR|LOCAL|TCPOPT|UDP)_/ ||
528539 $2 ~ /^NFC_(GENL|PROTO|COMM|RF|SE|DIRECTION|LLCP|SOCKPROTO)_/ ||
529540 $2 ~ /^NFC_.*_(MAX)?SIZE$/ ||
541 $2 ~ /^PTP_/ ||
530542 $2 ~ /^RAW_PAYLOAD_/ ||
531543 $2 ~ /^[US]F_/ ||
532544 $2 ~ /^TP_STATUS_/ ||
@@ -552,6 +564,7 @@ ccflags="$@"
552564 $2 !~ /^RTC_VL_(ACCURACY|BACKUP|DATA)/ &&
553565 $2 ~ /^(NETLINK|NLM|NLMSG|NLA|IFA|IFAN|RT|RTC|RTCF|RTN|RTPROT|RTNH|ARPHRD|ETH_P|NETNSA)_/ ||
554566 $2 ~ /^SOCK_|SK_DIAG_|SKNLGRP_$/ ||
567 $2 ~ /^(CONNECT|SAE)_/ ||
555568 $2 ~ /^FIORDCHK$/ ||
556569 $2 ~ /^SIOC/ ||
557570 $2 ~ /^TIOC/ ||
@@ -655,7 +668,7 @@ errors=$(
655668signals=$(
656669 echo '#include <signal.h>' | $CC -x c - -E -dM $ccflags |
657670 awk '$1=="#define" && $2 ~ /^SIG[A-Z0-9]+$/ { print $2 }' |
658 grep -v 'SIGSTKSIZE\|SIGSTKSZ\|SIGRT\|SIGMAX64' |
671 grep -E -v '(SIGSTKSIZE|SIGSTKSZ|SIGRT|SIGMAX64)' |
659672 sort
660673)
661674
@@ -665,7 +678,7 @@ echo '#include <errno.h>' | $CC -x c - -E -dM $ccflags |
665678 sort >_error.grep
666679echo '#include <signal.h>' | $CC -x c - -E -dM $ccflags |
667680 awk '$1=="#define" && $2 ~ /^SIG[A-Z0-9]+$/ { print "^\t" $2 "[ \t]*=" }' |
668 grep -v 'SIGSTKSIZE\|SIGSTKSZ\|SIGRT\|SIGMAX64' |
681 grep -E -v '(SIGSTKSIZE|SIGSTKSZ|SIGRT|SIGMAX64)' |
669682 sort >_signal.grep
670683
671684echo '// mkerrors.sh' "$@"
vendor/golang.org/x/sys/unix/syscall_aix.go +1 −1
@@ -360,7 +360,7 @@ func Wait4(pid int, wstatus *WaitStatus, options int, rusage *Rusage) (wpid int,
360360 var status _C_int
361361 var r Pid_t
362362 err = ERESTART
363 // AIX wait4 may return with ERESTART errno, while the processus is still
363 // AIX wait4 may return with ERESTART errno, while the process is still
364364 // active.
365365 for err == ERESTART {
366366 r, err = wait4(Pid_t(pid), &status, options, rusage)
vendor/golang.org/x/sys/unix/syscall_darwin.go +37
@@ -566,6 +566,43 @@ func PthreadFchdir(fd int) (err error) {
566566 return pthread_fchdir_np(fd)
567567}
568568
569// Connectx calls connectx(2) to initiate a connection on a socket.
570//
571// srcIf, srcAddr, and dstAddr are filled into a [SaEndpoints] struct and passed as the endpoints argument.
572//
573// - srcIf is the optional source interface index. 0 means unspecified.
574// - srcAddr is the optional source address. nil means unspecified.
575// - dstAddr is the destination address.
576//
577// On success, Connectx returns the number of bytes enqueued for transmission.
578func Connectx(fd int, srcIf uint32, srcAddr, dstAddr Sockaddr, associd SaeAssocID, flags uint32, iov []Iovec, connid *SaeConnID) (n uintptr, err error) {
579 endpoints := SaEndpoints{
580 Srcif: srcIf,
581 }
582
583 if srcAddr != nil {
584 addrp, addrlen, err := srcAddr.sockaddr()
585 if err != nil {
586 return 0, err
587 }
588 endpoints.Srcaddr = (*RawSockaddr)(addrp)
589 endpoints.Srcaddrlen = uint32(addrlen)
590 }
591
592 if dstAddr != nil {
593 addrp, addrlen, err := dstAddr.sockaddr()
594 if err != nil {
595 return 0, err
596 }
597 endpoints.Dstaddr = (*RawSockaddr)(addrp)
598 endpoints.Dstaddrlen = uint32(addrlen)
599 }
600
601 err = connectx(fd, &endpoints, associd, flags, iov, &n, connid)
602 return
603}
604
605//sys connectx(fd int, endpoints *SaEndpoints, associd SaeAssocID, flags uint32, iov []Iovec, n *uintptr, connid *SaeConnID) (err error)
569606//sys sendfile(infd int, outfd int, offset int64, len *int64, hdtr unsafe.Pointer, flags int) (err error)
570607
571608//sys shmat(id int, addr uintptr, flag int) (ret uintptr, err error)
vendor/golang.org/x/sys/unix/syscall_dragonfly.go +12
@@ -246,6 +246,18 @@ func Sendfile(outfd int, infd int, offset *int64, count int) (written int, err e
246246 return sendfile(outfd, infd, offset, count)
247247}
248248
249func Dup3(oldfd, newfd, flags int) error {
250 if oldfd == newfd || flags&^O_CLOEXEC != 0 {
251 return EINVAL
252 }
253 how := F_DUP2FD
254 if flags&O_CLOEXEC != 0 {
255 how = F_DUP2FD_CLOEXEC
256 }
257 _, err := fcntl(oldfd, how, newfd)
258 return err
259}
260
249261/*
250262 * Exposed directly
251263 */
vendor/golang.org/x/sys/unix/syscall_hurd.go +1
@@ -11,6 +11,7 @@ package unix
1111int ioctl(int, unsigned long int, uintptr_t);
1212*/
1313import "C"
14import "unsafe"
1415
1516func ioctl(fd int, req uint, arg uintptr) (err error) {
1617 r0, er := C.ioctl(C.int(fd), C.ulong(req), C.uintptr_t(arg))
vendor/golang.org/x/sys/unix/syscall_linux.go +63 −1
@@ -1295,6 +1295,48 @@ func GetsockoptTCPInfo(fd, level, opt int) (*TCPInfo, error) {
12951295 return &value, err
12961296}
12971297
1298// GetsockoptTCPCCVegasInfo returns algorithm specific congestion control information for a socket using the "vegas"
1299// algorithm.
1300//
1301// The socket's congestion control algorighm can be retrieved via [GetsockoptString] with the [TCP_CONGESTION] option:
1302//
1303// algo, err := unix.GetsockoptString(fd, unix.IPPROTO_TCP, unix.TCP_CONGESTION)
1304func GetsockoptTCPCCVegasInfo(fd, level, opt int) (*TCPVegasInfo, error) {
1305 var value [SizeofTCPCCInfo / 4]uint32 // ensure proper alignment
1306 vallen := _Socklen(SizeofTCPCCInfo)
1307 err := getsockopt(fd, level, opt, unsafe.Pointer(&value[0]), &vallen)
1308 out := (*TCPVegasInfo)(unsafe.Pointer(&value[0]))
1309 return out, err
1310}
1311
1312// GetsockoptTCPCCDCTCPInfo returns algorithm specific congestion control information for a socket using the "dctp"
1313// algorithm.
1314//
1315// The socket's congestion control algorighm can be retrieved via [GetsockoptString] with the [TCP_CONGESTION] option:
1316//
1317// algo, err := unix.GetsockoptString(fd, unix.IPPROTO_TCP, unix.TCP_CONGESTION)
1318func GetsockoptTCPCCDCTCPInfo(fd, level, opt int) (*TCPDCTCPInfo, error) {
1319 var value [SizeofTCPCCInfo / 4]uint32 // ensure proper alignment
1320 vallen := _Socklen(SizeofTCPCCInfo)
1321 err := getsockopt(fd, level, opt, unsafe.Pointer(&value[0]), &vallen)
1322 out := (*TCPDCTCPInfo)(unsafe.Pointer(&value[0]))
1323 return out, err
1324}
1325
1326// GetsockoptTCPCCBBRInfo returns algorithm specific congestion control information for a socket using the "bbr"
1327// algorithm.
1328//
1329// The socket's congestion control algorighm can be retrieved via [GetsockoptString] with the [TCP_CONGESTION] option:
1330//
1331// algo, err := unix.GetsockoptString(fd, unix.IPPROTO_TCP, unix.TCP_CONGESTION)
1332func GetsockoptTCPCCBBRInfo(fd, level, opt int) (*TCPBBRInfo, error) {
1333 var value [SizeofTCPCCInfo / 4]uint32 // ensure proper alignment
1334 vallen := _Socklen(SizeofTCPCCInfo)
1335 err := getsockopt(fd, level, opt, unsafe.Pointer(&value[0]), &vallen)
1336 out := (*TCPBBRInfo)(unsafe.Pointer(&value[0]))
1337 return out, err
1338}
1339
12981340// GetsockoptString returns the string value of the socket option opt for the
12991341// socket associated with fd at the given socket level.
13001342func GetsockoptString(fd, level, opt int) (string, error) {
@@ -1818,6 +1860,7 @@ func Sendfile(outfd int, infd int, offset *int64, count int) (written int, err e
18181860//sys ClockAdjtime(clockid int32, buf *Timex) (state int, err error)
18191861//sys ClockGetres(clockid int32, res *Timespec) (err error)
18201862//sys ClockGettime(clockid int32, time *Timespec) (err error)
1863//sys ClockSettime(clockid int32, time *Timespec) (err error)
18211864//sys ClockNanosleep(clockid int32, flags int, request *Timespec, remain *Timespec) (err error)
18221865//sys Close(fd int) (err error)
18231866//sys CloseRange(first uint, last uint, flags uint) (err error)
@@ -1959,7 +2002,26 @@ func Getpgrp() (pid int) {
19592002//sysnb Getpid() (pid int)
19602003//sysnb Getppid() (ppid int)
19612004//sys Getpriority(which int, who int) (prio int, err error)
1962//sys Getrandom(buf []byte, flags int) (n int, err error)
2005
2006func Getrandom(buf []byte, flags int) (n int, err error) {
2007 vdsoRet, supported := vgetrandom(buf, uint32(flags))
2008 if supported {
2009 if vdsoRet < 0 {
2010 return 0, errnoErr(syscall.Errno(-vdsoRet))
2011 }
2012 return vdsoRet, nil
2013 }
2014 var p *byte
2015 if len(buf) > 0 {
2016 p = &buf[0]
2017 }
2018 r, _, e := Syscall(SYS_GETRANDOM, uintptr(unsafe.Pointer(p)), uintptr(len(buf)), uintptr(flags))
2019 if e != 0 {
2020 return 0, errnoErr(e)
2021 }
2022 return int(r), nil
2023}
2024
19632025//sysnb Getrusage(who int, rusage *Rusage) (err error)
19642026//sysnb Getsid(pid int) (sid int, err error)
19652027//sysnb Gettid() (tid int)
vendor/golang.org/x/sys/unix/syscall_linux_arm64.go +2
@@ -182,3 +182,5 @@ func KexecFileLoad(kernelFd int, initrdFd int, cmdline string, flags int) error
182182 }
183183 return kexecFileLoad(kernelFd, initrdFd, cmdlineLen, cmdline, flags)
184184}
185
186const SYS_FSTATAT = SYS_NEWFSTATAT
vendor/golang.org/x/sys/unix/syscall_linux_loong64.go +2
@@ -214,3 +214,5 @@ func KexecFileLoad(kernelFd int, initrdFd int, cmdline string, flags int) error
214214 }
215215 return kexecFileLoad(kernelFd, initrdFd, cmdlineLen, cmdline, flags)
216216}
217
218const SYS_FSTATAT = SYS_NEWFSTATAT
vendor/golang.org/x/sys/unix/syscall_linux_riscv64.go +2
@@ -187,3 +187,5 @@ func RISCVHWProbe(pairs []RISCVHWProbePairs, set *CPUSet, flags uint) (err error
187187 }
188188 return riscvHWProbe(pairs, setSize, set, flags)
189189}
190
191const SYS_FSTATAT = SYS_NEWFSTATAT
vendor/golang.org/x/sys/unix/syscall_solaris.go +87
@@ -1102,3 +1102,90 @@ func (s *Strioctl) SetInt(i int) {
11021102func IoctlSetStrioctlRetInt(fd int, req int, s *Strioctl) (int, error) {
11031103 return ioctlPtrRet(fd, req, unsafe.Pointer(s))
11041104}
1105
1106// Ucred Helpers
1107// See ucred(3c) and getpeerucred(3c)
1108
1109//sys getpeerucred(fd uintptr, ucred *uintptr) (err error)
1110//sys ucredFree(ucred uintptr) = ucred_free
1111//sys ucredGet(pid int) (ucred uintptr, err error) = ucred_get
1112//sys ucredGeteuid(ucred uintptr) (uid int) = ucred_geteuid
1113//sys ucredGetegid(ucred uintptr) (gid int) = ucred_getegid
1114//sys ucredGetruid(ucred uintptr) (uid int) = ucred_getruid
1115//sys ucredGetrgid(ucred uintptr) (gid int) = ucred_getrgid
1116//sys ucredGetsuid(ucred uintptr) (uid int) = ucred_getsuid
1117//sys ucredGetsgid(ucred uintptr) (gid int) = ucred_getsgid
1118//sys ucredGetpid(ucred uintptr) (pid int) = ucred_getpid
1119
1120// Ucred is an opaque struct that holds user credentials.
1121type Ucred struct {
1122 ucred uintptr
1123}
1124
1125// We need to ensure that ucredFree is called on the underlying ucred
1126// when the Ucred is garbage collected.
1127func ucredFinalizer(u *Ucred) {
1128 ucredFree(u.ucred)
1129}
1130
1131func GetPeerUcred(fd uintptr) (*Ucred, error) {
1132 var ucred uintptr
1133 err := getpeerucred(fd, &ucred)
1134 if err != nil {
1135 return nil, err
1136 }
1137 result := &Ucred{
1138 ucred: ucred,
1139 }
1140 // set the finalizer on the result so that the ucred will be freed
1141 runtime.SetFinalizer(result, ucredFinalizer)
1142 return result, nil
1143}
1144
1145func UcredGet(pid int) (*Ucred, error) {
1146 ucred, err := ucredGet(pid)
1147 if err != nil {
1148 return nil, err
1149 }
1150 result := &Ucred{
1151 ucred: ucred,
1152 }
1153 // set the finalizer on the result so that the ucred will be freed
1154 runtime.SetFinalizer(result, ucredFinalizer)
1155 return result, nil
1156}
1157
1158func (u *Ucred) Geteuid() int {
1159 defer runtime.KeepAlive(u)
1160 return ucredGeteuid(u.ucred)
1161}
1162
1163func (u *Ucred) Getruid() int {
1164 defer runtime.KeepAlive(u)
1165 return ucredGetruid(u.ucred)
1166}
1167
1168func (u *Ucred) Getsuid() int {
1169 defer runtime.KeepAlive(u)
1170 return ucredGetsuid(u.ucred)
1171}
1172
1173func (u *Ucred) Getegid() int {
1174 defer runtime.KeepAlive(u)
1175 return ucredGetegid(u.ucred)
1176}
1177
1178func (u *Ucred) Getrgid() int {
1179 defer runtime.KeepAlive(u)
1180 return ucredGetrgid(u.ucred)
1181}
1182
1183func (u *Ucred) Getsgid() int {
1184 defer runtime.KeepAlive(u)
1185 return ucredGetsgid(u.ucred)
1186}
1187
1188func (u *Ucred) Getpid() int {
1189 defer runtime.KeepAlive(u)
1190 return ucredGetpid(u.ucred)
1191}
vendor/golang.org/x/sys/unix/syscall_zos_s390x.go +100 −4
@@ -768,6 +768,15 @@ func Munmap(b []byte) (err error) {
768768 return mapper.Munmap(b)
769769}
770770
771func MmapPtr(fd int, offset int64, addr unsafe.Pointer, length uintptr, prot int, flags int) (ret unsafe.Pointer, err error) {
772 xaddr, err := mapper.mmap(uintptr(addr), length, prot, flags, fd, offset)
773 return unsafe.Pointer(xaddr), err
774}
775
776func MunmapPtr(addr unsafe.Pointer, length uintptr) (err error) {
777 return mapper.munmap(uintptr(addr), length)
778}
779
771780//sys Gethostname(buf []byte) (err error) = SYS___GETHOSTNAME_A
772781//sysnb Getgid() (gid int)
773782//sysnb Getpid() (pid int)
@@ -816,10 +825,10 @@ func Lstat(path string, stat *Stat_t) (err error) {
816825// for checking symlinks begins with $VERSION/ $SYSNAME/ $SYSSYMR/ $SYSSYMA/
817826func isSpecialPath(path []byte) (v bool) {
818827 var special = [4][8]byte{
819 [8]byte{'V', 'E', 'R', 'S', 'I', 'O', 'N', '/'},
820 [8]byte{'S', 'Y', 'S', 'N', 'A', 'M', 'E', '/'},
821 [8]byte{'S', 'Y', 'S', 'S', 'Y', 'M', 'R', '/'},
822 [8]byte{'S', 'Y', 'S', 'S', 'Y', 'M', 'A', '/'}}
828 {'V', 'E', 'R', 'S', 'I', 'O', 'N', '/'},
829 {'S', 'Y', 'S', 'N', 'A', 'M', 'E', '/'},
830 {'S', 'Y', 'S', 'S', 'Y', 'M', 'R', '/'},
831 {'S', 'Y', 'S', 'S', 'Y', 'M', 'A', '/'}}
823832
824833 var i, j int
825834 for i = 0; i < len(special); i++ {
@@ -3115,3 +3124,90 @@ func legacy_Mkfifoat(dirfd int, path string, mode uint32) (err error) {
31153124//sys Posix_openpt(oflag int) (fd int, err error) = SYS_POSIX_OPENPT
31163125//sys Grantpt(fildes int) (rc int, err error) = SYS_GRANTPT
31173126//sys Unlockpt(fildes int) (rc int, err error) = SYS_UNLOCKPT
3127
3128func fcntlAsIs(fd uintptr, cmd int, arg uintptr) (val int, err error) {
3129 runtime.EnterSyscall()
3130 r0, e2, e1 := CallLeFuncWithErr(GetZosLibVec()+SYS_FCNTL<<4, uintptr(fd), uintptr(cmd), arg)
3131 runtime.ExitSyscall()
3132 val = int(r0)
3133 if int64(r0) == -1 {
3134 err = errnoErr2(e1, e2)
3135 }
3136 return
3137}
3138
3139func Fcntl(fd uintptr, cmd int, op interface{}) (ret int, err error) {
3140 switch op.(type) {
3141 case *Flock_t:
3142 err = FcntlFlock(fd, cmd, op.(*Flock_t))
3143 if err != nil {
3144 ret = -1
3145 }
3146 return
3147 case int:
3148 return FcntlInt(fd, cmd, op.(int))
3149 case *F_cnvrt:
3150 return fcntlAsIs(fd, cmd, uintptr(unsafe.Pointer(op.(*F_cnvrt))))
3151 case unsafe.Pointer:
3152 return fcntlAsIs(fd, cmd, uintptr(op.(unsafe.Pointer)))
3153 default:
3154 return -1, EINVAL
3155 }
3156 return
3157}
3158
3159func Sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) {
3160 if raceenabled {
3161 raceReleaseMerge(unsafe.Pointer(&ioSync))
3162 }
3163 return sendfile(outfd, infd, offset, count)
3164}
3165
3166func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) {
3167 // TODO: use LE call instead if the call is implemented
3168 originalOffset, err := Seek(infd, 0, SEEK_CUR)
3169 if err != nil {
3170 return -1, err
3171 }
3172 //start reading data from in_fd
3173 if offset != nil {
3174 _, err := Seek(infd, *offset, SEEK_SET)
3175 if err != nil {
3176 return -1, err
3177 }
3178 }
3179
3180 buf := make([]byte, count)
3181 readBuf := make([]byte, 0)
3182 var n int = 0
3183 for i := 0; i < count; i += n {
3184 n, err := Read(infd, buf)
3185 if n == 0 {
3186 if err != nil {
3187 return -1, err
3188 } else { // EOF
3189 break
3190 }
3191 }
3192 readBuf = append(readBuf, buf...)
3193 buf = buf[0:0]
3194 }
3195
3196 n2, err := Write(outfd, readBuf)
3197 if err != nil {
3198 return -1, err
3199 }
3200
3201 //When sendfile() returns, this variable will be set to the
3202 // offset of the byte following the last byte that was read.
3203 if offset != nil {
3204 *offset = *offset + int64(n)
3205 // If offset is not NULL, then sendfile() does not modify the file
3206 // offset of in_fd
3207 _, err := Seek(infd, originalOffset, SEEK_SET)
3208 if err != nil {
3209 return -1, err
3210 }
3211 }
3212 return n2, nil
3213}
vendor/golang.org/x/sys/unix/vgetrandom_linux.go added +13
@@ -0,0 +1,13 @@
1// Copyright 2024 The Go Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style
3// license that can be found in the LICENSE file.
4
5//go:build linux && go1.24
6
7package unix
8
9import _ "unsafe"
10
11//go:linkname vgetrandom runtime.vgetrandom
12//go:noescape
13func vgetrandom(p []byte, flags uint32) (ret int, supported bool)
vendor/golang.org/x/sys/unix/vgetrandom_unsupported.go added +11
@@ -0,0 +1,11 @@
1// Copyright 2024 The Go Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style
3// license that can be found in the LICENSE file.
4
5//go:build !linux || !go1.24
6
7package unix
8
9func vgetrandom(p []byte, flags uint32) (ret int, supported bool) {
10 return -1, false
11}
vendor/golang.org/x/sys/unix/zerrors_darwin_amd64.go +7
@@ -237,6 +237,9 @@ const (
237237 CLOCK_UPTIME_RAW_APPROX = 0x9
238238 CLONE_NOFOLLOW = 0x1
239239 CLONE_NOOWNERCOPY = 0x2
240 CONNECT_DATA_AUTHENTICATED = 0x4
241 CONNECT_DATA_IDEMPOTENT = 0x2
242 CONNECT_RESUME_ON_READ_WRITE = 0x1
240243 CR0 = 0x0
241244 CR1 = 0x1000
242245 CR2 = 0x2000
@@ -1265,6 +1268,10 @@ const (
12651268 RTV_SSTHRESH = 0x20
12661269 RUSAGE_CHILDREN = -0x1
12671270 RUSAGE_SELF = 0x0
1271 SAE_ASSOCID_ALL = 0xffffffff
1272 SAE_ASSOCID_ANY = 0x0
1273 SAE_CONNID_ALL = 0xffffffff
1274 SAE_CONNID_ANY = 0x0
12681275 SCM_CREDS = 0x3
12691276 SCM_RIGHTS = 0x1
12701277 SCM_TIMESTAMP = 0x2
vendor/golang.org/x/sys/unix/zerrors_darwin_arm64.go +7
@@ -237,6 +237,9 @@ const (
237237 CLOCK_UPTIME_RAW_APPROX = 0x9
238238 CLONE_NOFOLLOW = 0x1
239239 CLONE_NOOWNERCOPY = 0x2
240 CONNECT_DATA_AUTHENTICATED = 0x4
241 CONNECT_DATA_IDEMPOTENT = 0x2
242 CONNECT_RESUME_ON_READ_WRITE = 0x1
240243 CR0 = 0x0
241244 CR1 = 0x1000
242245 CR2 = 0x2000
@@ -1265,6 +1268,10 @@ const (
12651268 RTV_SSTHRESH = 0x20
12661269 RUSAGE_CHILDREN = -0x1
12671270 RUSAGE_SELF = 0x0
1271 SAE_ASSOCID_ALL = 0xffffffff
1272 SAE_ASSOCID_ANY = 0x0
1273 SAE_CONNID_ALL = 0xffffffff
1274 SAE_CONNID_ANY = 0x0
12681275 SCM_CREDS = 0x3
12691276 SCM_RIGHTS = 0x1
12701277 SCM_TIMESTAMP = 0x2
vendor/golang.org/x/sys/unix/zerrors_linux.go +61 −3
@@ -321,6 +321,9 @@ const (
321321 AUDIT_INTEGRITY_STATUS = 0x70a
322322 AUDIT_IPC = 0x517
323323 AUDIT_IPC_SET_PERM = 0x51f
324 AUDIT_IPE_ACCESS = 0x58c
325 AUDIT_IPE_CONFIG_CHANGE = 0x58d
326 AUDIT_IPE_POLICY_LOAD = 0x58e
324327 AUDIT_KERNEL = 0x7d0
325328 AUDIT_KERNEL_OTHER = 0x524
326329 AUDIT_KERN_MODULE = 0x532
@@ -489,12 +492,14 @@ const (
489492 BPF_F_ID = 0x20
490493 BPF_F_NETFILTER_IP_DEFRAG = 0x1
491494 BPF_F_QUERY_EFFECTIVE = 0x1
495 BPF_F_REDIRECT_FLAGS = 0x19
492496 BPF_F_REPLACE = 0x4
493497 BPF_F_SLEEPABLE = 0x10
494498 BPF_F_STRICT_ALIGNMENT = 0x1
495499 BPF_F_TEST_REG_INVARIANTS = 0x80
496500 BPF_F_TEST_RND_HI32 = 0x4
497501 BPF_F_TEST_RUN_ON_CPU = 0x1
502 BPF_F_TEST_SKB_CHECKSUM_COMPLETE = 0x4
498503 BPF_F_TEST_STATE_FREQ = 0x8
499504 BPF_F_TEST_XDP_LIVE_FRAMES = 0x2
500505 BPF_F_XDP_DEV_BOUND_ONLY = 0x40
@@ -1165,6 +1170,7 @@ const (
11651170 EXTA = 0xe
11661171 EXTB = 0xf
11671172 F2FS_SUPER_MAGIC = 0xf2f52010
1173 FALLOC_FL_ALLOCATE_RANGE = 0x0
11681174 FALLOC_FL_COLLAPSE_RANGE = 0x8
11691175 FALLOC_FL_INSERT_RANGE = 0x20
11701176 FALLOC_FL_KEEP_SIZE = 0x1
@@ -1239,6 +1245,7 @@ const (
12391245 FAN_REPORT_DFID_NAME = 0xc00
12401246 FAN_REPORT_DFID_NAME_TARGET = 0x1e00
12411247 FAN_REPORT_DIR_FID = 0x400
1248 FAN_REPORT_FD_ERROR = 0x2000
12421249 FAN_REPORT_FID = 0x200
12431250 FAN_REPORT_NAME = 0x800
12441251 FAN_REPORT_PIDFD = 0x80
@@ -1324,8 +1331,10 @@ const (
13241331 FUSE_SUPER_MAGIC = 0x65735546
13251332 FUTEXFS_SUPER_MAGIC = 0xbad1dea
13261333 F_ADD_SEALS = 0x409
1334 F_CREATED_QUERY = 0x404
13271335 F_DUPFD = 0x0
13281336 F_DUPFD_CLOEXEC = 0x406
1337 F_DUPFD_QUERY = 0x403
13291338 F_EXLCK = 0x4
13301339 F_GETFD = 0x1
13311340 F_GETFL = 0x3
@@ -1545,6 +1554,7 @@ const (
15451554 IPPROTO_ROUTING = 0x2b
15461555 IPPROTO_RSVP = 0x2e
15471556 IPPROTO_SCTP = 0x84
1557 IPPROTO_SMC = 0x100
15481558 IPPROTO_TCP = 0x6
15491559 IPPROTO_TP = 0x1d
15501560 IPPROTO_UDP = 0x11
@@ -1617,6 +1627,8 @@ const (
16171627 IPV6_UNICAST_IF = 0x4c
16181628 IPV6_USER_FLOW = 0xe
16191629 IPV6_V6ONLY = 0x1a
1630 IPV6_VERSION = 0x60
1631 IPV6_VERSION_MASK = 0xf0
16201632 IPV6_XFRM_POLICY = 0x23
16211633 IP_ADD_MEMBERSHIP = 0x23
16221634 IP_ADD_SOURCE_MEMBERSHIP = 0x27
@@ -1798,6 +1810,8 @@ const (
17981810 LANDLOCK_ACCESS_NET_BIND_TCP = 0x1
17991811 LANDLOCK_ACCESS_NET_CONNECT_TCP = 0x2
18001812 LANDLOCK_CREATE_RULESET_VERSION = 0x1
1813 LANDLOCK_SCOPE_ABSTRACT_UNIX_SOCKET = 0x1
1814 LANDLOCK_SCOPE_SIGNAL = 0x2
18011815 LINUX_REBOOT_CMD_CAD_OFF = 0x0
18021816 LINUX_REBOOT_CMD_CAD_ON = 0x89abcdef
18031817 LINUX_REBOOT_CMD_HALT = 0xcdef0123
@@ -1859,6 +1873,7 @@ const (
18591873 MADV_UNMERGEABLE = 0xd
18601874 MADV_WILLNEED = 0x3
18611875 MADV_WIPEONFORK = 0x12
1876 MAP_DROPPABLE = 0x8
18621877 MAP_FILE = 0x0
18631878 MAP_FIXED = 0x10
18641879 MAP_FIXED_NOREPLACE = 0x100000
@@ -1922,6 +1937,8 @@ const (
19221937 MNT_EXPIRE = 0x4
19231938 MNT_FORCE = 0x1
19241939 MNT_ID_REQ_SIZE_VER0 = 0x18
1940 MNT_ID_REQ_SIZE_VER1 = 0x20
1941 MNT_NS_INFO_SIZE_VER0 = 0x10
19251942 MODULE_INIT_COMPRESSED_FILE = 0x4
19261943 MODULE_INIT_IGNORE_MODVERSIONS = 0x1
19271944 MODULE_INIT_IGNORE_VERMAGIC = 0x2
@@ -1957,6 +1974,7 @@ const (
19571974 MSG_PEEK = 0x2
19581975 MSG_PROXY = 0x10
19591976 MSG_RST = 0x1000
1977 MSG_SOCK_DEVMEM = 0x2000000
19601978 MSG_SYN = 0x400
19611979 MSG_TRUNC = 0x20
19621980 MSG_TRYHARD = 0x4
@@ -2073,6 +2091,7 @@ const (
20732091 NFC_ATR_REQ_MAXSIZE = 0x40
20742092 NFC_ATR_RES_GB_MAXSIZE = 0x2f
20752093 NFC_ATR_RES_MAXSIZE = 0x40
2094 NFC_ATS_MAXSIZE = 0x14
20762095 NFC_COMM_ACTIVE = 0x0
20772096 NFC_COMM_PASSIVE = 0x1
20782097 NFC_DEVICE_NAME_MAXSIZE = 0x8
@@ -2153,6 +2172,7 @@ const (
21532172 NFNL_SUBSYS_QUEUE = 0x3
21542173 NFNL_SUBSYS_ULOG = 0x4
21552174 NFS_SUPER_MAGIC = 0x6969
2175 NFT_BITWISE_BOOL = 0x0
21562176 NFT_CHAIN_FLAGS = 0x7
21572177 NFT_CHAIN_MAXNAMELEN = 0x100
21582178 NFT_CT_MAX = 0x17
@@ -2187,7 +2207,7 @@ const (
21872207 NFT_REG_SIZE = 0x10
21882208 NFT_REJECT_ICMPX_MAX = 0x3
21892209 NFT_RT_MAX = 0x4
2190 NFT_SECMARK_CTX_MAXLEN = 0x100
2210 NFT_SECMARK_CTX_MAXLEN = 0x1000
21912211 NFT_SET_MAXNAMELEN = 0x100
21922212 NFT_SOCKET_MAX = 0x3
21932213 NFT_TABLE_F_MASK = 0x7
@@ -2356,9 +2376,11 @@ const (
23562376 PERF_MEM_LVLNUM_IO = 0xa
23572377 PERF_MEM_LVLNUM_L1 = 0x1
23582378 PERF_MEM_LVLNUM_L2 = 0x2
2379 PERF_MEM_LVLNUM_L2_MHB = 0x5
23592380 PERF_MEM_LVLNUM_L3 = 0x3
23602381 PERF_MEM_LVLNUM_L4 = 0x4
23612382 PERF_MEM_LVLNUM_LFB = 0xc
2383 PERF_MEM_LVLNUM_MSC = 0x6
23622384 PERF_MEM_LVLNUM_NA = 0xf
23632385 PERF_MEM_LVLNUM_PMEM = 0xe
23642386 PERF_MEM_LVLNUM_RAM = 0xd
@@ -2431,6 +2453,7 @@ const (
24312453 PRIO_PGRP = 0x1
24322454 PRIO_PROCESS = 0x0
24332455 PRIO_USER = 0x2
2456 PROCFS_IOCTL_MAGIC = 'f'
24342457 PROC_SUPER_MAGIC = 0x9fa0
24352458 PROT_EXEC = 0x4
24362459 PROT_GROWSDOWN = 0x1000000
@@ -2478,6 +2501,7 @@ const (
24782501 PR_GET_PDEATHSIG = 0x2
24792502 PR_GET_SECCOMP = 0x15
24802503 PR_GET_SECUREBITS = 0x1b
2504 PR_GET_SHADOW_STACK_STATUS = 0x4a
24812505 PR_GET_SPECULATION_CTRL = 0x34
24822506 PR_GET_TAGGED_ADDR_CTRL = 0x38
24832507 PR_GET_THP_DISABLE = 0x2a
@@ -2486,6 +2510,7 @@ const (
24862510 PR_GET_TIMING = 0xd
24872511 PR_GET_TSC = 0x19
24882512 PR_GET_UNALIGN = 0x5
2513 PR_LOCK_SHADOW_STACK_STATUS = 0x4c
24892514 PR_MCE_KILL = 0x21
24902515 PR_MCE_KILL_CLEAR = 0x0
24912516 PR_MCE_KILL_DEFAULT = 0x2
@@ -2512,6 +2537,8 @@ const (
25122537 PR_PAC_GET_ENABLED_KEYS = 0x3d
25132538 PR_PAC_RESET_KEYS = 0x36
25142539 PR_PAC_SET_ENABLED_KEYS = 0x3c
2540 PR_PMLEN_MASK = 0x7f000000
2541 PR_PMLEN_SHIFT = 0x18
25152542 PR_PPC_DEXCR_CTRL_CLEAR = 0x4
25162543 PR_PPC_DEXCR_CTRL_CLEAR_ONEXEC = 0x10
25172544 PR_PPC_DEXCR_CTRL_EDITABLE = 0x1
@@ -2579,6 +2606,7 @@ const (
25792606 PR_SET_PTRACER = 0x59616d61
25802607 PR_SET_SECCOMP = 0x16
25812608 PR_SET_SECUREBITS = 0x1c
2609 PR_SET_SHADOW_STACK_STATUS = 0x4b
25822610 PR_SET_SPECULATION_CTRL = 0x35
25832611 PR_SET_SYSCALL_USER_DISPATCH = 0x3b
25842612 PR_SET_TAGGED_ADDR_CTRL = 0x37
@@ -2589,6 +2617,9 @@ const (
25892617 PR_SET_UNALIGN = 0x6
25902618 PR_SET_VMA = 0x53564d41
25912619 PR_SET_VMA_ANON_NAME = 0x0
2620 PR_SHADOW_STACK_ENABLE = 0x1
2621 PR_SHADOW_STACK_PUSH = 0x4
2622 PR_SHADOW_STACK_WRITE = 0x2
25922623 PR_SME_GET_VL = 0x40
25932624 PR_SME_SET_VL = 0x3f
25942625 PR_SME_SET_VL_ONEXEC = 0x40000
@@ -2620,6 +2651,28 @@ const (
26202651 PR_UNALIGN_NOPRINT = 0x1
26212652 PR_UNALIGN_SIGBUS = 0x2
26222653 PSTOREFS_MAGIC = 0x6165676c
2654 PTP_CLK_MAGIC = '='
2655 PTP_ENABLE_FEATURE = 0x1
2656 PTP_EXTTS_EDGES = 0x6
2657 PTP_EXTTS_EVENT_VALID = 0x1
2658 PTP_EXTTS_V1_VALID_FLAGS = 0x7
2659 PTP_EXTTS_VALID_FLAGS = 0x1f
2660 PTP_EXT_OFFSET = 0x10
2661 PTP_FALLING_EDGE = 0x4
2662 PTP_MAX_SAMPLES = 0x19
2663 PTP_PEROUT_DUTY_CYCLE = 0x2
2664 PTP_PEROUT_ONE_SHOT = 0x1
2665 PTP_PEROUT_PHASE = 0x4
2666 PTP_PEROUT_V1_VALID_FLAGS = 0x0
2667 PTP_PEROUT_VALID_FLAGS = 0x7
2668 PTP_PIN_GETFUNC = 0xc0603d06
2669 PTP_PIN_GETFUNC2 = 0xc0603d0f
2670 PTP_RISING_EDGE = 0x2
2671 PTP_STRICT_FLAGS = 0x8
2672 PTP_SYS_OFFSET_EXTENDED = 0xc4c03d09
2673 PTP_SYS_OFFSET_EXTENDED2 = 0xc4c03d12
2674 PTP_SYS_OFFSET_PRECISE = 0xc0403d08
2675 PTP_SYS_OFFSET_PRECISE2 = 0xc0403d11
26232676 PTRACE_ATTACH = 0x10
26242677 PTRACE_CONT = 0x7
26252678 PTRACE_DETACH = 0x11
@@ -2876,7 +2929,6 @@ const (
28762929 RTM_NEWNEXTHOP = 0x68
28772930 RTM_NEWNEXTHOPBUCKET = 0x74
28782931 RTM_NEWNSID = 0x58
2879 RTM_NEWNVLAN = 0x70
28802932 RTM_NEWPREFIX = 0x34
28812933 RTM_NEWQDISC = 0x24
28822934 RTM_NEWROUTE = 0x18
@@ -2885,6 +2937,7 @@ const (
28852937 RTM_NEWTCLASS = 0x28
28862938 RTM_NEWTFILTER = 0x2c
28872939 RTM_NEWTUNNEL = 0x78
2940 RTM_NEWVLAN = 0x70
28882941 RTM_NR_FAMILIES = 0x1b
28892942 RTM_NR_MSGTYPES = 0x6c
28902943 RTM_SETDCB = 0x4f
@@ -2933,15 +2986,17 @@ const (
29332986 RUSAGE_SELF = 0x0
29342987 RUSAGE_THREAD = 0x1
29352988 RWF_APPEND = 0x10
2989 RWF_ATOMIC = 0x40
29362990 RWF_DSYNC = 0x2
29372991 RWF_HIPRI = 0x1
29382992 RWF_NOAPPEND = 0x20
29392993 RWF_NOWAIT = 0x8
2940 RWF_SUPPORTED = 0x3f
2994 RWF_SUPPORTED = 0x7f
29412995 RWF_SYNC = 0x4
29422996 RWF_WRITE_LIFE_NOT_SET = 0x0
29432997 SCHED_BATCH = 0x3
29442998 SCHED_DEADLINE = 0x6
2999 SCHED_EXT = 0x7
29453000 SCHED_FIFO = 0x1
29463001 SCHED_FLAG_ALL = 0x7f
29473002 SCHED_FLAG_DL_OVERRUN = 0x4
@@ -3210,6 +3265,7 @@ const (
32103265 STATX_ATTR_MOUNT_ROOT = 0x2000
32113266 STATX_ATTR_NODUMP = 0x40
32123267 STATX_ATTR_VERITY = 0x100000
3268 STATX_ATTR_WRITE_ATOMIC = 0x400000
32133269 STATX_BASIC_STATS = 0x7ff
32143270 STATX_BLOCKS = 0x400
32153271 STATX_BTIME = 0x800
@@ -3226,6 +3282,7 @@ const (
32263282 STATX_SUBVOL = 0x8000
32273283 STATX_TYPE = 0x1
32283284 STATX_UID = 0x8
3285 STATX_WRITE_ATOMIC = 0x10000
32293286 STATX__RESERVED = 0x80000000
32303287 SYNC_FILE_RANGE_WAIT_AFTER = 0x4
32313288 SYNC_FILE_RANGE_WAIT_BEFORE = 0x1
@@ -3624,6 +3681,7 @@ const (
36243681 XDP_UMEM_PGOFF_COMPLETION_RING = 0x180000000
36253682 XDP_UMEM_PGOFF_FILL_RING = 0x100000000
36263683 XDP_UMEM_REG = 0x4
3684 XDP_UMEM_TX_METADATA_LEN = 0x4
36273685 XDP_UMEM_TX_SW_CSUM = 0x2
36283686 XDP_UMEM_UNALIGNED_CHUNK_FLAG = 0x1
36293687 XDP_USE_NEED_WAKEUP = 0x8
vendor/golang.org/x/sys/unix/zerrors_linux_386.go +28
@@ -109,12 +109,15 @@ const (
109109 HIDIOCGRAWINFO = 0x80084803
110110 HIDIOCGRDESC = 0x90044802
111111 HIDIOCGRDESCSIZE = 0x80044801
112 HIDIOCREVOKE = 0x4004480d
112113 HUPCL = 0x400
113114 ICANON = 0x2
114115 IEXTEN = 0x8000
115116 IN_CLOEXEC = 0x80000
116117 IN_NONBLOCK = 0x800
117118 IOCTL_VM_SOCKETS_GET_LOCAL_CID = 0x7b9
119 IPV6_FLOWINFO_MASK = 0xffffff0f
120 IPV6_FLOWLABEL_MASK = 0xffff0f00
118121 ISIG = 0x1
119122 IUCLC = 0x200
120123 IXOFF = 0x1000
@@ -153,9 +156,14 @@ const (
153156 NFDBITS = 0x20
154157 NLDLY = 0x100
155158 NOFLSH = 0x80
159 NS_GET_MNTNS_ID = 0x8008b705
156160 NS_GET_NSTYPE = 0xb703
157161 NS_GET_OWNER_UID = 0xb704
158162 NS_GET_PARENT = 0xb702
163 NS_GET_PID_FROM_PIDNS = 0x8004b706
164 NS_GET_PID_IN_PIDNS = 0x8004b708
165 NS_GET_TGID_FROM_PIDNS = 0x8004b707
166 NS_GET_TGID_IN_PIDNS = 0x8004b709
159167 NS_GET_USERNS = 0xb701
160168 OLCUC = 0x2
161169 ONLCR = 0x4
@@ -232,6 +240,20 @@ const (
232240 PPPIOCUNBRIDGECHAN = 0x7434
233241 PPPIOCXFERUNIT = 0x744e
234242 PR_SET_PTRACER_ANY = 0xffffffff
243 PTP_CLOCK_GETCAPS = 0x80503d01
244 PTP_CLOCK_GETCAPS2 = 0x80503d0a
245 PTP_ENABLE_PPS = 0x40043d04
246 PTP_ENABLE_PPS2 = 0x40043d0d
247 PTP_EXTTS_REQUEST = 0x40103d02
248 PTP_EXTTS_REQUEST2 = 0x40103d0b
249 PTP_MASK_CLEAR_ALL = 0x3d13
250 PTP_MASK_EN_SINGLE = 0x40043d14
251 PTP_PEROUT_REQUEST = 0x40383d03
252 PTP_PEROUT_REQUEST2 = 0x40383d0c
253 PTP_PIN_SETFUNC = 0x40603d07
254 PTP_PIN_SETFUNC2 = 0x40603d10
255 PTP_SYS_OFFSET = 0x43403d05
256 PTP_SYS_OFFSET2 = 0x43403d0e
235257 PTRACE_GETFPREGS = 0xe
236258 PTRACE_GETFPXREGS = 0x12
237259 PTRACE_GET_THREAD_AREA = 0x19
@@ -278,10 +300,13 @@ const (
278300 RTC_WIE_ON = 0x700f
279301 RTC_WKALM_RD = 0x80287010
280302 RTC_WKALM_SET = 0x4028700f
303 SCM_DEVMEM_DMABUF = 0x4f
304 SCM_DEVMEM_LINEAR = 0x4e
281305 SCM_TIMESTAMPING = 0x25
282306 SCM_TIMESTAMPING_OPT_STATS = 0x36
283307 SCM_TIMESTAMPING_PKTINFO = 0x3a
284308 SCM_TIMESTAMPNS = 0x23
309 SCM_TS_OPT_ID = 0x51
285310 SCM_TXTIME = 0x3d
286311 SCM_WIFI_STATUS = 0x29
287312 SECCOMP_IOCTL_NOTIF_ADDFD = 0x40182103
@@ -316,6 +341,9 @@ const (
316341 SO_CNX_ADVICE = 0x35
317342 SO_COOKIE = 0x39
318343 SO_DETACH_REUSEPORT_BPF = 0x44
344 SO_DEVMEM_DMABUF = 0x4f
345 SO_DEVMEM_DONTNEED = 0x50
346 SO_DEVMEM_LINEAR = 0x4e
319347 SO_DOMAIN = 0x27
320348 SO_DONTROUTE = 0x5
321349 SO_ERROR = 0x4
vendor/golang.org/x/sys/unix/zerrors_linux_amd64.go +28
@@ -109,12 +109,15 @@ const (
109109 HIDIOCGRAWINFO = 0x80084803
110110 HIDIOCGRDESC = 0x90044802
111111 HIDIOCGRDESCSIZE = 0x80044801
112 HIDIOCREVOKE = 0x4004480d
112113 HUPCL = 0x400
113114 ICANON = 0x2
114115 IEXTEN = 0x8000
115116 IN_CLOEXEC = 0x80000
116117 IN_NONBLOCK = 0x800
117118 IOCTL_VM_SOCKETS_GET_LOCAL_CID = 0x7b9
119 IPV6_FLOWINFO_MASK = 0xffffff0f
120 IPV6_FLOWLABEL_MASK = 0xffff0f00
118121 ISIG = 0x1
119122 IUCLC = 0x200
120123 IXOFF = 0x1000
@@ -153,9 +156,14 @@ const (
153156 NFDBITS = 0x40
154157 NLDLY = 0x100
155158 NOFLSH = 0x80
159 NS_GET_MNTNS_ID = 0x8008b705
156160 NS_GET_NSTYPE = 0xb703
157161 NS_GET_OWNER_UID = 0xb704
158162 NS_GET_PARENT = 0xb702
163 NS_GET_PID_FROM_PIDNS = 0x8004b706
164 NS_GET_PID_IN_PIDNS = 0x8004b708
165 NS_GET_TGID_FROM_PIDNS = 0x8004b707
166 NS_GET_TGID_IN_PIDNS = 0x8004b709
159167 NS_GET_USERNS = 0xb701
160168 OLCUC = 0x2
161169 ONLCR = 0x4
@@ -232,6 +240,20 @@ const (
232240 PPPIOCUNBRIDGECHAN = 0x7434
233241 PPPIOCXFERUNIT = 0x744e
234242 PR_SET_PTRACER_ANY = 0xffffffffffffffff
243 PTP_CLOCK_GETCAPS = 0x80503d01
244 PTP_CLOCK_GETCAPS2 = 0x80503d0a
245 PTP_ENABLE_PPS = 0x40043d04
246 PTP_ENABLE_PPS2 = 0x40043d0d
247 PTP_EXTTS_REQUEST = 0x40103d02
248 PTP_EXTTS_REQUEST2 = 0x40103d0b
249 PTP_MASK_CLEAR_ALL = 0x3d13
250 PTP_MASK_EN_SINGLE = 0x40043d14
251 PTP_PEROUT_REQUEST = 0x40383d03
252 PTP_PEROUT_REQUEST2 = 0x40383d0c
253 PTP_PIN_SETFUNC = 0x40603d07
254 PTP_PIN_SETFUNC2 = 0x40603d10
255 PTP_SYS_OFFSET = 0x43403d05
256 PTP_SYS_OFFSET2 = 0x43403d0e
235257 PTRACE_ARCH_PRCTL = 0x1e
236258 PTRACE_GETFPREGS = 0xe
237259 PTRACE_GETFPXREGS = 0x12
@@ -279,10 +301,13 @@ const (
279301 RTC_WIE_ON = 0x700f
280302 RTC_WKALM_RD = 0x80287010
281303 RTC_WKALM_SET = 0x4028700f
304 SCM_DEVMEM_DMABUF = 0x4f
305 SCM_DEVMEM_LINEAR = 0x4e
282306 SCM_TIMESTAMPING = 0x25
283307 SCM_TIMESTAMPING_OPT_STATS = 0x36
284308 SCM_TIMESTAMPING_PKTINFO = 0x3a
285309 SCM_TIMESTAMPNS = 0x23
310 SCM_TS_OPT_ID = 0x51
286311 SCM_TXTIME = 0x3d
287312 SCM_WIFI_STATUS = 0x29
288313 SECCOMP_IOCTL_NOTIF_ADDFD = 0x40182103
@@ -317,6 +342,9 @@ const (
317342 SO_CNX_ADVICE = 0x35
318343 SO_COOKIE = 0x39
319344 SO_DETACH_REUSEPORT_BPF = 0x44
345 SO_DEVMEM_DMABUF = 0x4f
346 SO_DEVMEM_DONTNEED = 0x50
347 SO_DEVMEM_LINEAR = 0x4e
320348 SO_DOMAIN = 0x27
321349 SO_DONTROUTE = 0x5
322350 SO_ERROR = 0x4
vendor/golang.org/x/sys/unix/zerrors_linux_arm.go +28
@@ -108,12 +108,15 @@ const (
108108 HIDIOCGRAWINFO = 0x80084803
109109 HIDIOCGRDESC = 0x90044802
110110 HIDIOCGRDESCSIZE = 0x80044801
111 HIDIOCREVOKE = 0x4004480d
111112 HUPCL = 0x400
112113 ICANON = 0x2
113114 IEXTEN = 0x8000
114115 IN_CLOEXEC = 0x80000
115116 IN_NONBLOCK = 0x800
116117 IOCTL_VM_SOCKETS_GET_LOCAL_CID = 0x7b9
118 IPV6_FLOWINFO_MASK = 0xffffff0f
119 IPV6_FLOWLABEL_MASK = 0xffff0f00
117120 ISIG = 0x1
118121 IUCLC = 0x200
119122 IXOFF = 0x1000
@@ -150,9 +153,14 @@ const (
150153 NFDBITS = 0x20
151154 NLDLY = 0x100
152155 NOFLSH = 0x80
156 NS_GET_MNTNS_ID = 0x8008b705
153157 NS_GET_NSTYPE = 0xb703
154158 NS_GET_OWNER_UID = 0xb704
155159 NS_GET_PARENT = 0xb702
160 NS_GET_PID_FROM_PIDNS = 0x8004b706
161 NS_GET_PID_IN_PIDNS = 0x8004b708
162 NS_GET_TGID_FROM_PIDNS = 0x8004b707
163 NS_GET_TGID_IN_PIDNS = 0x8004b709
156164 NS_GET_USERNS = 0xb701
157165 OLCUC = 0x2
158166 ONLCR = 0x4
@@ -229,6 +237,20 @@ const (
229237 PPPIOCUNBRIDGECHAN = 0x7434
230238 PPPIOCXFERUNIT = 0x744e
231239 PR_SET_PTRACER_ANY = 0xffffffff
240 PTP_CLOCK_GETCAPS = 0x80503d01
241 PTP_CLOCK_GETCAPS2 = 0x80503d0a
242 PTP_ENABLE_PPS = 0x40043d04
243 PTP_ENABLE_PPS2 = 0x40043d0d
244 PTP_EXTTS_REQUEST = 0x40103d02
245 PTP_EXTTS_REQUEST2 = 0x40103d0b
246 PTP_MASK_CLEAR_ALL = 0x3d13
247 PTP_MASK_EN_SINGLE = 0x40043d14
248 PTP_PEROUT_REQUEST = 0x40383d03
249 PTP_PEROUT_REQUEST2 = 0x40383d0c
250 PTP_PIN_SETFUNC = 0x40603d07
251 PTP_PIN_SETFUNC2 = 0x40603d10
252 PTP_SYS_OFFSET = 0x43403d05
253 PTP_SYS_OFFSET2 = 0x43403d0e
232254 PTRACE_GETCRUNCHREGS = 0x19
233255 PTRACE_GETFDPIC = 0x1f
234256 PTRACE_GETFDPIC_EXEC = 0x0
@@ -284,10 +306,13 @@ const (
284306 RTC_WIE_ON = 0x700f
285307 RTC_WKALM_RD = 0x80287010
286308 RTC_WKALM_SET = 0x4028700f
309 SCM_DEVMEM_DMABUF = 0x4f
310 SCM_DEVMEM_LINEAR = 0x4e
287311 SCM_TIMESTAMPING = 0x25
288312 SCM_TIMESTAMPING_OPT_STATS = 0x36
289313 SCM_TIMESTAMPING_PKTINFO = 0x3a
290314 SCM_TIMESTAMPNS = 0x23
315 SCM_TS_OPT_ID = 0x51
291316 SCM_TXTIME = 0x3d
292317 SCM_WIFI_STATUS = 0x29
293318 SECCOMP_IOCTL_NOTIF_ADDFD = 0x40182103
@@ -322,6 +347,9 @@ const (
322347 SO_CNX_ADVICE = 0x35
323348 SO_COOKIE = 0x39
324349 SO_DETACH_REUSEPORT_BPF = 0x44
350 SO_DEVMEM_DMABUF = 0x4f
351 SO_DEVMEM_DONTNEED = 0x50
352 SO_DEVMEM_LINEAR = 0x4e
325353 SO_DOMAIN = 0x27
326354 SO_DONTROUTE = 0x5
327355 SO_ERROR = 0x4
vendor/golang.org/x/sys/unix/zerrors_linux_arm64.go +30
@@ -109,15 +109,19 @@ const (
109109 F_SETOWN = 0x8
110110 F_UNLCK = 0x2
111111 F_WRLCK = 0x1
112 GCS_MAGIC = 0x47435300
112113 HIDIOCGRAWINFO = 0x80084803
113114 HIDIOCGRDESC = 0x90044802
114115 HIDIOCGRDESCSIZE = 0x80044801
116 HIDIOCREVOKE = 0x4004480d
115117 HUPCL = 0x400
116118 ICANON = 0x2
117119 IEXTEN = 0x8000
118120 IN_CLOEXEC = 0x80000
119121 IN_NONBLOCK = 0x800
120122 IOCTL_VM_SOCKETS_GET_LOCAL_CID = 0x7b9
123 IPV6_FLOWINFO_MASK = 0xffffff0f
124 IPV6_FLOWLABEL_MASK = 0xffff0f00
121125 ISIG = 0x1
122126 IUCLC = 0x200
123127 IXOFF = 0x1000
@@ -154,9 +158,14 @@ const (
154158 NFDBITS = 0x40
155159 NLDLY = 0x100
156160 NOFLSH = 0x80
161 NS_GET_MNTNS_ID = 0x8008b705
157162 NS_GET_NSTYPE = 0xb703
158163 NS_GET_OWNER_UID = 0xb704
159164 NS_GET_PARENT = 0xb702
165 NS_GET_PID_FROM_PIDNS = 0x8004b706
166 NS_GET_PID_IN_PIDNS = 0x8004b708
167 NS_GET_TGID_FROM_PIDNS = 0x8004b707
168 NS_GET_TGID_IN_PIDNS = 0x8004b709
160169 NS_GET_USERNS = 0xb701
161170 OLCUC = 0x2
162171 ONLCR = 0x4
@@ -200,6 +209,7 @@ const (
200209 PERF_EVENT_IOC_SET_BPF = 0x40042408
201210 PERF_EVENT_IOC_SET_FILTER = 0x40082406
202211 PERF_EVENT_IOC_SET_OUTPUT = 0x2405
212 POE_MAGIC = 0x504f4530
203213 PPPIOCATTACH = 0x4004743d
204214 PPPIOCATTCHAN = 0x40047438
205215 PPPIOCBRIDGECHAN = 0x40047435
@@ -235,6 +245,20 @@ const (
235245 PROT_BTI = 0x10
236246 PROT_MTE = 0x20
237247 PR_SET_PTRACER_ANY = 0xffffffffffffffff
248 PTP_CLOCK_GETCAPS = 0x80503d01
249 PTP_CLOCK_GETCAPS2 = 0x80503d0a
250 PTP_ENABLE_PPS = 0x40043d04
251 PTP_ENABLE_PPS2 = 0x40043d0d
252 PTP_EXTTS_REQUEST = 0x40103d02
253 PTP_EXTTS_REQUEST2 = 0x40103d0b
254 PTP_MASK_CLEAR_ALL = 0x3d13
255 PTP_MASK_EN_SINGLE = 0x40043d14
256 PTP_PEROUT_REQUEST = 0x40383d03
257 PTP_PEROUT_REQUEST2 = 0x40383d0c
258 PTP_PIN_SETFUNC = 0x40603d07
259 PTP_PIN_SETFUNC2 = 0x40603d10
260 PTP_SYS_OFFSET = 0x43403d05
261 PTP_SYS_OFFSET2 = 0x43403d0e
238262 PTRACE_PEEKMTETAGS = 0x21
239263 PTRACE_POKEMTETAGS = 0x22
240264 PTRACE_SYSEMU = 0x1f
@@ -275,10 +299,13 @@ const (
275299 RTC_WIE_ON = 0x700f
276300 RTC_WKALM_RD = 0x80287010
277301 RTC_WKALM_SET = 0x4028700f
302 SCM_DEVMEM_DMABUF = 0x4f
303 SCM_DEVMEM_LINEAR = 0x4e
278304 SCM_TIMESTAMPING = 0x25
279305 SCM_TIMESTAMPING_OPT_STATS = 0x36
280306 SCM_TIMESTAMPING_PKTINFO = 0x3a
281307 SCM_TIMESTAMPNS = 0x23
308 SCM_TS_OPT_ID = 0x51
282309 SCM_TXTIME = 0x3d
283310 SCM_WIFI_STATUS = 0x29
284311 SECCOMP_IOCTL_NOTIF_ADDFD = 0x40182103
@@ -313,6 +340,9 @@ const (
313340 SO_CNX_ADVICE = 0x35
314341 SO_COOKIE = 0x39
315342 SO_DETACH_REUSEPORT_BPF = 0x44
343 SO_DEVMEM_DMABUF = 0x4f
344 SO_DEVMEM_DONTNEED = 0x50
345 SO_DEVMEM_LINEAR = 0x4e
316346 SO_DOMAIN = 0x27
317347 SO_DONTROUTE = 0x5
318348 SO_ERROR = 0x4
vendor/golang.org/x/sys/unix/zerrors_linux_loong64.go +28
@@ -109,12 +109,15 @@ const (
109109 HIDIOCGRAWINFO = 0x80084803
110110 HIDIOCGRDESC = 0x90044802
111111 HIDIOCGRDESCSIZE = 0x80044801
112 HIDIOCREVOKE = 0x4004480d
112113 HUPCL = 0x400
113114 ICANON = 0x2
114115 IEXTEN = 0x8000
115116 IN_CLOEXEC = 0x80000
116117 IN_NONBLOCK = 0x800
117118 IOCTL_VM_SOCKETS_GET_LOCAL_CID = 0x7b9
119 IPV6_FLOWINFO_MASK = 0xffffff0f
120 IPV6_FLOWLABEL_MASK = 0xffff0f00
118121 ISIG = 0x1
119122 IUCLC = 0x200
120123 IXOFF = 0x1000
@@ -154,9 +157,14 @@ const (
154157 NFDBITS = 0x40
155158 NLDLY = 0x100
156159 NOFLSH = 0x80
160 NS_GET_MNTNS_ID = 0x8008b705
157161 NS_GET_NSTYPE = 0xb703
158162 NS_GET_OWNER_UID = 0xb704
159163 NS_GET_PARENT = 0xb702
164 NS_GET_PID_FROM_PIDNS = 0x8004b706
165 NS_GET_PID_IN_PIDNS = 0x8004b708
166 NS_GET_TGID_FROM_PIDNS = 0x8004b707
167 NS_GET_TGID_IN_PIDNS = 0x8004b709
160168 NS_GET_USERNS = 0xb701
161169 OLCUC = 0x2
162170 ONLCR = 0x4
@@ -233,6 +241,20 @@ const (
233241 PPPIOCUNBRIDGECHAN = 0x7434
234242 PPPIOCXFERUNIT = 0x744e
235243 PR_SET_PTRACER_ANY = 0xffffffffffffffff
244 PTP_CLOCK_GETCAPS = 0x80503d01
245 PTP_CLOCK_GETCAPS2 = 0x80503d0a
246 PTP_ENABLE_PPS = 0x40043d04
247 PTP_ENABLE_PPS2 = 0x40043d0d
248 PTP_EXTTS_REQUEST = 0x40103d02
249 PTP_EXTTS_REQUEST2 = 0x40103d0b
250 PTP_MASK_CLEAR_ALL = 0x3d13
251 PTP_MASK_EN_SINGLE = 0x40043d14
252 PTP_PEROUT_REQUEST = 0x40383d03
253 PTP_PEROUT_REQUEST2 = 0x40383d0c
254 PTP_PIN_SETFUNC = 0x40603d07
255 PTP_PIN_SETFUNC2 = 0x40603d10
256 PTP_SYS_OFFSET = 0x43403d05
257 PTP_SYS_OFFSET2 = 0x43403d0e
236258 PTRACE_SYSEMU = 0x1f
237259 PTRACE_SYSEMU_SINGLESTEP = 0x20
238260 RLIMIT_AS = 0x9
@@ -271,10 +293,13 @@ const (
271293 RTC_WIE_ON = 0x700f
272294 RTC_WKALM_RD = 0x80287010
273295 RTC_WKALM_SET = 0x4028700f
296 SCM_DEVMEM_DMABUF = 0x4f
297 SCM_DEVMEM_LINEAR = 0x4e
274298 SCM_TIMESTAMPING = 0x25
275299 SCM_TIMESTAMPING_OPT_STATS = 0x36
276300 SCM_TIMESTAMPING_PKTINFO = 0x3a
277301 SCM_TIMESTAMPNS = 0x23
302 SCM_TS_OPT_ID = 0x51
278303 SCM_TXTIME = 0x3d
279304 SCM_WIFI_STATUS = 0x29
280305 SECCOMP_IOCTL_NOTIF_ADDFD = 0x40182103
@@ -309,6 +334,9 @@ const (
309334 SO_CNX_ADVICE = 0x35
310335 SO_COOKIE = 0x39
311336 SO_DETACH_REUSEPORT_BPF = 0x44
337 SO_DEVMEM_DMABUF = 0x4f
338 SO_DEVMEM_DONTNEED = 0x50
339 SO_DEVMEM_LINEAR = 0x4e
312340 SO_DOMAIN = 0x27
313341 SO_DONTROUTE = 0x5
314342 SO_ERROR = 0x4
vendor/golang.org/x/sys/unix/zerrors_linux_mips.go +28
@@ -108,12 +108,15 @@ const (
108108 HIDIOCGRAWINFO = 0x40084803
109109 HIDIOCGRDESC = 0x50044802
110110 HIDIOCGRDESCSIZE = 0x40044801
111 HIDIOCREVOKE = 0x8004480d
111112 HUPCL = 0x400
112113 ICANON = 0x2
113114 IEXTEN = 0x100
114115 IN_CLOEXEC = 0x80000
115116 IN_NONBLOCK = 0x80
116117 IOCTL_VM_SOCKETS_GET_LOCAL_CID = 0x200007b9
118 IPV6_FLOWINFO_MASK = 0xfffffff
119 IPV6_FLOWLABEL_MASK = 0xfffff
117120 ISIG = 0x1
118121 IUCLC = 0x200
119122 IXOFF = 0x1000
@@ -150,9 +153,14 @@ const (
150153 NFDBITS = 0x20
151154 NLDLY = 0x100
152155 NOFLSH = 0x80
156 NS_GET_MNTNS_ID = 0x4008b705
153157 NS_GET_NSTYPE = 0x2000b703
154158 NS_GET_OWNER_UID = 0x2000b704
155159 NS_GET_PARENT = 0x2000b702
160 NS_GET_PID_FROM_PIDNS = 0x4004b706
161 NS_GET_PID_IN_PIDNS = 0x4004b708
162 NS_GET_TGID_FROM_PIDNS = 0x4004b707
163 NS_GET_TGID_IN_PIDNS = 0x4004b709
156164 NS_GET_USERNS = 0x2000b701
157165 OLCUC = 0x2
158166 ONLCR = 0x4
@@ -229,6 +237,20 @@ const (
229237 PPPIOCUNBRIDGECHAN = 0x20007434
230238 PPPIOCXFERUNIT = 0x2000744e
231239 PR_SET_PTRACER_ANY = 0xffffffff
240 PTP_CLOCK_GETCAPS = 0x40503d01
241 PTP_CLOCK_GETCAPS2 = 0x40503d0a
242 PTP_ENABLE_PPS = 0x80043d04
243 PTP_ENABLE_PPS2 = 0x80043d0d
244 PTP_EXTTS_REQUEST = 0x80103d02
245 PTP_EXTTS_REQUEST2 = 0x80103d0b
246 PTP_MASK_CLEAR_ALL = 0x20003d13
247 PTP_MASK_EN_SINGLE = 0x80043d14
248 PTP_PEROUT_REQUEST = 0x80383d03
249 PTP_PEROUT_REQUEST2 = 0x80383d0c
250 PTP_PIN_SETFUNC = 0x80603d07
251 PTP_PIN_SETFUNC2 = 0x80603d10
252 PTP_SYS_OFFSET = 0x83403d05
253 PTP_SYS_OFFSET2 = 0x83403d0e
232254 PTRACE_GETFPREGS = 0xe
233255 PTRACE_GET_THREAD_AREA = 0x19
234256 PTRACE_GET_THREAD_AREA_3264 = 0xc4
@@ -277,10 +299,13 @@ const (
277299 RTC_WIE_ON = 0x2000700f
278300 RTC_WKALM_RD = 0x40287010
279301 RTC_WKALM_SET = 0x8028700f
302 SCM_DEVMEM_DMABUF = 0x4f
303 SCM_DEVMEM_LINEAR = 0x4e
280304 SCM_TIMESTAMPING = 0x25
281305 SCM_TIMESTAMPING_OPT_STATS = 0x36
282306 SCM_TIMESTAMPING_PKTINFO = 0x3a
283307 SCM_TIMESTAMPNS = 0x23
308 SCM_TS_OPT_ID = 0x51
284309 SCM_TXTIME = 0x3d
285310 SCM_WIFI_STATUS = 0x29
286311 SECCOMP_IOCTL_NOTIF_ADDFD = 0x80182103
@@ -315,6 +340,9 @@ const (
315340 SO_CNX_ADVICE = 0x35
316341 SO_COOKIE = 0x39
317342 SO_DETACH_REUSEPORT_BPF = 0x44
343 SO_DEVMEM_DMABUF = 0x4f
344 SO_DEVMEM_DONTNEED = 0x50
345 SO_DEVMEM_LINEAR = 0x4e
318346 SO_DOMAIN = 0x1029
319347 SO_DONTROUTE = 0x10
320348 SO_ERROR = 0x1007
vendor/golang.org/x/sys/unix/zerrors_linux_mips64.go +28
@@ -108,12 +108,15 @@ const (
108108 HIDIOCGRAWINFO = 0x40084803
109109 HIDIOCGRDESC = 0x50044802
110110 HIDIOCGRDESCSIZE = 0x40044801
111 HIDIOCREVOKE = 0x8004480d
111112 HUPCL = 0x400
112113 ICANON = 0x2
113114 IEXTEN = 0x100
114115 IN_CLOEXEC = 0x80000
115116 IN_NONBLOCK = 0x80
116117 IOCTL_VM_SOCKETS_GET_LOCAL_CID = 0x200007b9
118 IPV6_FLOWINFO_MASK = 0xfffffff
119 IPV6_FLOWLABEL_MASK = 0xfffff
117120 ISIG = 0x1
118121 IUCLC = 0x200
119122 IXOFF = 0x1000
@@ -150,9 +153,14 @@ const (
150153 NFDBITS = 0x40
151154 NLDLY = 0x100
152155 NOFLSH = 0x80
156 NS_GET_MNTNS_ID = 0x4008b705
153157 NS_GET_NSTYPE = 0x2000b703
154158 NS_GET_OWNER_UID = 0x2000b704
155159 NS_GET_PARENT = 0x2000b702
160 NS_GET_PID_FROM_PIDNS = 0x4004b706
161 NS_GET_PID_IN_PIDNS = 0x4004b708
162 NS_GET_TGID_FROM_PIDNS = 0x4004b707
163 NS_GET_TGID_IN_PIDNS = 0x4004b709
156164 NS_GET_USERNS = 0x2000b701
157165 OLCUC = 0x2
158166 ONLCR = 0x4
@@ -229,6 +237,20 @@ const (
229237 PPPIOCUNBRIDGECHAN = 0x20007434
230238 PPPIOCXFERUNIT = 0x2000744e
231239 PR_SET_PTRACER_ANY = 0xffffffffffffffff
240 PTP_CLOCK_GETCAPS = 0x40503d01
241 PTP_CLOCK_GETCAPS2 = 0x40503d0a
242 PTP_ENABLE_PPS = 0x80043d04
243 PTP_ENABLE_PPS2 = 0x80043d0d
244 PTP_EXTTS_REQUEST = 0x80103d02
245 PTP_EXTTS_REQUEST2 = 0x80103d0b
246 PTP_MASK_CLEAR_ALL = 0x20003d13
247 PTP_MASK_EN_SINGLE = 0x80043d14
248 PTP_PEROUT_REQUEST = 0x80383d03
249 PTP_PEROUT_REQUEST2 = 0x80383d0c
250 PTP_PIN_SETFUNC = 0x80603d07
251 PTP_PIN_SETFUNC2 = 0x80603d10
252 PTP_SYS_OFFSET = 0x83403d05
253 PTP_SYS_OFFSET2 = 0x83403d0e
232254 PTRACE_GETFPREGS = 0xe
233255 PTRACE_GET_THREAD_AREA = 0x19
234256 PTRACE_GET_THREAD_AREA_3264 = 0xc4
@@ -277,10 +299,13 @@ const (
277299 RTC_WIE_ON = 0x2000700f
278300 RTC_WKALM_RD = 0x40287010
279301 RTC_WKALM_SET = 0x8028700f
302 SCM_DEVMEM_DMABUF = 0x4f
303 SCM_DEVMEM_LINEAR = 0x4e
280304 SCM_TIMESTAMPING = 0x25
281305 SCM_TIMESTAMPING_OPT_STATS = 0x36
282306 SCM_TIMESTAMPING_PKTINFO = 0x3a
283307 SCM_TIMESTAMPNS = 0x23
308 SCM_TS_OPT_ID = 0x51
284309 SCM_TXTIME = 0x3d
285310 SCM_WIFI_STATUS = 0x29
286311 SECCOMP_IOCTL_NOTIF_ADDFD = 0x80182103
@@ -315,6 +340,9 @@ const (
315340 SO_CNX_ADVICE = 0x35
316341 SO_COOKIE = 0x39
317342 SO_DETACH_REUSEPORT_BPF = 0x44
343 SO_DEVMEM_DMABUF = 0x4f
344 SO_DEVMEM_DONTNEED = 0x50
345 SO_DEVMEM_LINEAR = 0x4e
318346 SO_DOMAIN = 0x1029
319347 SO_DONTROUTE = 0x10
320348 SO_ERROR = 0x1007
vendor/golang.org/x/sys/unix/zerrors_linux_mips64le.go +28
@@ -108,12 +108,15 @@ const (
108108 HIDIOCGRAWINFO = 0x40084803
109109 HIDIOCGRDESC = 0x50044802
110110 HIDIOCGRDESCSIZE = 0x40044801
111 HIDIOCREVOKE = 0x8004480d
111112 HUPCL = 0x400
112113 ICANON = 0x2
113114 IEXTEN = 0x100
114115 IN_CLOEXEC = 0x80000
115116 IN_NONBLOCK = 0x80
116117 IOCTL_VM_SOCKETS_GET_LOCAL_CID = 0x200007b9
118 IPV6_FLOWINFO_MASK = 0xffffff0f
119 IPV6_FLOWLABEL_MASK = 0xffff0f00
117120 ISIG = 0x1
118121 IUCLC = 0x200
119122 IXOFF = 0x1000
@@ -150,9 +153,14 @@ const (
150153 NFDBITS = 0x40
151154 NLDLY = 0x100
152155 NOFLSH = 0x80
156 NS_GET_MNTNS_ID = 0x4008b705
153157 NS_GET_NSTYPE = 0x2000b703
154158 NS_GET_OWNER_UID = 0x2000b704
155159 NS_GET_PARENT = 0x2000b702
160 NS_GET_PID_FROM_PIDNS = 0x4004b706
161 NS_GET_PID_IN_PIDNS = 0x4004b708
162 NS_GET_TGID_FROM_PIDNS = 0x4004b707
163 NS_GET_TGID_IN_PIDNS = 0x4004b709
156164 NS_GET_USERNS = 0x2000b701
157165 OLCUC = 0x2
158166 ONLCR = 0x4
@@ -229,6 +237,20 @@ const (
229237 PPPIOCUNBRIDGECHAN = 0x20007434
230238 PPPIOCXFERUNIT = 0x2000744e
231239 PR_SET_PTRACER_ANY = 0xffffffffffffffff
240 PTP_CLOCK_GETCAPS = 0x40503d01
241 PTP_CLOCK_GETCAPS2 = 0x40503d0a
242 PTP_ENABLE_PPS = 0x80043d04
243 PTP_ENABLE_PPS2 = 0x80043d0d
244 PTP_EXTTS_REQUEST = 0x80103d02
245 PTP_EXTTS_REQUEST2 = 0x80103d0b
246 PTP_MASK_CLEAR_ALL = 0x20003d13
247 PTP_MASK_EN_SINGLE = 0x80043d14
248 PTP_PEROUT_REQUEST = 0x80383d03
249 PTP_PEROUT_REQUEST2 = 0x80383d0c
250 PTP_PIN_SETFUNC = 0x80603d07
251 PTP_PIN_SETFUNC2 = 0x80603d10
252 PTP_SYS_OFFSET = 0x83403d05
253 PTP_SYS_OFFSET2 = 0x83403d0e
232254 PTRACE_GETFPREGS = 0xe
233255 PTRACE_GET_THREAD_AREA = 0x19
234256 PTRACE_GET_THREAD_AREA_3264 = 0xc4
@@ -277,10 +299,13 @@ const (
277299 RTC_WIE_ON = 0x2000700f
278300 RTC_WKALM_RD = 0x40287010
279301 RTC_WKALM_SET = 0x8028700f
302 SCM_DEVMEM_DMABUF = 0x4f
303 SCM_DEVMEM_LINEAR = 0x4e
280304 SCM_TIMESTAMPING = 0x25
281305 SCM_TIMESTAMPING_OPT_STATS = 0x36
282306 SCM_TIMESTAMPING_PKTINFO = 0x3a
283307 SCM_TIMESTAMPNS = 0x23
308 SCM_TS_OPT_ID = 0x51
284309 SCM_TXTIME = 0x3d
285310 SCM_WIFI_STATUS = 0x29
286311 SECCOMP_IOCTL_NOTIF_ADDFD = 0x80182103
@@ -315,6 +340,9 @@ const (
315340 SO_CNX_ADVICE = 0x35
316341 SO_COOKIE = 0x39
317342 SO_DETACH_REUSEPORT_BPF = 0x44
343 SO_DEVMEM_DMABUF = 0x4f
344 SO_DEVMEM_DONTNEED = 0x50
345 SO_DEVMEM_LINEAR = 0x4e
318346 SO_DOMAIN = 0x1029
319347 SO_DONTROUTE = 0x10
320348 SO_ERROR = 0x1007
vendor/golang.org/x/sys/unix/zerrors_linux_mipsle.go +28
@@ -108,12 +108,15 @@ const (
108108 HIDIOCGRAWINFO = 0x40084803
109109 HIDIOCGRDESC = 0x50044802
110110 HIDIOCGRDESCSIZE = 0x40044801
111 HIDIOCREVOKE = 0x8004480d
111112 HUPCL = 0x400
112113 ICANON = 0x2
113114 IEXTEN = 0x100
114115 IN_CLOEXEC = 0x80000
115116 IN_NONBLOCK = 0x80
116117 IOCTL_VM_SOCKETS_GET_LOCAL_CID = 0x200007b9
118 IPV6_FLOWINFO_MASK = 0xffffff0f
119 IPV6_FLOWLABEL_MASK = 0xffff0f00
117120 ISIG = 0x1
118121 IUCLC = 0x200
119122 IXOFF = 0x1000
@@ -150,9 +153,14 @@ const (
150153 NFDBITS = 0x20
151154 NLDLY = 0x100
152155 NOFLSH = 0x80
156 NS_GET_MNTNS_ID = 0x4008b705
153157 NS_GET_NSTYPE = 0x2000b703
154158 NS_GET_OWNER_UID = 0x2000b704
155159 NS_GET_PARENT = 0x2000b702
160 NS_GET_PID_FROM_PIDNS = 0x4004b706
161 NS_GET_PID_IN_PIDNS = 0x4004b708
162 NS_GET_TGID_FROM_PIDNS = 0x4004b707
163 NS_GET_TGID_IN_PIDNS = 0x4004b709
156164 NS_GET_USERNS = 0x2000b701
157165 OLCUC = 0x2
158166 ONLCR = 0x4
@@ -229,6 +237,20 @@ const (
229237 PPPIOCUNBRIDGECHAN = 0x20007434
230238 PPPIOCXFERUNIT = 0x2000744e
231239 PR_SET_PTRACER_ANY = 0xffffffff
240 PTP_CLOCK_GETCAPS = 0x40503d01
241 PTP_CLOCK_GETCAPS2 = 0x40503d0a
242 PTP_ENABLE_PPS = 0x80043d04
243 PTP_ENABLE_PPS2 = 0x80043d0d
244 PTP_EXTTS_REQUEST = 0x80103d02
245 PTP_EXTTS_REQUEST2 = 0x80103d0b
246 PTP_MASK_CLEAR_ALL = 0x20003d13
247 PTP_MASK_EN_SINGLE = 0x80043d14
248 PTP_PEROUT_REQUEST = 0x80383d03
249 PTP_PEROUT_REQUEST2 = 0x80383d0c
250 PTP_PIN_SETFUNC = 0x80603d07
251 PTP_PIN_SETFUNC2 = 0x80603d10
252 PTP_SYS_OFFSET = 0x83403d05
253 PTP_SYS_OFFSET2 = 0x83403d0e
232254 PTRACE_GETFPREGS = 0xe
233255 PTRACE_GET_THREAD_AREA = 0x19
234256 PTRACE_GET_THREAD_AREA_3264 = 0xc4
@@ -277,10 +299,13 @@ const (
277299 RTC_WIE_ON = 0x2000700f
278300 RTC_WKALM_RD = 0x40287010
279301 RTC_WKALM_SET = 0x8028700f
302 SCM_DEVMEM_DMABUF = 0x4f
303 SCM_DEVMEM_LINEAR = 0x4e
280304 SCM_TIMESTAMPING = 0x25
281305 SCM_TIMESTAMPING_OPT_STATS = 0x36
282306 SCM_TIMESTAMPING_PKTINFO = 0x3a
283307 SCM_TIMESTAMPNS = 0x23
308 SCM_TS_OPT_ID = 0x51
284309 SCM_TXTIME = 0x3d
285310 SCM_WIFI_STATUS = 0x29
286311 SECCOMP_IOCTL_NOTIF_ADDFD = 0x80182103
@@ -315,6 +340,9 @@ const (
315340 SO_CNX_ADVICE = 0x35
316341 SO_COOKIE = 0x39
317342 SO_DETACH_REUSEPORT_BPF = 0x44
343 SO_DEVMEM_DMABUF = 0x4f
344 SO_DEVMEM_DONTNEED = 0x50
345 SO_DEVMEM_LINEAR = 0x4e
318346 SO_DOMAIN = 0x1029
319347 SO_DONTROUTE = 0x10
320348 SO_ERROR = 0x1007
vendor/golang.org/x/sys/unix/zerrors_linux_ppc.go +28
@@ -108,12 +108,15 @@ const (
108108 HIDIOCGRAWINFO = 0x40084803
109109 HIDIOCGRDESC = 0x50044802
110110 HIDIOCGRDESCSIZE = 0x40044801
111 HIDIOCREVOKE = 0x8004480d
111112 HUPCL = 0x4000
112113 ICANON = 0x100
113114 IEXTEN = 0x400
114115 IN_CLOEXEC = 0x80000
115116 IN_NONBLOCK = 0x800
116117 IOCTL_VM_SOCKETS_GET_LOCAL_CID = 0x200007b9
118 IPV6_FLOWINFO_MASK = 0xfffffff
119 IPV6_FLOWLABEL_MASK = 0xfffff
117120 ISIG = 0x80
118121 IUCLC = 0x1000
119122 IXOFF = 0x400
@@ -152,9 +155,14 @@ const (
152155 NL3 = 0x300
153156 NLDLY = 0x300
154157 NOFLSH = 0x80000000
158 NS_GET_MNTNS_ID = 0x4008b705
155159 NS_GET_NSTYPE = 0x2000b703
156160 NS_GET_OWNER_UID = 0x2000b704
157161 NS_GET_PARENT = 0x2000b702
162 NS_GET_PID_FROM_PIDNS = 0x4004b706
163 NS_GET_PID_IN_PIDNS = 0x4004b708
164 NS_GET_TGID_FROM_PIDNS = 0x4004b707
165 NS_GET_TGID_IN_PIDNS = 0x4004b709
158166 NS_GET_USERNS = 0x2000b701
159167 OLCUC = 0x4
160168 ONLCR = 0x2
@@ -232,6 +240,20 @@ const (
232240 PPPIOCXFERUNIT = 0x2000744e
233241 PROT_SAO = 0x10
234242 PR_SET_PTRACER_ANY = 0xffffffff
243 PTP_CLOCK_GETCAPS = 0x40503d01
244 PTP_CLOCK_GETCAPS2 = 0x40503d0a
245 PTP_ENABLE_PPS = 0x80043d04
246 PTP_ENABLE_PPS2 = 0x80043d0d
247 PTP_EXTTS_REQUEST = 0x80103d02
248 PTP_EXTTS_REQUEST2 = 0x80103d0b
249 PTP_MASK_CLEAR_ALL = 0x20003d13
250 PTP_MASK_EN_SINGLE = 0x80043d14
251 PTP_PEROUT_REQUEST = 0x80383d03
252 PTP_PEROUT_REQUEST2 = 0x80383d0c
253 PTP_PIN_SETFUNC = 0x80603d07
254 PTP_PIN_SETFUNC2 = 0x80603d10
255 PTP_SYS_OFFSET = 0x83403d05
256 PTP_SYS_OFFSET2 = 0x83403d0e
235257 PTRACE_GETEVRREGS = 0x14
236258 PTRACE_GETFPREGS = 0xe
237259 PTRACE_GETREGS64 = 0x16
@@ -332,10 +354,13 @@ const (
332354 RTC_WIE_ON = 0x2000700f
333355 RTC_WKALM_RD = 0x40287010
334356 RTC_WKALM_SET = 0x8028700f
357 SCM_DEVMEM_DMABUF = 0x4f
358 SCM_DEVMEM_LINEAR = 0x4e
335359 SCM_TIMESTAMPING = 0x25
336360 SCM_TIMESTAMPING_OPT_STATS = 0x36
337361 SCM_TIMESTAMPING_PKTINFO = 0x3a
338362 SCM_TIMESTAMPNS = 0x23
363 SCM_TS_OPT_ID = 0x51
339364 SCM_TXTIME = 0x3d
340365 SCM_WIFI_STATUS = 0x29
341366 SECCOMP_IOCTL_NOTIF_ADDFD = 0x80182103
@@ -370,6 +395,9 @@ const (
370395 SO_CNX_ADVICE = 0x35
371396 SO_COOKIE = 0x39
372397 SO_DETACH_REUSEPORT_BPF = 0x44
398 SO_DEVMEM_DMABUF = 0x4f
399 SO_DEVMEM_DONTNEED = 0x50
400 SO_DEVMEM_LINEAR = 0x4e
373401 SO_DOMAIN = 0x27
374402 SO_DONTROUTE = 0x5
375403 SO_ERROR = 0x4
vendor/golang.org/x/sys/unix/zerrors_linux_ppc64.go +28
@@ -108,12 +108,15 @@ const (
108108 HIDIOCGRAWINFO = 0x40084803
109109 HIDIOCGRDESC = 0x50044802
110110 HIDIOCGRDESCSIZE = 0x40044801
111 HIDIOCREVOKE = 0x8004480d
111112 HUPCL = 0x4000
112113 ICANON = 0x100
113114 IEXTEN = 0x400
114115 IN_CLOEXEC = 0x80000
115116 IN_NONBLOCK = 0x800
116117 IOCTL_VM_SOCKETS_GET_LOCAL_CID = 0x200007b9
118 IPV6_FLOWINFO_MASK = 0xfffffff
119 IPV6_FLOWLABEL_MASK = 0xfffff
117120 ISIG = 0x80
118121 IUCLC = 0x1000
119122 IXOFF = 0x400
@@ -152,9 +155,14 @@ const (
152155 NL3 = 0x300
153156 NLDLY = 0x300
154157 NOFLSH = 0x80000000
158 NS_GET_MNTNS_ID = 0x4008b705
155159 NS_GET_NSTYPE = 0x2000b703
156160 NS_GET_OWNER_UID = 0x2000b704
157161 NS_GET_PARENT = 0x2000b702
162 NS_GET_PID_FROM_PIDNS = 0x4004b706
163 NS_GET_PID_IN_PIDNS = 0x4004b708
164 NS_GET_TGID_FROM_PIDNS = 0x4004b707
165 NS_GET_TGID_IN_PIDNS = 0x4004b709
158166 NS_GET_USERNS = 0x2000b701
159167 OLCUC = 0x4
160168 ONLCR = 0x2
@@ -232,6 +240,20 @@ const (
232240 PPPIOCXFERUNIT = 0x2000744e
233241 PROT_SAO = 0x10
234242 PR_SET_PTRACER_ANY = 0xffffffffffffffff
243 PTP_CLOCK_GETCAPS = 0x40503d01
244 PTP_CLOCK_GETCAPS2 = 0x40503d0a
245 PTP_ENABLE_PPS = 0x80043d04
246 PTP_ENABLE_PPS2 = 0x80043d0d
247 PTP_EXTTS_REQUEST = 0x80103d02
248 PTP_EXTTS_REQUEST2 = 0x80103d0b
249 PTP_MASK_CLEAR_ALL = 0x20003d13
250 PTP_MASK_EN_SINGLE = 0x80043d14
251 PTP_PEROUT_REQUEST = 0x80383d03
252 PTP_PEROUT_REQUEST2 = 0x80383d0c
253 PTP_PIN_SETFUNC = 0x80603d07
254 PTP_PIN_SETFUNC2 = 0x80603d10
255 PTP_SYS_OFFSET = 0x83403d05
256 PTP_SYS_OFFSET2 = 0x83403d0e
235257 PTRACE_GETEVRREGS = 0x14
236258 PTRACE_GETFPREGS = 0xe
237259 PTRACE_GETREGS64 = 0x16
@@ -336,10 +358,13 @@ const (
336358 RTC_WIE_ON = 0x2000700f
337359 RTC_WKALM_RD = 0x40287010
338360 RTC_WKALM_SET = 0x8028700f
361 SCM_DEVMEM_DMABUF = 0x4f
362 SCM_DEVMEM_LINEAR = 0x4e
339363 SCM_TIMESTAMPING = 0x25
340364 SCM_TIMESTAMPING_OPT_STATS = 0x36
341365 SCM_TIMESTAMPING_PKTINFO = 0x3a
342366 SCM_TIMESTAMPNS = 0x23
367 SCM_TS_OPT_ID = 0x51
343368 SCM_TXTIME = 0x3d
344369 SCM_WIFI_STATUS = 0x29
345370 SECCOMP_IOCTL_NOTIF_ADDFD = 0x80182103
@@ -374,6 +399,9 @@ const (
374399 SO_CNX_ADVICE = 0x35
375400 SO_COOKIE = 0x39
376401 SO_DETACH_REUSEPORT_BPF = 0x44
402 SO_DEVMEM_DMABUF = 0x4f
403 SO_DEVMEM_DONTNEED = 0x50
404 SO_DEVMEM_LINEAR = 0x4e
377405 SO_DOMAIN = 0x27
378406 SO_DONTROUTE = 0x5
379407 SO_ERROR = 0x4
vendor/golang.org/x/sys/unix/zerrors_linux_ppc64le.go +28
@@ -108,12 +108,15 @@ const (
108108 HIDIOCGRAWINFO = 0x40084803
109109 HIDIOCGRDESC = 0x50044802
110110 HIDIOCGRDESCSIZE = 0x40044801
111 HIDIOCREVOKE = 0x8004480d
111112 HUPCL = 0x4000
112113 ICANON = 0x100
113114 IEXTEN = 0x400
114115 IN_CLOEXEC = 0x80000
115116 IN_NONBLOCK = 0x800
116117 IOCTL_VM_SOCKETS_GET_LOCAL_CID = 0x200007b9
118 IPV6_FLOWINFO_MASK = 0xffffff0f
119 IPV6_FLOWLABEL_MASK = 0xffff0f00
117120 ISIG = 0x80
118121 IUCLC = 0x1000
119122 IXOFF = 0x400
@@ -152,9 +155,14 @@ const (
152155 NL3 = 0x300
153156 NLDLY = 0x300
154157 NOFLSH = 0x80000000
158 NS_GET_MNTNS_ID = 0x4008b705
155159 NS_GET_NSTYPE = 0x2000b703
156160 NS_GET_OWNER_UID = 0x2000b704
157161 NS_GET_PARENT = 0x2000b702
162 NS_GET_PID_FROM_PIDNS = 0x4004b706
163 NS_GET_PID_IN_PIDNS = 0x4004b708
164 NS_GET_TGID_FROM_PIDNS = 0x4004b707
165 NS_GET_TGID_IN_PIDNS = 0x4004b709
158166 NS_GET_USERNS = 0x2000b701
159167 OLCUC = 0x4
160168 ONLCR = 0x2
@@ -232,6 +240,20 @@ const (
232240 PPPIOCXFERUNIT = 0x2000744e
233241 PROT_SAO = 0x10
234242 PR_SET_PTRACER_ANY = 0xffffffffffffffff
243 PTP_CLOCK_GETCAPS = 0x40503d01
244 PTP_CLOCK_GETCAPS2 = 0x40503d0a
245 PTP_ENABLE_PPS = 0x80043d04
246 PTP_ENABLE_PPS2 = 0x80043d0d
247 PTP_EXTTS_REQUEST = 0x80103d02
248 PTP_EXTTS_REQUEST2 = 0x80103d0b
249 PTP_MASK_CLEAR_ALL = 0x20003d13
250 PTP_MASK_EN_SINGLE = 0x80043d14
251 PTP_PEROUT_REQUEST = 0x80383d03
252 PTP_PEROUT_REQUEST2 = 0x80383d0c
253 PTP_PIN_SETFUNC = 0x80603d07
254 PTP_PIN_SETFUNC2 = 0x80603d10
255 PTP_SYS_OFFSET = 0x83403d05
256 PTP_SYS_OFFSET2 = 0x83403d0e
235257 PTRACE_GETEVRREGS = 0x14
236258 PTRACE_GETFPREGS = 0xe
237259 PTRACE_GETREGS64 = 0x16
@@ -336,10 +358,13 @@ const (
336358 RTC_WIE_ON = 0x2000700f
337359 RTC_WKALM_RD = 0x40287010
338360 RTC_WKALM_SET = 0x8028700f
361 SCM_DEVMEM_DMABUF = 0x4f
362 SCM_DEVMEM_LINEAR = 0x4e
339363 SCM_TIMESTAMPING = 0x25
340364 SCM_TIMESTAMPING_OPT_STATS = 0x36
341365 SCM_TIMESTAMPING_PKTINFO = 0x3a
342366 SCM_TIMESTAMPNS = 0x23
367 SCM_TS_OPT_ID = 0x51
343368 SCM_TXTIME = 0x3d
344369 SCM_WIFI_STATUS = 0x29
345370 SECCOMP_IOCTL_NOTIF_ADDFD = 0x80182103
@@ -374,6 +399,9 @@ const (
374399 SO_CNX_ADVICE = 0x35
375400 SO_COOKIE = 0x39
376401 SO_DETACH_REUSEPORT_BPF = 0x44
402 SO_DEVMEM_DMABUF = 0x4f
403 SO_DEVMEM_DONTNEED = 0x50
404 SO_DEVMEM_LINEAR = 0x4e
377405 SO_DOMAIN = 0x27
378406 SO_DONTROUTE = 0x5
379407 SO_ERROR = 0x4
vendor/golang.org/x/sys/unix/zerrors_linux_riscv64.go +28
@@ -108,12 +108,15 @@ const (
108108 HIDIOCGRAWINFO = 0x80084803
109109 HIDIOCGRDESC = 0x90044802
110110 HIDIOCGRDESCSIZE = 0x80044801
111 HIDIOCREVOKE = 0x4004480d
111112 HUPCL = 0x400
112113 ICANON = 0x2
113114 IEXTEN = 0x8000
114115 IN_CLOEXEC = 0x80000
115116 IN_NONBLOCK = 0x800
116117 IOCTL_VM_SOCKETS_GET_LOCAL_CID = 0x7b9
118 IPV6_FLOWINFO_MASK = 0xffffff0f
119 IPV6_FLOWLABEL_MASK = 0xffff0f00
117120 ISIG = 0x1
118121 IUCLC = 0x200
119122 IXOFF = 0x1000
@@ -150,9 +153,14 @@ const (
150153 NFDBITS = 0x40
151154 NLDLY = 0x100
152155 NOFLSH = 0x80
156 NS_GET_MNTNS_ID = 0x8008b705
153157 NS_GET_NSTYPE = 0xb703
154158 NS_GET_OWNER_UID = 0xb704
155159 NS_GET_PARENT = 0xb702
160 NS_GET_PID_FROM_PIDNS = 0x8004b706
161 NS_GET_PID_IN_PIDNS = 0x8004b708
162 NS_GET_TGID_FROM_PIDNS = 0x8004b707
163 NS_GET_TGID_IN_PIDNS = 0x8004b709
156164 NS_GET_USERNS = 0xb701
157165 OLCUC = 0x2
158166 ONLCR = 0x4
@@ -229,6 +237,20 @@ const (
229237 PPPIOCUNBRIDGECHAN = 0x7434
230238 PPPIOCXFERUNIT = 0x744e
231239 PR_SET_PTRACER_ANY = 0xffffffffffffffff
240 PTP_CLOCK_GETCAPS = 0x80503d01
241 PTP_CLOCK_GETCAPS2 = 0x80503d0a
242 PTP_ENABLE_PPS = 0x40043d04
243 PTP_ENABLE_PPS2 = 0x40043d0d
244 PTP_EXTTS_REQUEST = 0x40103d02
245 PTP_EXTTS_REQUEST2 = 0x40103d0b
246 PTP_MASK_CLEAR_ALL = 0x3d13
247 PTP_MASK_EN_SINGLE = 0x40043d14
248 PTP_PEROUT_REQUEST = 0x40383d03
249 PTP_PEROUT_REQUEST2 = 0x40383d0c
250 PTP_PIN_SETFUNC = 0x40603d07
251 PTP_PIN_SETFUNC2 = 0x40603d10
252 PTP_SYS_OFFSET = 0x43403d05
253 PTP_SYS_OFFSET2 = 0x43403d0e
232254 PTRACE_GETFDPIC = 0x21
233255 PTRACE_GETFDPIC_EXEC = 0x0
234256 PTRACE_GETFDPIC_INTERP = 0x1
@@ -268,10 +290,13 @@ const (
268290 RTC_WIE_ON = 0x700f
269291 RTC_WKALM_RD = 0x80287010
270292 RTC_WKALM_SET = 0x4028700f
293 SCM_DEVMEM_DMABUF = 0x4f
294 SCM_DEVMEM_LINEAR = 0x4e
271295 SCM_TIMESTAMPING = 0x25
272296 SCM_TIMESTAMPING_OPT_STATS = 0x36
273297 SCM_TIMESTAMPING_PKTINFO = 0x3a
274298 SCM_TIMESTAMPNS = 0x23
299 SCM_TS_OPT_ID = 0x51
275300 SCM_TXTIME = 0x3d
276301 SCM_WIFI_STATUS = 0x29
277302 SECCOMP_IOCTL_NOTIF_ADDFD = 0x40182103
@@ -306,6 +331,9 @@ const (
306331 SO_CNX_ADVICE = 0x35
307332 SO_COOKIE = 0x39
308333 SO_DETACH_REUSEPORT_BPF = 0x44
334 SO_DEVMEM_DMABUF = 0x4f
335 SO_DEVMEM_DONTNEED = 0x50
336 SO_DEVMEM_LINEAR = 0x4e
309337 SO_DOMAIN = 0x27
310338 SO_DONTROUTE = 0x5
311339 SO_ERROR = 0x4
vendor/golang.org/x/sys/unix/zerrors_linux_s390x.go +28
@@ -108,12 +108,15 @@ const (
108108 HIDIOCGRAWINFO = 0x80084803
109109 HIDIOCGRDESC = 0x90044802
110110 HIDIOCGRDESCSIZE = 0x80044801
111 HIDIOCREVOKE = 0x4004480d
111112 HUPCL = 0x400
112113 ICANON = 0x2
113114 IEXTEN = 0x8000
114115 IN_CLOEXEC = 0x80000
115116 IN_NONBLOCK = 0x800
116117 IOCTL_VM_SOCKETS_GET_LOCAL_CID = 0x7b9
118 IPV6_FLOWINFO_MASK = 0xfffffff
119 IPV6_FLOWLABEL_MASK = 0xfffff
117120 ISIG = 0x1
118121 IUCLC = 0x200
119122 IXOFF = 0x1000
@@ -150,9 +153,14 @@ const (
150153 NFDBITS = 0x40
151154 NLDLY = 0x100
152155 NOFLSH = 0x80
156 NS_GET_MNTNS_ID = 0x8008b705
153157 NS_GET_NSTYPE = 0xb703
154158 NS_GET_OWNER_UID = 0xb704
155159 NS_GET_PARENT = 0xb702
160 NS_GET_PID_FROM_PIDNS = 0x8004b706
161 NS_GET_PID_IN_PIDNS = 0x8004b708
162 NS_GET_TGID_FROM_PIDNS = 0x8004b707
163 NS_GET_TGID_IN_PIDNS = 0x8004b709
156164 NS_GET_USERNS = 0xb701
157165 OLCUC = 0x2
158166 ONLCR = 0x4
@@ -229,6 +237,20 @@ const (
229237 PPPIOCUNBRIDGECHAN = 0x7434
230238 PPPIOCXFERUNIT = 0x744e
231239 PR_SET_PTRACER_ANY = 0xffffffffffffffff
240 PTP_CLOCK_GETCAPS = 0x80503d01
241 PTP_CLOCK_GETCAPS2 = 0x80503d0a
242 PTP_ENABLE_PPS = 0x40043d04
243 PTP_ENABLE_PPS2 = 0x40043d0d
244 PTP_EXTTS_REQUEST = 0x40103d02
245 PTP_EXTTS_REQUEST2 = 0x40103d0b
246 PTP_MASK_CLEAR_ALL = 0x3d13
247 PTP_MASK_EN_SINGLE = 0x40043d14
248 PTP_PEROUT_REQUEST = 0x40383d03
249 PTP_PEROUT_REQUEST2 = 0x40383d0c
250 PTP_PIN_SETFUNC = 0x40603d07
251 PTP_PIN_SETFUNC2 = 0x40603d10
252 PTP_SYS_OFFSET = 0x43403d05
253 PTP_SYS_OFFSET2 = 0x43403d0e
232254 PTRACE_DISABLE_TE = 0x5010
233255 PTRACE_ENABLE_TE = 0x5009
234256 PTRACE_GET_LAST_BREAK = 0x5006
@@ -340,10 +362,13 @@ const (
340362 RTC_WIE_ON = 0x700f
341363 RTC_WKALM_RD = 0x80287010
342364 RTC_WKALM_SET = 0x4028700f
365 SCM_DEVMEM_DMABUF = 0x4f
366 SCM_DEVMEM_LINEAR = 0x4e
343367 SCM_TIMESTAMPING = 0x25
344368 SCM_TIMESTAMPING_OPT_STATS = 0x36
345369 SCM_TIMESTAMPING_PKTINFO = 0x3a
346370 SCM_TIMESTAMPNS = 0x23
371 SCM_TS_OPT_ID = 0x51
347372 SCM_TXTIME = 0x3d
348373 SCM_WIFI_STATUS = 0x29
349374 SECCOMP_IOCTL_NOTIF_ADDFD = 0x40182103
@@ -378,6 +403,9 @@ const (
378403 SO_CNX_ADVICE = 0x35
379404 SO_COOKIE = 0x39
380405 SO_DETACH_REUSEPORT_BPF = 0x44
406 SO_DEVMEM_DMABUF = 0x4f
407 SO_DEVMEM_DONTNEED = 0x50
408 SO_DEVMEM_LINEAR = 0x4e
381409 SO_DOMAIN = 0x27
382410 SO_DONTROUTE = 0x5
383411 SO_ERROR = 0x4
vendor/golang.org/x/sys/unix/zerrors_linux_sparc64.go +28
@@ -112,12 +112,15 @@ const (
112112 HIDIOCGRAWINFO = 0x40084803
113113 HIDIOCGRDESC = 0x50044802
114114 HIDIOCGRDESCSIZE = 0x40044801
115 HIDIOCREVOKE = 0x8004480d
115116 HUPCL = 0x400
116117 ICANON = 0x2
117118 IEXTEN = 0x8000
118119 IN_CLOEXEC = 0x400000
119120 IN_NONBLOCK = 0x4000
120121 IOCTL_VM_SOCKETS_GET_LOCAL_CID = 0x200007b9
122 IPV6_FLOWINFO_MASK = 0xfffffff
123 IPV6_FLOWLABEL_MASK = 0xfffff
121124 ISIG = 0x1
122125 IUCLC = 0x200
123126 IXOFF = 0x1000
@@ -155,9 +158,14 @@ const (
155158 NFDBITS = 0x40
156159 NLDLY = 0x100
157160 NOFLSH = 0x80
161 NS_GET_MNTNS_ID = 0x4008b705
158162 NS_GET_NSTYPE = 0x2000b703
159163 NS_GET_OWNER_UID = 0x2000b704
160164 NS_GET_PARENT = 0x2000b702
165 NS_GET_PID_FROM_PIDNS = 0x4004b706
166 NS_GET_PID_IN_PIDNS = 0x4004b708
167 NS_GET_TGID_FROM_PIDNS = 0x4004b707
168 NS_GET_TGID_IN_PIDNS = 0x4004b709
161169 NS_GET_USERNS = 0x2000b701
162170 OLCUC = 0x2
163171 ONLCR = 0x4
@@ -234,6 +242,20 @@ const (
234242 PPPIOCUNBRIDGECHAN = 0x20007434
235243 PPPIOCXFERUNIT = 0x2000744e
236244 PR_SET_PTRACER_ANY = 0xffffffffffffffff
245 PTP_CLOCK_GETCAPS = 0x40503d01
246 PTP_CLOCK_GETCAPS2 = 0x40503d0a
247 PTP_ENABLE_PPS = 0x80043d04
248 PTP_ENABLE_PPS2 = 0x80043d0d
249 PTP_EXTTS_REQUEST = 0x80103d02
250 PTP_EXTTS_REQUEST2 = 0x80103d0b
251 PTP_MASK_CLEAR_ALL = 0x20003d13
252 PTP_MASK_EN_SINGLE = 0x80043d14
253 PTP_PEROUT_REQUEST = 0x80383d03
254 PTP_PEROUT_REQUEST2 = 0x80383d0c
255 PTP_PIN_SETFUNC = 0x80603d07
256 PTP_PIN_SETFUNC2 = 0x80603d10
257 PTP_SYS_OFFSET = 0x83403d05
258 PTP_SYS_OFFSET2 = 0x83403d0e
237259 PTRACE_GETFPAREGS = 0x14
238260 PTRACE_GETFPREGS = 0xe
239261 PTRACE_GETFPREGS64 = 0x19
@@ -331,10 +353,13 @@ const (
331353 RTC_WIE_ON = 0x2000700f
332354 RTC_WKALM_RD = 0x40287010
333355 RTC_WKALM_SET = 0x8028700f
356 SCM_DEVMEM_DMABUF = 0x58
357 SCM_DEVMEM_LINEAR = 0x57
334358 SCM_TIMESTAMPING = 0x23
335359 SCM_TIMESTAMPING_OPT_STATS = 0x38
336360 SCM_TIMESTAMPING_PKTINFO = 0x3c
337361 SCM_TIMESTAMPNS = 0x21
362 SCM_TS_OPT_ID = 0x5a
338363 SCM_TXTIME = 0x3f
339364 SCM_WIFI_STATUS = 0x25
340365 SECCOMP_IOCTL_NOTIF_ADDFD = 0x80182103
@@ -417,6 +442,9 @@ const (
417442 SO_CNX_ADVICE = 0x37
418443 SO_COOKIE = 0x3b
419444 SO_DETACH_REUSEPORT_BPF = 0x47
445 SO_DEVMEM_DMABUF = 0x58
446 SO_DEVMEM_DONTNEED = 0x59
447 SO_DEVMEM_LINEAR = 0x57
420448 SO_DOMAIN = 0x1029
421449 SO_DONTROUTE = 0x10
422450 SO_ERROR = 0x1007
vendor/golang.org/x/sys/unix/zerrors_zos_s390x.go +2
@@ -581,6 +581,8 @@ const (
581581 AT_EMPTY_PATH = 0x1000
582582 AT_REMOVEDIR = 0x200
583583 RENAME_NOREPLACE = 1 << 0
584 ST_RDONLY = 1
585 ST_NOSUID = 2
584586)
585587
586588const (
vendor/golang.org/x/sys/unix/zsyscall_darwin_amd64.go +20
@@ -841,6 +841,26 @@ var libc_pthread_fchdir_np_trampoline_addr uintptr
841841
842842// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
843843
844func connectx(fd int, endpoints *SaEndpoints, associd SaeAssocID, flags uint32, iov []Iovec, n *uintptr, connid *SaeConnID) (err error) {
845 var _p0 unsafe.Pointer
846 if len(iov) > 0 {
847 _p0 = unsafe.Pointer(&iov[0])
848 } else {
849 _p0 = unsafe.Pointer(&_zero)
850 }
851 _, _, e1 := syscall_syscall9(libc_connectx_trampoline_addr, uintptr(fd), uintptr(unsafe.Pointer(endpoints)), uintptr(associd), uintptr(flags), uintptr(_p0), uintptr(len(iov)), uintptr(unsafe.Pointer(n)), uintptr(unsafe.Pointer(connid)), 0)
852 if e1 != 0 {
853 err = errnoErr(e1)
854 }
855 return
856}
857
858var libc_connectx_trampoline_addr uintptr
859
860//go:cgo_import_dynamic libc_connectx connectx "/usr/lib/libSystem.B.dylib"
861
862// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
863
844864func sendfile(infd int, outfd int, offset int64, len *int64, hdtr unsafe.Pointer, flags int) (err error) {
845865 _, _, e1 := syscall_syscall6(libc_sendfile_trampoline_addr, uintptr(infd), uintptr(outfd), uintptr(offset), uintptr(unsafe.Pointer(len)), uintptr(hdtr), uintptr(flags))
846866 if e1 != 0 {
vendor/golang.org/x/sys/unix/zsyscall_darwin_amd64.s +5
@@ -248,6 +248,11 @@ TEXT libc_pthread_fchdir_np_trampoline<>(SB),NOSPLIT,$0-0
248248GLOBL ·libc_pthread_fchdir_np_trampoline_addr(SB), RODATA, $8
249249DATA ·libc_pthread_fchdir_np_trampoline_addr(SB)/8, $libc_pthread_fchdir_np_trampoline<>(SB)
250250
251TEXT libc_connectx_trampoline<>(SB),NOSPLIT,$0-0
252 JMP libc_connectx(SB)
253GLOBL ·libc_connectx_trampoline_addr(SB), RODATA, $8
254DATA ·libc_connectx_trampoline_addr(SB)/8, $libc_connectx_trampoline<>(SB)
255
251256TEXT libc_sendfile_trampoline<>(SB),NOSPLIT,$0-0
252257 JMP libc_sendfile(SB)
253258GLOBL ·libc_sendfile_trampoline_addr(SB), RODATA, $8
vendor/golang.org/x/sys/unix/zsyscall_darwin_arm64.go +20
@@ -841,6 +841,26 @@ var libc_pthread_fchdir_np_trampoline_addr uintptr
841841
842842// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
843843
844func connectx(fd int, endpoints *SaEndpoints, associd SaeAssocID, flags uint32, iov []Iovec, n *uintptr, connid *SaeConnID) (err error) {
845 var _p0 unsafe.Pointer
846 if len(iov) > 0 {
847 _p0 = unsafe.Pointer(&iov[0])
848 } else {
849 _p0 = unsafe.Pointer(&_zero)
850 }
851 _, _, e1 := syscall_syscall9(libc_connectx_trampoline_addr, uintptr(fd), uintptr(unsafe.Pointer(endpoints)), uintptr(associd), uintptr(flags), uintptr(_p0), uintptr(len(iov)), uintptr(unsafe.Pointer(n)), uintptr(unsafe.Pointer(connid)), 0)
852 if e1 != 0 {
853 err = errnoErr(e1)
854 }
855 return
856}
857
858var libc_connectx_trampoline_addr uintptr
859
860//go:cgo_import_dynamic libc_connectx connectx "/usr/lib/libSystem.B.dylib"
861
862// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
863
844864func sendfile(infd int, outfd int, offset int64, len *int64, hdtr unsafe.Pointer, flags int) (err error) {
845865 _, _, e1 := syscall_syscall6(libc_sendfile_trampoline_addr, uintptr(infd), uintptr(outfd), uintptr(offset), uintptr(unsafe.Pointer(len)), uintptr(hdtr), uintptr(flags))
846866 if e1 != 0 {
vendor/golang.org/x/sys/unix/zsyscall_darwin_arm64.s +5
@@ -248,6 +248,11 @@ TEXT libc_pthread_fchdir_np_trampoline<>(SB),NOSPLIT,$0-0
248248GLOBL ·libc_pthread_fchdir_np_trampoline_addr(SB), RODATA, $8
249249DATA ·libc_pthread_fchdir_np_trampoline_addr(SB)/8, $libc_pthread_fchdir_np_trampoline<>(SB)
250250
251TEXT libc_connectx_trampoline<>(SB),NOSPLIT,$0-0
252 JMP libc_connectx(SB)
253GLOBL ·libc_connectx_trampoline_addr(SB), RODATA, $8
254DATA ·libc_connectx_trampoline_addr(SB)/8, $libc_connectx_trampoline<>(SB)
255
251256TEXT libc_sendfile_trampoline<>(SB),NOSPLIT,$0-0
252257 JMP libc_sendfile(SB)
253258GLOBL ·libc_sendfile_trampoline_addr(SB), RODATA, $8
vendor/golang.org/x/sys/unix/zsyscall_linux.go +10 −17
@@ -592,6 +592,16 @@ func ClockGettime(clockid int32, time *Timespec) (err error) {
592592
593593// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
594594
595func ClockSettime(clockid int32, time *Timespec) (err error) {
596 _, _, e1 := Syscall(SYS_CLOCK_SETTIME, uintptr(clockid), uintptr(unsafe.Pointer(time)), 0)
597 if e1 != 0 {
598 err = errnoErr(e1)
599 }
600 return
601}
602
603// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
604
595605func ClockNanosleep(clockid int32, flags int, request *Timespec, remain *Timespec) (err error) {
596606 _, _, e1 := Syscall6(SYS_CLOCK_NANOSLEEP, uintptr(clockid), uintptr(flags), uintptr(unsafe.Pointer(request)), uintptr(unsafe.Pointer(remain)), 0, 0)
597607 if e1 != 0 {
@@ -971,23 +981,6 @@ func Getpriority(which int, who int) (prio int, err error) {
971981
972982// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
973983
974func Getrandom(buf []byte, flags int) (n int, err error) {
975 var _p0 unsafe.Pointer
976 if len(buf) > 0 {
977 _p0 = unsafe.Pointer(&buf[0])
978 } else {
979 _p0 = unsafe.Pointer(&_zero)
980 }
981 r0, _, e1 := Syscall(SYS_GETRANDOM, uintptr(_p0), uintptr(len(buf)), uintptr(flags))
982 n = int(r0)
983 if e1 != 0 {
984 err = errnoErr(e1)
985 }
986 return
987}
988
989// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
990
991984func Getrusage(who int, rusage *Rusage) (err error) {
992985 _, _, e1 := RawSyscall(SYS_GETRUSAGE, uintptr(who), uintptr(unsafe.Pointer(rusage)), 0)
993986 if e1 != 0 {
vendor/golang.org/x/sys/unix/zsyscall_solaris_amd64.go +114
@@ -141,6 +141,16 @@ import (
141141//go:cgo_import_dynamic libc_getpeername getpeername "libsocket.so"
142142//go:cgo_import_dynamic libc_setsockopt setsockopt "libsocket.so"
143143//go:cgo_import_dynamic libc_recvfrom recvfrom "libsocket.so"
144//go:cgo_import_dynamic libc_getpeerucred getpeerucred "libc.so"
145//go:cgo_import_dynamic libc_ucred_get ucred_get "libc.so"
146//go:cgo_import_dynamic libc_ucred_geteuid ucred_geteuid "libc.so"
147//go:cgo_import_dynamic libc_ucred_getegid ucred_getegid "libc.so"
148//go:cgo_import_dynamic libc_ucred_getruid ucred_getruid "libc.so"
149//go:cgo_import_dynamic libc_ucred_getrgid ucred_getrgid "libc.so"
150//go:cgo_import_dynamic libc_ucred_getsuid ucred_getsuid "libc.so"
151//go:cgo_import_dynamic libc_ucred_getsgid ucred_getsgid "libc.so"
152//go:cgo_import_dynamic libc_ucred_getpid ucred_getpid "libc.so"
153//go:cgo_import_dynamic libc_ucred_free ucred_free "libc.so"
144154//go:cgo_import_dynamic libc_port_create port_create "libc.so"
145155//go:cgo_import_dynamic libc_port_associate port_associate "libc.so"
146156//go:cgo_import_dynamic libc_port_dissociate port_dissociate "libc.so"
@@ -280,6 +290,16 @@ import (
280290//go:linkname procgetpeername libc_getpeername
281291//go:linkname procsetsockopt libc_setsockopt
282292//go:linkname procrecvfrom libc_recvfrom
293//go:linkname procgetpeerucred libc_getpeerucred
294//go:linkname procucred_get libc_ucred_get
295//go:linkname procucred_geteuid libc_ucred_geteuid
296//go:linkname procucred_getegid libc_ucred_getegid
297//go:linkname procucred_getruid libc_ucred_getruid
298//go:linkname procucred_getrgid libc_ucred_getrgid
299//go:linkname procucred_getsuid libc_ucred_getsuid
300//go:linkname procucred_getsgid libc_ucred_getsgid
301//go:linkname procucred_getpid libc_ucred_getpid
302//go:linkname procucred_free libc_ucred_free
283303//go:linkname procport_create libc_port_create
284304//go:linkname procport_associate libc_port_associate
285305//go:linkname procport_dissociate libc_port_dissociate
@@ -420,6 +440,16 @@ var (
420440 procgetpeername,
421441 procsetsockopt,
422442 procrecvfrom,
443 procgetpeerucred,
444 procucred_get,
445 procucred_geteuid,
446 procucred_getegid,
447 procucred_getruid,
448 procucred_getrgid,
449 procucred_getsuid,
450 procucred_getsgid,
451 procucred_getpid,
452 procucred_free,
423453 procport_create,
424454 procport_associate,
425455 procport_dissociate,
@@ -2029,6 +2059,90 @@ func recvfrom(fd int, p []byte, flags int, from *RawSockaddrAny, fromlen *_Sockl
20292059
20302060// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
20312061
2062func getpeerucred(fd uintptr, ucred *uintptr) (err error) {
2063 _, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procgetpeerucred)), 2, uintptr(fd), uintptr(unsafe.Pointer(ucred)), 0, 0, 0, 0)
2064 if e1 != 0 {
2065 err = errnoErr(e1)
2066 }
2067 return
2068}
2069
2070// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
2071
2072func ucredGet(pid int) (ucred uintptr, err error) {
2073 r0, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procucred_get)), 1, uintptr(pid), 0, 0, 0, 0, 0)
2074 ucred = uintptr(r0)
2075 if e1 != 0 {
2076 err = errnoErr(e1)
2077 }
2078 return
2079}
2080
2081// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
2082
2083func ucredGeteuid(ucred uintptr) (uid int) {
2084 r0, _, _ := sysvicall6(uintptr(unsafe.Pointer(&procucred_geteuid)), 1, uintptr(ucred), 0, 0, 0, 0, 0)
2085 uid = int(r0)
2086 return
2087}
2088
2089// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
2090
2091func ucredGetegid(ucred uintptr) (gid int) {
2092 r0, _, _ := sysvicall6(uintptr(unsafe.Pointer(&procucred_getegid)), 1, uintptr(ucred), 0, 0, 0, 0, 0)
2093 gid = int(r0)
2094 return
2095}
2096
2097// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
2098
2099func ucredGetruid(ucred uintptr) (uid int) {
2100 r0, _, _ := sysvicall6(uintptr(unsafe.Pointer(&procucred_getruid)), 1, uintptr(ucred), 0, 0, 0, 0, 0)
2101 uid = int(r0)
2102 return
2103}
2104
2105// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
2106
2107func ucredGetrgid(ucred uintptr) (gid int) {
2108 r0, _, _ := sysvicall6(uintptr(unsafe.Pointer(&procucred_getrgid)), 1, uintptr(ucred), 0, 0, 0, 0, 0)
2109 gid = int(r0)
2110 return
2111}
2112
2113// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
2114
2115func ucredGetsuid(ucred uintptr) (uid int) {
2116 r0, _, _ := sysvicall6(uintptr(unsafe.Pointer(&procucred_getsuid)), 1, uintptr(ucred), 0, 0, 0, 0, 0)
2117 uid = int(r0)
2118 return
2119}
2120
2121// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
2122
2123func ucredGetsgid(ucred uintptr) (gid int) {
2124 r0, _, _ := sysvicall6(uintptr(unsafe.Pointer(&procucred_getsgid)), 1, uintptr(ucred), 0, 0, 0, 0, 0)
2125 gid = int(r0)
2126 return
2127}
2128
2129// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
2130
2131func ucredGetpid(ucred uintptr) (pid int) {
2132 r0, _, _ := sysvicall6(uintptr(unsafe.Pointer(&procucred_getpid)), 1, uintptr(ucred), 0, 0, 0, 0, 0)
2133 pid = int(r0)
2134 return
2135}
2136
2137// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
2138
2139func ucredFree(ucred uintptr) {
2140 sysvicall6(uintptr(unsafe.Pointer(&procucred_free)), 1, uintptr(ucred), 0, 0, 0, 0, 0)
2141 return
2142}
2143
2144// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
2145
20322146func port_create() (n int, err error) {
20332147 r0, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procport_create)), 0, 0, 0, 0, 0, 0, 0)
20342148 n = int(r0)
vendor/golang.org/x/sys/unix/zsysnum_linux_386.go +4
@@ -458,4 +458,8 @@ const (
458458 SYS_LSM_SET_SELF_ATTR = 460
459459 SYS_LSM_LIST_MODULES = 461
460460 SYS_MSEAL = 462
461 SYS_SETXATTRAT = 463
462 SYS_GETXATTRAT = 464
463 SYS_LISTXATTRAT = 465
464 SYS_REMOVEXATTRAT = 466
461465)
vendor/golang.org/x/sys/unix/zsysnum_linux_amd64.go +5
@@ -341,6 +341,7 @@ const (
341341 SYS_STATX = 332
342342 SYS_IO_PGETEVENTS = 333
343343 SYS_RSEQ = 334
344 SYS_URETPROBE = 335
344345 SYS_PIDFD_SEND_SIGNAL = 424
345346 SYS_IO_URING_SETUP = 425
346347 SYS_IO_URING_ENTER = 426
@@ -380,4 +381,8 @@ const (
380381 SYS_LSM_SET_SELF_ATTR = 460
381382 SYS_LSM_LIST_MODULES = 461
382383 SYS_MSEAL = 462
384 SYS_SETXATTRAT = 463
385 SYS_GETXATTRAT = 464
386 SYS_LISTXATTRAT = 465
387 SYS_REMOVEXATTRAT = 466
383388)
vendor/golang.org/x/sys/unix/zsysnum_linux_arm.go +4
@@ -422,4 +422,8 @@ const (
422422 SYS_LSM_SET_SELF_ATTR = 460
423423 SYS_LSM_LIST_MODULES = 461
424424 SYS_MSEAL = 462
425 SYS_SETXATTRAT = 463
426 SYS_GETXATTRAT = 464
427 SYS_LISTXATTRAT = 465
428 SYS_REMOVEXATTRAT = 466
425429)
vendor/golang.org/x/sys/unix/zsysnum_linux_arm64.go +5 −1
@@ -85,7 +85,7 @@ const (
8585 SYS_SPLICE = 76
8686 SYS_TEE = 77
8787 SYS_READLINKAT = 78
88 SYS_FSTATAT = 79
88 SYS_NEWFSTATAT = 79
8989 SYS_FSTAT = 80
9090 SYS_SYNC = 81
9191 SYS_FSYNC = 82
@@ -325,4 +325,8 @@ const (
325325 SYS_LSM_SET_SELF_ATTR = 460
326326 SYS_LSM_LIST_MODULES = 461
327327 SYS_MSEAL = 462
328 SYS_SETXATTRAT = 463
329 SYS_GETXATTRAT = 464
330 SYS_LISTXATTRAT = 465
331 SYS_REMOVEXATTRAT = 466
328332)
vendor/golang.org/x/sys/unix/zsysnum_linux_loong64.go +6
@@ -84,6 +84,8 @@ const (
8484 SYS_SPLICE = 76
8585 SYS_TEE = 77
8686 SYS_READLINKAT = 78
87 SYS_NEWFSTATAT = 79
88 SYS_FSTAT = 80
8789 SYS_SYNC = 81
8890 SYS_FSYNC = 82
8991 SYS_FDATASYNC = 83
@@ -319,4 +321,8 @@ const (
319321 SYS_LSM_SET_SELF_ATTR = 460
320322 SYS_LSM_LIST_MODULES = 461
321323 SYS_MSEAL = 462
324 SYS_SETXATTRAT = 463
325 SYS_GETXATTRAT = 464
326 SYS_LISTXATTRAT = 465
327 SYS_REMOVEXATTRAT = 466
322328)
vendor/golang.org/x/sys/unix/zsysnum_linux_mips.go +4
@@ -442,4 +442,8 @@ const (
442442 SYS_LSM_SET_SELF_ATTR = 4460
443443 SYS_LSM_LIST_MODULES = 4461
444444 SYS_MSEAL = 4462
445 SYS_SETXATTRAT = 4463
446 SYS_GETXATTRAT = 4464
447 SYS_LISTXATTRAT = 4465
448 SYS_REMOVEXATTRAT = 4466
445449)
vendor/golang.org/x/sys/unix/zsysnum_linux_mips64.go +4
@@ -372,4 +372,8 @@ const (
372372 SYS_LSM_SET_SELF_ATTR = 5460
373373 SYS_LSM_LIST_MODULES = 5461
374374 SYS_MSEAL = 5462
375 SYS_SETXATTRAT = 5463
376 SYS_GETXATTRAT = 5464
377 SYS_LISTXATTRAT = 5465
378 SYS_REMOVEXATTRAT = 5466
375379)
vendor/golang.org/x/sys/unix/zsysnum_linux_mips64le.go +4
@@ -372,4 +372,8 @@ const (
372372 SYS_LSM_SET_SELF_ATTR = 5460
373373 SYS_LSM_LIST_MODULES = 5461
374374 SYS_MSEAL = 5462
375 SYS_SETXATTRAT = 5463
376 SYS_GETXATTRAT = 5464
377 SYS_LISTXATTRAT = 5465
378 SYS_REMOVEXATTRAT = 5466
375379)
vendor/golang.org/x/sys/unix/zsysnum_linux_mipsle.go +4
@@ -442,4 +442,8 @@ const (
442442 SYS_LSM_SET_SELF_ATTR = 4460
443443 SYS_LSM_LIST_MODULES = 4461
444444 SYS_MSEAL = 4462
445 SYS_SETXATTRAT = 4463
446 SYS_GETXATTRAT = 4464
447 SYS_LISTXATTRAT = 4465
448 SYS_REMOVEXATTRAT = 4466
445449)
vendor/golang.org/x/sys/unix/zsysnum_linux_ppc.go +4
@@ -449,4 +449,8 @@ const (
449449 SYS_LSM_SET_SELF_ATTR = 460
450450 SYS_LSM_LIST_MODULES = 461
451451 SYS_MSEAL = 462
452 SYS_SETXATTRAT = 463
453 SYS_GETXATTRAT = 464
454 SYS_LISTXATTRAT = 465
455 SYS_REMOVEXATTRAT = 466
452456)
vendor/golang.org/x/sys/unix/zsysnum_linux_ppc64.go +4
@@ -421,4 +421,8 @@ const (
421421 SYS_LSM_SET_SELF_ATTR = 460
422422 SYS_LSM_LIST_MODULES = 461
423423 SYS_MSEAL = 462
424 SYS_SETXATTRAT = 463
425 SYS_GETXATTRAT = 464
426 SYS_LISTXATTRAT = 465
427 SYS_REMOVEXATTRAT = 466
424428)
vendor/golang.org/x/sys/unix/zsysnum_linux_ppc64le.go +4
@@ -421,4 +421,8 @@ const (
421421 SYS_LSM_SET_SELF_ATTR = 460
422422 SYS_LSM_LIST_MODULES = 461
423423 SYS_MSEAL = 462
424 SYS_SETXATTRAT = 463
425 SYS_GETXATTRAT = 464
426 SYS_LISTXATTRAT = 465
427 SYS_REMOVEXATTRAT = 466
424428)
vendor/golang.org/x/sys/unix/zsysnum_linux_riscv64.go +5 −1
@@ -84,7 +84,7 @@ const (
8484 SYS_SPLICE = 76
8585 SYS_TEE = 77
8686 SYS_READLINKAT = 78
87 SYS_FSTATAT = 79
87 SYS_NEWFSTATAT = 79
8888 SYS_FSTAT = 80
8989 SYS_SYNC = 81
9090 SYS_FSYNC = 82
@@ -326,4 +326,8 @@ const (
326326 SYS_LSM_SET_SELF_ATTR = 460
327327 SYS_LSM_LIST_MODULES = 461
328328 SYS_MSEAL = 462
329 SYS_SETXATTRAT = 463
330 SYS_GETXATTRAT = 464
331 SYS_LISTXATTRAT = 465
332 SYS_REMOVEXATTRAT = 466
329333)
vendor/golang.org/x/sys/unix/zsysnum_linux_s390x.go +4
@@ -387,4 +387,8 @@ const (
387387 SYS_LSM_SET_SELF_ATTR = 460
388388 SYS_LSM_LIST_MODULES = 461
389389 SYS_MSEAL = 462
390 SYS_SETXATTRAT = 463
391 SYS_GETXATTRAT = 464
392 SYS_LISTXATTRAT = 465
393 SYS_REMOVEXATTRAT = 466
390394)
vendor/golang.org/x/sys/unix/zsysnum_linux_sparc64.go +4
@@ -400,4 +400,8 @@ const (
400400 SYS_LSM_SET_SELF_ATTR = 460
401401 SYS_LSM_LIST_MODULES = 461
402402 SYS_MSEAL = 462
403 SYS_SETXATTRAT = 463
404 SYS_GETXATTRAT = 464
405 SYS_LISTXATTRAT = 465
406 SYS_REMOVEXATTRAT = 466
403407)
vendor/golang.org/x/sys/unix/ztypes_darwin_amd64.go +73
@@ -306,6 +306,19 @@ type XVSockPgen struct {
306306
307307type _Socklen uint32
308308
309type SaeAssocID uint32
310
311type SaeConnID uint32
312
313type SaEndpoints struct {
314 Srcif uint32
315 Srcaddr *RawSockaddr
316 Srcaddrlen uint32
317 Dstaddr *RawSockaddr
318 Dstaddrlen uint32
319 _ [4]byte
320}
321
309322type Xucred struct {
310323 Version uint32
311324 Uid uint32
@@ -449,11 +462,14 @@ type FdSet struct {
449462
450463const (
451464 SizeofIfMsghdr = 0x70
465 SizeofIfMsghdr2 = 0xa0
452466 SizeofIfData = 0x60
467 SizeofIfData64 = 0x80
453468 SizeofIfaMsghdr = 0x14
454469 SizeofIfmaMsghdr = 0x10
455470 SizeofIfmaMsghdr2 = 0x14
456471 SizeofRtMsghdr = 0x5c
472 SizeofRtMsghdr2 = 0x5c
457473 SizeofRtMetrics = 0x38
458474)
459475
@@ -467,6 +483,20 @@ type IfMsghdr struct {
467483 Data IfData
468484}
469485
486type IfMsghdr2 struct {
487 Msglen uint16
488 Version uint8
489 Type uint8
490 Addrs int32
491 Flags int32
492 Index uint16
493 Snd_len int32
494 Snd_maxlen int32
495 Snd_drops int32
496 Timer int32
497 Data IfData64
498}
499
470500type IfData struct {
471501 Type uint8
472502 Typelen uint8
@@ -499,6 +529,34 @@ type IfData struct {
499529 Reserved2 uint32
500530}
501531
532type IfData64 struct {
533 Type uint8
534 Typelen uint8
535 Physical uint8
536 Addrlen uint8
537 Hdrlen uint8
538 Recvquota uint8
539 Xmitquota uint8
540 Unused1 uint8
541 Mtu uint32
542 Metric uint32
543 Baudrate uint64
544 Ipackets uint64
545 Ierrors uint64
546 Opackets uint64
547 Oerrors uint64
548 Collisions uint64
549 Ibytes uint64
550 Obytes uint64
551 Imcasts uint64
552 Omcasts uint64
553 Iqdrops uint64
554 Noproto uint64
555 Recvtiming uint32
556 Xmittiming uint32
557 Lastchange Timeval32
558}
559
502560type IfaMsghdr struct {
503561 Msglen uint16
504562 Version uint8
@@ -544,6 +602,21 @@ type RtMsghdr struct {
544602 Rmx RtMetrics
545603}
546604
605type RtMsghdr2 struct {
606 Msglen uint16
607 Version uint8
608 Type uint8
609 Index uint16
610 Flags int32
611 Addrs int32
612 Refcnt int32
613 Parentflags int32
614 Reserved int32
615 Use int32
616 Inits uint32
617 Rmx RtMetrics
618}
619
547620type RtMetrics struct {
548621 Locks uint32
549622 Mtu uint32
vendor/golang.org/x/sys/unix/ztypes_darwin_arm64.go +73
@@ -306,6 +306,19 @@ type XVSockPgen struct {
306306
307307type _Socklen uint32
308308
309type SaeAssocID uint32
310
311type SaeConnID uint32
312
313type SaEndpoints struct {
314 Srcif uint32
315 Srcaddr *RawSockaddr
316 Srcaddrlen uint32
317 Dstaddr *RawSockaddr
318 Dstaddrlen uint32
319 _ [4]byte
320}
321
309322type Xucred struct {
310323 Version uint32
311324 Uid uint32
@@ -449,11 +462,14 @@ type FdSet struct {
449462
450463const (
451464 SizeofIfMsghdr = 0x70
465 SizeofIfMsghdr2 = 0xa0
452466 SizeofIfData = 0x60
467 SizeofIfData64 = 0x80
453468 SizeofIfaMsghdr = 0x14
454469 SizeofIfmaMsghdr = 0x10
455470 SizeofIfmaMsghdr2 = 0x14
456471 SizeofRtMsghdr = 0x5c
472 SizeofRtMsghdr2 = 0x5c
457473 SizeofRtMetrics = 0x38
458474)
459475
@@ -467,6 +483,20 @@ type IfMsghdr struct {
467483 Data IfData
468484}
469485
486type IfMsghdr2 struct {
487 Msglen uint16
488 Version uint8
489 Type uint8
490 Addrs int32
491 Flags int32
492 Index uint16
493 Snd_len int32
494 Snd_maxlen int32
495 Snd_drops int32
496 Timer int32
497 Data IfData64
498}
499
470500type IfData struct {
471501 Type uint8
472502 Typelen uint8
@@ -499,6 +529,34 @@ type IfData struct {
499529 Reserved2 uint32
500530}
501531
532type IfData64 struct {
533 Type uint8
534 Typelen uint8
535 Physical uint8
536 Addrlen uint8
537 Hdrlen uint8
538 Recvquota uint8
539 Xmitquota uint8
540 Unused1 uint8
541 Mtu uint32
542 Metric uint32
543 Baudrate uint64
544 Ipackets uint64
545 Ierrors uint64
546 Opackets uint64
547 Oerrors uint64
548 Collisions uint64
549 Ibytes uint64
550 Obytes uint64
551 Imcasts uint64
552 Omcasts uint64
553 Iqdrops uint64
554 Noproto uint64
555 Recvtiming uint32
556 Xmittiming uint32
557 Lastchange Timeval32
558}
559
502560type IfaMsghdr struct {
503561 Msglen uint16
504562 Version uint8
@@ -544,6 +602,21 @@ type RtMsghdr struct {
544602 Rmx RtMetrics
545603}
546604
605type RtMsghdr2 struct {
606 Msglen uint16
607 Version uint8
608 Type uint8
609 Index uint16
610 Flags int32
611 Addrs int32
612 Refcnt int32
613 Parentflags int32
614 Reserved int32
615 Use int32
616 Inits uint32
617 Rmx RtMetrics
618}
619
547620type RtMetrics struct {
548621 Locks uint32
549622 Mtu uint32
vendor/golang.org/x/sys/unix/ztypes_freebsd_386.go +1
@@ -625,6 +625,7 @@ const (
625625 POLLRDNORM = 0x40
626626 POLLWRBAND = 0x100
627627 POLLWRNORM = 0x4
628 POLLRDHUP = 0x4000
628629)
629630
630631type CapRights struct {
vendor/golang.org/x/sys/unix/ztypes_freebsd_amd64.go +1
@@ -630,6 +630,7 @@ const (
630630 POLLRDNORM = 0x40
631631 POLLWRBAND = 0x100
632632 POLLWRNORM = 0x4
633 POLLRDHUP = 0x4000
633634)
634635
635636type CapRights struct {
vendor/golang.org/x/sys/unix/ztypes_freebsd_arm.go +1
@@ -616,6 +616,7 @@ const (
616616 POLLRDNORM = 0x40
617617 POLLWRBAND = 0x100
618618 POLLWRNORM = 0x4
619 POLLRDHUP = 0x4000
619620)
620621
621622type CapRights struct {
vendor/golang.org/x/sys/unix/ztypes_freebsd_arm64.go +1
@@ -610,6 +610,7 @@ const (
610610 POLLRDNORM = 0x40
611611 POLLWRBAND = 0x100
612612 POLLWRNORM = 0x4
613 POLLRDHUP = 0x4000
613614)
614615
615616type CapRights struct {
vendor/golang.org/x/sys/unix/ztypes_freebsd_riscv64.go +1
@@ -612,6 +612,7 @@ const (
612612 POLLRDNORM = 0x40
613613 POLLWRBAND = 0x100
614614 POLLWRNORM = 0x4
615 POLLRDHUP = 0x4000
615616)
616617
617618type CapRights struct {
vendor/golang.org/x/sys/unix/ztypes_linux.go +184 −44
@@ -87,31 +87,35 @@ type StatxTimestamp struct {
8787}
8888
8989type Statx_t struct {
90 Mask uint32
91 Blksize uint32
92 Attributes uint64
93 Nlink uint32
94 Uid uint32
95 Gid uint32
96 Mode uint16
97 _ [1]uint16
98 Ino uint64
99 Size uint64
100 Blocks uint64
101 Attributes_mask uint64
102 Atime StatxTimestamp
103 Btime StatxTimestamp
104 Ctime StatxTimestamp
105 Mtime StatxTimestamp
106 Rdev_major uint32
107 Rdev_minor uint32
108 Dev_major uint32
109 Dev_minor uint32
110 Mnt_id uint64
111 Dio_mem_align uint32
112 Dio_offset_align uint32
113 Subvol uint64
114 _ [11]uint64
90 Mask uint32
91 Blksize uint32
92 Attributes uint64
93 Nlink uint32
94 Uid uint32
95 Gid uint32
96 Mode uint16
97 _ [1]uint16
98 Ino uint64
99 Size uint64
100 Blocks uint64
101 Attributes_mask uint64
102 Atime StatxTimestamp
103 Btime StatxTimestamp
104 Ctime StatxTimestamp
105 Mtime StatxTimestamp
106 Rdev_major uint32
107 Rdev_minor uint32
108 Dev_major uint32
109 Dev_minor uint32
110 Mnt_id uint64
111 Dio_mem_align uint32
112 Dio_offset_align uint32
113 Subvol uint64
114 Atomic_write_unit_min uint32
115 Atomic_write_unit_max uint32
116 Atomic_write_segments_max uint32
117 _ [1]uint32
118 _ [9]uint64
115119}
116120
117121type Fsid struct {
@@ -516,6 +520,29 @@ type TCPInfo struct {
516520 Total_rto_time uint32
517521}
518522
523type TCPVegasInfo struct {
524 Enabled uint32
525 Rttcnt uint32
526 Rtt uint32
527 Minrtt uint32
528}
529
530type TCPDCTCPInfo struct {
531 Enabled uint16
532 Ce_state uint16
533 Alpha uint32
534 Ab_ecn uint32
535 Ab_tot uint32
536}
537
538type TCPBBRInfo struct {
539 Bw_lo uint32
540 Bw_hi uint32
541 Min_rtt uint32
542 Pacing_gain uint32
543 Cwnd_gain uint32
544}
545
519546type CanFilter struct {
520547 Id uint32
521548 Mask uint32
@@ -557,6 +584,7 @@ const (
557584 SizeofICMPv6Filter = 0x20
558585 SizeofUcred = 0xc
559586 SizeofTCPInfo = 0xf8
587 SizeofTCPCCInfo = 0x14
560588 SizeofCanFilter = 0x8
561589 SizeofTCPRepairOpt = 0x8
562590)
@@ -1724,12 +1752,6 @@ const (
17241752 IFLA_IPVLAN_UNSPEC = 0x0
17251753 IFLA_IPVLAN_MODE = 0x1
17261754 IFLA_IPVLAN_FLAGS = 0x2
1727 NETKIT_NEXT = -0x1
1728 NETKIT_PASS = 0x0
1729 NETKIT_DROP = 0x2
1730 NETKIT_REDIRECT = 0x7
1731 NETKIT_L2 = 0x0
1732 NETKIT_L3 = 0x1
17331755 IFLA_NETKIT_UNSPEC = 0x0
17341756 IFLA_NETKIT_PEER_INFO = 0x1
17351757 IFLA_NETKIT_PRIMARY = 0x2
@@ -1768,6 +1790,7 @@ const (
17681790 IFLA_VXLAN_DF = 0x1d
17691791 IFLA_VXLAN_VNIFILTER = 0x1e
17701792 IFLA_VXLAN_LOCALBYPASS = 0x1f
1793 IFLA_VXLAN_LABEL_POLICY = 0x20
17711794 IFLA_GENEVE_UNSPEC = 0x0
17721795 IFLA_GENEVE_ID = 0x1
17731796 IFLA_GENEVE_REMOTE = 0x2
@@ -1797,6 +1820,8 @@ const (
17971820 IFLA_GTP_ROLE = 0x4
17981821 IFLA_GTP_CREATE_SOCKETS = 0x5
17991822 IFLA_GTP_RESTART_COUNT = 0x6
1823 IFLA_GTP_LOCAL = 0x7
1824 IFLA_GTP_LOCAL6 = 0x8
18001825 IFLA_BOND_UNSPEC = 0x0
18011826 IFLA_BOND_MODE = 0x1
18021827 IFLA_BOND_ACTIVE_SLAVE = 0x2
@@ -1829,6 +1854,7 @@ const (
18291854 IFLA_BOND_AD_LACP_ACTIVE = 0x1d
18301855 IFLA_BOND_MISSED_MAX = 0x1e
18311856 IFLA_BOND_NS_IP6_TARGET = 0x1f
1857 IFLA_BOND_COUPLED_CONTROL = 0x20
18321858 IFLA_BOND_AD_INFO_UNSPEC = 0x0
18331859 IFLA_BOND_AD_INFO_AGGREGATOR = 0x1
18341860 IFLA_BOND_AD_INFO_NUM_PORTS = 0x2
@@ -1897,6 +1923,7 @@ const (
18971923 IFLA_HSR_SEQ_NR = 0x5
18981924 IFLA_HSR_VERSION = 0x6
18991925 IFLA_HSR_PROTOCOL = 0x7
1926 IFLA_HSR_INTERLINK = 0x8
19001927 IFLA_STATS_UNSPEC = 0x0
19011928 IFLA_STATS_LINK_64 = 0x1
19021929 IFLA_STATS_LINK_XSTATS = 0x2
@@ -1949,6 +1976,15 @@ const (
19491976 IFLA_DSA_MASTER = 0x1
19501977)
19511978
1979const (
1980 NETKIT_NEXT = -0x1
1981 NETKIT_PASS = 0x0
1982 NETKIT_DROP = 0x2
1983 NETKIT_REDIRECT = 0x7
1984 NETKIT_L2 = 0x0
1985 NETKIT_L3 = 0x1
1986)
1987
19521988const (
19531989 NF_INET_PRE_ROUTING = 0x0
19541990 NF_INET_LOCAL_IN = 0x1
@@ -2486,7 +2522,7 @@ type XDPMmapOffsets struct {
24862522type XDPUmemReg struct {
24872523 Addr uint64
24882524 Len uint64
2489 Chunk_size uint32
2525 Size uint32
24902526 Headroom uint32
24912527 Flags uint32
24922528 Tx_metadata_len uint32
@@ -2558,8 +2594,8 @@ const (
25582594 SOF_TIMESTAMPING_BIND_PHC = 0x8000
25592595 SOF_TIMESTAMPING_OPT_ID_TCP = 0x10000
25602596
2561 SOF_TIMESTAMPING_LAST = 0x10000
2562 SOF_TIMESTAMPING_MASK = 0x1ffff
2597 SOF_TIMESTAMPING_LAST = 0x20000
2598 SOF_TIMESTAMPING_MASK = 0x3ffff
25632599
25642600 SCM_TSTAMP_SND = 0x0
25652601 SCM_TSTAMP_SCHED = 0x1
@@ -3505,7 +3541,7 @@ type Nhmsg struct {
35053541type NexthopGrp struct {
35063542 Id uint32
35073543 Weight uint8
3508 Resvd1 uint8
3544 High uint8
35093545 Resvd2 uint16
35103546}
35113547
@@ -3766,7 +3802,7 @@ const (
37663802 ETHTOOL_MSG_PSE_GET = 0x24
37673803 ETHTOOL_MSG_PSE_SET = 0x25
37683804 ETHTOOL_MSG_RSS_GET = 0x26
3769 ETHTOOL_MSG_USER_MAX = 0x2b
3805 ETHTOOL_MSG_USER_MAX = 0x2d
37703806 ETHTOOL_MSG_KERNEL_NONE = 0x0
37713807 ETHTOOL_MSG_STRSET_GET_REPLY = 0x1
37723808 ETHTOOL_MSG_LINKINFO_GET_REPLY = 0x2
@@ -3806,7 +3842,7 @@ const (
38063842 ETHTOOL_MSG_MODULE_NTF = 0x24
38073843 ETHTOOL_MSG_PSE_GET_REPLY = 0x25
38083844 ETHTOOL_MSG_RSS_GET_REPLY = 0x26
3809 ETHTOOL_MSG_KERNEL_MAX = 0x2b
3845 ETHTOOL_MSG_KERNEL_MAX = 0x2e
38103846 ETHTOOL_FLAG_COMPACT_BITSETS = 0x1
38113847 ETHTOOL_FLAG_OMIT_REPLY = 0x2
38123848 ETHTOOL_FLAG_STATS = 0x4
@@ -3814,7 +3850,7 @@ const (
38143850 ETHTOOL_A_HEADER_DEV_INDEX = 0x1
38153851 ETHTOOL_A_HEADER_DEV_NAME = 0x2
38163852 ETHTOOL_A_HEADER_FLAGS = 0x3
3817 ETHTOOL_A_HEADER_MAX = 0x3
3853 ETHTOOL_A_HEADER_MAX = 0x4
38183854 ETHTOOL_A_BITSET_BIT_UNSPEC = 0x0
38193855 ETHTOOL_A_BITSET_BIT_INDEX = 0x1
38203856 ETHTOOL_A_BITSET_BIT_NAME = 0x2
@@ -3951,7 +3987,7 @@ const (
39513987 ETHTOOL_A_COALESCE_RATE_SAMPLE_INTERVAL = 0x17
39523988 ETHTOOL_A_COALESCE_USE_CQE_MODE_TX = 0x18
39533989 ETHTOOL_A_COALESCE_USE_CQE_MODE_RX = 0x19
3954 ETHTOOL_A_COALESCE_MAX = 0x1c
3990 ETHTOOL_A_COALESCE_MAX = 0x1e
39553991 ETHTOOL_A_PAUSE_UNSPEC = 0x0
39563992 ETHTOOL_A_PAUSE_HEADER = 0x1
39573993 ETHTOOL_A_PAUSE_AUTONEG = 0x2
@@ -3995,11 +4031,11 @@ const (
39954031 ETHTOOL_A_CABLE_RESULT_UNSPEC = 0x0
39964032 ETHTOOL_A_CABLE_RESULT_PAIR = 0x1
39974033 ETHTOOL_A_CABLE_RESULT_CODE = 0x2
3998 ETHTOOL_A_CABLE_RESULT_MAX = 0x2
4034 ETHTOOL_A_CABLE_RESULT_MAX = 0x3
39994035 ETHTOOL_A_CABLE_FAULT_LENGTH_UNSPEC = 0x0
40004036 ETHTOOL_A_CABLE_FAULT_LENGTH_PAIR = 0x1
40014037 ETHTOOL_A_CABLE_FAULT_LENGTH_CM = 0x2
4002 ETHTOOL_A_CABLE_FAULT_LENGTH_MAX = 0x2
4038 ETHTOOL_A_CABLE_FAULT_LENGTH_MAX = 0x3
40034039 ETHTOOL_A_CABLE_TEST_NTF_STATUS_UNSPEC = 0x0
40044040 ETHTOOL_A_CABLE_TEST_NTF_STATUS_STARTED = 0x1
40054041 ETHTOOL_A_CABLE_TEST_NTF_STATUS_COMPLETED = 0x2
@@ -4082,6 +4118,107 @@ type EthtoolDrvinfo struct {
40824118 Regdump_len uint32
40834119}
40844120
4121type EthtoolTsInfo struct {
4122 Cmd uint32
4123 So_timestamping uint32
4124 Phc_index int32
4125 Tx_types uint32
4126 Tx_reserved [3]uint32
4127 Rx_filters uint32
4128 Rx_reserved [3]uint32
4129}
4130
4131type HwTstampConfig struct {
4132 Flags int32
4133 Tx_type int32
4134 Rx_filter int32
4135}
4136
4137const (
4138 HWTSTAMP_FILTER_NONE = 0x0
4139 HWTSTAMP_FILTER_ALL = 0x1
4140 HWTSTAMP_FILTER_SOME = 0x2
4141 HWTSTAMP_FILTER_PTP_V1_L4_EVENT = 0x3
4142 HWTSTAMP_FILTER_PTP_V2_L4_EVENT = 0x6
4143 HWTSTAMP_FILTER_PTP_V2_L2_EVENT = 0x9
4144 HWTSTAMP_FILTER_PTP_V2_EVENT = 0xc
4145)
4146
4147const (
4148 HWTSTAMP_TX_OFF = 0x0
4149 HWTSTAMP_TX_ON = 0x1
4150 HWTSTAMP_TX_ONESTEP_SYNC = 0x2
4151)
4152
4153type (
4154 PtpClockCaps struct {
4155 Max_adj int32
4156 N_alarm int32
4157 N_ext_ts int32
4158 N_per_out int32
4159 Pps int32
4160 N_pins int32
4161 Cross_timestamping int32
4162 Adjust_phase int32
4163 Max_phase_adj int32
4164 Rsv [11]int32
4165 }
4166 PtpClockTime struct {
4167 Sec int64
4168 Nsec uint32
4169 Reserved uint32
4170 }
4171 PtpExttsEvent struct {
4172 T PtpClockTime
4173 Index uint32
4174 Flags uint32
4175 Rsv [2]uint32
4176 }
4177 PtpExttsRequest struct {
4178 Index uint32
4179 Flags uint32
4180 Rsv [2]uint32
4181 }
4182 PtpPeroutRequest struct {
4183 StartOrPhase PtpClockTime
4184 Period PtpClockTime
4185 Index uint32
4186 Flags uint32
4187 On PtpClockTime
4188 }
4189 PtpPinDesc struct {
4190 Name [64]byte
4191 Index uint32
4192 Func uint32
4193 Chan uint32
4194 Rsv [5]uint32
4195 }
4196 PtpSysOffset struct {
4197 Samples uint32
4198 Rsv [3]uint32
4199 Ts [51]PtpClockTime
4200 }
4201 PtpSysOffsetExtended struct {
4202 Samples uint32
4203 Clockid int32
4204 Rsv [2]uint32
4205 Ts [25][3]PtpClockTime
4206 }
4207 PtpSysOffsetPrecise struct {
4208 Device PtpClockTime
4209 Realtime PtpClockTime
4210 Monoraw PtpClockTime
4211 Rsv [4]uint32
4212 }
4213)
4214
4215const (
4216 PTP_PF_NONE = 0x0
4217 PTP_PF_EXTTS = 0x1
4218 PTP_PF_PEROUT = 0x2
4219 PTP_PF_PHYSYNC = 0x3
4220)
4221
40854222type (
40864223 HIDRawReportDescriptor struct {
40874224 Size uint32
@@ -4263,6 +4400,7 @@ const (
42634400type LandlockRulesetAttr struct {
42644401 Access_fs uint64
42654402 Access_net uint64
4403 Scoped uint64
42664404}
42674405
42684406type LandlockPathBeneathAttr struct {
@@ -4609,7 +4747,7 @@ const (
46094747 NL80211_ATTR_MAC_HINT = 0xc8
46104748 NL80211_ATTR_MAC_MASK = 0xd7
46114749 NL80211_ATTR_MAX_AP_ASSOC_STA = 0xca
4612 NL80211_ATTR_MAX = 0x14a
4750 NL80211_ATTR_MAX = 0x14d
46134751 NL80211_ATTR_MAX_CRIT_PROT_DURATION = 0xb4
46144752 NL80211_ATTR_MAX_CSA_COUNTERS = 0xce
46154753 NL80211_ATTR_MAX_MATCH_SETS = 0x85
@@ -5213,7 +5351,7 @@ const (
52135351 NL80211_FREQUENCY_ATTR_GO_CONCURRENT = 0xf
52145352 NL80211_FREQUENCY_ATTR_INDOOR_ONLY = 0xe
52155353 NL80211_FREQUENCY_ATTR_IR_CONCURRENT = 0xf
5216 NL80211_FREQUENCY_ATTR_MAX = 0x20
5354 NL80211_FREQUENCY_ATTR_MAX = 0x21
52175355 NL80211_FREQUENCY_ATTR_MAX_TX_POWER = 0x6
52185356 NL80211_FREQUENCY_ATTR_NO_10MHZ = 0x11
52195357 NL80211_FREQUENCY_ATTR_NO_160MHZ = 0xc
@@ -5381,7 +5519,7 @@ const (
53815519 NL80211_MNTR_FLAG_CONTROL = 0x3
53825520 NL80211_MNTR_FLAG_COOK_FRAMES = 0x5
53835521 NL80211_MNTR_FLAG_FCSFAIL = 0x1
5384 NL80211_MNTR_FLAG_MAX = 0x6
5522 NL80211_MNTR_FLAG_MAX = 0x7
53855523 NL80211_MNTR_FLAG_OTHER_BSS = 0x4
53865524 NL80211_MNTR_FLAG_PLCPFAIL = 0x2
53875525 NL80211_MPATH_FLAG_ACTIVE = 0x1
@@ -6036,3 +6174,5 @@ type SockDiagReq struct {
60366174 Family uint8
60376175 Protocol uint8
60386176}
6177
6178const RTM_NEWNVLAN = 0x70
vendor/golang.org/x/sys/unix/ztypes_linux_riscv64.go +33
@@ -727,6 +727,37 @@ const (
727727 RISCV_HWPROBE_EXT_ZBA = 0x8
728728 RISCV_HWPROBE_EXT_ZBB = 0x10
729729 RISCV_HWPROBE_EXT_ZBS = 0x20
730 RISCV_HWPROBE_EXT_ZICBOZ = 0x40
731 RISCV_HWPROBE_EXT_ZBC = 0x80
732 RISCV_HWPROBE_EXT_ZBKB = 0x100
733 RISCV_HWPROBE_EXT_ZBKC = 0x200
734 RISCV_HWPROBE_EXT_ZBKX = 0x400
735 RISCV_HWPROBE_EXT_ZKND = 0x800
736 RISCV_HWPROBE_EXT_ZKNE = 0x1000
737 RISCV_HWPROBE_EXT_ZKNH = 0x2000
738 RISCV_HWPROBE_EXT_ZKSED = 0x4000
739 RISCV_HWPROBE_EXT_ZKSH = 0x8000
740 RISCV_HWPROBE_EXT_ZKT = 0x10000
741 RISCV_HWPROBE_EXT_ZVBB = 0x20000
742 RISCV_HWPROBE_EXT_ZVBC = 0x40000
743 RISCV_HWPROBE_EXT_ZVKB = 0x80000
744 RISCV_HWPROBE_EXT_ZVKG = 0x100000
745 RISCV_HWPROBE_EXT_ZVKNED = 0x200000
746 RISCV_HWPROBE_EXT_ZVKNHA = 0x400000
747 RISCV_HWPROBE_EXT_ZVKNHB = 0x800000
748 RISCV_HWPROBE_EXT_ZVKSED = 0x1000000
749 RISCV_HWPROBE_EXT_ZVKSH = 0x2000000
750 RISCV_HWPROBE_EXT_ZVKT = 0x4000000
751 RISCV_HWPROBE_EXT_ZFH = 0x8000000
752 RISCV_HWPROBE_EXT_ZFHMIN = 0x10000000
753 RISCV_HWPROBE_EXT_ZIHINTNTL = 0x20000000
754 RISCV_HWPROBE_EXT_ZVFH = 0x40000000
755 RISCV_HWPROBE_EXT_ZVFHMIN = 0x80000000
756 RISCV_HWPROBE_EXT_ZFA = 0x100000000
757 RISCV_HWPROBE_EXT_ZTSO = 0x200000000
758 RISCV_HWPROBE_EXT_ZACAS = 0x400000000
759 RISCV_HWPROBE_EXT_ZICOND = 0x800000000
760 RISCV_HWPROBE_EXT_ZIHINTPAUSE = 0x1000000000
730761 RISCV_HWPROBE_KEY_CPUPERF_0 = 0x5
731762 RISCV_HWPROBE_MISALIGNED_UNKNOWN = 0x0
732763 RISCV_HWPROBE_MISALIGNED_EMULATED = 0x1
@@ -734,4 +765,6 @@ const (
734765 RISCV_HWPROBE_MISALIGNED_FAST = 0x3
735766 RISCV_HWPROBE_MISALIGNED_UNSUPPORTED = 0x4
736767 RISCV_HWPROBE_MISALIGNED_MASK = 0x7
768 RISCV_HWPROBE_KEY_ZICBOZ_BLOCK_SIZE = 0x6
769 RISCV_HWPROBE_WHICH_CPUS = 0x1
737770)
vendor/golang.org/x/sys/unix/ztypes_zos_s390x.go +6
@@ -377,6 +377,12 @@ type Flock_t struct {
377377 Pid int32
378378}
379379
380type F_cnvrt struct {
381 Cvtcmd int32
382 Pccsid int16
383 Fccsid int16
384}
385
380386type Termios struct {
381387 Cflag uint32
382388 Iflag uint32
vendor/golang.org/x/sys/windows/dll_windows.go +6 −7
@@ -43,8 +43,8 @@ type DLL struct {
4343// LoadDLL loads DLL file into memory.
4444//
4545// Warning: using LoadDLL without an absolute path name is subject to
46// DLL preloading attacks. To safely load a system DLL, use LazyDLL
47// with System set to true, or use LoadLibraryEx directly.
46// DLL preloading attacks. To safely load a system DLL, use [NewLazySystemDLL],
47// or use [LoadLibraryEx] directly.
4848func LoadDLL(name string) (dll *DLL, err error) {
4949 namep, err := UTF16PtrFromString(name)
5050 if err != nil {
@@ -65,7 +65,7 @@ func LoadDLL(name string) (dll *DLL, err error) {
6565 return d, nil
6666}
6767
68// MustLoadDLL is like LoadDLL but panics if load operation failes.
68// MustLoadDLL is like LoadDLL but panics if load operation fails.
6969func MustLoadDLL(name string) *DLL {
7070 d, e := LoadDLL(name)
7171 if e != nil {
@@ -271,6 +271,9 @@ func (d *LazyDLL) NewProc(name string) *LazyProc {
271271}
272272
273273// NewLazyDLL creates new LazyDLL associated with DLL file.
274//
275// Warning: using NewLazyDLL without an absolute path name is subject to
276// DLL preloading attacks. To safely load a system DLL, use [NewLazySystemDLL].
274277func NewLazyDLL(name string) *LazyDLL {
275278 return &LazyDLL{Name: name}
276279}
@@ -410,7 +413,3 @@ func loadLibraryEx(name string, system bool) (*DLL, error) {
410413 }
411414 return &DLL{Name: name, Handle: h}, nil
412415}
413
414type errString string
415
416func (s errString) Error() string { return string(s) }
vendor/golang.org/x/sys/windows/syscall_windows.go +23 −17
@@ -168,6 +168,8 @@ func NewCallbackCDecl(fn interface{}) uintptr {
168168//sys CreateNamedPipe(name *uint16, flags uint32, pipeMode uint32, maxInstances uint32, outSize uint32, inSize uint32, defaultTimeout uint32, sa *SecurityAttributes) (handle Handle, err error) [failretval==InvalidHandle] = CreateNamedPipeW
169169//sys ConnectNamedPipe(pipe Handle, overlapped *Overlapped) (err error)
170170//sys DisconnectNamedPipe(pipe Handle) (err error)
171//sys GetNamedPipeClientProcessId(pipe Handle, clientProcessID *uint32) (err error)
172//sys GetNamedPipeServerProcessId(pipe Handle, serverProcessID *uint32) (err error)
171173//sys GetNamedPipeInfo(pipe Handle, flags *uint32, outSize *uint32, inSize *uint32, maxInstances *uint32) (err error)
172174//sys GetNamedPipeHandleState(pipe Handle, state *uint32, curInstances *uint32, maxCollectionCount *uint32, collectDataTimeout *uint32, userName *uint16, maxUserNameSize uint32) (err error) = GetNamedPipeHandleStateW
173175//sys SetNamedPipeHandleState(pipe Handle, state *uint32, maxCollectionCount *uint32, collectDataTimeout *uint32) (err error) = SetNamedPipeHandleState
@@ -313,6 +315,10 @@ func NewCallbackCDecl(fn interface{}) uintptr {
313315//sys SetConsoleMode(console Handle, mode uint32) (err error) = kernel32.SetConsoleMode
314316//sys GetConsoleScreenBufferInfo(console Handle, info *ConsoleScreenBufferInfo) (err error) = kernel32.GetConsoleScreenBufferInfo
315317//sys setConsoleCursorPosition(console Handle, position uint32) (err error) = kernel32.SetConsoleCursorPosition
318//sys GetConsoleCP() (cp uint32, err error) = kernel32.GetConsoleCP
319//sys GetConsoleOutputCP() (cp uint32, err error) = kernel32.GetConsoleOutputCP
320//sys SetConsoleCP(cp uint32) (err error) = kernel32.SetConsoleCP
321//sys SetConsoleOutputCP(cp uint32) (err error) = kernel32.SetConsoleOutputCP
316322//sys WriteConsole(console Handle, buf *uint16, towrite uint32, written *uint32, reserved *byte) (err error) = kernel32.WriteConsoleW
317323//sys ReadConsole(console Handle, buf *uint16, toread uint32, read *uint32, inputControl *byte) (err error) = kernel32.ReadConsoleW
318324//sys resizePseudoConsole(pconsole Handle, size uint32) (hr error) = kernel32.ResizePseudoConsole
@@ -721,20 +727,12 @@ func DurationSinceBoot() time.Duration {
721727}
722728
723729func Ftruncate(fd Handle, length int64) (err error) {
724 curoffset, e := Seek(fd, 0, 1)
725 if e != nil {
726 return e
727 }
728 defer Seek(fd, curoffset, 0)
729 _, e = Seek(fd, length, 0)
730 if e != nil {
731 return e
730 type _FILE_END_OF_FILE_INFO struct {
731 EndOfFile int64
732732 }
733 e = SetEndOfFile(fd)
734 if e != nil {
735 return e
736 }
737 return nil
733 var info _FILE_END_OF_FILE_INFO
734 info.EndOfFile = length
735 return SetFileInformationByHandle(fd, FileEndOfFileInfo, (*byte)(unsafe.Pointer(&info)), uint32(unsafe.Sizeof(info)))
738736}
739737
740738func Gettimeofday(tv *Timeval) (err error) {
@@ -890,6 +888,11 @@ const socket_error = uintptr(^uint32(0))
890888//sys GetACP() (acp uint32) = kernel32.GetACP
891889//sys MultiByteToWideChar(codePage uint32, dwFlags uint32, str *byte, nstr int32, wchar *uint16, nwchar int32) (nwrite int32, err error) = kernel32.MultiByteToWideChar
892890//sys getBestInterfaceEx(sockaddr unsafe.Pointer, pdwBestIfIndex *uint32) (errcode error) = iphlpapi.GetBestInterfaceEx
891//sys GetIfEntry2Ex(level uint32, row *MibIfRow2) (errcode error) = iphlpapi.GetIfEntry2Ex
892//sys GetUnicastIpAddressEntry(row *MibUnicastIpAddressRow) (errcode error) = iphlpapi.GetUnicastIpAddressEntry
893//sys NotifyIpInterfaceChange(family uint16, callback uintptr, callerContext unsafe.Pointer, initialNotification bool, notificationHandle *Handle) (errcode error) = iphlpapi.NotifyIpInterfaceChange
894//sys NotifyUnicastIpAddressChange(family uint16, callback uintptr, callerContext unsafe.Pointer, initialNotification bool, notificationHandle *Handle) (errcode error) = iphlpapi.NotifyUnicastIpAddressChange
895//sys CancelMibChangeNotify2(notificationHandle Handle) (errcode error) = iphlpapi.CancelMibChangeNotify2
893896
894897// For testing: clients can set this flag to force
895898// creation of IPv6 sockets to return EAFNOSUPPORT.
@@ -1681,13 +1684,16 @@ func (s NTStatus) Error() string {
16811684// do not use NTUnicodeString, and instead UTF16PtrFromString should be used for
16821685// the more common *uint16 string type.
16831686func NewNTUnicodeString(s string) (*NTUnicodeString, error) {
1684 var u NTUnicodeString
1685 s16, err := UTF16PtrFromString(s)
1687 s16, err := UTF16FromString(s)
16861688 if err != nil {
16871689 return nil, err
16881690 }
1689 RtlInitUnicodeString(&u, s16)
1690 return &u, nil
1691 n := uint16(len(s16) * 2)
1692 return &NTUnicodeString{
1693 Length: n - 2, // subtract 2 bytes for the NULL terminator
1694 MaximumLength: n,
1695 Buffer: &s16[0],
1696 }, nil
16911697}
16921698
16931699// Slice returns a uint16 slice that aliases the data in the NTUnicodeString.
vendor/golang.org/x/sys/windows/types_windows.go +128
@@ -176,6 +176,7 @@ const (
176176 WAIT_FAILED = 0xFFFFFFFF
177177
178178 // Access rights for process.
179 PROCESS_ALL_ACCESS = 0xFFFF
179180 PROCESS_CREATE_PROCESS = 0x0080
180181 PROCESS_CREATE_THREAD = 0x0002
181182 PROCESS_DUP_HANDLE = 0x0040
@@ -1060,6 +1061,7 @@ const (
10601061 SIO_GET_EXTENSION_FUNCTION_POINTER = IOC_INOUT | IOC_WS2 | 6
10611062 SIO_KEEPALIVE_VALS = IOC_IN | IOC_VENDOR | 4
10621063 SIO_UDP_CONNRESET = IOC_IN | IOC_VENDOR | 12
1064 SIO_UDP_NETRESET = IOC_IN | IOC_VENDOR | 15
10631065
10641066 // cf. http://support.microsoft.com/default.aspx?scid=kb;en-us;257460
10651067
@@ -2202,6 +2204,132 @@ const (
22022204 IfOperStatusLowerLayerDown = 7
22032205)
22042206
2207const (
2208 IF_MAX_PHYS_ADDRESS_LENGTH = 32
2209 IF_MAX_STRING_SIZE = 256
2210)
2211
2212// MIB_IF_ENTRY_LEVEL enumeration from netioapi.h or
2213// https://learn.microsoft.com/en-us/windows/win32/api/netioapi/nf-netioapi-getifentry2ex.
2214const (
2215 MibIfEntryNormal = 0
2216 MibIfEntryNormalWithoutStatistics = 2
2217)
2218
2219// MIB_NOTIFICATION_TYPE enumeration from netioapi.h or
2220// https://learn.microsoft.com/en-us/windows/win32/api/netioapi/ne-netioapi-mib_notification_type.
2221const (
2222 MibParameterNotification = 0
2223 MibAddInstance = 1
2224 MibDeleteInstance = 2
2225 MibInitialNotification = 3
2226)
2227
2228// MibIfRow2 stores information about a particular interface. See
2229// https://learn.microsoft.com/en-us/windows/win32/api/netioapi/ns-netioapi-mib_if_row2.
2230type MibIfRow2 struct {
2231 InterfaceLuid uint64
2232 InterfaceIndex uint32
2233 InterfaceGuid GUID
2234 Alias [IF_MAX_STRING_SIZE + 1]uint16
2235 Description [IF_MAX_STRING_SIZE + 1]uint16
2236 PhysicalAddressLength uint32
2237 PhysicalAddress [IF_MAX_PHYS_ADDRESS_LENGTH]uint8
2238 PermanentPhysicalAddress [IF_MAX_PHYS_ADDRESS_LENGTH]uint8
2239 Mtu uint32
2240 Type uint32
2241 TunnelType uint32
2242 MediaType uint32
2243 PhysicalMediumType uint32
2244 AccessType uint32
2245 DirectionType uint32
2246 InterfaceAndOperStatusFlags uint8
2247 OperStatus uint32
2248 AdminStatus uint32
2249 MediaConnectState uint32
2250 NetworkGuid GUID
2251 ConnectionType uint32
2252 TransmitLinkSpeed uint64
2253 ReceiveLinkSpeed uint64
2254 InOctets uint64
2255 InUcastPkts uint64
2256 InNUcastPkts uint64
2257 InDiscards uint64
2258 InErrors uint64
2259 InUnknownProtos uint64
2260 InUcastOctets uint64
2261 InMulticastOctets uint64
2262 InBroadcastOctets uint64
2263 OutOctets uint64
2264 OutUcastPkts uint64
2265 OutNUcastPkts uint64
2266 OutDiscards uint64
2267 OutErrors uint64
2268 OutUcastOctets uint64
2269 OutMulticastOctets uint64
2270 OutBroadcastOctets uint64
2271 OutQLen uint64
2272}
2273
2274// MIB_UNICASTIPADDRESS_ROW stores information about a unicast IP address. See
2275// https://learn.microsoft.com/en-us/windows/win32/api/netioapi/ns-netioapi-mib_unicastipaddress_row.
2276type MibUnicastIpAddressRow struct {
2277 Address RawSockaddrInet6 // SOCKADDR_INET union
2278 InterfaceLuid uint64
2279 InterfaceIndex uint32
2280 PrefixOrigin uint32
2281 SuffixOrigin uint32
2282 ValidLifetime uint32
2283 PreferredLifetime uint32
2284 OnLinkPrefixLength uint8
2285 SkipAsSource uint8
2286 DadState uint32
2287 ScopeId uint32
2288 CreationTimeStamp Filetime
2289}
2290
2291const ScopeLevelCount = 16
2292
2293// MIB_IPINTERFACE_ROW stores interface management information for a particular IP address family on a network interface.
2294// See https://learn.microsoft.com/en-us/windows/win32/api/netioapi/ns-netioapi-mib_ipinterface_row.
2295type MibIpInterfaceRow struct {
2296 Family uint16
2297 InterfaceLuid uint64
2298 InterfaceIndex uint32
2299 MaxReassemblySize uint32
2300 InterfaceIdentifier uint64
2301 MinRouterAdvertisementInterval uint32
2302 MaxRouterAdvertisementInterval uint32
2303 AdvertisingEnabled uint8
2304 ForwardingEnabled uint8
2305 WeakHostSend uint8
2306 WeakHostReceive uint8
2307 UseAutomaticMetric uint8
2308 UseNeighborUnreachabilityDetection uint8
2309 ManagedAddressConfigurationSupported uint8
2310 OtherStatefulConfigurationSupported uint8
2311 AdvertiseDefaultRoute uint8
2312 RouterDiscoveryBehavior uint32
2313 DadTransmits uint32
2314 BaseReachableTime uint32
2315 RetransmitTime uint32
2316 PathMtuDiscoveryTimeout uint32
2317 LinkLocalAddressBehavior uint32
2318 LinkLocalAddressTimeout uint32
2319 ZoneIndices [ScopeLevelCount]uint32
2320 SitePrefixLength uint32
2321 Metric uint32
2322 NlMtu uint32
2323 Connected uint8
2324 SupportsWakeUpPatterns uint8
2325 SupportsNeighborDiscovery uint8
2326 SupportsRouterDiscovery uint8
2327 ReachableTime uint32
2328 TransmitOffload uint32
2329 ReceiveOffload uint32
2330 DisableDefaultRoutes uint8
2331}
2332
22052333// Console related constants used for the mode parameter to SetConsoleMode. See
22062334// https://docs.microsoft.com/en-us/windows/console/setconsolemode for details.
22072335
vendor/golang.org/x/sys/windows/zsyscall_windows.go +109
@@ -181,10 +181,15 @@ var (
181181 procDnsRecordListFree = moddnsapi.NewProc("DnsRecordListFree")
182182 procDwmGetWindowAttribute = moddwmapi.NewProc("DwmGetWindowAttribute")
183183 procDwmSetWindowAttribute = moddwmapi.NewProc("DwmSetWindowAttribute")
184 procCancelMibChangeNotify2 = modiphlpapi.NewProc("CancelMibChangeNotify2")
184185 procGetAdaptersAddresses = modiphlpapi.NewProc("GetAdaptersAddresses")
185186 procGetAdaptersInfo = modiphlpapi.NewProc("GetAdaptersInfo")
186187 procGetBestInterfaceEx = modiphlpapi.NewProc("GetBestInterfaceEx")
187188 procGetIfEntry = modiphlpapi.NewProc("GetIfEntry")
189 procGetIfEntry2Ex = modiphlpapi.NewProc("GetIfEntry2Ex")
190 procGetUnicastIpAddressEntry = modiphlpapi.NewProc("GetUnicastIpAddressEntry")
191 procNotifyIpInterfaceChange = modiphlpapi.NewProc("NotifyIpInterfaceChange")
192 procNotifyUnicastIpAddressChange = modiphlpapi.NewProc("NotifyUnicastIpAddressChange")
188193 procAddDllDirectory = modkernel32.NewProc("AddDllDirectory")
189194 procAssignProcessToJobObject = modkernel32.NewProc("AssignProcessToJobObject")
190195 procCancelIo = modkernel32.NewProc("CancelIo")
@@ -247,7 +252,9 @@ var (
247252 procGetCommandLineW = modkernel32.NewProc("GetCommandLineW")
248253 procGetComputerNameExW = modkernel32.NewProc("GetComputerNameExW")
249254 procGetComputerNameW = modkernel32.NewProc("GetComputerNameW")
255 procGetConsoleCP = modkernel32.NewProc("GetConsoleCP")
250256 procGetConsoleMode = modkernel32.NewProc("GetConsoleMode")
257 procGetConsoleOutputCP = modkernel32.NewProc("GetConsoleOutputCP")
251258 procGetConsoleScreenBufferInfo = modkernel32.NewProc("GetConsoleScreenBufferInfo")
252259 procGetCurrentDirectoryW = modkernel32.NewProc("GetCurrentDirectoryW")
253260 procGetCurrentProcessId = modkernel32.NewProc("GetCurrentProcessId")
@@ -273,8 +280,10 @@ var (
273280 procGetMaximumProcessorCount = modkernel32.NewProc("GetMaximumProcessorCount")
274281 procGetModuleFileNameW = modkernel32.NewProc("GetModuleFileNameW")
275282 procGetModuleHandleExW = modkernel32.NewProc("GetModuleHandleExW")
283 procGetNamedPipeClientProcessId = modkernel32.NewProc("GetNamedPipeClientProcessId")
276284 procGetNamedPipeHandleStateW = modkernel32.NewProc("GetNamedPipeHandleStateW")
277285 procGetNamedPipeInfo = modkernel32.NewProc("GetNamedPipeInfo")
286 procGetNamedPipeServerProcessId = modkernel32.NewProc("GetNamedPipeServerProcessId")
278287 procGetOverlappedResult = modkernel32.NewProc("GetOverlappedResult")
279288 procGetPriorityClass = modkernel32.NewProc("GetPriorityClass")
280289 procGetProcAddress = modkernel32.NewProc("GetProcAddress")
@@ -347,8 +356,10 @@ var (
347356 procSetCommMask = modkernel32.NewProc("SetCommMask")
348357 procSetCommState = modkernel32.NewProc("SetCommState")
349358 procSetCommTimeouts = modkernel32.NewProc("SetCommTimeouts")
359 procSetConsoleCP = modkernel32.NewProc("SetConsoleCP")
350360 procSetConsoleCursorPosition = modkernel32.NewProc("SetConsoleCursorPosition")
351361 procSetConsoleMode = modkernel32.NewProc("SetConsoleMode")
362 procSetConsoleOutputCP = modkernel32.NewProc("SetConsoleOutputCP")
352363 procSetCurrentDirectoryW = modkernel32.NewProc("SetCurrentDirectoryW")
353364 procSetDefaultDllDirectories = modkernel32.NewProc("SetDefaultDllDirectories")
354365 procSetDllDirectoryW = modkernel32.NewProc("SetDllDirectoryW")
@@ -1602,6 +1613,14 @@ func DwmSetWindowAttribute(hwnd HWND, attribute uint32, value unsafe.Pointer, si
16021613 return
16031614}
16041615
1616func CancelMibChangeNotify2(notificationHandle Handle) (errcode error) {
1617 r0, _, _ := syscall.Syscall(procCancelMibChangeNotify2.Addr(), 1, uintptr(notificationHandle), 0, 0)
1618 if r0 != 0 {
1619 errcode = syscall.Errno(r0)
1620 }
1621 return
1622}
1623
16051624func GetAdaptersAddresses(family uint32, flags uint32, reserved uintptr, adapterAddresses *IpAdapterAddresses, sizePointer *uint32) (errcode error) {
16061625 r0, _, _ := syscall.Syscall6(procGetAdaptersAddresses.Addr(), 5, uintptr(family), uintptr(flags), uintptr(reserved), uintptr(unsafe.Pointer(adapterAddresses)), uintptr(unsafe.Pointer(sizePointer)), 0)
16071626 if r0 != 0 {
@@ -1634,6 +1653,46 @@ func GetIfEntry(pIfRow *MibIfRow) (errcode error) {
16341653 return
16351654}
16361655
1656func GetIfEntry2Ex(level uint32, row *MibIfRow2) (errcode error) {
1657 r0, _, _ := syscall.Syscall(procGetIfEntry2Ex.Addr(), 2, uintptr(level), uintptr(unsafe.Pointer(row)), 0)
1658 if r0 != 0 {
1659 errcode = syscall.Errno(r0)
1660 }
1661 return
1662}
1663
1664func GetUnicastIpAddressEntry(row *MibUnicastIpAddressRow) (errcode error) {
1665 r0, _, _ := syscall.Syscall(procGetUnicastIpAddressEntry.Addr(), 1, uintptr(unsafe.Pointer(row)), 0, 0)
1666 if r0 != 0 {
1667 errcode = syscall.Errno(r0)
1668 }
1669 return
1670}
1671
1672func NotifyIpInterfaceChange(family uint16, callback uintptr, callerContext unsafe.Pointer, initialNotification bool, notificationHandle *Handle) (errcode error) {
1673 var _p0 uint32
1674 if initialNotification {
1675 _p0 = 1
1676 }
1677 r0, _, _ := syscall.Syscall6(procNotifyIpInterfaceChange.Addr(), 5, uintptr(family), uintptr(callback), uintptr(callerContext), uintptr(_p0), uintptr(unsafe.Pointer(notificationHandle)), 0)
1678 if r0 != 0 {
1679 errcode = syscall.Errno(r0)
1680 }
1681 return
1682}
1683
1684func NotifyUnicastIpAddressChange(family uint16, callback uintptr, callerContext unsafe.Pointer, initialNotification bool, notificationHandle *Handle) (errcode error) {
1685 var _p0 uint32
1686 if initialNotification {
1687 _p0 = 1
1688 }
1689 r0, _, _ := syscall.Syscall6(procNotifyUnicastIpAddressChange.Addr(), 5, uintptr(family), uintptr(callback), uintptr(callerContext), uintptr(_p0), uintptr(unsafe.Pointer(notificationHandle)), 0)
1690 if r0 != 0 {
1691 errcode = syscall.Errno(r0)
1692 }
1693 return
1694}
1695
16371696func AddDllDirectory(path *uint16) (cookie uintptr, err error) {
16381697 r0, _, e1 := syscall.Syscall(procAddDllDirectory.Addr(), 1, uintptr(unsafe.Pointer(path)), 0, 0)
16391698 cookie = uintptr(r0)
@@ -2162,6 +2221,15 @@ func GetComputerName(buf *uint16, n *uint32) (err error) {
21622221 return
21632222}
21642223
2224func GetConsoleCP() (cp uint32, err error) {
2225 r0, _, e1 := syscall.Syscall(procGetConsoleCP.Addr(), 0, 0, 0, 0)
2226 cp = uint32(r0)
2227 if cp == 0 {
2228 err = errnoErr(e1)
2229 }
2230 return
2231}
2232
21652233func GetConsoleMode(console Handle, mode *uint32) (err error) {
21662234 r1, _, e1 := syscall.Syscall(procGetConsoleMode.Addr(), 2, uintptr(console), uintptr(unsafe.Pointer(mode)), 0)
21672235 if r1 == 0 {
@@ -2170,6 +2238,15 @@ func GetConsoleMode(console Handle, mode *uint32) (err error) {
21702238 return
21712239}
21722240
2241func GetConsoleOutputCP() (cp uint32, err error) {
2242 r0, _, e1 := syscall.Syscall(procGetConsoleOutputCP.Addr(), 0, 0, 0, 0)
2243 cp = uint32(r0)
2244 if cp == 0 {
2245 err = errnoErr(e1)
2246 }
2247 return
2248}
2249
21732250func GetConsoleScreenBufferInfo(console Handle, info *ConsoleScreenBufferInfo) (err error) {
21742251 r1, _, e1 := syscall.Syscall(procGetConsoleScreenBufferInfo.Addr(), 2, uintptr(console), uintptr(unsafe.Pointer(info)), 0)
21752252 if r1 == 0 {
@@ -2371,6 +2448,14 @@ func GetModuleHandleEx(flags uint32, moduleName *uint16, module *Handle) (err er
23712448 return
23722449}
23732450
2451func GetNamedPipeClientProcessId(pipe Handle, clientProcessID *uint32) (err error) {
2452 r1, _, e1 := syscall.Syscall(procGetNamedPipeClientProcessId.Addr(), 2, uintptr(pipe), uintptr(unsafe.Pointer(clientProcessID)), 0)
2453 if r1 == 0 {
2454 err = errnoErr(e1)
2455 }
2456 return
2457}
2458
23742459func GetNamedPipeHandleState(pipe Handle, state *uint32, curInstances *uint32, maxCollectionCount *uint32, collectDataTimeout *uint32, userName *uint16, maxUserNameSize uint32) (err error) {
23752460 r1, _, e1 := syscall.Syscall9(procGetNamedPipeHandleStateW.Addr(), 7, uintptr(pipe), uintptr(unsafe.Pointer(state)), uintptr(unsafe.Pointer(curInstances)), uintptr(unsafe.Pointer(maxCollectionCount)), uintptr(unsafe.Pointer(collectDataTimeout)), uintptr(unsafe.Pointer(userName)), uintptr(maxUserNameSize), 0, 0)
23762461 if r1 == 0 {
@@ -2387,6 +2472,14 @@ func GetNamedPipeInfo(pipe Handle, flags *uint32, outSize *uint32, inSize *uint3
23872472 return
23882473}
23892474
2475func GetNamedPipeServerProcessId(pipe Handle, serverProcessID *uint32) (err error) {
2476 r1, _, e1 := syscall.Syscall(procGetNamedPipeServerProcessId.Addr(), 2, uintptr(pipe), uintptr(unsafe.Pointer(serverProcessID)), 0)
2477 if r1 == 0 {
2478 err = errnoErr(e1)
2479 }
2480 return
2481}
2482
23902483func GetOverlappedResult(handle Handle, overlapped *Overlapped, done *uint32, wait bool) (err error) {
23912484 var _p0 uint32
23922485 if wait {
@@ -3038,6 +3131,14 @@ func SetCommTimeouts(handle Handle, timeouts *CommTimeouts) (err error) {
30383131 return
30393132}
30403133
3134func SetConsoleCP(cp uint32) (err error) {
3135 r1, _, e1 := syscall.Syscall(procSetConsoleCP.Addr(), 1, uintptr(cp), 0, 0)
3136 if r1 == 0 {
3137 err = errnoErr(e1)
3138 }
3139 return
3140}
3141
30413142func setConsoleCursorPosition(console Handle, position uint32) (err error) {
30423143 r1, _, e1 := syscall.Syscall(procSetConsoleCursorPosition.Addr(), 2, uintptr(console), uintptr(position), 0)
30433144 if r1 == 0 {
@@ -3054,6 +3155,14 @@ func SetConsoleMode(console Handle, mode uint32) (err error) {
30543155 return
30553156}
30563157
3158func SetConsoleOutputCP(cp uint32) (err error) {
3159 r1, _, e1 := syscall.Syscall(procSetConsoleOutputCP.Addr(), 1, uintptr(cp), 0, 0)
3160 if r1 == 0 {
3161 err = errnoErr(e1)
3162 }
3163 return
3164}
3165
30573166func SetCurrentDirectory(path *uint16) (err error) {
30583167 r1, _, e1 := syscall.Syscall(procSetCurrentDirectoryW.Addr(), 1, uintptr(unsafe.Pointer(path)), 0, 0)
30593168 if r1 == 0 {
vendor/modules.txt +14 −13
@@ -8,17 +8,18 @@ github.com/Microsoft/go-winio/pkg/guid
88# github.com/aymanbagabas/go-osc52/v2 v2.0.1
99## explicit; go 1.16
1010github.com/aymanbagabas/go-osc52/v2
11# github.com/charmbracelet/bubbletea v1.1.1
11# github.com/charmbracelet/bubbletea v1.3.3
1212## explicit; go 1.18
1313github.com/charmbracelet/bubbletea
14# github.com/charmbracelet/lipgloss v0.13.0
14# github.com/charmbracelet/lipgloss v1.0.0
1515## explicit; go 1.18
1616github.com/charmbracelet/lipgloss
17# github.com/charmbracelet/x/ansi v0.2.3
17# github.com/charmbracelet/x/ansi v0.8.0
1818## explicit; go 1.18
1919github.com/charmbracelet/x/ansi
20github.com/charmbracelet/x/ansi/kitty
2021github.com/charmbracelet/x/ansi/parser
21# github.com/charmbracelet/x/term v0.2.0
22# github.com/charmbracelet/x/term v0.2.1
2223## explicit; go 1.18
2324github.com/charmbracelet/x/term
2425# github.com/erikgeiser/coninput v0.0.0-20211004153227-1c3628e74d0f
@@ -33,10 +34,6 @@ github.com/go-toast/toast
3334# github.com/godbus/dbus/v5 v5.1.0
3435## explicit; go 1.12
3536github.com/godbus/dbus/v5
36# github.com/hugolgst/rich-go v0.0.0-20240715122152-74618cc1ace2
37## explicit; go 1.17
38github.com/hugolgst/rich-go/client
39github.com/hugolgst/rich-go/ipc
4037# github.com/lucasb-eyer/go-colorful v1.2.0
4138## explicit; go 1.12
4239github.com/lucasb-eyer/go-colorful
@@ -46,7 +43,7 @@ github.com/mattn/go-isatty
4643# github.com/mattn/go-localereader v0.0.1
4744## explicit
4845github.com/mattn/go-localereader
49# github.com/mattn/go-runewidth v0.0.15
46# github.com/mattn/go-runewidth v0.0.16
5047## explicit; go 1.9
5148github.com/mattn/go-runewidth
5249# github.com/muesli/ansi v0.0.0-20230316100256-276c6243b2f6
@@ -68,16 +65,20 @@ github.com/rivo/uniseg
6865# github.com/tadvi/systray v0.0.0-20190226123456-11a2b8fa57af
6966## explicit
7067github.com/tadvi/systray
71# golang.org/x/sync v0.8.0
68# github.com/wraient/rich-go v0.0.0-20250215175626-21ded92fb65a
69## explicit; go 1.24.0
70github.com/wraient/rich-go/client
71github.com/wraient/rich-go/ipc
72# golang.org/x/sync v0.11.0
7273## explicit; go 1.18
7374golang.org/x/sync/errgroup
74# golang.org/x/sys v0.24.0
75# golang.org/x/sys v0.30.0
7576## explicit; go 1.18
7677golang.org/x/sys/unix
7778golang.org/x/sys/windows
7879golang.org/x/sys/windows/registry
79# golang.org/x/text v0.14.0
80## explicit; go 1.18
80# golang.org/x/text v0.3.8
81## explicit; go 1.17
8182golang.org/x/text/transform
8283# gopkg.in/natefinch/npipe.v2 v2.0.0-20160621034901-c1b8fa8bdcce
8384## explicit