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 @@
1run: 1run:
2 tests: false 2 tests: false
3 issues-exit-code: 0
3 4
4issues: 5issues:
5 include: 6 include:
@@ -14,16 +15,13 @@ issues:
14 15
15linters: 16linters:
16 enable: 17 enable:
17 # - dupl
18 - exhaustive 18 - exhaustive
19 # - exhaustivestruct
20 - goconst 19 - goconst
21 - godot 20 - godot
22 - godox 21 - godox
23 - gomnd 22 - mnd
24 - gomoddirectives 23 - gomoddirectives
25 - goprintffuncname 24 - goprintffuncname
26 # - lll
27 - misspell 25 - misspell
28 - nakedret 26 - nakedret
29 - nestif 27 - nestif
@@ -34,13 +32,9 @@ linters:
34 32
35 # disable default linters, they are already enabled in .golangci.yml 33 # disable default linters, they are already enabled in .golangci.yml
36 disable: 34 disable:
37 - deadcode
38 - errcheck 35 - errcheck
39 - gosimple 36 - gosimple
40 - govet 37 - govet
41 - ineffassign 38 - ineffassign
42 - staticcheck 39 - staticcheck
43 - structcheck
44 - typecheck
45 - unused 40 - unused
46 - varcheck
vendor/github.com/charmbracelet/bubbletea/.golangci.yml −2
@@ -15,12 +15,10 @@ issues:
15linters: 15linters:
16 enable: 16 enable:
17 - bodyclose 17 - bodyclose
18 - exportloopref
19 - gofumpt 18 - gofumpt
20 - goimports 19 - goimports
21 - gosec 20 - gosec
22 - nilerr 21 - nilerr
23 - predeclared
24 - revive 22 - revive
25 - rowserrcheck 23 - rowserrcheck
26 - sqlclosecheck 24 - 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
1includes: 3includes:
2 - from_url: 4 - from_url:
3 url: charmbracelet/meta/main/goreleaser-lib.yaml 5 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) {
57func (r *conInputReader) Cancel() bool { 57func (r *conInputReader) Cancel() bool {
58 r.setCanceled() 58 r.setCanceled()
59 59
60 return windows.CancelIo(r.conin) == nil 60 return windows.CancelIoEx(r.conin, nil) == nil || windows.CancelIo(r.conin) == nil
61} 61}
62 62
63// Close implements cancelreader.CancelReader. 63// Close implements cancelreader.CancelReader.
@@ -73,8 +73,11 @@ func (r *conInputReader) Close() error {
73} 73}
74 74
75// Read implements cancelreader.CancelReader. 75// Read implements cancelreader.CancelReader.
76func (*conInputReader) Read(_ []byte) (n int, err error) { 76func (r *conInputReader) Read(_ []byte) (n int, err error) {
77 return 0, nil 77 if r.isCanceled() {
78 err = cancelreader.ErrCanceled
79 }
80 return
78} 81}
79 82
80func prepareConsole(input windows.Handle, modes ...uint32) (originalMode uint32, err error) { 83func prepareConsole(input windows.Handle, modes ...uint32) (originalMode uint32, err error) {
@@ -105,3 +108,10 @@ func (c *cancelMixin) setCanceled() {
105 108
106 c.unsafeCanceled = true 109 c.unsafeCanceled = true
107} 110}
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 (
10 10
11 "github.com/erikgeiser/coninput" 11 "github.com/erikgeiser/coninput"
12 localereader "github.com/mattn/go-localereader" 12 localereader "github.com/mattn/go-localereader"
13 "golang.org/x/sys/windows" 13 "github.com/muesli/cancelreader"
14) 14)
15 15
16func readInputs(ctx context.Context, msgs chan<- Msg, input io.Reader) error { 16func readInputs(ctx context.Context, msgs chan<- Msg, input io.Reader) error {
17 if coninReader, ok := input.(*conInputReader); ok { 17 if coninReader, ok := input.(*conInputReader); ok {
18 return readConInputs(ctx, msgs, coninReader.conin) 18 return readConInputs(ctx, msgs, coninReader)
19 } 19 }
20 20
21 return readAnsiInputs(ctx, msgs, localereader.NewReader(input)) 21 return readAnsiInputs(ctx, msgs, localereader.NewReader(input))
22} 22}
23 23
24func readConInputs(ctx context.Context, msgsch chan<- Msg, con windows.Handle) error { 24func readConInputs(ctx context.Context, msgsch chan<- Msg, con *conInputReader) error {
25 var ps coninput.ButtonState // keep track of previous mouse state 25 var ps coninput.ButtonState // keep track of previous mouse state
26 var ws coninput.WindowBufferSizeEventRecord // keep track of the last window size event 26 var ws coninput.WindowBufferSizeEventRecord // keep track of the last window size event
27 for { 27 for {
28 events, err := coninput.ReadNConsoleInputs(con, 16) 28 events, err := coninput.ReadNConsoleInputs(con.conin, 16)
29 if err != nil { 29 if err != nil {
30 if con.isCanceled() {
31 return cancelreader.ErrCanceled
32 }
30 return fmt.Errorf("read coninput events: %w", err) 33 return fmt.Errorf("read coninput events: %w", err)
31 } 34 }
32 35
@@ -274,7 +277,11 @@ func keyType(e coninput.KeyEventRecord) KeyType {
274 case coninput.VK_DELETE: 277 case coninput.VK_DELETE:
275 return KeyDelete 278 return KeyDelete
276 default: 279 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):
278 return KeyRunes 285 return KeyRunes
279 } 286 }
280 287
@@ -334,7 +341,7 @@ func keyType(e coninput.KeyEventRecord) KeyType {
334 case '\x1a': 341 case '\x1a':
335 return KeyCtrlZ 342 return KeyCtrlZ
336 case '\x1b': 343 case '\x1b':
337 return KeyCtrlCloseBracket 344 return KeyCtrlOpenBracket // KeyEscape
338 case '\x1c': 345 case '\x1c':
339 return KeyCtrlBackslash 346 return KeyCtrlBackslash
340 case '\x1f': 347 case '\x1f':
@@ -344,6 +351,8 @@ func keyType(e coninput.KeyEventRecord) KeyType {
344 switch code { 351 switch code {
345 case coninput.VK_OEM_4: 352 case coninput.VK_OEM_4:
346 return KeyCtrlOpenBracket 353 return KeyCtrlOpenBracket
354 case coninput.VK_OEM_6:
355 return KeyCtrlCloseBracket
347 } 356 }
348 357
349 return KeyRunes 358 return KeyRunes
vendor/github.com/charmbracelet/bubbletea/options.go +3
@@ -185,6 +185,9 @@ func WithoutRenderer() ProgramOption {
185// 185//
186// This feature is provisional, and may be changed or removed in a future version 186// This feature is provisional, and may be changed or removed in a future version
187// of this package. 187// of this package.
188//
189// Deprecated: this incurs a noticeable performance hit. A future release will
190// optimize ANSI automatically without the performance penalty.
188func WithANSICompressor() ProgramOption { 191func WithANSICompressor() ProgramOption {
189 return func(p *Program) { 192 return func(p *Program) {
190 p.startupOptions |= withANSICompressor 193 p.startupOptions |= withANSICompressor
vendor/github.com/charmbracelet/bubbletea/standard_renderer.go +136 −105
@@ -34,7 +34,9 @@ type standardRenderer struct {
34 ticker *time.Ticker 34 ticker *time.Ticker
35 done chan struct{} 35 done chan struct{}
36 lastRender string 36 lastRender string
37 lastRenderedLines []string
37 linesRendered int 38 linesRendered int
39 altLinesRendered int
38 useANSICompressor bool 40 useANSICompressor bool
39 once sync.Once 41 once sync.Once
40 42
@@ -161,13 +163,20 @@ func (r *standardRenderer) flush() {
161 defer r.mtx.Unlock() 163 defer r.mtx.Unlock()
162 164
163 if r.buf.Len() == 0 || r.buf.String() == r.lastRender { 165 if r.buf.Len() == 0 || r.buf.String() == r.lastRender {
164 // Nothing to do 166 // Nothing to do.
165 return 167 return
166 } 168 }
167 169
168 // Output buffer 170 // Output buffer.
169 buf := &bytes.Buffer{} 171 buf := &bytes.Buffer{}
170 172
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
171 newLines := strings.Split(r.buf.String(), "\n") 180 newLines := strings.Split(r.buf.String(), "\n")
172 181
173 // If we know the output's height, we can use it to determine how many 182 // If we know the output's height, we can use it to determine how many
@@ -178,97 +187,87 @@ func (r *standardRenderer) flush() {
178 newLines = newLines[len(newLines)-r.height:] 187 newLines = newLines[len(newLines)-r.height:]
179 } 188 }
180 189
181 numLinesThisFlush := len(newLines)
182 oldLines := strings.Split(r.lastRender, "\n")
183 skipLines := make(map[int]struct{})
184 flushQueuedMessages := len(r.queuedMessageLines) > 0 && !r.altScreenActive 190 flushQueuedMessages := len(r.queuedMessageLines) > 0 && !r.altScreenActive
185 191
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
227 if flushQueuedMessages { 192 if flushQueuedMessages {
228 // Dump the lines we've queued up for printing 193 // Dump the lines we've queued up for printing.
229 for _, line := range r.queuedMessageLines { 194 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
230 _, _ = buf.WriteString(line) 205 _, _ = buf.WriteString(line)
231 _, _ = buf.WriteString("\r\n") 206 _, _ = buf.WriteString("\r\n")
232 } 207 }
233 // clear the queued message lines 208 // Clear the queued message lines.
234 r.queuedMessageLines = []string{} 209 r.queuedMessageLines = []string{}
235 } 210 }
236 211
237 // Paint new lines 212 // Paint new lines.
238 for i := 0; i < len(newLines); i++ { 213 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 {
240 // Unless this is the last line, move the cursor down. 218 // Unless this is the last line, move the cursor down.
241 if i < len(newLines)-1 { 219 if i < len(newLines)-1 {
242 buf.WriteString(ansi.CursorDown1) 220 buf.WriteByte('\n')
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')
249 } 221 }
222 continue
223 }
250 224
251 line := newLines[i] 225 if i == 0 && r.lastRender == "" {
252 226 // On first render, reset the cursor to the start of the line
253 // Truncate lines wider than the width of the window to avoid 227 // before writing anything.
254 // wrapping, which will mess up rendering. If we don't have the 228 buf.WriteByte('\r')
255 // width of the window this will be ignored. 229 }
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 }
263 230
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 }
265 243
266 if i < len(newLines)-1 { 244 if ansi.StringWidth(line) < r.width {
267 _, _ = buf.WriteString("\r\n") 245 // We only erase the rest of the line when the line is shorter than
268 } 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")
269 } 258 }
270 } 259 }
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 }
272 271
273 // Make sure the cursor is at the start of the last line to keep rendering 272 // Make sure the cursor is at the start of the last line to keep rendering
274 // behavior consistent. 273 // behavior consistent.
@@ -276,16 +275,29 @@ func (r *standardRenderer) flush() {
276 // This case fixes a bug in macOS terminal. In other terminals the 275 // This case fixes a bug in macOS terminal. In other terminals the
277 // other case seems to do the job regardless of whether or not we're 276 // other case seems to do the job regardless of whether or not we're
278 // using the full terminal window. 277 // using the full terminal window.
279 buf.WriteString(ansi.MoveCursor(r.linesRendered, 0)) 278 buf.WriteString(ansi.CursorPosition(0, len(newLines)))
280 } else { 279 } else {
281 buf.WriteString(ansi.CursorLeft(r.width)) 280 buf.WriteString(ansi.CursorBackward(r.width))
282 } 281 }
283 282
284 _, _ = r.out.Write(buf.Bytes()) 283 _, _ = r.out.Write(buf.Bytes())
285 r.lastRender = r.buf.String() 284 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
286 r.buf.Reset() 290 r.buf.Reset()
287} 291}
288 292
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
289// write writes to the internal buffer. The buffer will be outputted via the 301// write writes to the internal buffer. The buffer will be outputted via the
290// ticker which calls flush(). 302// ticker which calls flush().
291func (r *standardRenderer) write(s string) { 303func (r *standardRenderer) write(s string) {
@@ -306,14 +318,15 @@ func (r *standardRenderer) write(s string) {
306 318
307func (r *standardRenderer) repaint() { 319func (r *standardRenderer) repaint() {
308 r.lastRender = "" 320 r.lastRender = ""
321 r.lastRenderedLines = nil
309} 322}
310 323
311func (r *standardRenderer) clearScreen() { 324func (r *standardRenderer) clearScreen() {
312 r.mtx.Lock() 325 r.mtx.Lock()
313 defer r.mtx.Unlock() 326 defer r.mtx.Unlock()
314 327
315 r.execute(ansi.EraseEntireDisplay) 328 r.execute(ansi.EraseEntireScreen)
316 r.execute(ansi.MoveCursorOrigin) 329 r.execute(ansi.CursorHomePosition)
317 330
318 r.repaint() 331 r.repaint()
319} 332}
@@ -334,7 +347,7 @@ func (r *standardRenderer) enterAltScreen() {
334 } 347 }
335 348
336 r.altScreenActive = true 349 r.altScreenActive = true
337 r.execute(ansi.EnableAltScreenBuffer) 350 r.execute(ansi.SetAltScreenSaveCursorMode)
338 351
339 // Ensure that the terminal is cleared, even when it doesn't support 352 // Ensure that the terminal is cleared, even when it doesn't support
340 // alt screen (or alt screen support is disabled, like GNU screen by 353 // alt screen (or alt screen support is disabled, like GNU screen by
@@ -342,8 +355,8 @@ func (r *standardRenderer) enterAltScreen() {
342 // 355 //
343 // Note: we can't use r.clearScreen() here because the mutex is already 356 // Note: we can't use r.clearScreen() here because the mutex is already
344 // locked. 357 // locked.
345 r.execute(ansi.EraseEntireDisplay) 358 r.execute(ansi.EraseEntireScreen)
346 r.execute(ansi.MoveCursorOrigin) 359 r.execute(ansi.CursorHomePosition)
347 360
348 // cmd.exe and other terminals keep separate cursor states for the AltScreen 361 // cmd.exe and other terminals keep separate cursor states for the AltScreen
349 // and the main buffer. We have to explicitly reset the cursor visibility 362 // and the main buffer. We have to explicitly reset the cursor visibility
@@ -354,6 +367,9 @@ func (r *standardRenderer) enterAltScreen() {
354 r.execute(ansi.ShowCursor) 367 r.execute(ansi.ShowCursor)
355 } 368 }
356 369
370 // Entering the alt screen resets the lines rendered count.
371 r.altLinesRendered = 0
372
357 r.repaint() 373 r.repaint()
358} 374}
359 375
@@ -366,7 +382,7 @@ func (r *standardRenderer) exitAltScreen() {
366 } 382 }
367 383
368 r.altScreenActive = false 384 r.altScreenActive = false
369 r.execute(ansi.DisableAltScreenBuffer) 385 r.execute(ansi.ResetAltScreenSaveCursorMode)
370 386
371 // cmd.exe and other terminals keep separate cursor states for the AltScreen 387 // cmd.exe and other terminals keep separate cursor states for the AltScreen
372 // and the main buffer. We have to explicitly reset the cursor visibility 388 // and the main buffer. We have to explicitly reset the cursor visibility
@@ -400,49 +416,49 @@ func (r *standardRenderer) enableMouseCellMotion() {
400 r.mtx.Lock() 416 r.mtx.Lock()
401 defer r.mtx.Unlock() 417 defer r.mtx.Unlock()
402 418
403 r.execute(ansi.EnableMouseCellMotion) 419 r.execute(ansi.SetButtonEventMouseMode)
404} 420}
405 421
406func (r *standardRenderer) disableMouseCellMotion() { 422func (r *standardRenderer) disableMouseCellMotion() {
407 r.mtx.Lock() 423 r.mtx.Lock()
408 defer r.mtx.Unlock() 424 defer r.mtx.Unlock()
409 425
410 r.execute(ansi.DisableMouseCellMotion) 426 r.execute(ansi.ResetButtonEventMouseMode)
411} 427}
412 428
413func (r *standardRenderer) enableMouseAllMotion() { 429func (r *standardRenderer) enableMouseAllMotion() {
414 r.mtx.Lock() 430 r.mtx.Lock()
415 defer r.mtx.Unlock() 431 defer r.mtx.Unlock()
416 432
417 r.execute(ansi.EnableMouseAllMotion) 433 r.execute(ansi.SetAnyEventMouseMode)
418} 434}
419 435
420func (r *standardRenderer) disableMouseAllMotion() { 436func (r *standardRenderer) disableMouseAllMotion() {
421 r.mtx.Lock() 437 r.mtx.Lock()
422 defer r.mtx.Unlock() 438 defer r.mtx.Unlock()
423 439
424 r.execute(ansi.DisableMouseAllMotion) 440 r.execute(ansi.ResetAnyEventMouseMode)
425} 441}
426 442
427func (r *standardRenderer) enableMouseSGRMode() { 443func (r *standardRenderer) enableMouseSGRMode() {
428 r.mtx.Lock() 444 r.mtx.Lock()
429 defer r.mtx.Unlock() 445 defer r.mtx.Unlock()
430 446
431 r.execute(ansi.EnableMouseSgrExt) 447 r.execute(ansi.SetSgrExtMouseMode)
432} 448}
433 449
434func (r *standardRenderer) disableMouseSGRMode() { 450func (r *standardRenderer) disableMouseSGRMode() {
435 r.mtx.Lock() 451 r.mtx.Lock()
436 defer r.mtx.Unlock() 452 defer r.mtx.Unlock()
437 453
438 r.execute(ansi.DisableMouseSgrExt) 454 r.execute(ansi.ResetSgrExtMouseMode)
439} 455}
440 456
441func (r *standardRenderer) enableBracketedPaste() { 457func (r *standardRenderer) enableBracketedPaste() {
442 r.mtx.Lock() 458 r.mtx.Lock()
443 defer r.mtx.Unlock() 459 defer r.mtx.Unlock()
444 460
445 r.execute(ansi.EnableBracketedPaste) 461 r.execute(ansi.SetBracketedPasteMode)
446 r.bpActive = true 462 r.bpActive = true
447} 463}
448 464
@@ -450,7 +466,7 @@ func (r *standardRenderer) disableBracketedPaste() {
450 r.mtx.Lock() 466 r.mtx.Lock()
451 defer r.mtx.Unlock() 467 defer r.mtx.Unlock()
452 468
453 r.execute(ansi.DisableBracketedPaste) 469 r.execute(ansi.ResetBracketedPasteMode)
454 r.bpActive = false 470 r.bpActive = false
455} 471}
456 472
@@ -465,7 +481,7 @@ func (r *standardRenderer) enableReportFocus() {
465 r.mtx.Lock() 481 r.mtx.Lock()
466 defer r.mtx.Unlock() 482 defer r.mtx.Unlock()
467 483
468 r.execute(ansi.EnableReportFocus) 484 r.execute(ansi.SetFocusEventMode)
469 r.reportingFocus = true 485 r.reportingFocus = true
470} 486}
471 487
@@ -473,7 +489,7 @@ func (r *standardRenderer) disableReportFocus() {
473 r.mtx.Lock() 489 r.mtx.Lock()
474 defer r.mtx.Unlock() 490 defer r.mtx.Unlock()
475 491
476 r.execute(ansi.DisableReportFocus) 492 r.execute(ansi.ResetFocusEventMode)
477 r.reportingFocus = false 493 r.reportingFocus = false
478} 494}
479 495
@@ -494,7 +510,7 @@ func (r *standardRenderer) setWindowTitle(title string) {
494func (r *standardRenderer) setIgnoredLines(from int, to int) { 510func (r *standardRenderer) setIgnoredLines(from int, to int) {
495 // Lock if we're going to be clearing some lines since we don't want 511 // Lock if we're going to be clearing some lines since we don't want
496 // anything jacking our cursor. 512 // anything jacking our cursor.
497 if r.linesRendered > 0 { 513 if r.lastLinesRendered() > 0 {
498 r.mtx.Lock() 514 r.mtx.Lock()
499 defer r.mtx.Unlock() 515 defer r.mtx.Unlock()
500 } 516 }
@@ -507,16 +523,17 @@ func (r *standardRenderer) setIgnoredLines(from int, to int) {
507 } 523 }
508 524
509 // Erase ignored lines 525 // Erase ignored lines
510 if r.linesRendered > 0 { 526 lastLinesRendered := r.lastLinesRendered()
527 if lastLinesRendered > 0 {
511 buf := &bytes.Buffer{} 528 buf := &bytes.Buffer{}
512 529
513 for i := r.linesRendered - 1; i >= 0; i-- { 530 for i := lastLinesRendered - 1; i >= 0; i-- {
514 if _, exists := r.ignoreLines[i]; exists { 531 if _, exists := r.ignoreLines[i]; exists {
515 buf.WriteString(ansi.EraseEntireLine) 532 buf.WriteString(ansi.EraseEntireLine)
516 } 533 }
517 buf.WriteString(ansi.CursorUp1) 534 buf.WriteString(ansi.CUU1)
518 } 535 }
519 buf.WriteString(ansi.MoveCursor(r.linesRendered, 0)) // put cursor back 536 buf.WriteString(ansi.CursorPosition(0, lastLinesRendered)) // put cursor back
520 _, _ = r.out.Write(buf.Bytes()) 537 _, _ = r.out.Write(buf.Bytes())
521 } 538 }
522} 539}
@@ -546,20 +563,23 @@ func (r *standardRenderer) clearIgnoredLines() {
546// use in high-performance rendering, such as a pager that could potentially 563// use in high-performance rendering, such as a pager that could potentially
547// be rendering very complicated ansi. In cases where the content is simpler 564// be rendering very complicated ansi. In cases where the content is simpler
548// standard Bubble Tea rendering should suffice. 565// 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.
549func (r *standardRenderer) insertTop(lines []string, topBoundary, bottomBoundary int) { 569func (r *standardRenderer) insertTop(lines []string, topBoundary, bottomBoundary int) {
550 r.mtx.Lock() 570 r.mtx.Lock()
551 defer r.mtx.Unlock() 571 defer r.mtx.Unlock()
552 572
553 buf := &bytes.Buffer{} 573 buf := &bytes.Buffer{}
554 574
555 buf.WriteString(ansi.SetScrollingRegion(topBoundary, bottomBoundary)) 575 buf.WriteString(ansi.SetTopBottomMargins(topBoundary, bottomBoundary))
556 buf.WriteString(ansi.MoveCursor(topBoundary, 0)) 576 buf.WriteString(ansi.CursorPosition(0, topBoundary))
557 buf.WriteString(ansi.InsertLine(len(lines))) 577 buf.WriteString(ansi.InsertLine(len(lines)))
558 _, _ = buf.WriteString(strings.Join(lines, "\r\n")) 578 _, _ = buf.WriteString(strings.Join(lines, "\r\n"))
559 buf.WriteString(ansi.SetScrollingRegion(0, r.height)) 579 buf.WriteString(ansi.SetTopBottomMargins(0, r.height))
560 580
561 // Move cursor back to where the main rendering routine expects it to be 581 // 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()))
563 583
564 _, _ = r.out.Write(buf.Bytes()) 584 _, _ = r.out.Write(buf.Bytes())
565} 585}
@@ -573,19 +593,22 @@ func (r *standardRenderer) insertTop(lines []string, topBoundary, bottomBoundary
573// See note in insertTop() for caveats, how this function only makes sense for 593// See note in insertTop() for caveats, how this function only makes sense for
574// full-window applications, and how it differs from the normal way we do 594// full-window applications, and how it differs from the normal way we do
575// rendering in Bubble Tea. 595// rendering in Bubble Tea.
596//
597// Deprecated: This option is deprecated and will be removed in a future
598// version of this package.
576func (r *standardRenderer) insertBottom(lines []string, topBoundary, bottomBoundary int) { 599func (r *standardRenderer) insertBottom(lines []string, topBoundary, bottomBoundary int) {
577 r.mtx.Lock() 600 r.mtx.Lock()
578 defer r.mtx.Unlock() 601 defer r.mtx.Unlock()
579 602
580 buf := &bytes.Buffer{} 603 buf := &bytes.Buffer{}
581 604
582 buf.WriteString(ansi.SetScrollingRegion(topBoundary, bottomBoundary)) 605 buf.WriteString(ansi.SetTopBottomMargins(topBoundary, bottomBoundary))
583 buf.WriteString(ansi.MoveCursor(bottomBoundary, 0)) 606 buf.WriteString(ansi.CursorPosition(0, bottomBoundary))
584 _, _ = buf.WriteString("\r\n" + strings.Join(lines, "\r\n")) 607 _, _ = 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))
586 609
587 // Move cursor back to where the main rendering routine expects it to be 610 // 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()))
589 612
590 _, _ = r.out.Write(buf.Bytes()) 613 _, _ = r.out.Write(buf.Bytes())
591} 614}
@@ -657,6 +680,8 @@ type syncScrollAreaMsg struct {
657// should also be called on resize (WindowSizeMsg). 680// should also be called on resize (WindowSizeMsg).
658// 681//
659// For high-performance, scroll-based rendering only. 682// For high-performance, scroll-based rendering only.
683//
684// Deprecated: This option will be removed in a future version of this package.
660func SyncScrollArea(lines []string, topBoundary int, bottomBoundary int) Cmd { 685func SyncScrollArea(lines []string, topBoundary int, bottomBoundary int) Cmd {
661 return func() Msg { 686 return func() Msg {
662 return syncScrollAreaMsg{ 687 return syncScrollAreaMsg{
@@ -673,6 +698,8 @@ type clearScrollAreaMsg struct{}
673// those lines to the main rendering routine. 698// those lines to the main rendering routine.
674// 699//
675// For high-performance, scroll-based rendering only. 700// For high-performance, scroll-based rendering only.
701//
702// Deprecated: This option will be removed in a future version of this package.
676func ClearScrollArea() Msg { 703func ClearScrollArea() Msg {
677 return clearScrollAreaMsg{} 704 return clearScrollAreaMsg{}
678} 705}
@@ -688,6 +715,8 @@ type scrollUpMsg struct {
688// from view. 715// from view.
689// 716//
690// For high-performance, scroll-based rendering only. 717// For high-performance, scroll-based rendering only.
718//
719// Deprecated: This option will be removed in a future version of this package.
691func ScrollUp(newLines []string, topBoundary, bottomBoundary int) Cmd { 720func ScrollUp(newLines []string, topBoundary, bottomBoundary int) Cmd {
692 return func() Msg { 721 return func() Msg {
693 return scrollUpMsg{ 722 return scrollUpMsg{
@@ -709,6 +738,8 @@ type scrollDownMsg struct {
709// disappear from view. 738// disappear from view.
710// 739//
711// For high-performance, scroll-based rendering only. 740// For high-performance, scroll-based rendering only.
741//
742// Deprecated: This option will be removed in a future version of this package.
712func ScrollDown(newLines []string, topBoundary, bottomBoundary int) Cmd { 743func ScrollDown(newLines []string, topBoundary, bottomBoundary int) Cmd {
713 return func() Msg { 744 return func() Msg {
714 return scrollDownMsg{ 745 return scrollDownMsg{
vendor/github.com/charmbracelet/bubbletea/tea.go +37 −9
@@ -26,9 +26,13 @@ import (
26 "golang.org/x/sync/errgroup" 26 "golang.org/x/sync/errgroup"
27) 27)
28 28
29// ErrProgramKilled is returned by [Program.Run] when the program got killed. 29// ErrProgramKilled is returned by [Program.Run] when the program gets killed.
30var ErrProgramKilled = errors.New("program was killed") 30var ErrProgramKilled = errors.New("program was killed")
31 31
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
32// Msg contain data from the result of a IO operation. Msgs trigger the update 36// Msg contain data from the result of a IO operation. Msgs trigger the update
33// function and, henceforth, the UI. 37// function and, henceforth, the UI.
34type Msg interface{} 38type Msg interface{}
@@ -186,8 +190,8 @@ func Quit() Msg {
186 return QuitMsg{} 190 return QuitMsg{}
187} 191}
188 192
189// QuitMsg signals that the program should quit. You can send a QuitMsg with 193// QuitMsg signals that the program should quit. You can send a [QuitMsg] with
190// Quit. 194// [Quit].
191type QuitMsg struct{} 195type QuitMsg struct{}
192 196
193// Suspend is a special command that tells the Bubble Tea program to suspend. 197// Suspend is a special command that tells the Bubble Tea program to suspend.
@@ -199,13 +203,28 @@ func Suspend() Msg {
199// This usually happens when ctrl+z is pressed on common programs, but since 203// This usually happens when ctrl+z is pressed on common programs, but since
200// bubbletea puts the terminal in raw mode, we need to handle it in a 204// bubbletea puts the terminal in raw mode, we need to handle it in a
201// per-program basis. 205// per-program basis.
202// You can send this message with Suspend. 206//
207// You can send this message with [Suspend()].
203type SuspendMsg struct{} 208type SuspendMsg struct{}
204 209
205// ResumeMsg can be listen to to do something once a program is resumed back 210// ResumeMsg can be listen to to do something once a program is resumed back
206// from a suspend state. 211// from a suspend state.
207type ResumeMsg struct{} 212type ResumeMsg struct{}
208 213
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
209// NewProgram creates a new Program. 228// NewProgram creates a new Program.
210func NewProgram(model Model, opts ...ProgramOption) *Program { 229func NewProgram(model Model, opts ...ProgramOption) *Program {
211 p := &Program{ 230 p := &Program{
@@ -263,9 +282,14 @@ func (p *Program) handleSignals() chan struct{} {
263 case <-p.ctx.Done(): 282 case <-p.ctx.Done():
264 return 283 return
265 284
266 case <-sig: 285 case s := <-sig:
267 if atomic.LoadUint32(&p.ignoreSignals) == 0 { 286 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 }
269 return 293 return
270 } 294 }
271 } 295 }
@@ -362,6 +386,9 @@ func (p *Program) eventLoop(model Model, cmds chan Cmd) (Model, error) {
362 case QuitMsg: 386 case QuitMsg:
363 return model, nil 387 return model, nil
364 388
389 case InterruptMsg:
390 return model, ErrInterrupted
391
365 case SuspendMsg: 392 case SuspendMsg:
366 if suspendSupported { 393 if suspendSupported {
367 p.suspend() 394 p.suspend()
@@ -593,10 +620,11 @@ func (p *Program) Run() (Model, error) {
593 620
594 // Run event loop, handle updates and draw. 621 // Run event loop, handle updates and draw.
595 model, err := p.eventLoop(model, cmds) 622 model, err := p.eventLoop(model, cmds)
596 killed := p.ctx.Err() != nil 623 killed := p.ctx.Err() != nil || err != nil
597 if killed { 624 if killed && err == nil {
598 err = fmt.Errorf("%w: %s", ErrProgramKilled, p.ctx.Err()) 625 err = fmt.Errorf("%w: %s", ErrProgramKilled, p.ctx.Err())
599 } else { 626 }
627 if err == nil {
600 // Ensure we rendered the final state of the model. 628 // Ensure we rendered the final state of the model.
601 p.renderer.write(model.View()) 629 p.renderer.write(model.View())
602 } 630 }
vendor/github.com/charmbracelet/lipgloss/.golangci-soft.yml +1 −7
@@ -14,16 +14,13 @@ issues:
14 14
15linters: 15linters:
16 enable: 16 enable:
17 # - dupl
18 - exhaustive 17 - exhaustive
19 # - exhaustivestruct
20 - goconst 18 - goconst
21 - godot 19 - godot
22 - godox 20 - godox
23 - gomnd 21 - mnd
24 - gomoddirectives 22 - gomoddirectives
25 - goprintffuncname 23 - goprintffuncname
26 # - lll
27 - misspell 24 - misspell
28 - nakedret 25 - nakedret
29 - nestif 26 - nestif
@@ -34,13 +31,10 @@ linters:
34 31
35 # disable default linters, they are already enabled in .golangci.yml 32 # disable default linters, they are already enabled in .golangci.yml
36 disable: 33 disable:
37 - deadcode
38 - errcheck 34 - errcheck
39 - gosimple 35 - gosimple
40 - govet 36 - govet
41 - ineffassign 37 - ineffassign
42 - staticcheck 38 - staticcheck
43 - structcheck
44 - typecheck 39 - typecheck
45 - unused 40 - unused
46 - varcheck
vendor/github.com/charmbracelet/lipgloss/.golangci.yml −2
@@ -15,12 +15,10 @@ issues:
15linters: 15linters:
16 enable: 16 enable:
17 - bodyclose 17 - bodyclose
18 - exportloopref
19 - gofumpt 18 - gofumpt
20 - goimports 19 - goimports
21 - gosec 20 - gosec
22 - nilerr 21 - nilerr
23 - predeclared
24 - revive 22 - revive
25 - rowserrcheck 23 - rowserrcheck
26 - sqlclosecheck 24 - sqlclosecheck
vendor/github.com/charmbracelet/lipgloss/style.go +4 −2
@@ -353,6 +353,8 @@ func (s Style) Render(strs ...string) string {
353 353
354 // Potentially convert tabs to spaces 354 // Potentially convert tabs to spaces
355 str = s.maybeConvertTabs(str) 355 str = s.maybeConvertTabs(str)
356 // carriage returns can cause strange behaviour when rendering.
357 str = strings.ReplaceAll(str, "\r\n", "\n")
356 358
357 // Strip newlines in single line mode 359 // Strip newlines in single line mode
358 if inline { 360 if inline {
@@ -562,14 +564,14 @@ func pad(str string, n int, style *termenv.Style) string {
562 return b.String() 564 return b.String()
563} 565}
564 566
565func max(a, b int) int { //nolint:unparam 567func max(a, b int) int { //nolint:unparam,predeclared
566 if a > b { 568 if a > b {
567 return a 569 return a
568 } 570 }
569 return b 571 return b
570} 572}
571 573
572func min(a, b int) int { 574func min(a, b int) int { //nolint:predeclared
573 if a < b { 575 if a < b {
574 return a 576 return a
575 } 577 }
vendor/github.com/charmbracelet/x/ansi/background.go +111 −3
@@ -1,9 +1,73 @@
1package ansi 1package ansi
2 2
3import ( 3import (
4 "fmt"
4 "image/color" 5 "image/color"
5) 6)
6 7
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
7// SetForegroundColor returns a sequence that sets the default terminal 71// SetForegroundColor returns a sequence that sets the default terminal
8// foreground color. 72// foreground color.
9// 73//
@@ -14,7 +78,16 @@ import (
14// 78//
15// See: https://invisible-island.net/xterm/ctlseqs/ctlseqs.html#h3-Operating-System-Commands 79// See: https://invisible-island.net/xterm/ctlseqs/ctlseqs.html#h3-Operating-System-Commands
16func SetForegroundColor(c color.Color) string { 80func 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"
18} 91}
19 92
20// RequestForegroundColor is a sequence that requests the current default 93// RequestForegroundColor is a sequence that requests the current default
@@ -23,6 +96,12 @@ func SetForegroundColor(c color.Color) string {
23// See: https://invisible-island.net/xterm/ctlseqs/ctlseqs.html#h3-Operating-System-Commands 96// See: https://invisible-island.net/xterm/ctlseqs/ctlseqs.html#h3-Operating-System-Commands
24const RequestForegroundColor = "\x1b]10;?\x07" 97const RequestForegroundColor = "\x1b]10;?\x07"
25 98
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
26// SetBackgroundColor returns a sequence that sets the default terminal 105// SetBackgroundColor returns a sequence that sets the default terminal
27// background color. 106// background color.
28// 107//
@@ -33,7 +112,16 @@ const RequestForegroundColor = "\x1b]10;?\x07"
33// 112//
34// See: https://invisible-island.net/xterm/ctlseqs/ctlseqs.html#h3-Operating-System-Commands 113// See: https://invisible-island.net/xterm/ctlseqs/ctlseqs.html#h3-Operating-System-Commands
35func SetBackgroundColor(c color.Color) string { 114func 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"
37} 125}
38 126
39// RequestBackgroundColor is a sequence that requests the current default 127// RequestBackgroundColor is a sequence that requests the current default
@@ -42,6 +130,12 @@ func SetBackgroundColor(c color.Color) string {
42// See: https://invisible-island.net/xterm/ctlseqs/ctlseqs.html#h3-Operating-System-Commands 130// See: https://invisible-island.net/xterm/ctlseqs/ctlseqs.html#h3-Operating-System-Commands
43const RequestBackgroundColor = "\x1b]11;?\x07" 131const RequestBackgroundColor = "\x1b]11;?\x07"
44 132
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
45// SetCursorColor returns a sequence that sets the terminal cursor color. 139// SetCursorColor returns a sequence that sets the terminal cursor color.
46// 140//
47// OSC 12 ; color ST 141// OSC 12 ; color ST
@@ -51,7 +145,16 @@ const RequestBackgroundColor = "\x1b]11;?\x07"
51// 145//
52// See: https://invisible-island.net/xterm/ctlseqs/ctlseqs.html#h3-Operating-System-Commands 146// See: https://invisible-island.net/xterm/ctlseqs/ctlseqs.html#h3-Operating-System-Commands
53func SetCursorColor(c color.Color) string { 147func 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"
55} 158}
56 159
57// RequestCursorColor is a sequence that requests the current terminal cursor 160// RequestCursorColor is a sequence that requests the current terminal cursor
@@ -59,3 +162,8 @@ func SetCursorColor(c color.Color) string {
59// 162//
60// See: https://invisible-island.net/xterm/ctlseqs/ctlseqs.html#h3-Operating-System-Commands 163// See: https://invisible-island.net/xterm/ctlseqs/ctlseqs.html#h3-Operating-System-Commands
61const RequestCursorColor = "\x1b]12;?\x07" 164const 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 (
69 RS = 0x1E 69 RS = 0x1E
70 // US is the unit separator character (Caret: ^_). 70 // US is the unit separator character (Caret: ^_).
71 US = 0x1F 71 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
72) 79)
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) {
178// 178//
179// r, g, b := hexToRGB(0x0000FF) 179// r, g, b := hexToRGB(0x0000FF)
180func hexToRGB(hex uint32) (uint32, uint32, uint32) { 180func 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
182} 182}
183 183
184// toRGBA converts an RGB 8-bit color values to 32-bit color values suitable 184// 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 @@
1package ansi 1package ansi
2 2
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
3// RequestXTVersion is a control sequence that requests the terminal's XTVERSION. It responds with a DSR sequence identifying the version. 21// RequestXTVersion is a control sequence that requests the terminal's XTVERSION. It responds with a DSR sequence identifying the version.
4// 22//
5// CSI > Ps q 23// CSI > Ps q
6// DCS > | text ST 24// DCS > | text ST
7// 25//
8// See https://invisible-island.net/xterm/ctlseqs/ctlseqs.html#h3-PC-Style-Function-Keys 26// 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}
10 60
11// RequestPrimaryDeviceAttributes is a control sequence that requests the 61// RequestPrimaryDeviceAttributes is a control sequence that requests the
12// terminal's primary device attributes (DA1). 62// terminal's primary device attributes (DA1).
@@ -15,3 +65,73 @@ const RequestXTVersion = "\x1b[>0q"
15// 65//
16// See https://vt100.net/docs/vt510-rm/DA1.html 66// See https://vt100.net/docs/vt510-rm/DA1.html
17const RequestPrimaryDeviceAttributes = "\x1b[c" 67const 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"
8// ESC 7 8// ESC 7
9// 9//
10// See: https://vt100.net/docs/vt510-rm/DECSC.html 10// See: https://vt100.net/docs/vt510-rm/DECSC.html
11const SaveCursor = "\x1b7" 11const (
12 SaveCursor = "\x1b7"
13 DECSC = SaveCursor
14)
12 15
13// RestoreCursor (DECRC) is an escape sequence that restores the cursor 16// RestoreCursor (DECRC) is an escape sequence that restores the cursor
14// position. 17// position.
@@ -16,10 +19,13 @@ const SaveCursor = "\x1b7"
16// ESC 8 19// ESC 8
17// 20//
18// See: https://vt100.net/docs/vt510-rm/DECRC.html 21// See: https://vt100.net/docs/vt510-rm/DECRC.html
19const RestoreCursor = "\x1b8" 22const (
23 RestoreCursor = "\x1b8"
24 DECRC = RestoreCursor
25)
20 26
21// RequestCursorPosition (CPR) is an escape sequence that requests the current 27// RequestCursorPosition is an escape sequence that requests the current cursor
22// cursor position. 28// position.
23// 29//
24// CSI 6 n 30// CSI 6 n
25// 31//
@@ -30,6 +36,8 @@ const RestoreCursor = "\x1b8"
30// 36//
31// Where Pl is the line number and Pc is the column number. 37// Where Pl is the line number and Pc is the column number.
32// See: https://vt100.net/docs/vt510-rm/CPR.html 38// See: https://vt100.net/docs/vt510-rm/CPR.html
39//
40// Deprecated: use [RequestCursorPositionReport] instead.
33const RequestCursorPosition = "\x1b[6n" 41const RequestCursorPosition = "\x1b[6n"
34 42
35// RequestExtendedCursorPosition (DECXCPR) is a sequence for requesting the 43// RequestExtendedCursorPosition (DECXCPR) is a sequence for requesting the
@@ -45,6 +53,8 @@ const RequestCursorPosition = "\x1b[6n"
45// Where Pl is the line number, Pc is the column number, and Pp is the page 53// Where Pl is the line number, Pc is the column number, and Pp is the page
46// number. 54// number.
47// See: https://vt100.net/docs/vt510-rm/DECXCPR.html 55// See: https://vt100.net/docs/vt510-rm/DECXCPR.html
56//
57// Deprecated: use [RequestExtendedCursorPositionReport] instead.
48const RequestExtendedCursorPosition = "\x1b[?6n" 58const RequestExtendedCursorPosition = "\x1b[?6n"
49 59
50// CursorUp (CUU) returns a sequence for moving the cursor up n cells. 60// CursorUp (CUU) returns a sequence for moving the cursor up n cells.
@@ -60,9 +70,19 @@ func CursorUp(n int) string {
60 return "\x1b[" + s + "A" 70 return "\x1b[" + s + "A"
61} 71}
62 72
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
63// CursorUp1 is a sequence for moving the cursor up one cell. 81// CursorUp1 is a sequence for moving the cursor up one cell.
64// 82//
65// This is equivalent to CursorUp(1). 83// This is equivalent to CursorUp(1).
84//
85// Deprecated: use [CUU1] instead.
66const CursorUp1 = "\x1b[A" 86const CursorUp1 = "\x1b[A"
67 87
68// CursorDown (CUD) returns a sequence for moving the cursor down n cells. 88// CursorDown (CUD) returns a sequence for moving the cursor down n cells.
@@ -78,17 +98,27 @@ func CursorDown(n int) string {
78 return "\x1b[" + s + "B" 98 return "\x1b[" + s + "B"
79} 99}
80 100
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
81// CursorDown1 is a sequence for moving the cursor down one cell. 109// CursorDown1 is a sequence for moving the cursor down one cell.
82// 110//
83// This is equivalent to CursorDown(1). 111// This is equivalent to CursorDown(1).
112//
113// Deprecated: use [CUD1] instead.
84const CursorDown1 = "\x1b[B" 114const CursorDown1 = "\x1b[B"
85 115
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.
87// 117//
88// CSI n C 118// # CSI n C
89// 119//
90// See: https://vt100.net/docs/vt510-rm/CUF.html 120// See: https://vt100.net/docs/vt510-rm/CUF.html
91func CursorRight(n int) string { 121func CursorForward(n int) string {
92 var s string 122 var s string
93 if n > 1 { 123 if n > 1 {
94 s = strconv.Itoa(n) 124 s = strconv.Itoa(n)
@@ -96,17 +126,38 @@ func CursorRight(n int) string {
96 return "\x1b[" + s + "C" 126 return "\x1b[" + s + "C"
97} 127}
98 128
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
99// CursorRight1 is a sequence for moving the cursor right one cell. 148// CursorRight1 is a sequence for moving the cursor right one cell.
100// 149//
101// This is equivalent to CursorRight(1). 150// This is equivalent to CursorRight(1).
102const CursorRight1 = "\x1b[C" 151//
152// Deprecated: use [CUF1] instead.
153const CursorRight1 = CUF1
103 154
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.
105// 156//
106// CSI n D 157// # CSI n D
107// 158//
108// See: https://vt100.net/docs/vt510-rm/CUB.html 159// See: https://vt100.net/docs/vt510-rm/CUB.html
109func CursorLeft(n int) string { 160func CursorBackward(n int) string {
110 var s string 161 var s string
111 if n > 1 { 162 if n > 1 {
112 s = strconv.Itoa(n) 163 s = strconv.Itoa(n)
@@ -114,10 +165,31 @@ func CursorLeft(n int) string {
114 return "\x1b[" + s + "D" 165 return "\x1b[" + s + "D"
115} 166}
116 167
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
117// CursorLeft1 is a sequence for moving the cursor left one cell. 187// CursorLeft1 is a sequence for moving the cursor left one cell.
118// 188//
119// This is equivalent to CursorLeft(1). 189// This is equivalent to CursorLeft(1).
120const CursorLeft1 = "\x1b[D" 190//
191// Deprecated: use [CUB1] instead.
192const CursorLeft1 = CUB1
121 193
122// CursorNextLine (CNL) returns a sequence for moving the cursor to the 194// CursorNextLine (CNL) returns a sequence for moving the cursor to the
123// beginning of the next line n times. 195// beginning of the next line n times.
@@ -133,6 +205,11 @@ func CursorNextLine(n int) string {
133 return "\x1b[" + s + "E" 205 return "\x1b[" + s + "E"
134} 206}
135 207
208// CNL is an alias for [CursorNextLine].
209func CNL(n int) string {
210 return CursorNextLine(n)
211}
212
136// CursorPreviousLine (CPL) returns a sequence for moving the cursor to the 213// CursorPreviousLine (CPL) returns a sequence for moving the cursor to the
137// beginning of the previous line n times. 214// beginning of the previous line n times.
138// 215//
@@ -147,25 +224,266 @@ func CursorPreviousLine(n int) string {
147 return "\x1b[" + s + "F" 224 return "\x1b[" + s + "F"
148} 225}
149 226
150// MoveCursor (CUP) returns a sequence for moving the cursor to the given row 227// CPL is an alias for [CursorPreviousLine].
151// and column. 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.
152// 257//
153// CSI n ; m H 258// CSI n ; m H
154// 259//
155// See: https://vt100.net/docs/vt510-rm/CUP.html 260// See: https://vt100.net/docs/vt510-rm/CUP.html
156func MoveCursor(row, col int) string { 261func CursorPosition(col, row int) string {
157 if row < 0 { 262 if row <= 0 && col <= 0 {
158 row = 0 263 return HomeCursorPosition
264 }
265
266 var r, c string
267 if row > 0 {
268 r = strconv.Itoa(row)
159 } 269 }
160 if col < 0 { 270 if col > 0 {
161 col = 0 271 c = strconv.Itoa(col)
162 } 272 }
163 return "\x1b[" + strconv.Itoa(row) + ";" + strconv.Itoa(col) + "H" 273 return "\x1b[" + r + ";" + c + "H"
164} 274}
165 275
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
166// MoveCursorOrigin is a sequence for moving the cursor to the upper left 332// MoveCursorOrigin is a sequence for moving the cursor to the upper left
167// corner of the screen. This is equivalent to MoveCursor(1, 1). 333// corner of the display. This is equivalent to `SetCursorPosition(1, 1)`.
168const MoveCursorOrigin = "\x1b[1;1H" 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)
169 487
170// SaveCursorPosition (SCP or SCOSC) is a sequence for saving the cursor 488// SaveCursorPosition (SCP or SCOSC) is a sequence for saving the cursor
171// position. 489// position.
@@ -176,8 +494,24 @@ const MoveCursorOrigin = "\x1b[1;1H"
176// not saved. 494// not saved.
177// 495//
178// See: https://vt100.net/docs/vt510-rm/SCOSC.html 496// See: https://vt100.net/docs/vt510-rm/SCOSC.html
497//
498// Deprecated: use [SaveCurrentCursorPosition] instead.
179const SaveCursorPosition = "\x1b[s" 499const SaveCursorPosition = "\x1b[s"
180 500
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
181// RestoreCursorPosition (RCP or SCORC) is a sequence for restoring the cursor 515// RestoreCursorPosition (RCP or SCORC) is a sequence for restoring the cursor
182// position. 516// position.
183// 517//
@@ -187,10 +521,14 @@ const SaveCursorPosition = "\x1b[s"
187// cursor was saved. 521// cursor was saved.
188// 522//
189// See: https://vt100.net/docs/vt510-rm/SCORC.html 523// See: https://vt100.net/docs/vt510-rm/SCORC.html
524//
525// Deprecated: use [RestoreCurrentCursorPosition] instead.
190const RestoreCursorPosition = "\x1b[u" 526const RestoreCursorPosition = "\x1b[u"
191 527
192// SetCursorStyle (DECSCUSR) returns a sequence for changing the cursor style. 528// SetCursorStyle (DECSCUSR) returns a sequence for changing the cursor style.
193// 529//
530// Default is 1.
531//
194// CSI Ps SP q 532// CSI Ps SP q
195// 533//
196// Where Ps is the cursor style: 534// Where Ps is the cursor style:
@@ -212,6 +550,11 @@ func SetCursorStyle(style int) string {
212 return "\x1b[" + strconv.Itoa(style) + " q" 550 return "\x1b[" + strconv.Itoa(style) + " q"
213} 551}
214 552
553// DECSCUSR is an alias for [SetCursorStyle].
554func DECSCUSR(style int) string {
555 return SetCursorStyle(style)
556}
557
215// SetPointerShape returns a sequence for changing the mouse pointer cursor 558// SetPointerShape returns a sequence for changing the mouse pointer cursor
216// shape. Use "default" for the default pointer shape. 559// shape. Use "default" for the default pointer shape.
217// 560//
@@ -233,3 +576,58 @@ func SetCursorStyle(style int) string {
233func SetPointerShape(shape string) string { 576func SetPointerShape(shape string) string {
234 return "\x1b]22;" + shape + "\x07" 577 return "\x1b]22;" + shape + "\x07"
235} 578}
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 {
72// Keyboard stack to disable the protocol. 72// Keyboard stack to disable the protocol.
73// 73//
74// This is equivalent to PushKittyKeyboard(0). 74// This is equivalent to PushKittyKeyboard(0).
75const DisableKittyKeyboard = "\x1b[>0u" 75const DisableKittyKeyboard = "\x1b[>u"
76 76
77// PopKittyKeyboard returns a sequence to pop n number of flags from the 77// PopKittyKeyboard returns a sequence to pop n number of flags from the
78// terminal Kitty Keyboard stack. 78// 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 @@
1package ansi 1package ansi
2 2
3// This file define uses multiple sequences to set (SM), reset (RM), and request 3import (
4// (DECRQM) different ANSI and DEC modes. 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
5// 64//
6// See: https://vt100.net/docs/vt510-rm/SM.html 65// 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//
7// See: https://vt100.net/docs/vt510-rm/RM.html 89// 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].
9// 140//
10// The terminal then responds to the request with a Report Mode function 141// ANSI format:
11// (DECRPM) in the 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].
12// 166//
13// ANSI format: 167// ANSI format:
14// 168//
15// CSI Pa ; Ps ; $ y 169// CSI Pa ; Ps ; $ y
16// 170//
17// DEC format: 171// DEC format:
18// 172//
19// CSI ? Pa ; Ps $ y 173// CSI ? Pa ; Ps $ y
20// 174//
21// Where Pa is the mode number, and Ps is the mode value. 175// 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//
22// See: https://vt100.net/docs/vt510-rm/DECRPM.html 183// 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
23 210
24// Application Cursor Keys (DECCKM) is a mode that determines whether the 211// Mode returns the DEC mode as an integer.
25// cursor keys send ANSI cursor sequences or application sequences. 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.
26// 287//
27// See: https://vt100.net/docs/vt510-rm/DECCKM.html 288// 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.
28const ( 299const (
29 EnableCursorKeys = "\x1b[?1h" 300 EnableCursorKeys = "\x1b[?1h"
30 DisableCursorKeys = "\x1b[?1l" 301 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"
32) 347)
33 348
34// Text Cursor Enable Mode (DECTCEM) is a mode that shows/hides the cursor. 349// Text Cursor Enable Mode (DECTCEM) is a mode that shows/hides the cursor.
35// 350//
36// See: https://vt100.net/docs/vt510-rm/DECTCEM.html 351// See: https://vt100.net/docs/vt510-rm/DECTCEM.html
37const ( 352const (
38 ShowCursor = "\x1b[?25h" 353 TextCursorEnableMode = DECMode(25)
39 HideCursor = "\x1b[?25l" 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)
40 RequestCursorVisibility = "\x1b[?25$p" 374 RequestCursorVisibility = "\x1b[?25$p"
41) 375)
42 376
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
43// VT Mouse Tracking is a mode that determines whether the mouse reports on 433// VT Mouse Tracking is a mode that determines whether the mouse reports on
44// button press and release. 434// button press and release.
45// 435//
46// See: https://invisible-island.net/xterm/ctlseqs/ctlseqs.html#h2-Mouse-Tracking 436// See: https://invisible-island.net/xterm/ctlseqs/ctlseqs.html#h2-Mouse-Tracking
437//
438// Deprecated: use [NormalMouseMode] instead.
47const ( 439const (
440 MouseMode = DECMode(1000)
441
48 EnableMouse = "\x1b[?1000h" 442 EnableMouse = "\x1b[?1000h"
49 DisableMouse = "\x1b[?1000l" 443 DisableMouse = "\x1b[?1000l"
50 RequestMouse = "\x1b[?1000$p" 444 RequestMouse = "\x1b[?1000$p"
51) 445)
52 446
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
53// VT Hilite Mouse Tracking is a mode that determines whether the mouse reports on 466// VT Hilite Mouse Tracking is a mode that determines whether the mouse reports on
54// button presses, releases, and highlighted cells. 467// button presses, releases, and highlighted cells.
55// 468//
56// See: https://invisible-island.net/xterm/ctlseqs/ctlseqs.html#h2-Mouse-Tracking 469// See: https://invisible-island.net/xterm/ctlseqs/ctlseqs.html#h2-Mouse-Tracking
470//
471// Deprecated: use [HighlightMouseMode] instead.
57const ( 472const (
473 MouseHiliteMode = DECMode(1001)
474
58 EnableMouseHilite = "\x1b[?1001h" 475 EnableMouseHilite = "\x1b[?1001h"
59 DisableMouseHilite = "\x1b[?1001l" 476 DisableMouseHilite = "\x1b[?1001l"
60 RequestMouseHilite = "\x1b[?1001$p" 477 RequestMouseHilite = "\x1b[?1001$p"
61) 478)
62 479
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
63// Cell Motion Mouse Tracking is a mode that determines whether the mouse 492// Cell Motion Mouse Tracking is a mode that determines whether the mouse
64// reports on button press, release, and motion events. 493// reports on button press, release, and motion events.
65// 494//
66// See: https://invisible-island.net/xterm/ctlseqs/ctlseqs.html#h2-Mouse-Tracking 495// See: https://invisible-island.net/xterm/ctlseqs/ctlseqs.html#h2-Mouse-Tracking
496//
497// Deprecated: use [ButtonEventMouseMode] instead.
67const ( 498const (
499 MouseCellMotionMode = DECMode(1002)
500
68 EnableMouseCellMotion = "\x1b[?1002h" 501 EnableMouseCellMotion = "\x1b[?1002h"
69 DisableMouseCellMotion = "\x1b[?1002l" 502 DisableMouseCellMotion = "\x1b[?1002l"
70 RequestMouseCellMotion = "\x1b[?1002$p" 503 RequestMouseCellMotion = "\x1b[?1002$p"
71) 504)
72 505
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
73// All Mouse Tracking is a mode that determines whether the mouse reports on 518// All Mouse Tracking is a mode that determines whether the mouse reports on
74// button press, release, motion, and highlight events. 519// button press, release, motion, and highlight events.
75// 520//
76// See: https://invisible-island.net/xterm/ctlseqs/ctlseqs.html#h2-Mouse-Tracking 521// See: https://invisible-island.net/xterm/ctlseqs/ctlseqs.html#h2-Mouse-Tracking
522//
523// Deprecated: use [AnyEventMouseMode] instead.
77const ( 524const (
525 MouseAllMotionMode = DECMode(1003)
526
78 EnableMouseAllMotion = "\x1b[?1003h" 527 EnableMouseAllMotion = "\x1b[?1003h"
79 DisableMouseAllMotion = "\x1b[?1003l" 528 DisableMouseAllMotion = "\x1b[?1003l"
80 RequestMouseAllMotion = "\x1b[?1003$p" 529 RequestMouseAllMotion = "\x1b[?1003$p"
81) 530)
82 531
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:
84// 536//
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.
86const ( 551const (
552 ReportFocusMode = DECMode(1004)
553
87 EnableReportFocus = "\x1b[?1004h" 554 EnableReportFocus = "\x1b[?1004h"
88 DisableReportFocus = "\x1b[?1004l" 555 DisableReportFocus = "\x1b[?1004l"
89 RequestReportFocus = "\x1b[?1004$p" 556 RequestReportFocus = "\x1b[?1004$p"
90) 557)
91 558
92// SGR Mouse Extension is a mode that determines whether the mouse reports events 559// SGR Extended Mouse Mode is a mode that changes the mouse tracking encoding
93// formatted with SGR parameters. 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.
94// 567//
95// See: https://invisible-island.net/xterm/ctlseqs/ctlseqs.html#h2-Mouse-Tracking 568// See: https://invisible-island.net/xterm/ctlseqs/ctlseqs.html#h2-Mouse-Tracking
96const ( 569const (
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)
97 EnableMouseSgrExt = "\x1b[?1006h" 581 EnableMouseSgrExt = "\x1b[?1006h"
98 DisableMouseSgrExt = "\x1b[?1006l" 582 DisableMouseSgrExt = "\x1b[?1006l"
99 RequestMouseSgrExt = "\x1b[?1006$p" 583 RequestMouseSgrExt = "\x1b[?1006$p"
100) 584)
101 585
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
102// Alternate Screen Buffer is a mode that determines whether the alternate screen 662// Alternate Screen Buffer is a mode that determines whether the alternate screen
103// buffer is active. 663// buffer is active.
104// 664//
105// See: https://invisible-island.net/xterm/ctlseqs/ctlseqs.html#h2-The-Alternate-Screen-Buffer 665// See: https://invisible-island.net/xterm/ctlseqs/ctlseqs.html#h2-The-Alternate-Screen-Buffer
666//
667// Deprecated: use [AltScreenSaveCursorMode] instead.
106const ( 668const (
669 AltScreenBufferMode = DECMode(1049)
670
671 SetAltScreenBufferMode = "\x1b[?1049h"
672 ResetAltScreenBufferMode = "\x1b[?1049l"
673 RequestAltScreenBufferMode = "\x1b[?1049$p"
674
107 EnableAltScreenBuffer = "\x1b[?1049h" 675 EnableAltScreenBuffer = "\x1b[?1049h"
108 DisableAltScreenBuffer = "\x1b[?1049l" 676 DisableAltScreenBuffer = "\x1b[?1049l"
109 RequestAltScreenBuffer = "\x1b[?1049$p" 677 RequestAltScreenBuffer = "\x1b[?1049$p"
@@ -114,6 +682,16 @@ const (
114// 682//
115// See: https://cirw.in/blog/bracketed-paste 683// See: https://cirw.in/blog/bracketed-paste
116// See: https://invisible-island.net/xterm/ctlseqs/ctlseqs.html#h2-Bracketed-Paste-Mode 684// 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.
117const ( 695const (
118 EnableBracketedPaste = "\x1b[?2004h" 696 EnableBracketedPaste = "\x1b[?2004h"
119 DisableBracketedPaste = "\x1b[?2004l" 697 DisableBracketedPaste = "\x1b[?2004l"
@@ -125,6 +703,18 @@ const (
125// 703//
126// See: https://gist.github.com/christianparpart/d8a62cc1ab659194337d73e399004036 704// See: https://gist.github.com/christianparpart/d8a62cc1ab659194337d73e399004036
127const ( 705const (
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
128 EnableSyncdOutput = "\x1b[?2026h" 718 EnableSyncdOutput = "\x1b[?2026h"
129 DisableSyncdOutput = "\x1b[?2026l" 719 DisableSyncdOutput = "\x1b[?2026l"
130 RequestSyncdOutput = "\x1b[?2026$p" 720 RequestSyncdOutput = "\x1b[?2026$p"
@@ -136,6 +726,16 @@ const (
136// emojis. 726// emojis.
137// 727//
138// See: https://github.com/contour-terminal/terminal-unicode-core 728// 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.
139const ( 739const (
140 EnableGraphemeClustering = "\x1b[?2027h" 740 EnableGraphemeClustering = "\x1b[?2027h"
141 DisableGraphemeClustering = "\x1b[?2027l" 741 DisableGraphemeClustering = "\x1b[?2027l"
@@ -146,6 +746,16 @@ const (
146// Win32 console and Conpty. 746// Win32 console and Conpty.
147// 747//
148// See: https://github.com/microsoft/terminal/blob/main/doc/specs/%234999%20-%20Improved%20keyboard%20handling%20in%20Conpty.md 748// 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.
149const ( 759const (
150 EnableWin32Input = "\x1b[?9001h" 760 EnableWin32Input = "\x1b[?9001h"
151 DisableWin32Input = "\x1b[?9001l" 761 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 (
7 "github.com/charmbracelet/x/ansi/parser" 7 "github.com/charmbracelet/x/ansi/parser"
8) 8)
9 9
10// ParserDispatcher is a function that dispatches a sequence.
11type ParserDispatcher func(Sequence)
12
13// Parser represents a DEC ANSI compatible sequence parser. 10// Parser represents a DEC ANSI compatible sequence parser.
14// 11//
15// It uses a state machine to parse ANSI escape sequences and control 12// It uses a state machine to parse ANSI escape sequences and control
@@ -20,137 +17,194 @@ type ParserDispatcher func(Sequence)
20// 17//
21//go:generate go run ./gen.go 18//go:generate go run ./gen.go
22type Parser struct { 19type Parser struct {
23 // Params contains the raw parameters of the sequence. 20 handler Handler
21
22 // params contains the raw parameters of the sequence.
24 // These parameters used when constructing CSI and DCS sequences. 23 // These parameters used when constructing CSI and DCS sequences.
25 Params []int 24 params []int
26 25
27 // Data contains the raw data of the sequence. 26 // data contains the raw data of the sequence.
28 // These data used when constructing OSC, DCS, SOS, PM, and APC sequences. 27 // These data used when constructing OSC, DCS, SOS, PM, and APC sequences.
29 Data []byte 28 data []byte
30 29
31 // DataLen keeps track of the length of the data buffer. 30 // 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. 31 // 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. 32 // Otherwise, dataLen is limited by the size of the data buffer.
34 DataLen int 33 dataLen int
35 34
36 // ParamsLen keeps track of the number of parameters. 35 // paramsLen keeps track of the number of parameters.
37 // This is limited by the size of the Params buffer. 36 // This is limited by the size of the params buffer.
38 // 37 //
39 // This is also used when collecting UTF-8 runes to keep track of the 38 // This is also used when collecting UTF-8 runes to keep track of the
40 // number of rune bytes collected. 39 // number of rune bytes collected.
41 ParamsLen int 40 paramsLen int
42 41
43 // Cmd contains the raw command along with the private marker and 42 // cmd contains the raw command along with the private prefix and
44 // intermediate bytes of the sequence. 43 // intermediate bytes of the sequence.
45 // The first lower byte contains the command byte, the next byte contains 44 // 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.
47 // 46 //
48 // This is also used when collecting UTF-8 runes treating it as a slice of 47 // This is also used when collecting UTF-8 runes treating it as a slice of
49 // 4 bytes. 48 // 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}
51 65
52 // State is the current state of the parser. 66// SetParamsSize sets the size of the parameters buffer.
53 State byte 67// This is used when constructing CSI and DCS sequences.
68func (p *Parser) SetParamsSize(size int) {
69 p.params = make([]int, size)
54} 70}
55 71
56// NewParser returns a new parser with the given sizes allocated. 72// SetDataSize sets the size of the data buffer.
57// If dataSize is zero, the underlying data buffer will be unlimited and will 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
58// grow as needed. 75// grow as needed.
59func NewParser(paramsSize, dataSize int) *Parser { 76func (p *Parser) SetDataSize(size int) {
60 s := new(Parser) 77 if size <= 0 {
61 if dataSize <= 0 { 78 size = 0
62 dataSize = 0 79 p.dataLen = -1
63 s.DataLen = -1
64 } 80 }
65 s.Params = make([]int, paramsSize) 81 p.data = make([]byte, size)
66 s.Data = make([]byte, dataSize) 82}
67 return s 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]
68} 123}
69 124
70// Reset resets the parser to its initial state. 125// Reset resets the parser to its initial state.
71func (p *Parser) Reset() { 126func (p *Parser) Reset() {
72 p.clear() 127 p.clear()
73 p.State = parser.GroundState 128 p.state = parser.GroundState
74} 129}
75 130
76// clear clears the parser parameters and command. 131// clear clears the parser parameters and command.
77func (p *Parser) clear() { 132func (p *Parser) clear() {
78 if len(p.Params) > 0 { 133 if len(p.params) > 0 {
79 p.Params[0] = parser.MissingParam 134 p.params[0] = parser.MissingParam
80 } 135 }
81 p.ParamsLen = 0 136 p.paramsLen = 0
82 p.Cmd = 0 137 p.cmd = 0
83} 138}
84 139
85// clearCmd clears the parser command, params len and data len. 140// State returns the current state of the parser.
86func (p *Parser) clearCmd() { 141func (p *Parser) State() parser.State {
87 p.Cmd = 0 142 return p.state
88 p.ParamsLen = 0
89 p.DataLen = 0
90} 143}
91 144
92// StateName returns the name of the current state. 145// StateName returns the name of the current state.
93func (p *Parser) StateName() string { 146func (p *Parser) StateName() string {
94 return parser.StateNames[p.State] 147 return parser.StateNames[p.state]
95} 148}
96 149
97// Parse parses the given dispatcher and byte buffer. 150// 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) {
99 for i := 0; i < len(b); i++ { 153 for i := 0; i < len(b); i++ {
100 p.Advance(dispatcher, b[i], i < len(b)-1) 154 p.Advance(b[i])
101 } 155 }
102} 156}
103 157
104// Advance advances the parser with the given dispatcher and byte. 158// Advance advances the parser using the given byte. It returns the action
105func (p *Parser) Advance(dispatcher ParserDispatcher, b byte, more bool) parser.Action { 159// performed by the parser.
106 switch p.State { 160func (p *Parser) Advance(b byte) parser.Action {
161 switch p.state {
107 case parser.Utf8State: 162 case parser.Utf8State:
108 // We handle UTF-8 here. 163 // We handle UTF-8 here.
109 return p.advanceUtf8(dispatcher, b) 164 return p.advanceUtf8(b)
110 default: 165 default:
111 return p.advance(dispatcher, b, more) 166 return p.advance(b)
112 } 167 }
113} 168}
114 169
115func (p *Parser) collectRune(b byte) { 170func (p *Parser) collectRune(b byte) {
116 if p.ParamsLen >= utf8.UTFMax { 171 if p.paramsLen >= utf8.UTFMax {
117 return 172 return
118 } 173 }
119 174
120 shift := p.ParamsLen * 8 175 shift := p.paramsLen * 8
121 p.Cmd &^= 0xff << shift 176 p.cmd &^= 0xff << shift
122 p.Cmd |= int(b) << shift 177 p.cmd |= int(b) << shift
123 p.ParamsLen++ 178 p.paramsLen++
124} 179}
125 180
126func (p *Parser) advanceUtf8(dispatcher ParserDispatcher, b byte) parser.Action { 181func (p *Parser) advanceUtf8(b byte) parser.Action {
127 // Collect UTF-8 rune bytes. 182 // Collect UTF-8 rune bytes.
128 p.collectRune(b) 183 p.collectRune(b)
129 rw := utf8ByteLen(byte(p.Cmd & 0xff)) 184 rw := utf8ByteLen(byte(p.cmd & 0xff))
130 if rw == -1 { 185 if rw == -1 {
131 // We panic here because the first byte comes from the state machine, 186 // We panic here because the first byte comes from the state machine,
132 // if this panics, it means there is a bug in the state machine! 187 // if this panics, it means there is a bug in the state machine!
133 panic("invalid rune") // unreachable 188 panic("invalid rune") // unreachable
134 } 189 }
135 190
136 if p.ParamsLen < rw { 191 if p.paramsLen < rw {
137 return parser.CollectAction 192 return parser.CollectAction
138 } 193 }
139 194
140 // We have enough bytes to decode the rune using unsafe 195 // We have enough bytes to decode the rune using unsafe
141 r, _ := utf8.DecodeRune((*[utf8.UTFMax]byte)(unsafe.Pointer(&p.Cmd))[:rw]) 196 if p.handler.Print != nil {
142 if dispatcher != nil { 197 p.handler.Print(p.Rune())
143 dispatcher(Rune(r))
144 } 198 }
145 199
146 p.State = parser.GroundState 200 p.state = parser.GroundState
147 p.ParamsLen = 0 201 p.paramsLen = 0
148 202
149 return parser.PrintAction 203 return parser.PrintAction
150} 204}
151 205
152func (p *Parser) advance(d ParserDispatcher, b byte, more bool) parser.Action { 206func (p *Parser) advance(b byte) parser.Action {
153 state, action := parser.Table.Transition(p.State, b) 207 state, action := parser.Table.Transition(p.state, b)
154 208
155 // We need to clear the parser state if the state changes from EscapeState. 209 // We need to clear the parser state if the state changes from EscapeState.
156 // This is because when we enter the EscapeState, we don't get a chance to 210 // 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 {
158 // ST (\x1b\\ or \x9c), we dispatch the current sequence and transition to 212 // ST (\x1b\\ or \x9c), we dispatch the current sequence and transition to
159 // EscapeState. However, the parser state is not cleared in this case and 213 // EscapeState. However, the parser state is not cleared in this case and
160 // we need to clear it here before dispatching the esc sequence. 214 // we need to clear it here before dispatching the esc sequence.
161 if p.State != state { 215 if p.state != state {
162 if p.State == parser.EscapeState { 216 if p.state == parser.EscapeState {
163 p.performAction(d, parser.ClearAction, state, b) 217 p.performAction(parser.ClearAction, state, b)
164 } 218 }
165 if action == parser.PutAction && 219 if action == parser.PutAction &&
166 p.State == parser.DcsEntryState && state == parser.DcsStringState { 220 p.state == parser.DcsEntryState && state == parser.DcsStringState {
167 // XXX: This is a special case where we need to start collecting 221 // XXX: This is a special case where we need to start collecting
168 // non-string parameterized data i.e. doesn't follow the ECMA-48 § 222 // non-string parameterized data i.e. doesn't follow the ECMA-48 §
169 // 5.4.1 string parameters format. 223 // 5.4.1 string parameters format.
170 p.performAction(d, parser.StartAction, state, 0) 224 p.performAction(parser.StartAction, state, 0)
171 } 225 }
172 } 226 }
173 227
174 // Handle special cases 228 // Handle special cases
175 switch { 229 switch {
176 case b == ESC && p.State == parser.EscapeState: 230 case b == ESC && p.state == parser.EscapeState:
177 // Two ESCs in a row 231 // Two ESCs in a row
178 p.performAction(d, parser.ExecuteAction, state, b) 232 p.performAction(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)
204 default: 233 default:
205 p.performAction(d, action, state, b) 234 p.performAction(action, state, b)
206 } 235 }
207 236
208 p.State = state 237 p.state = state
209 238
210 return action 239 return action
211} 240}
212 241
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) {
214 switch action { 262 switch action {
215 case parser.IgnoreAction: 263 case parser.IgnoreAction:
216 break 264 break
@@ -219,140 +267,139 @@ func (p *Parser) performAction(dispatcher ParserDispatcher, action parser.Action
219 p.clear() 267 p.clear()
220 268
221 case parser.PrintAction: 269 case parser.PrintAction:
222 if dispatcher != nil { 270 p.cmd = int(b)
223 dispatcher(Rune(b)) 271 if p.handler.Print != nil {
272 p.handler.Print(rune(b))
224 } 273 }
225 274
226 case parser.ExecuteAction: 275 case parser.ExecuteAction:
227 if dispatcher != nil { 276 p.cmd = int(b)
228 dispatcher(ControlCode(b)) 277 if p.handler.Execute != nil {
278 p.handler.Execute(b)
229 } 279 }
230 280
231 case parser.MarkerAction: 281 case parser.PrefixAction:
232 // Collect private marker 282 // Collect private prefix
233 // we only store the last marker 283 // we only store the last prefix
234 p.Cmd &^= 0xff << parser.MarkerShift 284 p.cmd &^= 0xff << parser.PrefixShift
235 p.Cmd |= int(b) << parser.MarkerShift 285 p.cmd |= int(b) << parser.PrefixShift
236 286
237 case parser.CollectAction: 287 case parser.CollectAction:
238 if state == parser.Utf8State { 288 if state == parser.Utf8State {
239 // Reset the UTF-8 counter 289 // Reset the UTF-8 counter
240 p.ParamsLen = 0 290 p.paramsLen = 0
241 p.collectRune(b) 291 p.collectRune(b)
242 } else { 292 } else {
243 // Collect intermediate bytes 293 // Collect intermediate bytes
244 // we only store the last intermediate byte 294 // we only store the last intermediate byte
245 p.Cmd &^= 0xff << parser.IntermedShift 295 p.cmd &^= 0xff << parser.IntermedShift
246 p.Cmd |= int(b) << parser.IntermedShift 296 p.cmd |= int(b) << parser.IntermedShift
247 } 297 }
248 298
249 case parser.ParamAction: 299 case parser.ParamAction:
250 // Collect parameters 300 // Collect parameters
251 if p.ParamsLen >= len(p.Params) { 301 if p.paramsLen >= len(p.params) {
252 break 302 break
253 } 303 }
254 304
255 if b >= '0' && b <= '9' { 305 if b >= '0' && b <= '9' {
256 if p.Params[p.ParamsLen] == parser.MissingParam { 306 if p.params[p.paramsLen] == parser.MissingParam {
257 p.Params[p.ParamsLen] = 0 307 p.params[p.paramsLen] = 0
258 } 308 }
259 309
260 p.Params[p.ParamsLen] *= 10 310 p.params[p.paramsLen] *= 10
261 p.Params[p.ParamsLen] += int(b - '0') 311 p.params[p.paramsLen] += int(b - '0')
262 } 312 }
263 313
264 if b == ':' { 314 if b == ':' {
265 p.Params[p.ParamsLen] |= parser.HasMoreFlag 315 p.params[p.paramsLen] |= parser.HasMoreFlag
266 } 316 }
267 317
268 if b == ';' || b == ':' { 318 if b == ';' || b == ':' {
269 p.ParamsLen++ 319 p.paramsLen++
270 if p.ParamsLen < len(p.Params) { 320 if p.paramsLen < len(p.params) {
271 p.Params[p.ParamsLen] = parser.MissingParam 321 p.params[p.paramsLen] = parser.MissingParam
272 } 322 }
273 } 323 }
274 324
275 case parser.StartAction: 325 case parser.StartAction:
276 if p.DataLen < 0 && p.Data != nil { 326 if p.dataLen < 0 && p.data != nil {
277 p.Data = p.Data[:0] 327 p.data = p.data[:0]
278 } else { 328 } else {
279 p.DataLen = 0 329 p.dataLen = 0
280 } 330 }
281 if p.State >= parser.DcsEntryState && p.State <= parser.DcsStringState { 331 if p.state >= parser.DcsEntryState && p.state <= parser.DcsStringState {
282 // Collect the command byte for DCS 332 // Collect the command byte for DCS
283 p.Cmd |= int(b) 333 p.cmd |= int(b)
284 } else { 334 } else {
285 p.Cmd = parser.MissingCommand 335 p.cmd = parser.MissingCommand
286 } 336 }
287 337
288 case parser.PutAction: 338 case parser.PutAction:
289 switch p.State { 339 switch p.state {
290 case parser.OscStringState: 340 case parser.OscStringState:
291 if b == ';' && p.Cmd == parser.MissingCommand { 341 if b == ';' && p.cmd == parser.MissingCommand {
292 // Try to parse the command 342 p.parseStringCmd()
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 }
308 } 343 }
309 } 344 }
310 345
311 if p.DataLen < 0 { 346 if p.dataLen < 0 {
312 p.Data = append(p.Data, b) 347 p.data = append(p.data, b)
313 } else { 348 } else {
314 if p.DataLen < len(p.Data) { 349 if p.dataLen < len(p.data) {
315 p.Data[p.DataLen] = b 350 p.data[p.dataLen] = b
316 p.DataLen++ 351 p.dataLen++
317 } 352 }
318 } 353 }
319 354
320 case parser.DispatchAction: 355 case parser.DispatchAction:
321 // Increment the last parameter 356 // Increment the last parameter
322 if p.ParamsLen > 0 && p.ParamsLen < len(p.Params)-1 || 357 if p.paramsLen > 0 && p.paramsLen < len(p.params)-1 ||
323 p.ParamsLen == 0 && len(p.Params) > 0 && p.Params[0] != parser.MissingParam { 358 p.paramsLen == 0 && len(p.params) > 0 && p.params[0] != parser.MissingParam {
324 p.ParamsLen++ 359 p.paramsLen++
325 } 360 }
326 361
327 if dispatcher == nil { 362 if p.state == parser.OscStringState && p.cmd == parser.MissingCommand {
328 break 363 // Ensure we have a command for OSC
364 p.parseStringCmd()
329 } 365 }
330 366
331 var seq Sequence 367 data := p.data
332 data := p.Data 368 if p.dataLen >= 0 {
333 if p.DataLen >= 0 { 369 data = data[:p.dataLen]
334 data = data[:p.DataLen]
335 } 370 }
336 switch p.State { 371 switch p.state {
337 case parser.CsiEntryState, parser.CsiParamState, parser.CsiIntermediateState: 372 case parser.CsiEntryState, parser.CsiParamState, parser.CsiIntermediateState:
338 p.Cmd |= int(b) 373 p.cmd |= int(b)
339 seq = CsiSequence{Cmd: p.Cmd, Params: p.Params[:p.ParamsLen]} 374 if p.handler.HandleCsi != nil {
375 p.handler.HandleCsi(Cmd(p.cmd), p.Params())
376 }
340 case parser.EscapeState, parser.EscapeIntermediateState: 377 case parser.EscapeState, parser.EscapeIntermediateState:
341 p.Cmd |= int(b) 378 p.cmd |= int(b)
342 seq = EscSequence(p.Cmd) 379 if p.handler.HandleEsc != nil {
380 p.handler.HandleEsc(Cmd(p.cmd))
381 }
343 case parser.DcsEntryState, parser.DcsParamState, parser.DcsIntermediateState, parser.DcsStringState: 382 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 }
345 case parser.OscStringState: 386 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 }
347 case parser.SosStringState: 390 case parser.SosStringState:
348 seq = SosSequence{Data: data} 391 if p.handler.HandleSos != nil {
392 p.handler.HandleSos(data)
393 }
349 case parser.PmStringState: 394 case parser.PmStringState:
350 seq = PmSequence{Data: data} 395 if p.handler.HandlePm != nil {
396 p.handler.HandlePm(data)
397 }
351 case parser.ApcStringState: 398 case parser.ApcStringState:
352 seq = ApcSequence{Data: data} 399 if p.handler.HandleApc != nil {
400 p.handler.HandleApc(data)
401 }
353 } 402 }
354
355 dispatcher(seq)
356 } 403 }
357} 404}
358 405
vendor/github.com/charmbracelet/x/ansi/parser/const.go +2 −2
@@ -8,7 +8,7 @@ const (
8 NoneAction Action = iota 8 NoneAction Action = iota
9 ClearAction 9 ClearAction
10 CollectAction 10 CollectAction
11 MarkerAction 11 PrefixAction
12 DispatchAction 12 DispatchAction
13 ExecuteAction 13 ExecuteAction
14 StartAction // Start of a data string 14 StartAction // Start of a data string
@@ -24,7 +24,7 @@ var ActionNames = []string{
24 "NoneAction", 24 "NoneAction",
25 "ClearAction", 25 "ClearAction",
26 "CollectAction", 26 "CollectAction",
27 "MarkerAction", 27 "PrefixAction",
28 "DispatchAction", 28 "DispatchAction",
29 "ExecuteAction", 29 "ExecuteAction",
30 "StartAction", 30 "StartAction",
vendor/github.com/charmbracelet/x/ansi/parser/seq.go +8 −8
@@ -4,9 +4,9 @@ import "math"
4 4
5// Shift and masks for sequence parameters and intermediates. 5// Shift and masks for sequence parameters and intermediates.
6const ( 6const (
7 MarkerShift = 8 7 PrefixShift = 8
8 IntermedShift = 16 8 IntermedShift = 16
9 CommandMask = 0xff 9 FinalMask = 0xff
10 HasMoreFlag = math.MinInt32 10 HasMoreFlag = math.MinInt32
11 ParamMask = ^HasMoreFlag 11 ParamMask = ^HasMoreFlag
12 MissingParam = ParamMask 12 MissingParam = ParamMask
@@ -22,12 +22,12 @@ const (
22 DefaultParamValue = 0 22 DefaultParamValue = 0
23) 23)
24 24
25// Marker returns the marker byte of the sequence. 25// Prefix returns the prefix byte of the sequence.
26// This is always gonna be one of the following '<' '=' '>' '?' and in the 26// This is always gonna be one of the following '<' '=' '>' '?' and in the
27// range of 0x3C-0x3F. 27// range of 0x3C-0x3F.
28// Zero is returned if the sequence does not have a marker. 28// Zero is returned if the sequence does not have a prefix.
29func Marker(cmd int) int { 29func Prefix(cmd int) int {
30 return (cmd >> MarkerShift) & CommandMask 30 return (cmd >> PrefixShift) & FinalMask
31} 31}
32 32
33// Intermediate returns the intermediate byte of the sequence. 33// Intermediate returns the intermediate byte of the sequence.
@@ -36,12 +36,12 @@ func Marker(cmd int) int {
36// ',', '-', '.', '/'. 36// ',', '-', '.', '/'.
37// Zero is returned if the sequence does not have an intermediate byte. 37// Zero is returned if the sequence does not have an intermediate byte.
38func Intermediate(cmd int) int { 38func Intermediate(cmd int) int {
39 return (cmd >> IntermedShift) & CommandMask 39 return (cmd >> IntermedShift) & FinalMask
40} 40}
41 41
42// Command returns the command byte of the CSI sequence. 42// Command returns the command byte of the CSI sequence.
43func Command(cmd int) int { 43func Command(cmd int) int {
44 return cmd & CommandMask 44 return cmd & FinalMask
45} 45}
46 46
47// Param returns the parameter at the given index. 47// 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 {
178 table.AddRange(0x20, 0x2F, DcsEntryState, CollectAction, DcsIntermediateState) 178 table.AddRange(0x20, 0x2F, DcsEntryState, CollectAction, DcsIntermediateState)
179 // Dcs_entry -> Dcs_param 179 // Dcs_entry -> Dcs_param
180 table.AddRange(0x30, 0x3B, DcsEntryState, ParamAction, DcsParamState) 180 table.AddRange(0x30, 0x3B, DcsEntryState, ParamAction, DcsParamState)
181 table.AddRange(0x3C, 0x3F, DcsEntryState, MarkerAction, DcsParamState) 181 table.AddRange(0x3C, 0x3F, DcsEntryState, PrefixAction, DcsParamState)
182 // Dcs_entry -> Dcs_passthrough 182 // Dcs_entry -> Dcs_passthrough
183 table.AddRange(0x08, 0x0D, DcsEntryState, PutAction, DcsStringState) // Follows ECMA-48 § 8.3.27 183 table.AddRange(0x08, 0x0D, DcsEntryState, PutAction, DcsStringState) // Follows ECMA-48 § 8.3.27
184 // XXX: allows passing ESC (not a ECMA-48 standard) this to allow for 184 // XXX: allows passing ESC (not a ECMA-48 standard) this to allow for
@@ -254,7 +254,7 @@ func GenerateTransitionTable() TransitionTable {
254 table.AddRange(0x20, 0x2F, CsiEntryState, CollectAction, CsiIntermediateState) 254 table.AddRange(0x20, 0x2F, CsiEntryState, CollectAction, CsiIntermediateState)
255 // Csi_entry -> Csi_param 255 // Csi_entry -> Csi_param
256 table.AddRange(0x30, 0x3B, CsiEntryState, ParamAction, CsiParamState) 256 table.AddRange(0x30, 0x3B, CsiEntryState, ParamAction, CsiParamState)
257 table.AddRange(0x3C, 0x3F, CsiEntryState, MarkerAction, CsiParamState) 257 table.AddRange(0x3C, 0x3F, CsiEntryState, PrefixAction, CsiParamState)
258 258
259 // Osc_string 259 // Osc_string
260 table.AddRange(0x00, 0x06, OscStringState, IgnoreAction, OscStringState) 260 table.AddRange(0x00, 0x06, OscStringState, IgnoreAction, OscStringState)
vendor/github.com/charmbracelet/x/ansi/parser_decode.go +206 −105
@@ -1,11 +1,10 @@
1package ansi 1package ansi
2 2
3import ( 3import (
4 "bytes"
5 "strings"
6 "unicode/utf8" 4 "unicode/utf8"
7 5
8 "github.com/charmbracelet/x/ansi/parser" 6 "github.com/charmbracelet/x/ansi/parser"
7 "github.com/mattn/go-runewidth"
9 "github.com/rivo/uniseg" 8 "github.com/rivo/uniseg"
10) 9)
11 10
@@ -16,7 +15,7 @@ type State = byte
16// ANSI escape sequence states used by [DecodeSequence]. 15// ANSI escape sequence states used by [DecodeSequence].
17const ( 16const (
18 NormalState State = iota 17 NormalState State = iota
19 MarkerState 18 PrefixState
20 ParamsState 19 ParamsState
21 IntermedState 20 IntermedState
22 EscapeState 21 EscapeState
@@ -35,22 +34,22 @@ const (
35// 34//
36// Passing a non-nil [*Parser] as the last argument will allow the decoder to 35// Passing a non-nil [*Parser] as the last argument will allow the decoder to
37// collect sequence parameters, data, and commands. The parser cmd will have 36// 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.
39// In the case of a OSC sequence, the cmd will be the OSC command number. Use 38// 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
41// as parameters. 40// as parameters.
42// 41//
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
44// validity of other data sequences, OSC, DCS, etc, will require checking for 43// validity of other data sequences, OSC, DCS, etc, will require checking for
45// the returned sequence terminator bytes such as ST (ESC \\) and BEL). 44// the returned sequence terminator bytes such as ST (ESC \\) and BEL).
46// 45//
47// We store the command byte in [p.Cmd] in the most significant byte, the 46// We store the command byte in [Cmd] in the most significant byte, the
48// marker byte in the next byte, and the intermediate byte in the least 47// prefix byte in the next byte, and the intermediate byte in the least
49// significant byte. This is done to avoid using a struct to store the command 48// 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 49// and its intermediates and prefixes. The command byte is always the least
51// significant byte i.e. [p.Cmd & 0xff]. Use the [Cmd] type to unpack the 50// significant byte i.e. [Cmd & 0xff]. Use the [Cmd] type to unpack the
52// command, intermediate, and marker bytes. Note that we only collect the last 51// command, intermediate, and prefix bytes. Note that we only collect the last
53// marker character and intermediate byte. 52// prefix character and intermediate byte.
54// 53//
55// The [p.Params] slice will contain the parameters of the sequence. Any 54// The [p.Params] slice will contain the parameters of the sequence. Any
56// sub-parameter will have the [parser.HasMoreFlag] set. Use the [Param] type 55// sub-parameter will have the [parser.HasMoreFlag] set. Use the [Param] type
@@ -67,7 +66,63 @@ const (
67// state = newState 66// state = newState
68// input = input[n:] 67// input = input[n:]
69// } 68// }
69//
70// This function treats the text as a sequence of grapheme clusters.
70func DecodeSequence[T string | []byte](b T, state byte, p *Parser) (seq T, width int, n int, newState byte) { 71func 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) {
71 for i := 0; i < len(b); i++ { 126 for i := 0; i < len(b); i++ {
72 c := b[i] 127 c := b[i]
73 128
@@ -76,39 +131,39 @@ func DecodeSequence[T string | []byte](b T, state byte, p *Parser) (seq T, width
76 switch c { 131 switch c {
77 case ESC: 132 case ESC:
78 if p != nil { 133 if p != nil {
79 if len(p.Params) > 0 { 134 if len(p.params) > 0 {
80 p.Params[0] = parser.MissingParam 135 p.params[0] = parser.MissingParam
81 } 136 }
82 p.Cmd = 0 137 p.cmd = 0
83 p.ParamsLen = 0 138 p.paramsLen = 0
84 p.DataLen = 0 139 p.dataLen = 0
85 } 140 }
86 state = EscapeState 141 state = EscapeState
87 continue 142 continue
88 case CSI, DCS: 143 case CSI, DCS:
89 if p != nil { 144 if p != nil {
90 if len(p.Params) > 0 { 145 if len(p.params) > 0 {
91 p.Params[0] = parser.MissingParam 146 p.params[0] = parser.MissingParam
92 } 147 }
93 p.Cmd = 0 148 p.cmd = 0
94 p.ParamsLen = 0 149 p.paramsLen = 0
95 p.DataLen = 0 150 p.dataLen = 0
96 } 151 }
97 state = MarkerState 152 state = PrefixState
98 continue 153 continue
99 case OSC, APC, SOS, PM: 154 case OSC, APC, SOS, PM:
100 if p != nil { 155 if p != nil {
101 p.Cmd = parser.MissingCommand 156 p.cmd = parser.MissingCommand
102 p.DataLen = 0 157 p.dataLen = 0
103 } 158 }
104 state = StringState 159 state = StringState
105 continue 160 continue
106 } 161 }
107 162
108 if p != nil { 163 if p != nil {
109 p.DataLen = 0 164 p.dataLen = 0
110 p.ParamsLen = 0 165 p.paramsLen = 0
111 p.Cmd = 0 166 p.cmd = 0
112 } 167 }
113 if c > US && c < DEL { 168 if c > US && c < DEL {
114 // ASCII printable characters 169 // ASCII printable characters
@@ -122,18 +177,21 @@ func DecodeSequence[T string | []byte](b T, state byte, p *Parser) (seq T, width
122 177
123 if utf8.RuneStart(c) { 178 if utf8.RuneStart(c) {
124 seq, _, width, _ = FirstGraphemeCluster(b, -1) 179 seq, _, width, _ = FirstGraphemeCluster(b, -1)
180 if m == WcWidth {
181 width = runewidth.StringWidth(string(seq))
182 }
125 i += len(seq) 183 i += len(seq)
126 return b[:i], width, i, NormalState 184 return b[:i], width, i, NormalState
127 } 185 }
128 186
129 // Invalid UTF-8 sequence 187 // Invalid UTF-8 sequence
130 return b[:i], 0, i, NormalState 188 return b[:i], 0, i, NormalState
131 case MarkerState: 189 case PrefixState:
132 if c >= '<' && c <= '?' { 190 if c >= '<' && c <= '?' {
133 if p != nil { 191 if p != nil {
134 // We only collect the last marker character. 192 // We only collect the last prefix character.
135 p.Cmd &^= 0xff << parser.MarkerShift 193 p.cmd &^= 0xff << parser.PrefixShift
136 p.Cmd |= int(c) << parser.MarkerShift 194 p.cmd |= int(c) << parser.PrefixShift
137 } 195 }
138 break 196 break
139 } 197 }
@@ -143,27 +201,27 @@ func DecodeSequence[T string | []byte](b T, state byte, p *Parser) (seq T, width
143 case ParamsState: 201 case ParamsState:
144 if c >= '0' && c <= '9' { 202 if c >= '0' && c <= '9' {
145 if p != nil { 203 if p != nil {
146 if p.Params[p.ParamsLen] == parser.MissingParam { 204 if p.params[p.paramsLen] == parser.MissingParam {
147 p.Params[p.ParamsLen] = 0 205 p.params[p.paramsLen] = 0
148 } 206 }
149 207
150 p.Params[p.ParamsLen] *= 10 208 p.params[p.paramsLen] *= 10
151 p.Params[p.ParamsLen] += int(c - '0') 209 p.params[p.paramsLen] += int(c - '0')
152 } 210 }
153 break 211 break
154 } 212 }
155 213
156 if c == ':' { 214 if c == ':' {
157 if p != nil { 215 if p != nil {
158 p.Params[p.ParamsLen] |= parser.HasMoreFlag 216 p.params[p.paramsLen] |= parser.HasMoreFlag
159 } 217 }
160 } 218 }
161 219
162 if c == ';' || c == ':' { 220 if c == ';' || c == ':' {
163 if p != nil { 221 if p != nil {
164 p.ParamsLen++ 222 p.paramsLen++
165 if p.ParamsLen < len(p.Params) { 223 if p.paramsLen < len(p.params) {
166 p.Params[p.ParamsLen] = parser.MissingParam 224 p.params[p.paramsLen] = parser.MissingParam
167 } 225 }
168 } 226 }
169 break 227 break
@@ -174,35 +232,36 @@ func DecodeSequence[T string | []byte](b T, state byte, p *Parser) (seq T, width
174 case IntermedState: 232 case IntermedState:
175 if c >= ' ' && c <= '/' { 233 if c >= ' ' && c <= '/' {
176 if p != nil { 234 if p != nil {
177 p.Cmd &^= 0xff << parser.IntermedShift 235 p.cmd &^= 0xff << parser.IntermedShift
178 p.Cmd |= int(c) << parser.IntermedShift 236 p.cmd |= int(c) << parser.IntermedShift
179 } 237 }
180 break 238 break
181 } 239 }
182 240
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
184 if c >= '@' && c <= '~' { 249 if c >= '@' && c <= '~' {
185 if p != nil { 250 if p != nil {
186 // Increment the last parameter 251 p.cmd &^= 0xff
187 if p.ParamsLen > 0 && p.ParamsLen < len(p.Params)-1 || 252 p.cmd |= int(c)
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)
194 } 253 }
195 254
196 if HasDcsPrefix(b) { 255 if HasDcsPrefix(b) {
197 // Continue to collect DCS data 256 // Continue to collect DCS data
198 if p != nil { 257 if p != nil {
199 p.DataLen = 0 258 p.dataLen = 0
200 } 259 }
201 state = StringState 260 state = StringState
202 continue 261 continue
203 } 262 }
204 263
205 return b[:i+1], 0, i + 1, state 264 return b[:i+1], 0, i + 1, NormalState
206 } 265 }
207 266
208 // Invalid CSI/DCS sequence 267 // Invalid CSI/DCS sequence
@@ -211,18 +270,18 @@ func DecodeSequence[T string | []byte](b T, state byte, p *Parser) (seq T, width
211 switch c { 270 switch c {
212 case '[', 'P': 271 case '[', 'P':
213 if p != nil { 272 if p != nil {
214 if len(p.Params) > 0 { 273 if len(p.params) > 0 {
215 p.Params[0] = parser.MissingParam 274 p.params[0] = parser.MissingParam
216 } 275 }
217 p.ParamsLen = 0 276 p.paramsLen = 0
218 p.Cmd = 0 277 p.cmd = 0
219 } 278 }
220 state = MarkerState 279 state = PrefixState
221 continue 280 continue
222 case ']', 'X', '^', '_': 281 case ']', 'X', '^', '_':
223 if p != nil { 282 if p != nil {
224 p.Cmd = parser.MissingCommand 283 p.cmd = parser.MissingCommand
225 p.DataLen = 0 284 p.dataLen = 0
226 } 285 }
227 state = StringState 286 state = StringState
228 continue 287 continue
@@ -230,14 +289,14 @@ func DecodeSequence[T string | []byte](b T, state byte, p *Parser) (seq T, width
230 289
231 if c >= ' ' && c <= '/' { 290 if c >= ' ' && c <= '/' {
232 if p != nil { 291 if p != nil {
233 p.Cmd &^= 0xff << parser.IntermedShift 292 p.cmd &^= 0xff << parser.IntermedShift
234 p.Cmd |= int(c) << parser.IntermedShift 293 p.cmd |= int(c) << parser.IntermedShift
235 } 294 }
236 continue 295 continue
237 } else if c >= '0' && c <= '~' { 296 } else if c >= '0' && c <= '~' {
238 if p != nil { 297 if p != nil {
239 p.Cmd &^= 0xff 298 p.cmd &^= 0xff
240 p.Cmd |= int(c) 299 p.cmd |= int(c)
241 } 300 }
242 return b[:i+1], 0, i + 1, NormalState 301 return b[:i+1], 0, i + 1, NormalState
243 } 302 }
@@ -248,15 +307,31 @@ func DecodeSequence[T string | []byte](b T, state byte, p *Parser) (seq T, width
248 switch c { 307 switch c {
249 case BEL: 308 case BEL:
250 if HasOscPrefix(b) { 309 if HasOscPrefix(b) {
310 parseOscCmd(p)
251 return b[:i+1], 0, i + 1, NormalState 311 return b[:i+1], 0, i + 1, NormalState
252 } 312 }
253 case CAN, SUB: 313 case CAN, SUB:
314 if HasOscPrefix(b) {
315 // Ensure we parse the OSC command number
316 parseOscCmd(p)
317 }
318
254 // Cancel the sequence 319 // Cancel the sequence
255 return b[:i], 0, i, NormalState 320 return b[:i], 0, i, NormalState
256 case ST: 321 case ST:
322 if HasOscPrefix(b) {
323 // Ensure we parse the OSC command number
324 parseOscCmd(p)
325 }
326
257 return b[:i+1], 0, i + 1, NormalState 327 return b[:i+1], 0, i + 1, NormalState
258 case ESC: 328 case ESC:
259 if HasStPrefix(b[i:]) { 329 if HasStPrefix(b[i:]) {
330 if HasOscPrefix(b) {
331 // Ensure we parse the OSC command number
332 parseOscCmd(p)
333 }
334
260 // End of string 7-bit (ST) 335 // End of string 7-bit (ST)
261 return b[:i+2], 0, i + 2, NormalState 336 return b[:i+2], 0, i + 2, NormalState
262 } 337 }
@@ -265,23 +340,13 @@ func DecodeSequence[T string | []byte](b T, state byte, p *Parser) (seq T, width
265 return b[:i], 0, i, NormalState 340 return b[:i], 0, i, NormalState
266 } 341 }
267 342
268 if p != nil && p.DataLen < len(p.Data) { 343 if p != nil && p.dataLen < len(p.data) {
269 p.Data[p.DataLen] = c 344 p.data[p.dataLen] = c
270 p.DataLen++ 345 p.dataLen++
271 346
272 // Parse the OSC command number 347 // Parse the OSC command number
273 if c == ';' && p.Cmd == parser.MissingCommand && HasOscPrefix(b) { 348 if c == ';' && HasOscPrefix(b) {
274 for j := 0; j < p.DataLen; j++ { 349 parseOscCmd(p)
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 }
285 } 350 }
286 } 351 }
287 } 352 }
@@ -290,16 +355,21 @@ func DecodeSequence[T string | []byte](b T, state byte, p *Parser) (seq T, width
290 return b, 0, len(b), state 355 return b, 0, len(b), state
291} 356}
292 357
293// Index returns the index of the first occurrence of the given byte slice in 358func parseOscCmd(p *Parser) {
294// the data. It returns -1 if the byte slice is not found. 359 if p == nil || p.cmd != parser.MissingCommand {
295func Index[T string | []byte](data, b T) int { 360 return
296 switch data := any(data).(type) { 361 }
297 case string: 362 for j := 0; j < p.dataLen; j++ {
298 return strings.Index(data, string(b)) 363 d := p.data[j]
299 case []byte: 364 if d < '0' || d > '9' {
300 return bytes.Index(data, []byte(b)) 365 break
366 }
367 if p.cmd == parser.MissingCommand {
368 p.cmd = 0
369 }
370 p.cmd *= 10
371 p.cmd += int(d - '0')
301 } 372 }
302 panic("unreachable")
303} 373}
304 374
305// Equal returns true if the given byte slices are equal. 375// 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) {
380} 450}
381 451
382// Cmd represents a sequence command. This is used to pack/unpack a sequence 452// 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
384// found in CSI and DCS sequences. 454// found in CSI and DCS sequences.
385type Cmd int 455type Cmd int
386 456
387// Marker returns the marker byte of the CSI sequence. 457// Prefix returns the unpacked prefix byte of the CSI sequence.
388// This is always gonna be one of the following '<' '=' '>' '?' and in the 458// This is always gonna be one of the following '<' '=' '>' '?' and in the
389// range of 0x3C-0x3F. 459// range of 0x3C-0x3F.
390// Zero is returned if the sequence does not have a marker. 460// Zero is returned if the sequence does not have a prefix.
391func (c Cmd) Marker() int { 461func (c Cmd) Prefix() byte {
392 return parser.Marker(int(c)) 462 return byte(parser.Prefix(int(c)))
393} 463}
394 464
395// Intermediate returns the intermediate byte of the CSI sequence. 465// Intermediate returns the unpacked intermediate byte of the CSI sequence.
396// An intermediate byte is in the range of 0x20-0x2F. This includes these 466// An intermediate byte is in the range of 0x20-0x2F. This includes these
397// characters from ' ', '!', '"', '#', '$', '%', '&', ”', '(', ')', '*', '+', 467// characters from ' ', '!', '"', '#', '$', '%', '&', ”', '(', ')', '*', '+',
398// ',', '-', '.', '/'. 468// ',', '-', '.', '/'.
399// Zero is returned if the sequence does not have an intermediate byte. 469// Zero is returned if the sequence does not have an intermediate byte.
400func (c Cmd) Intermediate() int { 470func (c Cmd) Intermediate() byte {
401 return parser.Intermediate(int(c)) 471 return byte(parser.Intermediate(int(c)))
402} 472}
403 473
404// Command returns the command byte of the CSI sequence. 474// Final returns the unpacked command byte of the CSI sequence.
405func (c Cmd) Command() int { 475func (c Cmd) Final() byte {
406 return parser.Command(int(c)) 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
407} 494}
408 495
409// Param represents a sequence parameter. Sequence parameters with 496// Param represents a sequence parameter. Sequence parameters with
@@ -411,13 +498,27 @@ func (c Cmd) Command() int {
411// the parameters from a CSI and DCS sequences. 498// the parameters from a CSI and DCS sequences.
412type Param int 499type Param int
413 500
414// Param returns the parameter at the given index. 501// Param returns the unpacked parameter at the given index.
415// It returns -1 if the parameter does not exist. 502// It returns the default value if the parameter is missing.
416func (s Param) Param() int { 503func (s Param) Param(def int) int {
417 return int(s) & parser.ParamMask 504 p := int(s) & parser.ParamMask
505 if p == parser.MissingParam {
506 return def
507 }
508 return p
418} 509}
419 510
420// HasMore returns true if the parameter has more sub-parameters. 511// HasMore unpacks the HasMoreFlag from the parameter.
421func (s Param) HasMore() bool { 512func (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
423} 524}
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 @@
1package ansi 1package ansi
2 2
3import "strconv" 3import (
4 "strconv"
5 "strings"
6)
4 7
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.
6// 13//
7// 0: Clear from cursor to end of screen. 14// 0: Clear from cursor to end of screen.
8// 1: Clear from cursor to beginning of the screen. 15// 1: Clear from cursor to beginning of the screen.
9// 2: Clear entire screen (and moves cursor to upper left on DOS). 16// 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).
11// 18//
12// CSI <n> J 19// CSI <n> J
13// 20//
14// See: https://vt100.net/docs/vt510-rm/ED.html 21// See: https://vt100.net/docs/vt510-rm/ED.html
15func EraseDisplay(n int) string { 22func EraseDisplay(n int) string {
16 if n < 0 { 23 var s string
17 n = 0 24 if n > 0 {
25 s = strconv.Itoa(n)
18 } 26 }
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)
20} 33}
21 34
22// EraseDisplay constants. 35// EraseDisplay constants.
23// These are the possible values for the EraseDisplay function. 36// These are the possible values for the EraseDisplay function.
24const ( 37const (
25 EraseDisplayRight = "\x1b[0J" 38 EraseScreenBelow = "\x1b[J"
26 EraseDisplayLeft = "\x1b[1J" 39 EraseScreenAbove = "\x1b[1J"
27 EraseEntireDisplay = "\x1b[2J" 40 EraseEntireScreen = "\x1b[2J"
41 EraseEntireDisplay = "\x1b[3J"
28) 42)
29 43
30// EraseLine (EL) clears the current line or parts of the line. Possible values: 44// EraseLine (EL) clears the current line or parts of the line. Possible values:
@@ -39,16 +53,22 @@ const (
39// 53//
40// See: https://vt100.net/docs/vt510-rm/EL.html 54// See: https://vt100.net/docs/vt510-rm/EL.html
41func EraseLine(n int) string { 55func EraseLine(n int) string {
42 if n < 0 { 56 var s string
43 n = 0 57 if n > 0 {
58 s = strconv.Itoa(n)
44 } 59 }
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)
46} 66}
47 67
48// EraseLine constants. 68// EraseLine constants.
49// These are the possible values for the EraseLine function. 69// These are the possible values for the EraseLine function.
50const ( 70const (
51 EraseLineRight = "\x1b[0K" 71 EraseLineRight = "\x1b[K"
52 EraseLineLeft = "\x1b[1K" 72 EraseLineLeft = "\x1b[1K"
53 EraseEntireLine = "\x1b[2K" 73 EraseEntireLine = "\x1b[2K"
54) 74)
@@ -56,7 +76,7 @@ const (
56// ScrollUp (SU) scrolls the screen up n lines. New lines are added at the 76// ScrollUp (SU) scrolls the screen up n lines. New lines are added at the
57// bottom of the screen. 77// bottom of the screen.
58// 78//
59// CSI <n> S 79// CSI Pn S
60// 80//
61// See: https://vt100.net/docs/vt510-rm/SU.html 81// See: https://vt100.net/docs/vt510-rm/SU.html
62func ScrollUp(n int) string { 82func ScrollUp(n int) string {
@@ -67,10 +87,20 @@ func ScrollUp(n int) string {
67 return "\x1b[" + s + "S" 87 return "\x1b[" + s + "S"
68} 88}
69 89
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
70// ScrollDown (SD) scrolls the screen down n lines. New lines are added at the 100// ScrollDown (SD) scrolls the screen down n lines. New lines are added at the
71// top of the screen. 101// top of the screen.
72// 102//
73// CSI <n> T 103// CSI Pn T
74// 104//
75// See: https://vt100.net/docs/vt510-rm/SD.html 105// See: https://vt100.net/docs/vt510-rm/SD.html
76func ScrollDown(n int) string { 106func ScrollDown(n int) string {
@@ -81,10 +111,20 @@ func ScrollDown(n int) string {
81 return "\x1b[" + s + "T" 111 return "\x1b[" + s + "T"
82} 112}
83 113
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
84// InsertLine (IL) inserts n blank lines at the current cursor position. 124// InsertLine (IL) inserts n blank lines at the current cursor position.
85// Existing lines are moved down. 125// Existing lines are moved down.
86// 126//
87// CSI <n> L 127// CSI Pn L
88// 128//
89// See: https://vt100.net/docs/vt510-rm/IL.html 129// See: https://vt100.net/docs/vt510-rm/IL.html
90func InsertLine(n int) string { 130func InsertLine(n int) string {
@@ -95,10 +135,15 @@ func InsertLine(n int) string {
95 return "\x1b[" + s + "L" 135 return "\x1b[" + s + "L"
96} 136}
97 137
138// IL is an alias for [InsertLine].
139func IL(n int) string {
140 return InsertLine(n)
141}
142
98// DeleteLine (DL) deletes n lines at the current cursor position. Existing 143// DeleteLine (DL) deletes n lines at the current cursor position. Existing
99// lines are moved up. 144// lines are moved up.
100// 145//
101// CSI <n> M 146// CSI Pn M
102// 147//
103// See: https://vt100.net/docs/vt510-rm/DL.html 148// See: https://vt100.net/docs/vt510-rm/DL.html
104func DeleteLine(n int) string { 149func DeleteLine(n int) string {
@@ -109,12 +154,67 @@ func DeleteLine(n int) string {
109 return "\x1b[" + s + "M" 154 return "\x1b[" + s + "M"
110} 155}
111 156
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
112// SetScrollingRegion (DECSTBM) sets the top and bottom margins for the scrolling 210// SetScrollingRegion (DECSTBM) sets the top and bottom margins for the scrolling
113// region. The default is the entire screen. 211// region. The default is the entire screen.
114// 212//
115// CSI <top> ; <bottom> r 213// CSI <top> ; <bottom> r
116// 214//
117// See: https://vt100.net/docs/vt510-rm/DECSTBM.html 215// See: https://vt100.net/docs/vt510-rm/DECSTBM.html
216//
217// Deprecated: use [SetTopBottomMargins] instead.
118func SetScrollingRegion(t, b int) string { 218func SetScrollingRegion(t, b int) string {
119 if t < 0 { 219 if t < 0 {
120 t = 0 220 t = 0
@@ -124,3 +224,187 @@ func SetScrollingRegion(t, b int) string {
124 } 224 }
125 return "\x1b[" + strconv.Itoa(t) + ";" + strconv.Itoa(b) + "r" 225 return "\x1b[" + strconv.Itoa(t) + ";" + strconv.Itoa(b) + "r"
126} 226}
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 (
12const ResetStyle = "\x1b[m" 12const ResetStyle = "\x1b[m"
13 13
14// Attr is a SGR (Select Graphic Rendition) style attribute. 14// Attr is a SGR (Select Graphic Rendition) style attribute.
15type Attr = string 15type Attr = int
16 16
17// Style represents an ANSI SGR (Select Graphic Rendition) style. 17// Style represents an ANSI SGR (Select Graphic Rendition) style.
18type Style []Attr 18type Style []string
19 19
20// String returns the ANSI SGR (Select Graphic Rendition) style sequence for 20// String returns the ANSI SGR (Select Graphic Rendition) style sequence for
21// the given style. 21// the given style.
@@ -36,186 +36,357 @@ func (s Style) Styled(str string) string {
36 36
37// Reset appends the reset style attribute to the style. 37// Reset appends the reset style attribute to the style.
38func (s Style) Reset() Style { 38func (s Style) Reset() Style {
39 return append(s, ResetAttr) 39 return append(s, resetAttr)
40} 40}
41 41
42// Bold appends the bold style attribute to the style. 42// Bold appends the bold style attribute to the style.
43func (s Style) Bold() Style { 43func (s Style) Bold() Style {
44 return append(s, BoldAttr) 44 return append(s, boldAttr)
45} 45}
46 46
47// Faint appends the faint style attribute to the style. 47// Faint appends the faint style attribute to the style.
48func (s Style) Faint() Style { 48func (s Style) Faint() Style {
49 return append(s, FaintAttr) 49 return append(s, faintAttr)
50} 50}
51 51
52// Italic appends the italic style attribute to the style. 52// Italic appends the italic style attribute to the style.
53func (s Style) Italic() Style { 53func (s Style) Italic() Style {
54 return append(s, ItalicAttr) 54 return append(s, italicAttr)
55} 55}
56 56
57// Underline appends the underline style attribute to the style. 57// Underline appends the underline style attribute to the style.
58func (s Style) Underline() Style { 58func (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
60} 79}
61 80
62// DoubleUnderline appends the double underline style attribute to the style. 81// DoubleUnderline appends the double underline style attribute to the style.
82// This is a convenience method for UnderlineStyle(DoubleUnderlineStyle).
63func (s Style) DoubleUnderline() Style { 83func (s Style) DoubleUnderline() Style {
64 return append(s, DoubleUnderlineAttr) 84 return s.UnderlineStyle(DoubleUnderlineStyle)
65} 85}
66 86
67// CurlyUnderline appends the curly underline style attribute to the style. 87// CurlyUnderline appends the curly underline style attribute to the style.
88// This is a convenience method for UnderlineStyle(CurlyUnderlineStyle).
68func (s Style) CurlyUnderline() Style { 89func (s Style) CurlyUnderline() Style {
69 return append(s, CurlyUnderlineAttr) 90 return s.UnderlineStyle(CurlyUnderlineStyle)
70} 91}
71 92
72// DottedUnderline appends the dotted underline style attribute to the style. 93// DottedUnderline appends the dotted underline style attribute to the style.
94// This is a convenience method for UnderlineStyle(DottedUnderlineStyle).
73func (s Style) DottedUnderline() Style { 95func (s Style) DottedUnderline() Style {
74 return append(s, DottedUnderlineAttr) 96 return s.UnderlineStyle(DottedUnderlineStyle)
75} 97}
76 98
77// DashedUnderline appends the dashed underline style attribute to the style. 99// DashedUnderline appends the dashed underline style attribute to the style.
100// This is a convenience method for UnderlineStyle(DashedUnderlineStyle).
78func (s Style) DashedUnderline() Style { 101func (s Style) DashedUnderline() Style {
79 return append(s, DashedUnderlineAttr) 102 return s.UnderlineStyle(DashedUnderlineStyle)
80} 103}
81 104
82// SlowBlink appends the slow blink style attribute to the style. 105// SlowBlink appends the slow blink style attribute to the style.
83func (s Style) SlowBlink() Style { 106func (s Style) SlowBlink() Style {
84 return append(s, SlowBlinkAttr) 107 return append(s, slowBlinkAttr)
85} 108}
86 109
87// RapidBlink appends the rapid blink style attribute to the style. 110// RapidBlink appends the rapid blink style attribute to the style.
88func (s Style) RapidBlink() Style { 111func (s Style) RapidBlink() Style {
89 return append(s, RapidBlinkAttr) 112 return append(s, rapidBlinkAttr)
90} 113}
91 114
92// Reverse appends the reverse style attribute to the style. 115// Reverse appends the reverse style attribute to the style.
93func (s Style) Reverse() Style { 116func (s Style) Reverse() Style {
94 return append(s, ReverseAttr) 117 return append(s, reverseAttr)
95} 118}
96 119
97// Conceal appends the conceal style attribute to the style. 120// Conceal appends the conceal style attribute to the style.
98func (s Style) Conceal() Style { 121func (s Style) Conceal() Style {
99 return append(s, ConcealAttr) 122 return append(s, concealAttr)
100} 123}
101 124
102// Strikethrough appends the strikethrough style attribute to the style. 125// Strikethrough appends the strikethrough style attribute to the style.
103func (s Style) Strikethrough() Style { 126func (s Style) Strikethrough() Style {
104 return append(s, StrikethroughAttr) 127 return append(s, strikethroughAttr)
105} 128}
106 129
107// NoBold appends the no bold style attribute to the style. 130// NoBold appends the no bold style attribute to the style.
108func (s Style) NoBold() Style { 131func (s Style) NoBold() Style {
109 return append(s, NoBoldAttr) 132 return append(s, noBoldAttr)
110} 133}
111 134
112// NormalIntensity appends the normal intensity style attribute to the style. 135// NormalIntensity appends the normal intensity style attribute to the style.
113func (s Style) NormalIntensity() Style { 136func (s Style) NormalIntensity() Style {
114 return append(s, NormalIntensityAttr) 137 return append(s, normalIntensityAttr)
115} 138}
116 139
117// NoItalic appends the no italic style attribute to the style. 140// NoItalic appends the no italic style attribute to the style.
118func (s Style) NoItalic() Style { 141func (s Style) NoItalic() Style {
119 return append(s, NoItalicAttr) 142 return append(s, noItalicAttr)
120} 143}
121 144
122// NoUnderline appends the no underline style attribute to the style. 145// NoUnderline appends the no underline style attribute to the style.
123func (s Style) NoUnderline() Style { 146func (s Style) NoUnderline() Style {
124 return append(s, NoUnderlineAttr) 147 return append(s, noUnderlineAttr)
125} 148}
126 149
127// NoBlink appends the no blink style attribute to the style. 150// NoBlink appends the no blink style attribute to the style.
128func (s Style) NoBlink() Style { 151func (s Style) NoBlink() Style {
129 return append(s, NoBlinkAttr) 152 return append(s, noBlinkAttr)
130} 153}
131 154
132// NoReverse appends the no reverse style attribute to the style. 155// NoReverse appends the no reverse style attribute to the style.
133func (s Style) NoReverse() Style { 156func (s Style) NoReverse() Style {
134 return append(s, NoReverseAttr) 157 return append(s, noReverseAttr)
135} 158}
136 159
137// NoConceal appends the no conceal style attribute to the style. 160// NoConceal appends the no conceal style attribute to the style.
138func (s Style) NoConceal() Style { 161func (s Style) NoConceal() Style {
139 return append(s, NoConcealAttr) 162 return append(s, noConcealAttr)
140} 163}
141 164
142// NoStrikethrough appends the no strikethrough style attribute to the style. 165// NoStrikethrough appends the no strikethrough style attribute to the style.
143func (s Style) NoStrikethrough() Style { 166func (s Style) NoStrikethrough() Style {
144 return append(s, NoStrikethroughAttr) 167 return append(s, noStrikethroughAttr)
145} 168}
146 169
147// DefaultForegroundColor appends the default foreground color style attribute to the style. 170// DefaultForegroundColor appends the default foreground color style attribute to the style.
148func (s Style) DefaultForegroundColor() Style { 171func (s Style) DefaultForegroundColor() Style {
149 return append(s, DefaultForegroundColorAttr) 172 return append(s, defaultForegroundColorAttr)
150} 173}
151 174
152// DefaultBackgroundColor appends the default background color style attribute to the style. 175// DefaultBackgroundColor appends the default background color style attribute to the style.
153func (s Style) DefaultBackgroundColor() Style { 176func (s Style) DefaultBackgroundColor() Style {
154 return append(s, DefaultBackgroundColorAttr) 177 return append(s, defaultBackgroundColorAttr)
155} 178}
156 179
157// DefaultUnderlineColor appends the default underline color style attribute to the style. 180// DefaultUnderlineColor appends the default underline color style attribute to the style.
158func (s Style) DefaultUnderlineColor() Style { 181func (s Style) DefaultUnderlineColor() Style {
159 return append(s, DefaultUnderlineColorAttr) 182 return append(s, defaultUnderlineColorAttr)
160} 183}
161 184
162// ForegroundColor appends the foreground color style attribute to the style. 185// ForegroundColor appends the foreground color style attribute to the style.
163func (s Style) ForegroundColor(c Color) Style { 186func (s Style) ForegroundColor(c Color) Style {
164 return append(s, ForegroundColorAttr(c)) 187 return append(s, foregroundColorString(c))
165} 188}
166 189
167// BackgroundColor appends the background color style attribute to the style. 190// BackgroundColor appends the background color style attribute to the style.
168func (s Style) BackgroundColor(c Color) Style { 191func (s Style) BackgroundColor(c Color) Style {
169 return append(s, BackgroundColorAttr(c)) 192 return append(s, backgroundColorString(c))
170} 193}
171 194
172// UnderlineColor appends the underline color style attribute to the style. 195// UnderlineColor appends the underline color style attribute to the style.
173func (s Style) UnderlineColor(c Color) Style { 196func (s Style) UnderlineColor(c Color) Style {
174 return append(s, UnderlineColorAttr(c)) 197 return append(s, underlineColorString(c))
175} 198}
176 199
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
177// SGR (Select Graphic Rendition) style attributes. 226// SGR (Select Graphic Rendition) style attributes.
178// See: https://en.wikipedia.org/wiki/ANSI_escape_code#SGR_(Select_Graphic_Rendition)_parameters 227// See: https://en.wikipedia.org/wiki/ANSI_escape_code#SGR_(Select_Graphic_Rendition)_parameters
179const ( 228const (
180 ResetAttr Attr = "0" 229 ResetAttr Attr = 0
181 BoldAttr Attr = "1" 230 BoldAttr Attr = 1
182 FaintAttr Attr = "2" 231 FaintAttr Attr = 2
183 ItalicAttr Attr = "3" 232 ItalicAttr Attr = 3
184 UnderlineAttr Attr = "4" 233 UnderlineAttr Attr = 4
185 DoubleUnderlineAttr Attr = "4:2" 234 SlowBlinkAttr Attr = 5
186 CurlyUnderlineAttr Attr = "4:3" 235 RapidBlinkAttr Attr = 6
187 DottedUnderlineAttr Attr = "4:4" 236 ReverseAttr Attr = 7
188 DashedUnderlineAttr Attr = "4:5" 237 ConcealAttr Attr = 8
189 SlowBlinkAttr Attr = "5" 238 StrikethroughAttr Attr = 9
190 RapidBlinkAttr Attr = "6" 239 NoBoldAttr Attr = 21 // Some terminals treat this as double underline.
191 ReverseAttr Attr = "7" 240 NormalIntensityAttr Attr = 22
192 ConcealAttr Attr = "8" 241 NoItalicAttr Attr = 23
193 StrikethroughAttr Attr = "9" 242 NoUnderlineAttr Attr = 24
194 NoBoldAttr Attr = "21" // Some terminals treat this as double underline. 243 NoBlinkAttr Attr = 25
195 NormalIntensityAttr Attr = "22" 244 NoReverseAttr Attr = 27
196 NoItalicAttr Attr = "23" 245 NoConcealAttr Attr = 28
197 NoUnderlineAttr Attr = "24" 246 NoStrikethroughAttr Attr = 29
198 NoBlinkAttr Attr = "25" 247 BlackForegroundColorAttr Attr = 30
199 NoReverseAttr Attr = "27" 248 RedForegroundColorAttr Attr = 31
200 NoConcealAttr Attr = "28" 249 GreenForegroundColorAttr Attr = 32
201 NoStrikethroughAttr Attr = "29" 250 YellowForegroundColorAttr Attr = 33
202 DefaultForegroundColorAttr Attr = "39" 251 BlueForegroundColorAttr Attr = 34
203 DefaultBackgroundColorAttr Attr = "49" 252 MagentaForegroundColorAttr Attr = 35
204 DefaultUnderlineColorAttr Attr = "59" 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
205) 288)
206 289
207// ForegroundColorAttr returns the style SGR attribute for the given foreground 290const (
208// color. 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.
209// See: https://en.wikipedia.org/wiki/ANSI_escape_code#SGR_(Select_Graphic_Rendition)_parameters 351// See: https://en.wikipedia.org/wiki/ANSI_escape_code#SGR_(Select_Graphic_Rendition)_parameters
210func ForegroundColorAttr(c Color) Attr { 352func foregroundColorString(c Color) string {
211 switch c := c.(type) { 353 switch c := c.(type) {
212 case BasicColor: 354 case BasicColor:
213 // 3-bit or 4-bit ANSI foreground 355 // 3-bit or 4-bit ANSI foreground
214 // "3<n>" or "9<n>" where n is the color number from 0 to 7 356 // "3<n>" or "9<n>" where n is the color number from 0 to 7
215 if c < 8 { 357 switch c {
216 return "3" + string('0'+c) 358 case Black:
217 } else if c < 16 { 359 return blackForegroundColorAttr
218 return "9" + string('0'+c-8) 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
219 } 390 }
220 case ExtendedColor: 391 case ExtendedColor:
221 // 256-color ANSI foreground 392 // 256-color ANSI foreground
@@ -230,21 +401,50 @@ func ForegroundColorAttr(c Color) Attr {
230 strconv.FormatUint(uint64(shift(g)), 10) + ";" + 401 strconv.FormatUint(uint64(shift(g)), 10) + ";" +
231 strconv.FormatUint(uint64(shift(b)), 10) 402 strconv.FormatUint(uint64(shift(b)), 10)
232 } 403 }
233 return DefaultForegroundColorAttr 404 return defaultForegroundColorAttr
234} 405}
235 406
236// BackgroundColorAttr returns the style SGR attribute for the given background 407// backgroundColorString returns the style SGR attribute for the given
237// color. 408// background color.
238// See: https://en.wikipedia.org/wiki/ANSI_escape_code#SGR_(Select_Graphic_Rendition)_parameters 409// See: https://en.wikipedia.org/wiki/ANSI_escape_code#SGR_(Select_Graphic_Rendition)_parameters
239func BackgroundColorAttr(c Color) Attr { 410func backgroundColorString(c Color) string {
240 switch c := c.(type) { 411 switch c := c.(type) {
241 case BasicColor: 412 case BasicColor:
242 // 3-bit or 4-bit ANSI foreground 413 // 3-bit or 4-bit ANSI foreground
243 // "4<n>" or "10<n>" where n is the color number from 0 to 7 414 // "4<n>" or "10<n>" where n is the color number from 0 to 7
244 if c < 8 { 415 switch c {
245 return "4" + string('0'+c) 416 case Black:
246 } else { 417 return blackBackgroundColorAttr
247 return "10" + string('0'+c-8) 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
248 } 448 }
249 case ExtendedColor: 449 case ExtendedColor:
250 // 256-color ANSI foreground 450 // 256-color ANSI foreground
@@ -259,13 +459,13 @@ func BackgroundColorAttr(c Color) Attr {
259 strconv.FormatUint(uint64(shift(g)), 10) + ";" + 459 strconv.FormatUint(uint64(shift(g)), 10) + ";" +
260 strconv.FormatUint(uint64(shift(b)), 10) 460 strconv.FormatUint(uint64(shift(b)), 10)
261 } 461 }
262 return DefaultBackgroundColorAttr 462 return defaultBackgroundColorAttr
263} 463}
264 464
265// UnderlineColorAttr returns the style SGR attribute for the given underline 465// underlineColorString returns the style SGR attribute for the given underline
266// color. 466// color.
267// See: https://en.wikipedia.org/wiki/ANSI_escape_code#SGR_(Select_Graphic_Rendition)_parameters 467// See: https://en.wikipedia.org/wiki/ANSI_escape_code#SGR_(Select_Graphic_Rendition)_parameters
268func UnderlineColorAttr(c Color) Attr { 468func underlineColorString(c Color) string {
269 switch c := c.(type) { 469 switch c := c.(type) {
270 // NOTE: we can't use 3-bit and 4-bit ANSI color codes with underline 470 // NOTE: we can't use 3-bit and 4-bit ANSI color codes with underline
271 // color, use 256-color instead. 471 // color, use 256-color instead.
@@ -285,12 +485,176 @@ func UnderlineColorAttr(c Color) Attr {
285 strconv.FormatUint(uint64(shift(g)), 10) + ";" + 485 strconv.FormatUint(uint64(shift(g)), 10) + ";" +
286 strconv.FormatUint(uint64(shift(b)), 10) 486 strconv.FormatUint(uint64(shift(b)), 10)
287 } 487 }
288 return DefaultUnderlineColorAttr 488 return defaultUnderlineColorAttr
289} 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
290 656
291func shift(v uint32) uint32 { 657 default:
292 if v > 0xff { 658 return 0
293 return v >> 8
294 } 659 }
295 return v
296} 660}
vendor/github.com/charmbracelet/x/ansi/termcap.go +11 −1
@@ -14,7 +14,7 @@ import (
14// 14//
15// See: https://man7.org/linux/man-pages/man5/terminfo.5.html 15// See: https://man7.org/linux/man-pages/man5/terminfo.5.html
16// See: https://invisible-island.net/xterm/ctlseqs/ctlseqs.html#h3-Operating-System-Commands 16// See: https://invisible-island.net/xterm/ctlseqs/ctlseqs.html#h3-Operating-System-Commands
17func RequestTermcap(caps ...string) string { 17func XTGETTCAP(caps ...string) string {
18 if len(caps) == 0 { 18 if len(caps) == 0 {
19 return "" 19 return ""
20 } 20 }
@@ -29,3 +29,13 @@ func RequestTermcap(caps ...string) string {
29 29
30 return s + "\x1b\\" 30 return s + "\x1b\\"
31} 31}
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 (
4 "bytes" 4 "bytes"
5 5
6 "github.com/charmbracelet/x/ansi/parser" 6 "github.com/charmbracelet/x/ansi/parser"
7 "github.com/mattn/go-runewidth"
7 "github.com/rivo/uniseg" 8 "github.com/rivo/uniseg"
8) 9)
9 10
10// Truncate truncates a string to a given length, adding a tail to the 11// Cut the string, without adding any prefix or tail strings. This function is
11// end if the string is longer than the given length. 12// aware of ANSI escape codes and will not break them, and accounts for
12// This function is aware of ANSI escape codes and will not break them, and 13// wide-characters (such as East-Asian characters and emojis). Note that the
13// accounts for wide-characters (such as East Asians and emojis). 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.
14func Truncate(s string, length int, tail string) string { 52func 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 {
15 if sw := StringWidth(s); sw <= length { 66 if sw := StringWidth(s); sw <= length {
16 return s 67 return s
17 } 68 }
@@ -33,6 +84,7 @@ func Truncate(s string, length int, tail string) string {
33 // Here we iterate over the bytes of the string and collect printable 84 // Here we iterate over the bytes of the string and collect printable
34 // characters and runes. We also keep track of the width of the string 85 // characters and runes. We also keep track of the width of the string
35 // in cells. 86 // in cells.
87 //
36 // Once we reach the given length, we start ignoring characters and only 88 // Once we reach the given length, we start ignoring characters and only
37 // collect ANSI escape codes until we reach the end of string. 89 // collect ANSI escape codes until we reach the end of string.
38 for i < len(b) { 90 for i < len(b) {
@@ -41,6 +93,9 @@ func Truncate(s string, length int, tail string) string {
41 // This action happens when we transition to the Utf8State. 93 // This action happens when we transition to the Utf8State.
42 var width int 94 var width int
43 cluster, _, width, _ = uniseg.FirstGraphemeCluster(b[i:], -1) 95 cluster, _, width, _ = uniseg.FirstGraphemeCluster(b[i:], -1)
96 if m == WcWidth {
97 width = runewidth.StringWidth(string(cluster))
98 }
44 99
45 // increment the index by the length of the cluster 100 // increment the index by the length of the cluster
46 i += len(cluster) 101 i += len(cluster)
@@ -105,3 +160,123 @@ func Truncate(s string, length int, tail string) string {
105 160
106 return buf.String() 161 return buf.String()
107} 162}
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
3import ( 3import (
4 "fmt" 4 "fmt"
5 "image/color" 5 "image/color"
6 "strconv"
7 "strings"
8
9 "github.com/lucasb-eyer/go-colorful"
6) 10)
7 11
8// colorToHexString returns a hex string representation of a color. 12// colorToHexString returns a hex string representation of a color.
@@ -27,3 +31,76 @@ func colorToHexString(c color.Color) string {
27func rgbToHex(r, g, b uint32) uint32 { 31func rgbToHex(r, g, b uint32) uint32 {
28 return r<<16 + g<<8 + b 32 return r<<16 + g<<8 + b
29} 33}
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 (
4 "bytes" 4 "bytes"
5 5
6 "github.com/charmbracelet/x/ansi/parser" 6 "github.com/charmbracelet/x/ansi/parser"
7 "github.com/mattn/go-runewidth"
7 "github.com/rivo/uniseg" 8 "github.com/rivo/uniseg"
8) 9)
9 10
@@ -62,7 +63,21 @@ func Strip(s string) string {
62// cells that the string will occupy when printed in a terminal. ANSI escape 63// cells that the string will occupy when printed in a terminal. ANSI escape
63// codes are ignored and wide characters (such as East Asians and emojis) are 64// codes are ignored and wide characters (such as East Asians and emojis) are
64// accounted for. 65// accounted for.
66// This treats the text as a sequence of grapheme clusters.
65func StringWidth(s string) int { 67func 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 {
66 if s == "" { 81 if s == "" {
67 return 0 82 return 0
68 } 83 }
@@ -78,6 +93,9 @@ func StringWidth(s string) int {
78 if state == parser.Utf8State { 93 if state == parser.Utf8State {
79 var w int 94 var w int
80 cluster, _, w, _ = uniseg.FirstGraphemeClusterInString(s[i:], -1) 95 cluster, _, w, _ = uniseg.FirstGraphemeClusterInString(s[i:], -1)
96 if m == WcWidth {
97 w = runewidth.StringWidth(cluster)
98 }
81 width += w 99 width += w
82 i += len(cluster) - 1 100 i += len(cluster) - 1
83 pstate = parser.GroundState 101 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 (
6 "unicode/utf8" 6 "unicode/utf8"
7 7
8 "github.com/charmbracelet/x/ansi/parser" 8 "github.com/charmbracelet/x/ansi/parser"
9 "github.com/mattn/go-runewidth"
9 "github.com/rivo/uniseg" 10 "github.com/rivo/uniseg"
10) 11)
11 12
@@ -17,7 +18,22 @@ const nbsp = 0xA0
17// wide-characters in the string. 18// wide-characters in the string.
18// When preserveSpace is true, spaces at the beginning of a line will be 19// When preserveSpace is true, spaces at the beginning of a line will be
19// preserved. 20// preserved.
21// This treats the text as a sequence of graphemes.
20func Hardwrap(s string, limit int, preserveSpace bool) string { 22func 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 {
21 if limit < 1 { 37 if limit < 1 {
22 return s 38 return s
23 } 39 }
@@ -42,6 +58,9 @@ func Hardwrap(s string, limit int, preserveSpace bool) string {
42 if state == parser.Utf8State { 58 if state == parser.Utf8State {
43 var width int 59 var width int
44 cluster, _, width, _ = uniseg.FirstGraphemeCluster(b[i:], -1) 60 cluster, _, width, _ = uniseg.FirstGraphemeCluster(b[i:], -1)
61 if m == WcWidth {
62 width = runewidth.StringWidth(string(cluster))
63 }
45 i += len(cluster) 64 i += len(cluster)
46 65
47 if curWidth+width > limit { 66 if curWidth+width > limit {
@@ -83,7 +102,9 @@ func Hardwrap(s string, limit int, preserveSpace bool) string {
83 } 102 }
84 103
85 buf.WriteByte(b[i]) 104 buf.WriteByte(b[i])
86 curWidth++ 105 if action == parser.PrintAction {
106 curWidth++
107 }
87 default: 108 default:
88 buf.WriteByte(b[i]) 109 buf.WriteByte(b[i])
89 } 110 }
@@ -106,7 +127,27 @@ func Hardwrap(s string, limit int, preserveSpace bool) string {
106// breakpoint. 127// breakpoint.
107// 128//
108// Note: breakpoints must be a string of 1-cell wide rune characters. 129// Note: breakpoints must be a string of 1-cell wide rune characters.
130//
131// This treats the text as a sequence of graphemes.
109func Wordwrap(s string, limit int, breakpoints string) string { 132func 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 {
110 if limit < 1 { 151 if limit < 1 {
111 return s 152 return s
112 } 153 }
@@ -152,6 +193,9 @@ func Wordwrap(s string, limit int, breakpoints string) string {
152 if state == parser.Utf8State { 193 if state == parser.Utf8State {
153 var width int 194 var width int
154 cluster, _, width, _ = uniseg.FirstGraphemeCluster(b[i:], -1) 195 cluster, _, width, _ = uniseg.FirstGraphemeCluster(b[i:], -1)
196 if m == WcWidth {
197 width = runewidth.StringWidth(string(cluster))
198 }
155 i += len(cluster) 199 i += len(cluster)
156 200
157 r, _ := utf8.DecodeRune(cluster) 201 r, _ := utf8.DecodeRune(cluster)
@@ -234,7 +278,26 @@ func Wordwrap(s string, limit int, breakpoints string) string {
234// (-) is always considered a breakpoint. 278// (-) is always considered a breakpoint.
235// 279//
236// Note: breakpoints must be a string of 1-cell wide rune characters. 280// Note: breakpoints must be a string of 1-cell wide rune characters.
281//
282// This treats the text as a sequence of graphemes.
237func Wrap(s string, limit int, breakpoints string) string { 283func 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 {
238 if limit < 1 { 301 if limit < 1 {
239 return s 302 return s
240 } 303 }
@@ -280,6 +343,9 @@ func Wrap(s string, limit int, breakpoints string) string {
280 if state == parser.Utf8State { 343 if state == parser.Utf8State {
281 var width int 344 var width int
282 cluster, _, width, _ = uniseg.FirstGraphemeCluster(b[i:], -1) 345 cluster, _, width, _ = uniseg.FirstGraphemeCluster(b[i:], -1)
346 if m == WcWidth {
347 width = runewidth.StringWidth(string(cluster))
348 }
283 i += len(cluster) 349 i += len(cluster)
284 350
285 r, _ := utf8.DecodeRune(cluster) 351 r, _ := utf8.DecodeRune(cluster)
@@ -349,6 +415,9 @@ func Wrap(s string, limit int, breakpoints string) string {
349 curWidth++ 415 curWidth++
350 } 416 }
351 default: 417 default:
418 if curWidth == limit {
419 addNewline()
420 }
352 word.WriteRune(r) 421 word.WriteRune(r)
353 wordLen++ 422 wordLen++
354 423
@@ -373,14 +442,17 @@ func Wrap(s string, limit int, breakpoints string) string {
373 i++ 442 i++
374 } 443 }
375 444
376 if word.Len() != 0 { 445 if wordLen == 0 {
377 // Preserve ANSI wrapped spaces at the end of string
378 if curWidth+space.Len() > limit { 446 if curWidth+space.Len() > limit {
379 buf.WriteByte('\n') 447 curWidth = 0
448 } else {
449 // preserve whitespaces
450 buf.Write(space.Bytes())
380 } 451 }
381 addSpace() 452 space.Reset()
382 } 453 }
383 buf.Write(word.Bytes()) 454
455 addWord()
384 456
385 return buf.String() 457 return buf.String()
386} 458}
vendor/github.com/charmbracelet/x/ansi/xterm.go +88
@@ -2,6 +2,84 @@ package ansi
2 2
3import "strconv" 3import "strconv"
4 4
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
5// ModifyOtherKeys returns a sequence that sets XTerm modifyOtherKeys mode. 83// ModifyOtherKeys returns a sequence that sets XTerm modifyOtherKeys mode.
6// The mode argument specifies the mode to set. 84// The mode argument specifies the mode to set.
7// 85//
@@ -13,6 +91,8 @@ import "strconv"
13// 91//
14// See: https://invisible-island.net/xterm/ctlseqs/ctlseqs.html#h3-Functions-using-CSI-_-ordered-by-the-final-character_s_ 92// See: https://invisible-island.net/xterm/ctlseqs/ctlseqs.html#h3-Functions-using-CSI-_-ordered-by-the-final-character_s_
15// See: https://invisible-island.net/xterm/manpage/xterm.html#VT100-Widget-Resources:modifyOtherKeys 93// See: https://invisible-island.net/xterm/manpage/xterm.html#VT100-Widget-Resources:modifyOtherKeys
94//
95// Deprecated: use [SetModifyOtherKeys1] or [SetModifyOtherKeys2] instead.
16func ModifyOtherKeys(mode int) string { 96func ModifyOtherKeys(mode int) string {
17 return "\x1b[>4;" + strconv.Itoa(mode) + "m" 97 return "\x1b[>4;" + strconv.Itoa(mode) + "m"
18} 98}
@@ -23,6 +103,8 @@ func ModifyOtherKeys(mode int) string {
23// 103//
24// See: https://invisible-island.net/xterm/ctlseqs/ctlseqs.html#h3-Functions-using-CSI-_-ordered-by-the-final-character_s_ 104// See: https://invisible-island.net/xterm/ctlseqs/ctlseqs.html#h3-Functions-using-CSI-_-ordered-by-the-final-character_s_
25// See: https://invisible-island.net/xterm/manpage/xterm.html#VT100-Widget-Resources:modifyOtherKeys 105// See: https://invisible-island.net/xterm/manpage/xterm.html#VT100-Widget-Resources:modifyOtherKeys
106//
107// Deprecated: use [ResetModifyOtherKeys] instead.
26const DisableModifyOtherKeys = "\x1b[>4;0m" 108const DisableModifyOtherKeys = "\x1b[>4;0m"
27 109
28// EnableModifyOtherKeys1 enables the modifyOtherKeys mode 1. 110// EnableModifyOtherKeys1 enables the modifyOtherKeys mode 1.
@@ -31,6 +113,8 @@ const DisableModifyOtherKeys = "\x1b[>4;0m"
31// 113//
32// See: https://invisible-island.net/xterm/ctlseqs/ctlseqs.html#h3-Functions-using-CSI-_-ordered-by-the-final-character_s_ 114// See: https://invisible-island.net/xterm/ctlseqs/ctlseqs.html#h3-Functions-using-CSI-_-ordered-by-the-final-character_s_
33// See: https://invisible-island.net/xterm/manpage/xterm.html#VT100-Widget-Resources:modifyOtherKeys 115// See: https://invisible-island.net/xterm/manpage/xterm.html#VT100-Widget-Resources:modifyOtherKeys
116//
117// Deprecated: use [SetModifyOtherKeys1] instead.
34const EnableModifyOtherKeys1 = "\x1b[>4;1m" 118const EnableModifyOtherKeys1 = "\x1b[>4;1m"
35 119
36// EnableModifyOtherKeys2 enables the modifyOtherKeys mode 2. 120// EnableModifyOtherKeys2 enables the modifyOtherKeys mode 2.
@@ -39,6 +123,8 @@ const EnableModifyOtherKeys1 = "\x1b[>4;1m"
39// 123//
40// See: https://invisible-island.net/xterm/ctlseqs/ctlseqs.html#h3-Functions-using-CSI-_-ordered-by-the-final-character_s_ 124// See: https://invisible-island.net/xterm/ctlseqs/ctlseqs.html#h3-Functions-using-CSI-_-ordered-by-the-final-character_s_
41// See: https://invisible-island.net/xterm/manpage/xterm.html#VT100-Widget-Resources:modifyOtherKeys 125// See: https://invisible-island.net/xterm/manpage/xterm.html#VT100-Widget-Resources:modifyOtherKeys
126//
127// Deprecated: use [SetModifyOtherKeys2] instead.
42const EnableModifyOtherKeys2 = "\x1b[>4;2m" 128const EnableModifyOtherKeys2 = "\x1b[>4;2m"
43 129
44// RequestModifyOtherKeys requests the modifyOtherKeys mode. 130// RequestModifyOtherKeys requests the modifyOtherKeys mode.
@@ -47,4 +133,6 @@ const EnableModifyOtherKeys2 = "\x1b[>4;2m"
47// 133//
48// See: https://invisible-island.net/xterm/ctlseqs/ctlseqs.html#h3-Functions-using-CSI-_-ordered-by-the-final-character_s_ 134// See: https://invisible-island.net/xterm/ctlseqs/ctlseqs.html#h3-Functions-using-CSI-_-ordered-by-the-final-character_s_
49// See: https://invisible-island.net/xterm/manpage/xterm.html#VT100-Widget-Resources:modifyOtherKeys 135// See: https://invisible-island.net/xterm/manpage/xterm.html#VT100-Widget-Resources:modifyOtherKeys
136//
137// Deprecated: use [QueryModifyOtherKeys] instead.
50const RequestModifyOtherKeys = "\x1b[?4m" 138const RequestModifyOtherKeys = "\x1b[?4m"
vendor/github.com/charmbracelet/x/term/term_windows.go +1
@@ -25,6 +25,7 @@ func makeRaw(fd uintptr) (*State, error) {
25 return nil, err 25 return nil, err
26 } 26 }
27 raw := st &^ (windows.ENABLE_ECHO_INPUT | windows.ENABLE_PROCESSED_INPUT | windows.ENABLE_LINE_INPUT | windows.ENABLE_PROCESSED_OUTPUT) 27 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
28 if err := windows.SetConsoleMode(windows.Handle(fd), raw); err != nil { 29 if err := windows.SetConsoleMode(windows.Handle(fd), raw); err != nil {
29 return nil, err 30 return nil, err
30 } 31 }
vendor/github.com/mattn/go-runewidth/runewidth_table.go +167 −156
@@ -4,20 +4,21 @@ package runewidth
4 4
5var combining = table{ 5var combining = table{
6 {0x0300, 0x036F}, {0x0483, 0x0489}, {0x07EB, 0x07F3}, 6 {0x0300, 0x036F}, {0x0483, 0x0489}, {0x07EB, 0x07F3},
7 {0x0C00, 0x0C00}, {0x0C04, 0x0C04}, {0x0D00, 0x0D01}, 7 {0x0C00, 0x0C00}, {0x0C04, 0x0C04}, {0x0CF3, 0x0CF3},
8 {0x135D, 0x135F}, {0x1A7F, 0x1A7F}, {0x1AB0, 0x1AC0}, 8 {0x0D00, 0x0D01}, {0x135D, 0x135F}, {0x1A7F, 0x1A7F},
9 {0x1B6B, 0x1B73}, {0x1DC0, 0x1DF9}, {0x1DFB, 0x1DFF}, 9 {0x1AB0, 0x1ACE}, {0x1B6B, 0x1B73}, {0x1DC0, 0x1DFF},
10 {0x20D0, 0x20F0}, {0x2CEF, 0x2CF1}, {0x2DE0, 0x2DFF}, 10 {0x20D0, 0x20F0}, {0x2CEF, 0x2CF1}, {0x2DE0, 0x2DFF},
11 {0x3099, 0x309A}, {0xA66F, 0xA672}, {0xA674, 0xA67D}, 11 {0x3099, 0x309A}, {0xA66F, 0xA672}, {0xA674, 0xA67D},
12 {0xA69E, 0xA69F}, {0xA6F0, 0xA6F1}, {0xA8E0, 0xA8F1}, 12 {0xA69E, 0xA69F}, {0xA6F0, 0xA6F1}, {0xA8E0, 0xA8F1},
13 {0xFE20, 0xFE2F}, {0x101FD, 0x101FD}, {0x10376, 0x1037A}, 13 {0xFE20, 0xFE2F}, {0x101FD, 0x101FD}, {0x10376, 0x1037A},
14 {0x10EAB, 0x10EAC}, {0x10F46, 0x10F50}, {0x11300, 0x11301}, 14 {0x10EAB, 0x10EAC}, {0x10F46, 0x10F50}, {0x10F82, 0x10F85},
15 {0x1133B, 0x1133C}, {0x11366, 0x1136C}, {0x11370, 0x11374}, 15 {0x11300, 0x11301}, {0x1133B, 0x1133C}, {0x11366, 0x1136C},
16 {0x16AF0, 0x16AF4}, {0x1D165, 0x1D169}, {0x1D16D, 0x1D172}, 16 {0x11370, 0x11374}, {0x16AF0, 0x16AF4}, {0x1CF00, 0x1CF2D},
17 {0x1CF30, 0x1CF46}, {0x1D165, 0x1D169}, {0x1D16D, 0x1D172},
17 {0x1D17B, 0x1D182}, {0x1D185, 0x1D18B}, {0x1D1AA, 0x1D1AD}, 18 {0x1D17B, 0x1D182}, {0x1D185, 0x1D18B}, {0x1D1AA, 0x1D1AD},
18 {0x1D242, 0x1D244}, {0x1E000, 0x1E006}, {0x1E008, 0x1E018}, 19 {0x1D242, 0x1D244}, {0x1E000, 0x1E006}, {0x1E008, 0x1E018},
19 {0x1E01B, 0x1E021}, {0x1E023, 0x1E024}, {0x1E026, 0x1E02A}, 20 {0x1E01B, 0x1E021}, {0x1E023, 0x1E024}, {0x1E026, 0x1E02A},
20 {0x1E8D0, 0x1E8D6}, 21 {0x1E08F, 0x1E08F}, {0x1E8D0, 0x1E8D6},
21} 22}
22 23
23var doublewidth = table{ 24var doublewidth = table{
@@ -33,33 +34,34 @@ var doublewidth = table{
33 {0x2753, 0x2755}, {0x2757, 0x2757}, {0x2795, 0x2797}, 34 {0x2753, 0x2755}, {0x2757, 0x2757}, {0x2795, 0x2797},
34 {0x27B0, 0x27B0}, {0x27BF, 0x27BF}, {0x2B1B, 0x2B1C}, 35 {0x27B0, 0x27B0}, {0x27BF, 0x27BF}, {0x2B1B, 0x2B1C},
35 {0x2B50, 0x2B50}, {0x2B55, 0x2B55}, {0x2E80, 0x2E99}, 36 {0x2B50, 0x2B50}, {0x2B55, 0x2B55}, {0x2E80, 0x2E99},
36 {0x2E9B, 0x2EF3}, {0x2F00, 0x2FD5}, {0x2FF0, 0x2FFB}, 37 {0x2E9B, 0x2EF3}, {0x2F00, 0x2FD5}, {0x2FF0, 0x303E},
37 {0x3000, 0x303E}, {0x3041, 0x3096}, {0x3099, 0x30FF}, 38 {0x3041, 0x3096}, {0x3099, 0x30FF}, {0x3105, 0x312F},
38 {0x3105, 0x312F}, {0x3131, 0x318E}, {0x3190, 0x31E3}, 39 {0x3131, 0x318E}, {0x3190, 0x31E3}, {0x31EF, 0x321E},
39 {0x31F0, 0x321E}, {0x3220, 0x3247}, {0x3250, 0x4DBF}, 40 {0x3220, 0x3247}, {0x3250, 0x4DBF}, {0x4E00, 0xA48C},
40 {0x4E00, 0xA48C}, {0xA490, 0xA4C6}, {0xA960, 0xA97C}, 41 {0xA490, 0xA4C6}, {0xA960, 0xA97C}, {0xAC00, 0xD7A3},
41 {0xAC00, 0xD7A3}, {0xF900, 0xFAFF}, {0xFE10, 0xFE19}, 42 {0xF900, 0xFAFF}, {0xFE10, 0xFE19}, {0xFE30, 0xFE52},
42 {0xFE30, 0xFE52}, {0xFE54, 0xFE66}, {0xFE68, 0xFE6B}, 43 {0xFE54, 0xFE66}, {0xFE68, 0xFE6B}, {0xFF01, 0xFF60},
43 {0xFF01, 0xFF60}, {0xFFE0, 0xFFE6}, {0x16FE0, 0x16FE4}, 44 {0xFFE0, 0xFFE6}, {0x16FE0, 0x16FE4}, {0x16FF0, 0x16FF1},
44 {0x16FF0, 0x16FF1}, {0x17000, 0x187F7}, {0x18800, 0x18CD5}, 45 {0x17000, 0x187F7}, {0x18800, 0x18CD5}, {0x18D00, 0x18D08},
45 {0x18D00, 0x18D08}, {0x1B000, 0x1B11E}, {0x1B150, 0x1B152}, 46 {0x1AFF0, 0x1AFF3}, {0x1AFF5, 0x1AFFB}, {0x1AFFD, 0x1AFFE},
46 {0x1B164, 0x1B167}, {0x1B170, 0x1B2FB}, {0x1F004, 0x1F004}, 47 {0x1B000, 0x1B122}, {0x1B132, 0x1B132}, {0x1B150, 0x1B152},
47 {0x1F0CF, 0x1F0CF}, {0x1F18E, 0x1F18E}, {0x1F191, 0x1F19A}, 48 {0x1B155, 0x1B155}, {0x1B164, 0x1B167}, {0x1B170, 0x1B2FB},
48 {0x1F200, 0x1F202}, {0x1F210, 0x1F23B}, {0x1F240, 0x1F248}, 49 {0x1F004, 0x1F004}, {0x1F0CF, 0x1F0CF}, {0x1F18E, 0x1F18E},
49 {0x1F250, 0x1F251}, {0x1F260, 0x1F265}, {0x1F300, 0x1F320}, 50 {0x1F191, 0x1F19A}, {0x1F200, 0x1F202}, {0x1F210, 0x1F23B},
50 {0x1F32D, 0x1F335}, {0x1F337, 0x1F37C}, {0x1F37E, 0x1F393}, 51 {0x1F240, 0x1F248}, {0x1F250, 0x1F251}, {0x1F260, 0x1F265},
51 {0x1F3A0, 0x1F3CA}, {0x1F3CF, 0x1F3D3}, {0x1F3E0, 0x1F3F0}, 52 {0x1F300, 0x1F320}, {0x1F32D, 0x1F335}, {0x1F337, 0x1F37C},
52 {0x1F3F4, 0x1F3F4}, {0x1F3F8, 0x1F43E}, {0x1F440, 0x1F440}, 53 {0x1F37E, 0x1F393}, {0x1F3A0, 0x1F3CA}, {0x1F3CF, 0x1F3D3},
53 {0x1F442, 0x1F4FC}, {0x1F4FF, 0x1F53D}, {0x1F54B, 0x1F54E}, 54 {0x1F3E0, 0x1F3F0}, {0x1F3F4, 0x1F3F4}, {0x1F3F8, 0x1F43E},
54 {0x1F550, 0x1F567}, {0x1F57A, 0x1F57A}, {0x1F595, 0x1F596}, 55 {0x1F440, 0x1F440}, {0x1F442, 0x1F4FC}, {0x1F4FF, 0x1F53D},
55 {0x1F5A4, 0x1F5A4}, {0x1F5FB, 0x1F64F}, {0x1F680, 0x1F6C5}, 56 {0x1F54B, 0x1F54E}, {0x1F550, 0x1F567}, {0x1F57A, 0x1F57A},
56 {0x1F6CC, 0x1F6CC}, {0x1F6D0, 0x1F6D2}, {0x1F6D5, 0x1F6D7}, 57 {0x1F595, 0x1F596}, {0x1F5A4, 0x1F5A4}, {0x1F5FB, 0x1F64F},
57 {0x1F6EB, 0x1F6EC}, {0x1F6F4, 0x1F6FC}, {0x1F7E0, 0x1F7EB}, 58 {0x1F680, 0x1F6C5}, {0x1F6CC, 0x1F6CC}, {0x1F6D0, 0x1F6D2},
58 {0x1F90C, 0x1F93A}, {0x1F93C, 0x1F945}, {0x1F947, 0x1F978}, 59 {0x1F6D5, 0x1F6D7}, {0x1F6DC, 0x1F6DF}, {0x1F6EB, 0x1F6EC},
59 {0x1F97A, 0x1F9CB}, {0x1F9CD, 0x1F9FF}, {0x1FA70, 0x1FA74}, 60 {0x1F6F4, 0x1F6FC}, {0x1F7E0, 0x1F7EB}, {0x1F7F0, 0x1F7F0},
60 {0x1FA78, 0x1FA7A}, {0x1FA80, 0x1FA86}, {0x1FA90, 0x1FAA8}, 61 {0x1F90C, 0x1F93A}, {0x1F93C, 0x1F945}, {0x1F947, 0x1F9FF},
61 {0x1FAB0, 0x1FAB6}, {0x1FAC0, 0x1FAC2}, {0x1FAD0, 0x1FAD6}, 62 {0x1FA70, 0x1FA7C}, {0x1FA80, 0x1FA88}, {0x1FA90, 0x1FABD},
62 {0x20000, 0x2FFFD}, {0x30000, 0x3FFFD}, 63 {0x1FABF, 0x1FAC5}, {0x1FACE, 0x1FADB}, {0x1FAE0, 0x1FAE8},
64 {0x1FAF0, 0x1FAF8}, {0x20000, 0x2FFFD}, {0x30000, 0x3FFFD},
63} 65}
64 66
65var ambiguous = table{ 67var ambiguous = table{
@@ -154,43 +156,43 @@ var neutral = table{
154 {0x0402, 0x040F}, {0x0450, 0x0450}, {0x0452, 0x052F}, 156 {0x0402, 0x040F}, {0x0450, 0x0450}, {0x0452, 0x052F},
155 {0x0531, 0x0556}, {0x0559, 0x058A}, {0x058D, 0x058F}, 157 {0x0531, 0x0556}, {0x0559, 0x058A}, {0x058D, 0x058F},
156 {0x0591, 0x05C7}, {0x05D0, 0x05EA}, {0x05EF, 0x05F4}, 158 {0x0591, 0x05C7}, {0x05D0, 0x05EA}, {0x05EF, 0x05F4},
157 {0x0600, 0x061C}, {0x061E, 0x070D}, {0x070F, 0x074A}, 159 {0x0600, 0x070D}, {0x070F, 0x074A}, {0x074D, 0x07B1},
158 {0x074D, 0x07B1}, {0x07C0, 0x07FA}, {0x07FD, 0x082D}, 160 {0x07C0, 0x07FA}, {0x07FD, 0x082D}, {0x0830, 0x083E},
159 {0x0830, 0x083E}, {0x0840, 0x085B}, {0x085E, 0x085E}, 161 {0x0840, 0x085B}, {0x085E, 0x085E}, {0x0860, 0x086A},
160 {0x0860, 0x086A}, {0x08A0, 0x08B4}, {0x08B6, 0x08C7}, 162 {0x0870, 0x088E}, {0x0890, 0x0891}, {0x0898, 0x0983},
161 {0x08D3, 0x0983}, {0x0985, 0x098C}, {0x098F, 0x0990}, 163 {0x0985, 0x098C}, {0x098F, 0x0990}, {0x0993, 0x09A8},
162 {0x0993, 0x09A8}, {0x09AA, 0x09B0}, {0x09B2, 0x09B2}, 164 {0x09AA, 0x09B0}, {0x09B2, 0x09B2}, {0x09B6, 0x09B9},
163 {0x09B6, 0x09B9}, {0x09BC, 0x09C4}, {0x09C7, 0x09C8}, 165 {0x09BC, 0x09C4}, {0x09C7, 0x09C8}, {0x09CB, 0x09CE},
164 {0x09CB, 0x09CE}, {0x09D7, 0x09D7}, {0x09DC, 0x09DD}, 166 {0x09D7, 0x09D7}, {0x09DC, 0x09DD}, {0x09DF, 0x09E3},
165 {0x09DF, 0x09E3}, {0x09E6, 0x09FE}, {0x0A01, 0x0A03}, 167 {0x09E6, 0x09FE}, {0x0A01, 0x0A03}, {0x0A05, 0x0A0A},
166 {0x0A05, 0x0A0A}, {0x0A0F, 0x0A10}, {0x0A13, 0x0A28}, 168 {0x0A0F, 0x0A10}, {0x0A13, 0x0A28}, {0x0A2A, 0x0A30},
167 {0x0A2A, 0x0A30}, {0x0A32, 0x0A33}, {0x0A35, 0x0A36}, 169 {0x0A32, 0x0A33}, {0x0A35, 0x0A36}, {0x0A38, 0x0A39},
168 {0x0A38, 0x0A39}, {0x0A3C, 0x0A3C}, {0x0A3E, 0x0A42}, 170 {0x0A3C, 0x0A3C}, {0x0A3E, 0x0A42}, {0x0A47, 0x0A48},
169 {0x0A47, 0x0A48}, {0x0A4B, 0x0A4D}, {0x0A51, 0x0A51}, 171 {0x0A4B, 0x0A4D}, {0x0A51, 0x0A51}, {0x0A59, 0x0A5C},
170 {0x0A59, 0x0A5C}, {0x0A5E, 0x0A5E}, {0x0A66, 0x0A76}, 172 {0x0A5E, 0x0A5E}, {0x0A66, 0x0A76}, {0x0A81, 0x0A83},
171 {0x0A81, 0x0A83}, {0x0A85, 0x0A8D}, {0x0A8F, 0x0A91}, 173 {0x0A85, 0x0A8D}, {0x0A8F, 0x0A91}, {0x0A93, 0x0AA8},
172 {0x0A93, 0x0AA8}, {0x0AAA, 0x0AB0}, {0x0AB2, 0x0AB3}, 174 {0x0AAA, 0x0AB0}, {0x0AB2, 0x0AB3}, {0x0AB5, 0x0AB9},
173 {0x0AB5, 0x0AB9}, {0x0ABC, 0x0AC5}, {0x0AC7, 0x0AC9}, 175 {0x0ABC, 0x0AC5}, {0x0AC7, 0x0AC9}, {0x0ACB, 0x0ACD},
174 {0x0ACB, 0x0ACD}, {0x0AD0, 0x0AD0}, {0x0AE0, 0x0AE3}, 176 {0x0AD0, 0x0AD0}, {0x0AE0, 0x0AE3}, {0x0AE6, 0x0AF1},
175 {0x0AE6, 0x0AF1}, {0x0AF9, 0x0AFF}, {0x0B01, 0x0B03}, 177 {0x0AF9, 0x0AFF}, {0x0B01, 0x0B03}, {0x0B05, 0x0B0C},
176 {0x0B05, 0x0B0C}, {0x0B0F, 0x0B10}, {0x0B13, 0x0B28}, 178 {0x0B0F, 0x0B10}, {0x0B13, 0x0B28}, {0x0B2A, 0x0B30},
177 {0x0B2A, 0x0B30}, {0x0B32, 0x0B33}, {0x0B35, 0x0B39}, 179 {0x0B32, 0x0B33}, {0x0B35, 0x0B39}, {0x0B3C, 0x0B44},
178 {0x0B3C, 0x0B44}, {0x0B47, 0x0B48}, {0x0B4B, 0x0B4D}, 180 {0x0B47, 0x0B48}, {0x0B4B, 0x0B4D}, {0x0B55, 0x0B57},
179 {0x0B55, 0x0B57}, {0x0B5C, 0x0B5D}, {0x0B5F, 0x0B63}, 181 {0x0B5C, 0x0B5D}, {0x0B5F, 0x0B63}, {0x0B66, 0x0B77},
180 {0x0B66, 0x0B77}, {0x0B82, 0x0B83}, {0x0B85, 0x0B8A}, 182 {0x0B82, 0x0B83}, {0x0B85, 0x0B8A}, {0x0B8E, 0x0B90},
181 {0x0B8E, 0x0B90}, {0x0B92, 0x0B95}, {0x0B99, 0x0B9A}, 183 {0x0B92, 0x0B95}, {0x0B99, 0x0B9A}, {0x0B9C, 0x0B9C},
182 {0x0B9C, 0x0B9C}, {0x0B9E, 0x0B9F}, {0x0BA3, 0x0BA4}, 184 {0x0B9E, 0x0B9F}, {0x0BA3, 0x0BA4}, {0x0BA8, 0x0BAA},
183 {0x0BA8, 0x0BAA}, {0x0BAE, 0x0BB9}, {0x0BBE, 0x0BC2}, 185 {0x0BAE, 0x0BB9}, {0x0BBE, 0x0BC2}, {0x0BC6, 0x0BC8},
184 {0x0BC6, 0x0BC8}, {0x0BCA, 0x0BCD}, {0x0BD0, 0x0BD0}, 186 {0x0BCA, 0x0BCD}, {0x0BD0, 0x0BD0}, {0x0BD7, 0x0BD7},
185 {0x0BD7, 0x0BD7}, {0x0BE6, 0x0BFA}, {0x0C00, 0x0C0C}, 187 {0x0BE6, 0x0BFA}, {0x0C00, 0x0C0C}, {0x0C0E, 0x0C10},
186 {0x0C0E, 0x0C10}, {0x0C12, 0x0C28}, {0x0C2A, 0x0C39}, 188 {0x0C12, 0x0C28}, {0x0C2A, 0x0C39}, {0x0C3C, 0x0C44},
187 {0x0C3D, 0x0C44}, {0x0C46, 0x0C48}, {0x0C4A, 0x0C4D}, 189 {0x0C46, 0x0C48}, {0x0C4A, 0x0C4D}, {0x0C55, 0x0C56},
188 {0x0C55, 0x0C56}, {0x0C58, 0x0C5A}, {0x0C60, 0x0C63}, 190 {0x0C58, 0x0C5A}, {0x0C5D, 0x0C5D}, {0x0C60, 0x0C63},
189 {0x0C66, 0x0C6F}, {0x0C77, 0x0C8C}, {0x0C8E, 0x0C90}, 191 {0x0C66, 0x0C6F}, {0x0C77, 0x0C8C}, {0x0C8E, 0x0C90},
190 {0x0C92, 0x0CA8}, {0x0CAA, 0x0CB3}, {0x0CB5, 0x0CB9}, 192 {0x0C92, 0x0CA8}, {0x0CAA, 0x0CB3}, {0x0CB5, 0x0CB9},
191 {0x0CBC, 0x0CC4}, {0x0CC6, 0x0CC8}, {0x0CCA, 0x0CCD}, 193 {0x0CBC, 0x0CC4}, {0x0CC6, 0x0CC8}, {0x0CCA, 0x0CCD},
192 {0x0CD5, 0x0CD6}, {0x0CDE, 0x0CDE}, {0x0CE0, 0x0CE3}, 194 {0x0CD5, 0x0CD6}, {0x0CDD, 0x0CDE}, {0x0CE0, 0x0CE3},
193 {0x0CE6, 0x0CEF}, {0x0CF1, 0x0CF2}, {0x0D00, 0x0D0C}, 195 {0x0CE6, 0x0CEF}, {0x0CF1, 0x0CF3}, {0x0D00, 0x0D0C},
194 {0x0D0E, 0x0D10}, {0x0D12, 0x0D44}, {0x0D46, 0x0D48}, 196 {0x0D0E, 0x0D10}, {0x0D12, 0x0D44}, {0x0D46, 0x0D48},
195 {0x0D4A, 0x0D4F}, {0x0D54, 0x0D63}, {0x0D66, 0x0D7F}, 197 {0x0D4A, 0x0D4F}, {0x0D54, 0x0D63}, {0x0D66, 0x0D7F},
196 {0x0D81, 0x0D83}, {0x0D85, 0x0D96}, {0x0D9A, 0x0DB1}, 198 {0x0D81, 0x0D83}, {0x0D85, 0x0D96}, {0x0D9A, 0x0DB1},
@@ -200,7 +202,7 @@ var neutral = table{
200 {0x0E01, 0x0E3A}, {0x0E3F, 0x0E5B}, {0x0E81, 0x0E82}, 202 {0x0E01, 0x0E3A}, {0x0E3F, 0x0E5B}, {0x0E81, 0x0E82},
201 {0x0E84, 0x0E84}, {0x0E86, 0x0E8A}, {0x0E8C, 0x0EA3}, 203 {0x0E84, 0x0E84}, {0x0E86, 0x0E8A}, {0x0E8C, 0x0EA3},
202 {0x0EA5, 0x0EA5}, {0x0EA7, 0x0EBD}, {0x0EC0, 0x0EC4}, 204 {0x0EA5, 0x0EA5}, {0x0EA7, 0x0EBD}, {0x0EC0, 0x0EC4},
203 {0x0EC6, 0x0EC6}, {0x0EC8, 0x0ECD}, {0x0ED0, 0x0ED9}, 205 {0x0EC6, 0x0EC6}, {0x0EC8, 0x0ECE}, {0x0ED0, 0x0ED9},
204 {0x0EDC, 0x0EDF}, {0x0F00, 0x0F47}, {0x0F49, 0x0F6C}, 206 {0x0EDC, 0x0EDF}, {0x0F00, 0x0F47}, {0x0F49, 0x0F6C},
205 {0x0F71, 0x0F97}, {0x0F99, 0x0FBC}, {0x0FBE, 0x0FCC}, 207 {0x0F71, 0x0F97}, {0x0F99, 0x0FBC}, {0x0FBE, 0x0FCC},
206 {0x0FCE, 0x0FDA}, {0x1000, 0x10C5}, {0x10C7, 0x10C7}, 208 {0x0FCE, 0x0FDA}, {0x1000, 0x10C5}, {0x10C7, 0x10C7},
@@ -212,20 +214,19 @@ var neutral = table{
212 {0x12D8, 0x1310}, {0x1312, 0x1315}, {0x1318, 0x135A}, 214 {0x12D8, 0x1310}, {0x1312, 0x1315}, {0x1318, 0x135A},
213 {0x135D, 0x137C}, {0x1380, 0x1399}, {0x13A0, 0x13F5}, 215 {0x135D, 0x137C}, {0x1380, 0x1399}, {0x13A0, 0x13F5},
214 {0x13F8, 0x13FD}, {0x1400, 0x169C}, {0x16A0, 0x16F8}, 216 {0x13F8, 0x13FD}, {0x1400, 0x169C}, {0x16A0, 0x16F8},
215 {0x1700, 0x170C}, {0x170E, 0x1714}, {0x1720, 0x1736}, 217 {0x1700, 0x1715}, {0x171F, 0x1736}, {0x1740, 0x1753},
216 {0x1740, 0x1753}, {0x1760, 0x176C}, {0x176E, 0x1770}, 218 {0x1760, 0x176C}, {0x176E, 0x1770}, {0x1772, 0x1773},
217 {0x1772, 0x1773}, {0x1780, 0x17DD}, {0x17E0, 0x17E9}, 219 {0x1780, 0x17DD}, {0x17E0, 0x17E9}, {0x17F0, 0x17F9},
218 {0x17F0, 0x17F9}, {0x1800, 0x180E}, {0x1810, 0x1819}, 220 {0x1800, 0x1819}, {0x1820, 0x1878}, {0x1880, 0x18AA},
219 {0x1820, 0x1878}, {0x1880, 0x18AA}, {0x18B0, 0x18F5}, 221 {0x18B0, 0x18F5}, {0x1900, 0x191E}, {0x1920, 0x192B},
220 {0x1900, 0x191E}, {0x1920, 0x192B}, {0x1930, 0x193B}, 222 {0x1930, 0x193B}, {0x1940, 0x1940}, {0x1944, 0x196D},
221 {0x1940, 0x1940}, {0x1944, 0x196D}, {0x1970, 0x1974}, 223 {0x1970, 0x1974}, {0x1980, 0x19AB}, {0x19B0, 0x19C9},
222 {0x1980, 0x19AB}, {0x19B0, 0x19C9}, {0x19D0, 0x19DA}, 224 {0x19D0, 0x19DA}, {0x19DE, 0x1A1B}, {0x1A1E, 0x1A5E},
223 {0x19DE, 0x1A1B}, {0x1A1E, 0x1A5E}, {0x1A60, 0x1A7C}, 225 {0x1A60, 0x1A7C}, {0x1A7F, 0x1A89}, {0x1A90, 0x1A99},
224 {0x1A7F, 0x1A89}, {0x1A90, 0x1A99}, {0x1AA0, 0x1AAD}, 226 {0x1AA0, 0x1AAD}, {0x1AB0, 0x1ACE}, {0x1B00, 0x1B4C},
225 {0x1AB0, 0x1AC0}, {0x1B00, 0x1B4B}, {0x1B50, 0x1B7C}, 227 {0x1B50, 0x1B7E}, {0x1B80, 0x1BF3}, {0x1BFC, 0x1C37},
226 {0x1B80, 0x1BF3}, {0x1BFC, 0x1C37}, {0x1C3B, 0x1C49}, 228 {0x1C3B, 0x1C49}, {0x1C4D, 0x1C88}, {0x1C90, 0x1CBA},
227 {0x1C4D, 0x1C88}, {0x1C90, 0x1CBA}, {0x1CBD, 0x1CC7}, 229 {0x1CBD, 0x1CC7}, {0x1CD0, 0x1CFA}, {0x1D00, 0x1F15},
228 {0x1CD0, 0x1CFA}, {0x1D00, 0x1DF9}, {0x1DFB, 0x1F15},
229 {0x1F18, 0x1F1D}, {0x1F20, 0x1F45}, {0x1F48, 0x1F4D}, 230 {0x1F18, 0x1F1D}, {0x1F20, 0x1F45}, {0x1F48, 0x1F4D},
230 {0x1F50, 0x1F57}, {0x1F59, 0x1F59}, {0x1F5B, 0x1F5B}, 231 {0x1F50, 0x1F57}, {0x1F59, 0x1F59}, {0x1F5B, 0x1F5B},
231 {0x1F5D, 0x1F5D}, {0x1F5F, 0x1F7D}, {0x1F80, 0x1FB4}, 232 {0x1F5D, 0x1F5D}, {0x1F5F, 0x1F7D}, {0x1F80, 0x1FB4},
@@ -237,7 +238,7 @@ var neutral = table{
237 {0x2036, 0x203A}, {0x203C, 0x203D}, {0x203F, 0x2064}, 238 {0x2036, 0x203A}, {0x203C, 0x203D}, {0x203F, 0x2064},
238 {0x2066, 0x2071}, {0x2075, 0x207E}, {0x2080, 0x2080}, 239 {0x2066, 0x2071}, {0x2075, 0x207E}, {0x2080, 0x2080},
239 {0x2085, 0x208E}, {0x2090, 0x209C}, {0x20A0, 0x20A8}, 240 {0x2085, 0x208E}, {0x2090, 0x209C}, {0x20A0, 0x20A8},
240 {0x20AA, 0x20AB}, {0x20AD, 0x20BF}, {0x20D0, 0x20F0}, 241 {0x20AA, 0x20AB}, {0x20AD, 0x20C0}, {0x20D0, 0x20F0},
241 {0x2100, 0x2102}, {0x2104, 0x2104}, {0x2106, 0x2108}, 242 {0x2100, 0x2102}, {0x2104, 0x2104}, {0x2106, 0x2108},
242 {0x210A, 0x2112}, {0x2114, 0x2115}, {0x2117, 0x2120}, 243 {0x210A, 0x2112}, {0x2114, 0x2115}, {0x2117, 0x2120},
243 {0x2123, 0x2125}, {0x2127, 0x212A}, {0x212C, 0x2152}, 244 {0x2123, 0x2125}, {0x2127, 0x212A}, {0x212C, 0x2152},
@@ -275,15 +276,15 @@ var neutral = table{
275 {0x2780, 0x2794}, {0x2798, 0x27AF}, {0x27B1, 0x27BE}, 276 {0x2780, 0x2794}, {0x2798, 0x27AF}, {0x27B1, 0x27BE},
276 {0x27C0, 0x27E5}, {0x27EE, 0x2984}, {0x2987, 0x2B1A}, 277 {0x27C0, 0x27E5}, {0x27EE, 0x2984}, {0x2987, 0x2B1A},
277 {0x2B1D, 0x2B4F}, {0x2B51, 0x2B54}, {0x2B5A, 0x2B73}, 278 {0x2B1D, 0x2B4F}, {0x2B51, 0x2B54}, {0x2B5A, 0x2B73},
278 {0x2B76, 0x2B95}, {0x2B97, 0x2C2E}, {0x2C30, 0x2C5E}, 279 {0x2B76, 0x2B95}, {0x2B97, 0x2CF3}, {0x2CF9, 0x2D25},
279 {0x2C60, 0x2CF3}, {0x2CF9, 0x2D25}, {0x2D27, 0x2D27}, 280 {0x2D27, 0x2D27}, {0x2D2D, 0x2D2D}, {0x2D30, 0x2D67},
280 {0x2D2D, 0x2D2D}, {0x2D30, 0x2D67}, {0x2D6F, 0x2D70}, 281 {0x2D6F, 0x2D70}, {0x2D7F, 0x2D96}, {0x2DA0, 0x2DA6},
281 {0x2D7F, 0x2D96}, {0x2DA0, 0x2DA6}, {0x2DA8, 0x2DAE}, 282 {0x2DA8, 0x2DAE}, {0x2DB0, 0x2DB6}, {0x2DB8, 0x2DBE},
282 {0x2DB0, 0x2DB6}, {0x2DB8, 0x2DBE}, {0x2DC0, 0x2DC6}, 283 {0x2DC0, 0x2DC6}, {0x2DC8, 0x2DCE}, {0x2DD0, 0x2DD6},
283 {0x2DC8, 0x2DCE}, {0x2DD0, 0x2DD6}, {0x2DD8, 0x2DDE}, 284 {0x2DD8, 0x2DDE}, {0x2DE0, 0x2E5D}, {0x303F, 0x303F},
284 {0x2DE0, 0x2E52}, {0x303F, 0x303F}, {0x4DC0, 0x4DFF}, 285 {0x4DC0, 0x4DFF}, {0xA4D0, 0xA62B}, {0xA640, 0xA6F7},
285 {0xA4D0, 0xA62B}, {0xA640, 0xA6F7}, {0xA700, 0xA7BF}, 286 {0xA700, 0xA7CA}, {0xA7D0, 0xA7D1}, {0xA7D3, 0xA7D3},
286 {0xA7C2, 0xA7CA}, {0xA7F5, 0xA82C}, {0xA830, 0xA839}, 287 {0xA7D5, 0xA7D9}, {0xA7F2, 0xA82C}, {0xA830, 0xA839},
287 {0xA840, 0xA877}, {0xA880, 0xA8C5}, {0xA8CE, 0xA8D9}, 288 {0xA840, 0xA877}, {0xA880, 0xA8C5}, {0xA8CE, 0xA8D9},
288 {0xA8E0, 0xA953}, {0xA95F, 0xA95F}, {0xA980, 0xA9CD}, 289 {0xA8E0, 0xA953}, {0xA95F, 0xA95F}, {0xA980, 0xA9CD},
289 {0xA9CF, 0xA9D9}, {0xA9DE, 0xA9FE}, {0xAA00, 0xAA36}, 290 {0xA9CF, 0xA9D9}, {0xA9DE, 0xA9FE}, {0xAA00, 0xAA36},
@@ -294,8 +295,8 @@ var neutral = table{
294 {0xD7B0, 0xD7C6}, {0xD7CB, 0xD7FB}, {0xD800, 0xDFFF}, 295 {0xD7B0, 0xD7C6}, {0xD7CB, 0xD7FB}, {0xD800, 0xDFFF},
295 {0xFB00, 0xFB06}, {0xFB13, 0xFB17}, {0xFB1D, 0xFB36}, 296 {0xFB00, 0xFB06}, {0xFB13, 0xFB17}, {0xFB1D, 0xFB36},
296 {0xFB38, 0xFB3C}, {0xFB3E, 0xFB3E}, {0xFB40, 0xFB41}, 297 {0xFB38, 0xFB3C}, {0xFB3E, 0xFB3E}, {0xFB40, 0xFB41},
297 {0xFB43, 0xFB44}, {0xFB46, 0xFBC1}, {0xFBD3, 0xFD3F}, 298 {0xFB43, 0xFB44}, {0xFB46, 0xFBC2}, {0xFBD3, 0xFD8F},
298 {0xFD50, 0xFD8F}, {0xFD92, 0xFDC7}, {0xFDF0, 0xFDFD}, 299 {0xFD92, 0xFDC7}, {0xFDCF, 0xFDCF}, {0xFDF0, 0xFDFF},
299 {0xFE20, 0xFE2F}, {0xFE70, 0xFE74}, {0xFE76, 0xFEFC}, 300 {0xFE20, 0xFE2F}, {0xFE70, 0xFE74}, {0xFE76, 0xFEFC},
300 {0xFEFF, 0xFEFF}, {0xFFF9, 0xFFFC}, {0x10000, 0x1000B}, 301 {0xFEFF, 0xFEFF}, {0xFFF9, 0xFFFC}, {0x10000, 0x1000B},
301 {0x1000D, 0x10026}, {0x10028, 0x1003A}, {0x1003C, 0x1003D}, 302 {0x1000D, 0x10026}, {0x10028, 0x1003A}, {0x1003C, 0x1003D},
@@ -307,44 +308,48 @@ var neutral = table{
307 {0x10380, 0x1039D}, {0x1039F, 0x103C3}, {0x103C8, 0x103D5}, 308 {0x10380, 0x1039D}, {0x1039F, 0x103C3}, {0x103C8, 0x103D5},
308 {0x10400, 0x1049D}, {0x104A0, 0x104A9}, {0x104B0, 0x104D3}, 309 {0x10400, 0x1049D}, {0x104A0, 0x104A9}, {0x104B0, 0x104D3},
309 {0x104D8, 0x104FB}, {0x10500, 0x10527}, {0x10530, 0x10563}, 310 {0x104D8, 0x104FB}, {0x10500, 0x10527}, {0x10530, 0x10563},
310 {0x1056F, 0x1056F}, {0x10600, 0x10736}, {0x10740, 0x10755}, 311 {0x1056F, 0x1057A}, {0x1057C, 0x1058A}, {0x1058C, 0x10592},
311 {0x10760, 0x10767}, {0x10800, 0x10805}, {0x10808, 0x10808}, 312 {0x10594, 0x10595}, {0x10597, 0x105A1}, {0x105A3, 0x105B1},
312 {0x1080A, 0x10835}, {0x10837, 0x10838}, {0x1083C, 0x1083C}, 313 {0x105B3, 0x105B9}, {0x105BB, 0x105BC}, {0x10600, 0x10736},
313 {0x1083F, 0x10855}, {0x10857, 0x1089E}, {0x108A7, 0x108AF}, 314 {0x10740, 0x10755}, {0x10760, 0x10767}, {0x10780, 0x10785},
314 {0x108E0, 0x108F2}, {0x108F4, 0x108F5}, {0x108FB, 0x1091B}, 315 {0x10787, 0x107B0}, {0x107B2, 0x107BA}, {0x10800, 0x10805},
315 {0x1091F, 0x10939}, {0x1093F, 0x1093F}, {0x10980, 0x109B7}, 316 {0x10808, 0x10808}, {0x1080A, 0x10835}, {0x10837, 0x10838},
316 {0x109BC, 0x109CF}, {0x109D2, 0x10A03}, {0x10A05, 0x10A06}, 317 {0x1083C, 0x1083C}, {0x1083F, 0x10855}, {0x10857, 0x1089E},
317 {0x10A0C, 0x10A13}, {0x10A15, 0x10A17}, {0x10A19, 0x10A35}, 318 {0x108A7, 0x108AF}, {0x108E0, 0x108F2}, {0x108F4, 0x108F5},
318 {0x10A38, 0x10A3A}, {0x10A3F, 0x10A48}, {0x10A50, 0x10A58}, 319 {0x108FB, 0x1091B}, {0x1091F, 0x10939}, {0x1093F, 0x1093F},
319 {0x10A60, 0x10A9F}, {0x10AC0, 0x10AE6}, {0x10AEB, 0x10AF6}, 320 {0x10980, 0x109B7}, {0x109BC, 0x109CF}, {0x109D2, 0x10A03},
320 {0x10B00, 0x10B35}, {0x10B39, 0x10B55}, {0x10B58, 0x10B72}, 321 {0x10A05, 0x10A06}, {0x10A0C, 0x10A13}, {0x10A15, 0x10A17},
321 {0x10B78, 0x10B91}, {0x10B99, 0x10B9C}, {0x10BA9, 0x10BAF}, 322 {0x10A19, 0x10A35}, {0x10A38, 0x10A3A}, {0x10A3F, 0x10A48},
322 {0x10C00, 0x10C48}, {0x10C80, 0x10CB2}, {0x10CC0, 0x10CF2}, 323 {0x10A50, 0x10A58}, {0x10A60, 0x10A9F}, {0x10AC0, 0x10AE6},
323 {0x10CFA, 0x10D27}, {0x10D30, 0x10D39}, {0x10E60, 0x10E7E}, 324 {0x10AEB, 0x10AF6}, {0x10B00, 0x10B35}, {0x10B39, 0x10B55},
324 {0x10E80, 0x10EA9}, {0x10EAB, 0x10EAD}, {0x10EB0, 0x10EB1}, 325 {0x10B58, 0x10B72}, {0x10B78, 0x10B91}, {0x10B99, 0x10B9C},
325 {0x10F00, 0x10F27}, {0x10F30, 0x10F59}, {0x10FB0, 0x10FCB}, 326 {0x10BA9, 0x10BAF}, {0x10C00, 0x10C48}, {0x10C80, 0x10CB2},
326 {0x10FE0, 0x10FF6}, {0x11000, 0x1104D}, {0x11052, 0x1106F}, 327 {0x10CC0, 0x10CF2}, {0x10CFA, 0x10D27}, {0x10D30, 0x10D39},
327 {0x1107F, 0x110C1}, {0x110CD, 0x110CD}, {0x110D0, 0x110E8}, 328 {0x10E60, 0x10E7E}, {0x10E80, 0x10EA9}, {0x10EAB, 0x10EAD},
328 {0x110F0, 0x110F9}, {0x11100, 0x11134}, {0x11136, 0x11147}, 329 {0x10EB0, 0x10EB1}, {0x10EFD, 0x10F27}, {0x10F30, 0x10F59},
329 {0x11150, 0x11176}, {0x11180, 0x111DF}, {0x111E1, 0x111F4}, 330 {0x10F70, 0x10F89}, {0x10FB0, 0x10FCB}, {0x10FE0, 0x10FF6},
330 {0x11200, 0x11211}, {0x11213, 0x1123E}, {0x11280, 0x11286}, 331 {0x11000, 0x1104D}, {0x11052, 0x11075}, {0x1107F, 0x110C2},
331 {0x11288, 0x11288}, {0x1128A, 0x1128D}, {0x1128F, 0x1129D}, 332 {0x110CD, 0x110CD}, {0x110D0, 0x110E8}, {0x110F0, 0x110F9},
332 {0x1129F, 0x112A9}, {0x112B0, 0x112EA}, {0x112F0, 0x112F9}, 333 {0x11100, 0x11134}, {0x11136, 0x11147}, {0x11150, 0x11176},
333 {0x11300, 0x11303}, {0x11305, 0x1130C}, {0x1130F, 0x11310}, 334 {0x11180, 0x111DF}, {0x111E1, 0x111F4}, {0x11200, 0x11211},
334 {0x11313, 0x11328}, {0x1132A, 0x11330}, {0x11332, 0x11333}, 335 {0x11213, 0x11241}, {0x11280, 0x11286}, {0x11288, 0x11288},
335 {0x11335, 0x11339}, {0x1133B, 0x11344}, {0x11347, 0x11348}, 336 {0x1128A, 0x1128D}, {0x1128F, 0x1129D}, {0x1129F, 0x112A9},
336 {0x1134B, 0x1134D}, {0x11350, 0x11350}, {0x11357, 0x11357}, 337 {0x112B0, 0x112EA}, {0x112F0, 0x112F9}, {0x11300, 0x11303},
337 {0x1135D, 0x11363}, {0x11366, 0x1136C}, {0x11370, 0x11374}, 338 {0x11305, 0x1130C}, {0x1130F, 0x11310}, {0x11313, 0x11328},
338 {0x11400, 0x1145B}, {0x1145D, 0x11461}, {0x11480, 0x114C7}, 339 {0x1132A, 0x11330}, {0x11332, 0x11333}, {0x11335, 0x11339},
339 {0x114D0, 0x114D9}, {0x11580, 0x115B5}, {0x115B8, 0x115DD}, 340 {0x1133B, 0x11344}, {0x11347, 0x11348}, {0x1134B, 0x1134D},
340 {0x11600, 0x11644}, {0x11650, 0x11659}, {0x11660, 0x1166C}, 341 {0x11350, 0x11350}, {0x11357, 0x11357}, {0x1135D, 0x11363},
341 {0x11680, 0x116B8}, {0x116C0, 0x116C9}, {0x11700, 0x1171A}, 342 {0x11366, 0x1136C}, {0x11370, 0x11374}, {0x11400, 0x1145B},
342 {0x1171D, 0x1172B}, {0x11730, 0x1173F}, {0x11800, 0x1183B}, 343 {0x1145D, 0x11461}, {0x11480, 0x114C7}, {0x114D0, 0x114D9},
343 {0x118A0, 0x118F2}, {0x118FF, 0x11906}, {0x11909, 0x11909}, 344 {0x11580, 0x115B5}, {0x115B8, 0x115DD}, {0x11600, 0x11644},
344 {0x1190C, 0x11913}, {0x11915, 0x11916}, {0x11918, 0x11935}, 345 {0x11650, 0x11659}, {0x11660, 0x1166C}, {0x11680, 0x116B9},
345 {0x11937, 0x11938}, {0x1193B, 0x11946}, {0x11950, 0x11959}, 346 {0x116C0, 0x116C9}, {0x11700, 0x1171A}, {0x1171D, 0x1172B},
346 {0x119A0, 0x119A7}, {0x119AA, 0x119D7}, {0x119DA, 0x119E4}, 347 {0x11730, 0x11746}, {0x11800, 0x1183B}, {0x118A0, 0x118F2},
347 {0x11A00, 0x11A47}, {0x11A50, 0x11AA2}, {0x11AC0, 0x11AF8}, 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},
348 {0x11C00, 0x11C08}, {0x11C0A, 0x11C36}, {0x11C38, 0x11C45}, 353 {0x11C00, 0x11C08}, {0x11C0A, 0x11C36}, {0x11C38, 0x11C45},
349 {0x11C50, 0x11C6C}, {0x11C70, 0x11C8F}, {0x11C92, 0x11CA7}, 354 {0x11C50, 0x11C6C}, {0x11C70, 0x11C8F}, {0x11C92, 0x11CA7},
350 {0x11CA9, 0x11CB6}, {0x11D00, 0x11D06}, {0x11D08, 0x11D09}, 355 {0x11CA9, 0x11CB6}, {0x11D00, 0x11D06}, {0x11D08, 0x11D09},
@@ -352,30 +357,36 @@ var neutral = table{
352 {0x11D3F, 0x11D47}, {0x11D50, 0x11D59}, {0x11D60, 0x11D65}, 357 {0x11D3F, 0x11D47}, {0x11D50, 0x11D59}, {0x11D60, 0x11D65},
353 {0x11D67, 0x11D68}, {0x11D6A, 0x11D8E}, {0x11D90, 0x11D91}, 358 {0x11D67, 0x11D68}, {0x11D6A, 0x11D8E}, {0x11D90, 0x11D91},
354 {0x11D93, 0x11D98}, {0x11DA0, 0x11DA9}, {0x11EE0, 0x11EF8}, 359 {0x11D93, 0x11D98}, {0x11DA0, 0x11DA9}, {0x11EE0, 0x11EF8},
360 {0x11F00, 0x11F10}, {0x11F12, 0x11F3A}, {0x11F3E, 0x11F59},
355 {0x11FB0, 0x11FB0}, {0x11FC0, 0x11FF1}, {0x11FFF, 0x12399}, 361 {0x11FB0, 0x11FB0}, {0x11FC0, 0x11FF1}, {0x11FFF, 0x12399},
356 {0x12400, 0x1246E}, {0x12470, 0x12474}, {0x12480, 0x12543}, 362 {0x12400, 0x1246E}, {0x12470, 0x12474}, {0x12480, 0x12543},
357 {0x13000, 0x1342E}, {0x13430, 0x13438}, {0x14400, 0x14646}, 363 {0x12F90, 0x12FF2}, {0x13000, 0x13455}, {0x14400, 0x14646},
358 {0x16800, 0x16A38}, {0x16A40, 0x16A5E}, {0x16A60, 0x16A69}, 364 {0x16800, 0x16A38}, {0x16A40, 0x16A5E}, {0x16A60, 0x16A69},
359 {0x16A6E, 0x16A6F}, {0x16AD0, 0x16AED}, {0x16AF0, 0x16AF5}, 365 {0x16A6E, 0x16ABE}, {0x16AC0, 0x16AC9}, {0x16AD0, 0x16AED},
360 {0x16B00, 0x16B45}, {0x16B50, 0x16B59}, {0x16B5B, 0x16B61}, 366 {0x16AF0, 0x16AF5}, {0x16B00, 0x16B45}, {0x16B50, 0x16B59},
361 {0x16B63, 0x16B77}, {0x16B7D, 0x16B8F}, {0x16E40, 0x16E9A}, 367 {0x16B5B, 0x16B61}, {0x16B63, 0x16B77}, {0x16B7D, 0x16B8F},
362 {0x16F00, 0x16F4A}, {0x16F4F, 0x16F87}, {0x16F8F, 0x16F9F}, 368 {0x16E40, 0x16E9A}, {0x16F00, 0x16F4A}, {0x16F4F, 0x16F87},
363 {0x1BC00, 0x1BC6A}, {0x1BC70, 0x1BC7C}, {0x1BC80, 0x1BC88}, 369 {0x16F8F, 0x16F9F}, {0x1BC00, 0x1BC6A}, {0x1BC70, 0x1BC7C},
364 {0x1BC90, 0x1BC99}, {0x1BC9C, 0x1BCA3}, {0x1D000, 0x1D0F5}, 370 {0x1BC80, 0x1BC88}, {0x1BC90, 0x1BC99}, {0x1BC9C, 0x1BCA3},
365 {0x1D100, 0x1D126}, {0x1D129, 0x1D1E8}, {0x1D200, 0x1D245}, 371 {0x1CF00, 0x1CF2D}, {0x1CF30, 0x1CF46}, {0x1CF50, 0x1CFC3},
366 {0x1D2E0, 0x1D2F3}, {0x1D300, 0x1D356}, {0x1D360, 0x1D378}, 372 {0x1D000, 0x1D0F5}, {0x1D100, 0x1D126}, {0x1D129, 0x1D1EA},
367 {0x1D400, 0x1D454}, {0x1D456, 0x1D49C}, {0x1D49E, 0x1D49F}, 373 {0x1D200, 0x1D245}, {0x1D2C0, 0x1D2D3}, {0x1D2E0, 0x1D2F3},
368 {0x1D4A2, 0x1D4A2}, {0x1D4A5, 0x1D4A6}, {0x1D4A9, 0x1D4AC}, 374 {0x1D300, 0x1D356}, {0x1D360, 0x1D378}, {0x1D400, 0x1D454},
369 {0x1D4AE, 0x1D4B9}, {0x1D4BB, 0x1D4BB}, {0x1D4BD, 0x1D4C3}, 375 {0x1D456, 0x1D49C}, {0x1D49E, 0x1D49F}, {0x1D4A2, 0x1D4A2},
370 {0x1D4C5, 0x1D505}, {0x1D507, 0x1D50A}, {0x1D50D, 0x1D514}, 376 {0x1D4A5, 0x1D4A6}, {0x1D4A9, 0x1D4AC}, {0x1D4AE, 0x1D4B9},
371 {0x1D516, 0x1D51C}, {0x1D51E, 0x1D539}, {0x1D53B, 0x1D53E}, 377 {0x1D4BB, 0x1D4BB}, {0x1D4BD, 0x1D4C3}, {0x1D4C5, 0x1D505},
372 {0x1D540, 0x1D544}, {0x1D546, 0x1D546}, {0x1D54A, 0x1D550}, 378 {0x1D507, 0x1D50A}, {0x1D50D, 0x1D514}, {0x1D516, 0x1D51C},
373 {0x1D552, 0x1D6A5}, {0x1D6A8, 0x1D7CB}, {0x1D7CE, 0x1DA8B}, 379 {0x1D51E, 0x1D539}, {0x1D53B, 0x1D53E}, {0x1D540, 0x1D544},
374 {0x1DA9B, 0x1DA9F}, {0x1DAA1, 0x1DAAF}, {0x1E000, 0x1E006}, 380 {0x1D546, 0x1D546}, {0x1D54A, 0x1D550}, {0x1D552, 0x1D6A5},
375 {0x1E008, 0x1E018}, {0x1E01B, 0x1E021}, {0x1E023, 0x1E024}, 381 {0x1D6A8, 0x1D7CB}, {0x1D7CE, 0x1DA8B}, {0x1DA9B, 0x1DA9F},
376 {0x1E026, 0x1E02A}, {0x1E100, 0x1E12C}, {0x1E130, 0x1E13D}, 382 {0x1DAA1, 0x1DAAF}, {0x1DF00, 0x1DF1E}, {0x1DF25, 0x1DF2A},
377 {0x1E140, 0x1E149}, {0x1E14E, 0x1E14F}, {0x1E2C0, 0x1E2F9}, 383 {0x1E000, 0x1E006}, {0x1E008, 0x1E018}, {0x1E01B, 0x1E021},
378 {0x1E2FF, 0x1E2FF}, {0x1E800, 0x1E8C4}, {0x1E8C7, 0x1E8D6}, 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},
379 {0x1E900, 0x1E94B}, {0x1E950, 0x1E959}, {0x1E95E, 0x1E95F}, 390 {0x1E900, 0x1E94B}, {0x1E950, 0x1E959}, {0x1E95E, 0x1E95F},
380 {0x1EC71, 0x1ECB4}, {0x1ED01, 0x1ED3D}, {0x1EE00, 0x1EE03}, 391 {0x1EC71, 0x1ECB4}, {0x1ED01, 0x1ED3D}, {0x1EE00, 0x1EE03},
381 {0x1EE05, 0x1EE1F}, {0x1EE21, 0x1EE22}, {0x1EE24, 0x1EE24}, 392 {0x1EE05, 0x1EE1F}, {0x1EE21, 0x1EE22}, {0x1EE24, 0x1EE24},
@@ -400,8 +411,8 @@ var neutral = table{
400 {0x1F54F, 0x1F54F}, {0x1F568, 0x1F579}, {0x1F57B, 0x1F594}, 411 {0x1F54F, 0x1F54F}, {0x1F568, 0x1F579}, {0x1F57B, 0x1F594},
401 {0x1F597, 0x1F5A3}, {0x1F5A5, 0x1F5FA}, {0x1F650, 0x1F67F}, 412 {0x1F597, 0x1F5A3}, {0x1F5A5, 0x1F5FA}, {0x1F650, 0x1F67F},
402 {0x1F6C6, 0x1F6CB}, {0x1F6CD, 0x1F6CF}, {0x1F6D3, 0x1F6D4}, 413 {0x1F6C6, 0x1F6CB}, {0x1F6CD, 0x1F6CF}, {0x1F6D3, 0x1F6D4},
403 {0x1F6E0, 0x1F6EA}, {0x1F6F0, 0x1F6F3}, {0x1F700, 0x1F773}, 414 {0x1F6E0, 0x1F6EA}, {0x1F6F0, 0x1F6F3}, {0x1F700, 0x1F776},
404 {0x1F780, 0x1F7D8}, {0x1F800, 0x1F80B}, {0x1F810, 0x1F847}, 415 {0x1F77B, 0x1F7D9}, {0x1F800, 0x1F80B}, {0x1F810, 0x1F847},
405 {0x1F850, 0x1F859}, {0x1F860, 0x1F887}, {0x1F890, 0x1F8AD}, 416 {0x1F850, 0x1F859}, {0x1F860, 0x1F887}, {0x1F890, 0x1F8AD},
406 {0x1F8B0, 0x1F8B1}, {0x1F900, 0x1F90B}, {0x1F93B, 0x1F93B}, 417 {0x1F8B0, 0x1F8B1}, {0x1F900, 0x1F90B}, {0x1F93B, 0x1F93B},
407 {0x1F946, 0x1F946}, {0x1FA00, 0x1FA53}, {0x1FA60, 0x1FA6D}, 418 {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 (
6 "fmt" 6 "fmt"
7 "os" 7 "os"
8 8
9 "github.com/hugolgst/rich-go/ipc" 9 "github.com/wraient/rich-go/ipc"
10) 10)
11 11
12var logged bool 12var 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 (
4 "time" 4 "time"
5) 5)
6 6
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
7// Activity holds the data for discord rich presence 21// Activity holds the data for discord rich presence
8type Activity struct { 22type Activity struct {
9 // What the player is currently doing 23 // What the player is currently doing
10 Details string 24 Details string
11 // The user's current party status 25 // The user's current party status
12 State string 26 State string
27 // The activity type, defaults to Playing if not specified
28 Type ActivityType
13 // The id for a large asset of the activity, usually a snowflake 29 // The id for a large asset of the activity, usually a snowflake
14 LargeImage string 30 LargeImage string
15 // Text displayed when hovering over the large image of the activity 31 // 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 {
19type PayloadActivity struct { 19type PayloadActivity struct {
20 Details string `json:"details,omitempty"` 20 Details string `json:"details,omitempty"`
21 State string `json:"state,omitempty"` 21 State string `json:"state,omitempty"`
22 Type ActivityType `json:"type,omitempty"`
22 Assets PayloadAssets `json:"assets,omitempty"` 23 Assets PayloadAssets `json:"assets,omitempty"`
23 Party *PayloadParty `json:"party,omitempty"` 24 Party *PayloadParty `json:"party,omitempty"`
24 Timestamps *PayloadTimestamps `json:"timestamps,omitempty"` 25 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
1// +build !windows 2// +build !windows
2 3
3package ipc 4package 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
1// +build windows 2// +build windows
2 3
3package ipc 4package ipc
4 5
5import ( 6import (
6 npipe "gopkg.in/natefinch/npipe.v2"
7 "time" 7 "time"
8
9 npipe "gopkg.in/natefinch/npipe.v2"
8) 10)
9 11
10// OpenSocket opens the discord-ipc-0 named pipe 12// 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 {
118 118
119// SetLimit limits the number of active goroutines in this group to at most n. 119// SetLimit limits the number of active goroutines in this group to at most n.
120// A negative value indicates no limit. 120// A negative value indicates no limit.
121// A limit of zero will prevent any new goroutines from being added.
121// 122//
122// Any subsequent call to the Go method will block until it can add an active 123// Any subsequent call to the Go method will block until it can add an active
123// goroutine without exceeding the configured limit. 124// 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) {
58 return &value, err 58 return &value, err
59} 59}
60 60
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
61// IoctlGetWatchdogInfo fetches information about a watchdog device from the 157// IoctlGetWatchdogInfo fetches information about a watchdog device from the
62// Linux watchdog API. For more information, see: 158// Linux watchdog API. For more information, see:
63// https://www.kernel.org/doc/html/latest/watchdog/watchdog-api.html. 159// 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='
158#endif 158#endif
159#define _GNU_SOURCE 159#define _GNU_SOURCE
160 160
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
161// <sys/ioctl.h> is broken on powerpc64, as it fails to include definitions of 171// <sys/ioctl.h> is broken on powerpc64, as it fails to include definitions of
162// these structures. We just include them copied from <bits/termios.h>. 172// these structures. We just include them copied from <bits/termios.h>.
163#if defined(__powerpc__) 173#if defined(__powerpc__)
@@ -256,6 +266,7 @@ struct ltchars {
256#include <linux/nsfs.h> 266#include <linux/nsfs.h>
257#include <linux/perf_event.h> 267#include <linux/perf_event.h>
258#include <linux/pps.h> 268#include <linux/pps.h>
269#include <linux/ptp_clock.h>
259#include <linux/ptrace.h> 270#include <linux/ptrace.h>
260#include <linux/random.h> 271#include <linux/random.h>
261#include <linux/reboot.h> 272#include <linux/reboot.h>
@@ -527,6 +538,7 @@ ccflags="$@"
527 $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)_/ || 538 $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)_/ ||
528 $2 ~ /^NFC_(GENL|PROTO|COMM|RF|SE|DIRECTION|LLCP|SOCKPROTO)_/ || 539 $2 ~ /^NFC_(GENL|PROTO|COMM|RF|SE|DIRECTION|LLCP|SOCKPROTO)_/ ||
529 $2 ~ /^NFC_.*_(MAX)?SIZE$/ || 540 $2 ~ /^NFC_.*_(MAX)?SIZE$/ ||
541 $2 ~ /^PTP_/ ||
530 $2 ~ /^RAW_PAYLOAD_/ || 542 $2 ~ /^RAW_PAYLOAD_/ ||
531 $2 ~ /^[US]F_/ || 543 $2 ~ /^[US]F_/ ||
532 $2 ~ /^TP_STATUS_/ || 544 $2 ~ /^TP_STATUS_/ ||
@@ -552,6 +564,7 @@ ccflags="$@"
552 $2 !~ /^RTC_VL_(ACCURACY|BACKUP|DATA)/ && 564 $2 !~ /^RTC_VL_(ACCURACY|BACKUP|DATA)/ &&
553 $2 ~ /^(NETLINK|NLM|NLMSG|NLA|IFA|IFAN|RT|RTC|RTCF|RTN|RTPROT|RTNH|ARPHRD|ETH_P|NETNSA)_/ || 565 $2 ~ /^(NETLINK|NLM|NLMSG|NLA|IFA|IFAN|RT|RTC|RTCF|RTN|RTPROT|RTNH|ARPHRD|ETH_P|NETNSA)_/ ||
554 $2 ~ /^SOCK_|SK_DIAG_|SKNLGRP_$/ || 566 $2 ~ /^SOCK_|SK_DIAG_|SKNLGRP_$/ ||
567 $2 ~ /^(CONNECT|SAE)_/ ||
555 $2 ~ /^FIORDCHK$/ || 568 $2 ~ /^FIORDCHK$/ ||
556 $2 ~ /^SIOC/ || 569 $2 ~ /^SIOC/ ||
557 $2 ~ /^TIOC/ || 570 $2 ~ /^TIOC/ ||
@@ -655,7 +668,7 @@ errors=$(
655signals=$( 668signals=$(
656 echo '#include <signal.h>' | $CC -x c - -E -dM $ccflags | 669 echo '#include <signal.h>' | $CC -x c - -E -dM $ccflags |
657 awk '$1=="#define" && $2 ~ /^SIG[A-Z0-9]+$/ { print $2 }' | 670 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)' |
659 sort 672 sort
660) 673)
661 674
@@ -665,7 +678,7 @@ echo '#include <errno.h>' | $CC -x c - -E -dM $ccflags |
665 sort >_error.grep 678 sort >_error.grep
666echo '#include <signal.h>' | $CC -x c - -E -dM $ccflags | 679echo '#include <signal.h>' | $CC -x c - -E -dM $ccflags |
667 awk '$1=="#define" && $2 ~ /^SIG[A-Z0-9]+$/ { print "^\t" $2 "[ \t]*=" }' | 680 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)' |
669 sort >_signal.grep 682 sort >_signal.grep
670 683
671echo '// mkerrors.sh' "$@" 684echo '// 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,
360 var status _C_int 360 var status _C_int
361 var r Pid_t 361 var r Pid_t
362 err = ERESTART 362 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
364 // active. 364 // active.
365 for err == ERESTART { 365 for err == ERESTART {
366 r, err = wait4(Pid_t(pid), &status, options, rusage) 366 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) {
566 return pthread_fchdir_np(fd) 566 return pthread_fchdir_np(fd)
567} 567}
568 568
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)
569//sys sendfile(infd int, outfd int, offset int64, len *int64, hdtr unsafe.Pointer, flags int) (err error) 606//sys sendfile(infd int, outfd int, offset int64, len *int64, hdtr unsafe.Pointer, flags int) (err error)
570 607
571//sys shmat(id int, addr uintptr, flag int) (ret uintptr, err error) 608//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
246 return sendfile(outfd, infd, offset, count) 246 return sendfile(outfd, infd, offset, count)
247} 247}
248 248
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
249/* 261/*
250 * Exposed directly 262 * Exposed directly
251 */ 263 */
vendor/golang.org/x/sys/unix/syscall_hurd.go +1
@@ -11,6 +11,7 @@ package unix
11int ioctl(int, unsigned long int, uintptr_t); 11int ioctl(int, unsigned long int, uintptr_t);
12*/ 12*/
13import "C" 13import "C"
14import "unsafe"
14 15
15func ioctl(fd int, req uint, arg uintptr) (err error) { 16func ioctl(fd int, req uint, arg uintptr) (err error) {
16 r0, er := C.ioctl(C.int(fd), C.ulong(req), C.uintptr_t(arg)) 17 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) {
1295 return &value, err 1295 return &value, err
1296} 1296}
1297 1297
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
1298// GetsockoptString returns the string value of the socket option opt for the 1340// GetsockoptString returns the string value of the socket option opt for the
1299// socket associated with fd at the given socket level. 1341// socket associated with fd at the given socket level.
1300func GetsockoptString(fd, level, opt int) (string, error) { 1342func 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
1818//sys ClockAdjtime(clockid int32, buf *Timex) (state int, err error) 1860//sys ClockAdjtime(clockid int32, buf *Timex) (state int, err error)
1819//sys ClockGetres(clockid int32, res *Timespec) (err error) 1861//sys ClockGetres(clockid int32, res *Timespec) (err error)
1820//sys ClockGettime(clockid int32, time *Timespec) (err error) 1862//sys ClockGettime(clockid int32, time *Timespec) (err error)
1863//sys ClockSettime(clockid int32, time *Timespec) (err error)
1821//sys ClockNanosleep(clockid int32, flags int, request *Timespec, remain *Timespec) (err error) 1864//sys ClockNanosleep(clockid int32, flags int, request *Timespec, remain *Timespec) (err error)
1822//sys Close(fd int) (err error) 1865//sys Close(fd int) (err error)
1823//sys CloseRange(first uint, last uint, flags uint) (err error) 1866//sys CloseRange(first uint, last uint, flags uint) (err error)
@@ -1959,7 +2002,26 @@ func Getpgrp() (pid int) {
1959//sysnb Getpid() (pid int) 2002//sysnb Getpid() (pid int)
1960//sysnb Getppid() (ppid int) 2003//sysnb Getppid() (ppid int)
1961//sys Getpriority(which int, who int) (prio int, err error) 2004//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
1963//sysnb Getrusage(who int, rusage *Rusage) (err error) 2025//sysnb Getrusage(who int, rusage *Rusage) (err error)
1964//sysnb Getsid(pid int) (sid int, err error) 2026//sysnb Getsid(pid int) (sid int, err error)
1965//sysnb Gettid() (tid int) 2027//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
182 } 182 }
183 return kexecFileLoad(kernelFd, initrdFd, cmdlineLen, cmdline, flags) 183 return kexecFileLoad(kernelFd, initrdFd, cmdlineLen, cmdline, flags)
184} 184}
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
214 } 214 }
215 return kexecFileLoad(kernelFd, initrdFd, cmdlineLen, cmdline, flags) 215 return kexecFileLoad(kernelFd, initrdFd, cmdlineLen, cmdline, flags)
216} 216}
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
187 } 187 }
188 return riscvHWProbe(pairs, setSize, set, flags) 188 return riscvHWProbe(pairs, setSize, set, flags)
189} 189}
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) {
1102func IoctlSetStrioctlRetInt(fd int, req int, s *Strioctl) (int, error) { 1102func IoctlSetStrioctlRetInt(fd int, req int, s *Strioctl) (int, error) {
1103 return ioctlPtrRet(fd, req, unsafe.Pointer(s)) 1103 return ioctlPtrRet(fd, req, unsafe.Pointer(s))
1104} 1104}
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) {
768 return mapper.Munmap(b) 768 return mapper.Munmap(b)
769} 769}
770 770
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
771//sys Gethostname(buf []byte) (err error) = SYS___GETHOSTNAME_A 780//sys Gethostname(buf []byte) (err error) = SYS___GETHOSTNAME_A
772//sysnb Getgid() (gid int) 781//sysnb Getgid() (gid int)
773//sysnb Getpid() (pid int) 782//sysnb Getpid() (pid int)
@@ -816,10 +825,10 @@ func Lstat(path string, stat *Stat_t) (err error) {
816// for checking symlinks begins with $VERSION/ $SYSNAME/ $SYSSYMR/ $SYSSYMA/ 825// for checking symlinks begins with $VERSION/ $SYSNAME/ $SYSSYMR/ $SYSSYMA/
817func isSpecialPath(path []byte) (v bool) { 826func isSpecialPath(path []byte) (v bool) {
818 var special = [4][8]byte{ 827 var special = [4][8]byte{
819 [8]byte{'V', 'E', 'R', 'S', 'I', 'O', 'N', '/'}, 828 {'V', 'E', 'R', 'S', 'I', 'O', 'N', '/'},
820 [8]byte{'S', 'Y', 'S', 'N', 'A', 'M', 'E', '/'}, 829 {'S', 'Y', 'S', 'N', 'A', 'M', 'E', '/'},
821 [8]byte{'S', 'Y', 'S', 'S', 'Y', 'M', 'R', '/'}, 830 {'S', 'Y', 'S', 'S', 'Y', 'M', 'R', '/'},
822 [8]byte{'S', 'Y', 'S', 'S', 'Y', 'M', 'A', '/'}} 831 {'S', 'Y', 'S', 'S', 'Y', 'M', 'A', '/'}}
823 832
824 var i, j int 833 var i, j int
825 for i = 0; i < len(special); i++ { 834 for i = 0; i < len(special); i++ {
@@ -3115,3 +3124,90 @@ func legacy_Mkfifoat(dirfd int, path string, mode uint32) (err error) {
3115//sys Posix_openpt(oflag int) (fd int, err error) = SYS_POSIX_OPENPT 3124//sys Posix_openpt(oflag int) (fd int, err error) = SYS_POSIX_OPENPT
3116//sys Grantpt(fildes int) (rc int, err error) = SYS_GRANTPT 3125//sys Grantpt(fildes int) (rc int, err error) = SYS_GRANTPT
3117//sys Unlockpt(fildes int) (rc int, err error) = SYS_UNLOCKPT 3126//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 (
237 CLOCK_UPTIME_RAW_APPROX = 0x9 237 CLOCK_UPTIME_RAW_APPROX = 0x9
238 CLONE_NOFOLLOW = 0x1 238 CLONE_NOFOLLOW = 0x1
239 CLONE_NOOWNERCOPY = 0x2 239 CLONE_NOOWNERCOPY = 0x2
240 CONNECT_DATA_AUTHENTICATED = 0x4
241 CONNECT_DATA_IDEMPOTENT = 0x2
242 CONNECT_RESUME_ON_READ_WRITE = 0x1
240 CR0 = 0x0 243 CR0 = 0x0
241 CR1 = 0x1000 244 CR1 = 0x1000
242 CR2 = 0x2000 245 CR2 = 0x2000
@@ -1265,6 +1268,10 @@ const (
1265 RTV_SSTHRESH = 0x20 1268 RTV_SSTHRESH = 0x20
1266 RUSAGE_CHILDREN = -0x1 1269 RUSAGE_CHILDREN = -0x1
1267 RUSAGE_SELF = 0x0 1270 RUSAGE_SELF = 0x0
1271 SAE_ASSOCID_ALL = 0xffffffff
1272 SAE_ASSOCID_ANY = 0x0
1273 SAE_CONNID_ALL = 0xffffffff
1274 SAE_CONNID_ANY = 0x0
1268 SCM_CREDS = 0x3 1275 SCM_CREDS = 0x3
1269 SCM_RIGHTS = 0x1 1276 SCM_RIGHTS = 0x1
1270 SCM_TIMESTAMP = 0x2 1277 SCM_TIMESTAMP = 0x2
vendor/golang.org/x/sys/unix/zerrors_darwin_arm64.go +7
@@ -237,6 +237,9 @@ const (
237 CLOCK_UPTIME_RAW_APPROX = 0x9 237 CLOCK_UPTIME_RAW_APPROX = 0x9
238 CLONE_NOFOLLOW = 0x1 238 CLONE_NOFOLLOW = 0x1
239 CLONE_NOOWNERCOPY = 0x2 239 CLONE_NOOWNERCOPY = 0x2
240 CONNECT_DATA_AUTHENTICATED = 0x4
241 CONNECT_DATA_IDEMPOTENT = 0x2
242 CONNECT_RESUME_ON_READ_WRITE = 0x1
240 CR0 = 0x0 243 CR0 = 0x0
241 CR1 = 0x1000 244 CR1 = 0x1000
242 CR2 = 0x2000 245 CR2 = 0x2000
@@ -1265,6 +1268,10 @@ const (
1265 RTV_SSTHRESH = 0x20 1268 RTV_SSTHRESH = 0x20
1266 RUSAGE_CHILDREN = -0x1 1269 RUSAGE_CHILDREN = -0x1
1267 RUSAGE_SELF = 0x0 1270 RUSAGE_SELF = 0x0
1271 SAE_ASSOCID_ALL = 0xffffffff
1272 SAE_ASSOCID_ANY = 0x0
1273 SAE_CONNID_ALL = 0xffffffff
1274 SAE_CONNID_ANY = 0x0
1268 SCM_CREDS = 0x3 1275 SCM_CREDS = 0x3
1269 SCM_RIGHTS = 0x1 1276 SCM_RIGHTS = 0x1
1270 SCM_TIMESTAMP = 0x2 1277 SCM_TIMESTAMP = 0x2
vendor/golang.org/x/sys/unix/zerrors_linux.go +61 −3
@@ -321,6 +321,9 @@ const (
321 AUDIT_INTEGRITY_STATUS = 0x70a 321 AUDIT_INTEGRITY_STATUS = 0x70a
322 AUDIT_IPC = 0x517 322 AUDIT_IPC = 0x517
323 AUDIT_IPC_SET_PERM = 0x51f 323 AUDIT_IPC_SET_PERM = 0x51f
324 AUDIT_IPE_ACCESS = 0x58c
325 AUDIT_IPE_CONFIG_CHANGE = 0x58d
326 AUDIT_IPE_POLICY_LOAD = 0x58e
324 AUDIT_KERNEL = 0x7d0 327 AUDIT_KERNEL = 0x7d0
325 AUDIT_KERNEL_OTHER = 0x524 328 AUDIT_KERNEL_OTHER = 0x524
326 AUDIT_KERN_MODULE = 0x532 329 AUDIT_KERN_MODULE = 0x532
@@ -489,12 +492,14 @@ const (
489 BPF_F_ID = 0x20 492 BPF_F_ID = 0x20
490 BPF_F_NETFILTER_IP_DEFRAG = 0x1 493 BPF_F_NETFILTER_IP_DEFRAG = 0x1
491 BPF_F_QUERY_EFFECTIVE = 0x1 494 BPF_F_QUERY_EFFECTIVE = 0x1
495 BPF_F_REDIRECT_FLAGS = 0x19
492 BPF_F_REPLACE = 0x4 496 BPF_F_REPLACE = 0x4
493 BPF_F_SLEEPABLE = 0x10 497 BPF_F_SLEEPABLE = 0x10
494 BPF_F_STRICT_ALIGNMENT = 0x1 498 BPF_F_STRICT_ALIGNMENT = 0x1
495 BPF_F_TEST_REG_INVARIANTS = 0x80 499 BPF_F_TEST_REG_INVARIANTS = 0x80
496 BPF_F_TEST_RND_HI32 = 0x4 500 BPF_F_TEST_RND_HI32 = 0x4
497 BPF_F_TEST_RUN_ON_CPU = 0x1 501 BPF_F_TEST_RUN_ON_CPU = 0x1
502 BPF_F_TEST_SKB_CHECKSUM_COMPLETE = 0x4
498 BPF_F_TEST_STATE_FREQ = 0x8 503 BPF_F_TEST_STATE_FREQ = 0x8
499 BPF_F_TEST_XDP_LIVE_FRAMES = 0x2 504 BPF_F_TEST_XDP_LIVE_FRAMES = 0x2
500 BPF_F_XDP_DEV_BOUND_ONLY = 0x40 505 BPF_F_XDP_DEV_BOUND_ONLY = 0x40
@@ -1165,6 +1170,7 @@ const (
1165 EXTA = 0xe 1170 EXTA = 0xe
1166 EXTB = 0xf 1171 EXTB = 0xf
1167 F2FS_SUPER_MAGIC = 0xf2f52010 1172 F2FS_SUPER_MAGIC = 0xf2f52010
1173 FALLOC_FL_ALLOCATE_RANGE = 0x0
1168 FALLOC_FL_COLLAPSE_RANGE = 0x8 1174 FALLOC_FL_COLLAPSE_RANGE = 0x8
1169 FALLOC_FL_INSERT_RANGE = 0x20 1175 FALLOC_FL_INSERT_RANGE = 0x20
1170 FALLOC_FL_KEEP_SIZE = 0x1 1176 FALLOC_FL_KEEP_SIZE = 0x1
@@ -1239,6 +1245,7 @@ const (
1239 FAN_REPORT_DFID_NAME = 0xc00 1245 FAN_REPORT_DFID_NAME = 0xc00
1240 FAN_REPORT_DFID_NAME_TARGET = 0x1e00 1246 FAN_REPORT_DFID_NAME_TARGET = 0x1e00
1241 FAN_REPORT_DIR_FID = 0x400 1247 FAN_REPORT_DIR_FID = 0x400
1248 FAN_REPORT_FD_ERROR = 0x2000
1242 FAN_REPORT_FID = 0x200 1249 FAN_REPORT_FID = 0x200
1243 FAN_REPORT_NAME = 0x800 1250 FAN_REPORT_NAME = 0x800
1244 FAN_REPORT_PIDFD = 0x80 1251 FAN_REPORT_PIDFD = 0x80
@@ -1324,8 +1331,10 @@ const (
1324 FUSE_SUPER_MAGIC = 0x65735546 1331 FUSE_SUPER_MAGIC = 0x65735546
1325 FUTEXFS_SUPER_MAGIC = 0xbad1dea 1332 FUTEXFS_SUPER_MAGIC = 0xbad1dea
1326 F_ADD_SEALS = 0x409 1333 F_ADD_SEALS = 0x409
1334 F_CREATED_QUERY = 0x404
1327 F_DUPFD = 0x0 1335 F_DUPFD = 0x0
1328 F_DUPFD_CLOEXEC = 0x406 1336 F_DUPFD_CLOEXEC = 0x406
1337 F_DUPFD_QUERY = 0x403
1329 F_EXLCK = 0x4 1338 F_EXLCK = 0x4
1330 F_GETFD = 0x1 1339 F_GETFD = 0x1
1331 F_GETFL = 0x3 1340 F_GETFL = 0x3
@@ -1545,6 +1554,7 @@ const (
1545 IPPROTO_ROUTING = 0x2b 1554 IPPROTO_ROUTING = 0x2b
1546 IPPROTO_RSVP = 0x2e 1555 IPPROTO_RSVP = 0x2e
1547 IPPROTO_SCTP = 0x84 1556 IPPROTO_SCTP = 0x84
1557 IPPROTO_SMC = 0x100
1548 IPPROTO_TCP = 0x6 1558 IPPROTO_TCP = 0x6
1549 IPPROTO_TP = 0x1d 1559 IPPROTO_TP = 0x1d
1550 IPPROTO_UDP = 0x11 1560 IPPROTO_UDP = 0x11
@@ -1617,6 +1627,8 @@ const (
1617 IPV6_UNICAST_IF = 0x4c 1627 IPV6_UNICAST_IF = 0x4c
1618 IPV6_USER_FLOW = 0xe 1628 IPV6_USER_FLOW = 0xe
1619 IPV6_V6ONLY = 0x1a 1629 IPV6_V6ONLY = 0x1a
1630 IPV6_VERSION = 0x60
1631 IPV6_VERSION_MASK = 0xf0
1620 IPV6_XFRM_POLICY = 0x23 1632 IPV6_XFRM_POLICY = 0x23
1621 IP_ADD_MEMBERSHIP = 0x23 1633 IP_ADD_MEMBERSHIP = 0x23
1622 IP_ADD_SOURCE_MEMBERSHIP = 0x27 1634 IP_ADD_SOURCE_MEMBERSHIP = 0x27
@@ -1798,6 +1810,8 @@ const (
1798 LANDLOCK_ACCESS_NET_BIND_TCP = 0x1 1810 LANDLOCK_ACCESS_NET_BIND_TCP = 0x1
1799 LANDLOCK_ACCESS_NET_CONNECT_TCP = 0x2 1811 LANDLOCK_ACCESS_NET_CONNECT_TCP = 0x2
1800 LANDLOCK_CREATE_RULESET_VERSION = 0x1 1812 LANDLOCK_CREATE_RULESET_VERSION = 0x1
1813 LANDLOCK_SCOPE_ABSTRACT_UNIX_SOCKET = 0x1
1814 LANDLOCK_SCOPE_SIGNAL = 0x2
1801 LINUX_REBOOT_CMD_CAD_OFF = 0x0 1815 LINUX_REBOOT_CMD_CAD_OFF = 0x0
1802 LINUX_REBOOT_CMD_CAD_ON = 0x89abcdef 1816 LINUX_REBOOT_CMD_CAD_ON = 0x89abcdef
1803 LINUX_REBOOT_CMD_HALT = 0xcdef0123 1817 LINUX_REBOOT_CMD_HALT = 0xcdef0123
@@ -1859,6 +1873,7 @@ const (
1859 MADV_UNMERGEABLE = 0xd 1873 MADV_UNMERGEABLE = 0xd
1860 MADV_WILLNEED = 0x3 1874 MADV_WILLNEED = 0x3
1861 MADV_WIPEONFORK = 0x12 1875 MADV_WIPEONFORK = 0x12
1876 MAP_DROPPABLE = 0x8
1862 MAP_FILE = 0x0 1877 MAP_FILE = 0x0
1863 MAP_FIXED = 0x10 1878 MAP_FIXED = 0x10
1864 MAP_FIXED_NOREPLACE = 0x100000 1879 MAP_FIXED_NOREPLACE = 0x100000
@@ -1922,6 +1937,8 @@ const (
1922 MNT_EXPIRE = 0x4 1937 MNT_EXPIRE = 0x4
1923 MNT_FORCE = 0x1 1938 MNT_FORCE = 0x1
1924 MNT_ID_REQ_SIZE_VER0 = 0x18 1939 MNT_ID_REQ_SIZE_VER0 = 0x18
1940 MNT_ID_REQ_SIZE_VER1 = 0x20
1941 MNT_NS_INFO_SIZE_VER0 = 0x10
1925 MODULE_INIT_COMPRESSED_FILE = 0x4 1942 MODULE_INIT_COMPRESSED_FILE = 0x4
1926 MODULE_INIT_IGNORE_MODVERSIONS = 0x1 1943 MODULE_INIT_IGNORE_MODVERSIONS = 0x1
1927 MODULE_INIT_IGNORE_VERMAGIC = 0x2 1944 MODULE_INIT_IGNORE_VERMAGIC = 0x2
@@ -1957,6 +1974,7 @@ const (
1957 MSG_PEEK = 0x2 1974 MSG_PEEK = 0x2
1958 MSG_PROXY = 0x10 1975 MSG_PROXY = 0x10
1959 MSG_RST = 0x1000 1976 MSG_RST = 0x1000
1977 MSG_SOCK_DEVMEM = 0x2000000
1960 MSG_SYN = 0x400 1978 MSG_SYN = 0x400
1961 MSG_TRUNC = 0x20 1979 MSG_TRUNC = 0x20
1962 MSG_TRYHARD = 0x4 1980 MSG_TRYHARD = 0x4
@@ -2073,6 +2091,7 @@ const (
2073 NFC_ATR_REQ_MAXSIZE = 0x40 2091 NFC_ATR_REQ_MAXSIZE = 0x40
2074 NFC_ATR_RES_GB_MAXSIZE = 0x2f 2092 NFC_ATR_RES_GB_MAXSIZE = 0x2f
2075 NFC_ATR_RES_MAXSIZE = 0x40 2093 NFC_ATR_RES_MAXSIZE = 0x40
2094 NFC_ATS_MAXSIZE = 0x14
2076 NFC_COMM_ACTIVE = 0x0 2095 NFC_COMM_ACTIVE = 0x0
2077 NFC_COMM_PASSIVE = 0x1 2096 NFC_COMM_PASSIVE = 0x1
2078 NFC_DEVICE_NAME_MAXSIZE = 0x8 2097 NFC_DEVICE_NAME_MAXSIZE = 0x8
@@ -2153,6 +2172,7 @@ const (
2153 NFNL_SUBSYS_QUEUE = 0x3 2172 NFNL_SUBSYS_QUEUE = 0x3
2154 NFNL_SUBSYS_ULOG = 0x4 2173 NFNL_SUBSYS_ULOG = 0x4
2155 NFS_SUPER_MAGIC = 0x6969 2174 NFS_SUPER_MAGIC = 0x6969
2175 NFT_BITWISE_BOOL = 0x0
2156 NFT_CHAIN_FLAGS = 0x7 2176 NFT_CHAIN_FLAGS = 0x7
2157 NFT_CHAIN_MAXNAMELEN = 0x100 2177 NFT_CHAIN_MAXNAMELEN = 0x100
2158 NFT_CT_MAX = 0x17 2178 NFT_CT_MAX = 0x17
@@ -2187,7 +2207,7 @@ const (
2187 NFT_REG_SIZE = 0x10 2207 NFT_REG_SIZE = 0x10
2188 NFT_REJECT_ICMPX_MAX = 0x3 2208 NFT_REJECT_ICMPX_MAX = 0x3
2189 NFT_RT_MAX = 0x4 2209 NFT_RT_MAX = 0x4
2190 NFT_SECMARK_CTX_MAXLEN = 0x100 2210 NFT_SECMARK_CTX_MAXLEN = 0x1000
2191 NFT_SET_MAXNAMELEN = 0x100 2211 NFT_SET_MAXNAMELEN = 0x100
2192 NFT_SOCKET_MAX = 0x3 2212 NFT_SOCKET_MAX = 0x3
2193 NFT_TABLE_F_MASK = 0x7 2213 NFT_TABLE_F_MASK = 0x7
@@ -2356,9 +2376,11 @@ const (
2356 PERF_MEM_LVLNUM_IO = 0xa 2376 PERF_MEM_LVLNUM_IO = 0xa
2357 PERF_MEM_LVLNUM_L1 = 0x1 2377 PERF_MEM_LVLNUM_L1 = 0x1
2358 PERF_MEM_LVLNUM_L2 = 0x2 2378 PERF_MEM_LVLNUM_L2 = 0x2
2379 PERF_MEM_LVLNUM_L2_MHB = 0x5
2359 PERF_MEM_LVLNUM_L3 = 0x3 2380 PERF_MEM_LVLNUM_L3 = 0x3
2360 PERF_MEM_LVLNUM_L4 = 0x4 2381 PERF_MEM_LVLNUM_L4 = 0x4
2361 PERF_MEM_LVLNUM_LFB = 0xc 2382 PERF_MEM_LVLNUM_LFB = 0xc
2383 PERF_MEM_LVLNUM_MSC = 0x6
2362 PERF_MEM_LVLNUM_NA = 0xf 2384 PERF_MEM_LVLNUM_NA = 0xf
2363 PERF_MEM_LVLNUM_PMEM = 0xe 2385 PERF_MEM_LVLNUM_PMEM = 0xe
2364 PERF_MEM_LVLNUM_RAM = 0xd 2386 PERF_MEM_LVLNUM_RAM = 0xd
@@ -2431,6 +2453,7 @@ const (
2431 PRIO_PGRP = 0x1 2453 PRIO_PGRP = 0x1
2432 PRIO_PROCESS = 0x0 2454 PRIO_PROCESS = 0x0
2433 PRIO_USER = 0x2 2455 PRIO_USER = 0x2
2456 PROCFS_IOCTL_MAGIC = 'f'
2434 PROC_SUPER_MAGIC = 0x9fa0 2457 PROC_SUPER_MAGIC = 0x9fa0
2435 PROT_EXEC = 0x4 2458 PROT_EXEC = 0x4
2436 PROT_GROWSDOWN = 0x1000000 2459 PROT_GROWSDOWN = 0x1000000
@@ -2478,6 +2501,7 @@ const (
2478 PR_GET_PDEATHSIG = 0x2 2501 PR_GET_PDEATHSIG = 0x2
2479 PR_GET_SECCOMP = 0x15 2502 PR_GET_SECCOMP = 0x15
2480 PR_GET_SECUREBITS = 0x1b 2503 PR_GET_SECUREBITS = 0x1b
2504 PR_GET_SHADOW_STACK_STATUS = 0x4a
2481 PR_GET_SPECULATION_CTRL = 0x34 2505 PR_GET_SPECULATION_CTRL = 0x34
2482 PR_GET_TAGGED_ADDR_CTRL = 0x38 2506 PR_GET_TAGGED_ADDR_CTRL = 0x38
2483 PR_GET_THP_DISABLE = 0x2a 2507 PR_GET_THP_DISABLE = 0x2a
@@ -2486,6 +2510,7 @@ const (
2486 PR_GET_TIMING = 0xd 2510 PR_GET_TIMING = 0xd
2487 PR_GET_TSC = 0x19 2511 PR_GET_TSC = 0x19
2488 PR_GET_UNALIGN = 0x5 2512 PR_GET_UNALIGN = 0x5
2513 PR_LOCK_SHADOW_STACK_STATUS = 0x4c
2489 PR_MCE_KILL = 0x21 2514 PR_MCE_KILL = 0x21
2490 PR_MCE_KILL_CLEAR = 0x0 2515 PR_MCE_KILL_CLEAR = 0x0
2491 PR_MCE_KILL_DEFAULT = 0x2 2516 PR_MCE_KILL_DEFAULT = 0x2
@@ -2512,6 +2537,8 @@ const (
2512 PR_PAC_GET_ENABLED_KEYS = 0x3d 2537 PR_PAC_GET_ENABLED_KEYS = 0x3d
2513 PR_PAC_RESET_KEYS = 0x36 2538 PR_PAC_RESET_KEYS = 0x36
2514 PR_PAC_SET_ENABLED_KEYS = 0x3c 2539 PR_PAC_SET_ENABLED_KEYS = 0x3c
2540 PR_PMLEN_MASK = 0x7f000000
2541 PR_PMLEN_SHIFT = 0x18
2515 PR_PPC_DEXCR_CTRL_CLEAR = 0x4 2542 PR_PPC_DEXCR_CTRL_CLEAR = 0x4
2516 PR_PPC_DEXCR_CTRL_CLEAR_ONEXEC = 0x10 2543 PR_PPC_DEXCR_CTRL_CLEAR_ONEXEC = 0x10
2517 PR_PPC_DEXCR_CTRL_EDITABLE = 0x1 2544 PR_PPC_DEXCR_CTRL_EDITABLE = 0x1
@@ -2579,6 +2606,7 @@ const (
2579 PR_SET_PTRACER = 0x59616d61 2606 PR_SET_PTRACER = 0x59616d61
2580 PR_SET_SECCOMP = 0x16 2607 PR_SET_SECCOMP = 0x16
2581 PR_SET_SECUREBITS = 0x1c 2608 PR_SET_SECUREBITS = 0x1c
2609 PR_SET_SHADOW_STACK_STATUS = 0x4b
2582 PR_SET_SPECULATION_CTRL = 0x35 2610 PR_SET_SPECULATION_CTRL = 0x35
2583 PR_SET_SYSCALL_USER_DISPATCH = 0x3b 2611 PR_SET_SYSCALL_USER_DISPATCH = 0x3b
2584 PR_SET_TAGGED_ADDR_CTRL = 0x37 2612 PR_SET_TAGGED_ADDR_CTRL = 0x37
@@ -2589,6 +2617,9 @@ const (
2589 PR_SET_UNALIGN = 0x6 2617 PR_SET_UNALIGN = 0x6
2590 PR_SET_VMA = 0x53564d41 2618 PR_SET_VMA = 0x53564d41
2591 PR_SET_VMA_ANON_NAME = 0x0 2619 PR_SET_VMA_ANON_NAME = 0x0
2620 PR_SHADOW_STACK_ENABLE = 0x1
2621 PR_SHADOW_STACK_PUSH = 0x4
2622 PR_SHADOW_STACK_WRITE = 0x2
2592 PR_SME_GET_VL = 0x40 2623 PR_SME_GET_VL = 0x40
2593 PR_SME_SET_VL = 0x3f 2624 PR_SME_SET_VL = 0x3f
2594 PR_SME_SET_VL_ONEXEC = 0x40000 2625 PR_SME_SET_VL_ONEXEC = 0x40000
@@ -2620,6 +2651,28 @@ const (
2620 PR_UNALIGN_NOPRINT = 0x1 2651 PR_UNALIGN_NOPRINT = 0x1
2621 PR_UNALIGN_SIGBUS = 0x2 2652 PR_UNALIGN_SIGBUS = 0x2
2622 PSTOREFS_MAGIC = 0x6165676c 2653 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
2623 PTRACE_ATTACH = 0x10 2676 PTRACE_ATTACH = 0x10
2624 PTRACE_CONT = 0x7 2677 PTRACE_CONT = 0x7
2625 PTRACE_DETACH = 0x11 2678 PTRACE_DETACH = 0x11
@@ -2876,7 +2929,6 @@ const (
2876 RTM_NEWNEXTHOP = 0x68 2929 RTM_NEWNEXTHOP = 0x68
2877 RTM_NEWNEXTHOPBUCKET = 0x74 2930 RTM_NEWNEXTHOPBUCKET = 0x74
2878 RTM_NEWNSID = 0x58 2931 RTM_NEWNSID = 0x58
2879 RTM_NEWNVLAN = 0x70
2880 RTM_NEWPREFIX = 0x34 2932 RTM_NEWPREFIX = 0x34
2881 RTM_NEWQDISC = 0x24 2933 RTM_NEWQDISC = 0x24
2882 RTM_NEWROUTE = 0x18 2934 RTM_NEWROUTE = 0x18
@@ -2885,6 +2937,7 @@ const (
2885 RTM_NEWTCLASS = 0x28 2937 RTM_NEWTCLASS = 0x28
2886 RTM_NEWTFILTER = 0x2c 2938 RTM_NEWTFILTER = 0x2c
2887 RTM_NEWTUNNEL = 0x78 2939 RTM_NEWTUNNEL = 0x78
2940 RTM_NEWVLAN = 0x70
2888 RTM_NR_FAMILIES = 0x1b 2941 RTM_NR_FAMILIES = 0x1b
2889 RTM_NR_MSGTYPES = 0x6c 2942 RTM_NR_MSGTYPES = 0x6c
2890 RTM_SETDCB = 0x4f 2943 RTM_SETDCB = 0x4f
@@ -2933,15 +2986,17 @@ const (
2933 RUSAGE_SELF = 0x0 2986 RUSAGE_SELF = 0x0
2934 RUSAGE_THREAD = 0x1 2987 RUSAGE_THREAD = 0x1
2935 RWF_APPEND = 0x10 2988 RWF_APPEND = 0x10
2989 RWF_ATOMIC = 0x40
2936 RWF_DSYNC = 0x2 2990 RWF_DSYNC = 0x2
2937 RWF_HIPRI = 0x1 2991 RWF_HIPRI = 0x1
2938 RWF_NOAPPEND = 0x20 2992 RWF_NOAPPEND = 0x20
2939 RWF_NOWAIT = 0x8 2993 RWF_NOWAIT = 0x8
2940 RWF_SUPPORTED = 0x3f 2994 RWF_SUPPORTED = 0x7f
2941 RWF_SYNC = 0x4 2995 RWF_SYNC = 0x4
2942 RWF_WRITE_LIFE_NOT_SET = 0x0 2996 RWF_WRITE_LIFE_NOT_SET = 0x0
2943 SCHED_BATCH = 0x3 2997 SCHED_BATCH = 0x3
2944 SCHED_DEADLINE = 0x6 2998 SCHED_DEADLINE = 0x6
2999 SCHED_EXT = 0x7
2945 SCHED_FIFO = 0x1 3000 SCHED_FIFO = 0x1
2946 SCHED_FLAG_ALL = 0x7f 3001 SCHED_FLAG_ALL = 0x7f
2947 SCHED_FLAG_DL_OVERRUN = 0x4 3002 SCHED_FLAG_DL_OVERRUN = 0x4
@@ -3210,6 +3265,7 @@ const (
3210 STATX_ATTR_MOUNT_ROOT = 0x2000 3265 STATX_ATTR_MOUNT_ROOT = 0x2000
3211 STATX_ATTR_NODUMP = 0x40 3266 STATX_ATTR_NODUMP = 0x40
3212 STATX_ATTR_VERITY = 0x100000 3267 STATX_ATTR_VERITY = 0x100000
3268 STATX_ATTR_WRITE_ATOMIC = 0x400000
3213 STATX_BASIC_STATS = 0x7ff 3269 STATX_BASIC_STATS = 0x7ff
3214 STATX_BLOCKS = 0x400 3270 STATX_BLOCKS = 0x400
3215 STATX_BTIME = 0x800 3271 STATX_BTIME = 0x800
@@ -3226,6 +3282,7 @@ const (
3226 STATX_SUBVOL = 0x8000 3282 STATX_SUBVOL = 0x8000
3227 STATX_TYPE = 0x1 3283 STATX_TYPE = 0x1
3228 STATX_UID = 0x8 3284 STATX_UID = 0x8
3285 STATX_WRITE_ATOMIC = 0x10000
3229 STATX__RESERVED = 0x80000000 3286 STATX__RESERVED = 0x80000000
3230 SYNC_FILE_RANGE_WAIT_AFTER = 0x4 3287 SYNC_FILE_RANGE_WAIT_AFTER = 0x4
3231 SYNC_FILE_RANGE_WAIT_BEFORE = 0x1 3288 SYNC_FILE_RANGE_WAIT_BEFORE = 0x1
@@ -3624,6 +3681,7 @@ const (
3624 XDP_UMEM_PGOFF_COMPLETION_RING = 0x180000000 3681 XDP_UMEM_PGOFF_COMPLETION_RING = 0x180000000
3625 XDP_UMEM_PGOFF_FILL_RING = 0x100000000 3682 XDP_UMEM_PGOFF_FILL_RING = 0x100000000
3626 XDP_UMEM_REG = 0x4 3683 XDP_UMEM_REG = 0x4
3684 XDP_UMEM_TX_METADATA_LEN = 0x4
3627 XDP_UMEM_TX_SW_CSUM = 0x2 3685 XDP_UMEM_TX_SW_CSUM = 0x2
3628 XDP_UMEM_UNALIGNED_CHUNK_FLAG = 0x1 3686 XDP_UMEM_UNALIGNED_CHUNK_FLAG = 0x1
3629 XDP_USE_NEED_WAKEUP = 0x8 3687 XDP_USE_NEED_WAKEUP = 0x8
vendor/golang.org/x/sys/unix/zerrors_linux_386.go +28
@@ -109,12 +109,15 @@ const (
109 HIDIOCGRAWINFO = 0x80084803 109 HIDIOCGRAWINFO = 0x80084803
110 HIDIOCGRDESC = 0x90044802 110 HIDIOCGRDESC = 0x90044802
111 HIDIOCGRDESCSIZE = 0x80044801 111 HIDIOCGRDESCSIZE = 0x80044801
112 HIDIOCREVOKE = 0x4004480d
112 HUPCL = 0x400 113 HUPCL = 0x400
113 ICANON = 0x2 114 ICANON = 0x2
114 IEXTEN = 0x8000 115 IEXTEN = 0x8000
115 IN_CLOEXEC = 0x80000 116 IN_CLOEXEC = 0x80000
116 IN_NONBLOCK = 0x800 117 IN_NONBLOCK = 0x800
117 IOCTL_VM_SOCKETS_GET_LOCAL_CID = 0x7b9 118 IOCTL_VM_SOCKETS_GET_LOCAL_CID = 0x7b9
119 IPV6_FLOWINFO_MASK = 0xffffff0f
120 IPV6_FLOWLABEL_MASK = 0xffff0f00
118 ISIG = 0x1 121 ISIG = 0x1
119 IUCLC = 0x200 122 IUCLC = 0x200
120 IXOFF = 0x1000 123 IXOFF = 0x1000
@@ -153,9 +156,14 @@ const (
153 NFDBITS = 0x20 156 NFDBITS = 0x20
154 NLDLY = 0x100 157 NLDLY = 0x100
155 NOFLSH = 0x80 158 NOFLSH = 0x80
159 NS_GET_MNTNS_ID = 0x8008b705
156 NS_GET_NSTYPE = 0xb703 160 NS_GET_NSTYPE = 0xb703
157 NS_GET_OWNER_UID = 0xb704 161 NS_GET_OWNER_UID = 0xb704
158 NS_GET_PARENT = 0xb702 162 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
159 NS_GET_USERNS = 0xb701 167 NS_GET_USERNS = 0xb701
160 OLCUC = 0x2 168 OLCUC = 0x2
161 ONLCR = 0x4 169 ONLCR = 0x4
@@ -232,6 +240,20 @@ const (
232 PPPIOCUNBRIDGECHAN = 0x7434 240 PPPIOCUNBRIDGECHAN = 0x7434
233 PPPIOCXFERUNIT = 0x744e 241 PPPIOCXFERUNIT = 0x744e
234 PR_SET_PTRACER_ANY = 0xffffffff 242 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
235 PTRACE_GETFPREGS = 0xe 257 PTRACE_GETFPREGS = 0xe
236 PTRACE_GETFPXREGS = 0x12 258 PTRACE_GETFPXREGS = 0x12
237 PTRACE_GET_THREAD_AREA = 0x19 259 PTRACE_GET_THREAD_AREA = 0x19
@@ -278,10 +300,13 @@ const (
278 RTC_WIE_ON = 0x700f 300 RTC_WIE_ON = 0x700f
279 RTC_WKALM_RD = 0x80287010 301 RTC_WKALM_RD = 0x80287010
280 RTC_WKALM_SET = 0x4028700f 302 RTC_WKALM_SET = 0x4028700f
303 SCM_DEVMEM_DMABUF = 0x4f
304 SCM_DEVMEM_LINEAR = 0x4e
281 SCM_TIMESTAMPING = 0x25 305 SCM_TIMESTAMPING = 0x25
282 SCM_TIMESTAMPING_OPT_STATS = 0x36 306 SCM_TIMESTAMPING_OPT_STATS = 0x36
283 SCM_TIMESTAMPING_PKTINFO = 0x3a 307 SCM_TIMESTAMPING_PKTINFO = 0x3a
284 SCM_TIMESTAMPNS = 0x23 308 SCM_TIMESTAMPNS = 0x23
309 SCM_TS_OPT_ID = 0x51
285 SCM_TXTIME = 0x3d 310 SCM_TXTIME = 0x3d
286 SCM_WIFI_STATUS = 0x29 311 SCM_WIFI_STATUS = 0x29
287 SECCOMP_IOCTL_NOTIF_ADDFD = 0x40182103 312 SECCOMP_IOCTL_NOTIF_ADDFD = 0x40182103
@@ -316,6 +341,9 @@ const (
316 SO_CNX_ADVICE = 0x35 341 SO_CNX_ADVICE = 0x35
317 SO_COOKIE = 0x39 342 SO_COOKIE = 0x39
318 SO_DETACH_REUSEPORT_BPF = 0x44 343 SO_DETACH_REUSEPORT_BPF = 0x44
344 SO_DEVMEM_DMABUF = 0x4f
345 SO_DEVMEM_DONTNEED = 0x50
346 SO_DEVMEM_LINEAR = 0x4e
319 SO_DOMAIN = 0x27 347 SO_DOMAIN = 0x27
320 SO_DONTROUTE = 0x5 348 SO_DONTROUTE = 0x5
321 SO_ERROR = 0x4 349 SO_ERROR = 0x4
vendor/golang.org/x/sys/unix/zerrors_linux_amd64.go +28
@@ -109,12 +109,15 @@ const (
109 HIDIOCGRAWINFO = 0x80084803 109 HIDIOCGRAWINFO = 0x80084803
110 HIDIOCGRDESC = 0x90044802 110 HIDIOCGRDESC = 0x90044802
111 HIDIOCGRDESCSIZE = 0x80044801 111 HIDIOCGRDESCSIZE = 0x80044801
112 HIDIOCREVOKE = 0x4004480d
112 HUPCL = 0x400 113 HUPCL = 0x400
113 ICANON = 0x2 114 ICANON = 0x2
114 IEXTEN = 0x8000 115 IEXTEN = 0x8000
115 IN_CLOEXEC = 0x80000 116 IN_CLOEXEC = 0x80000
116 IN_NONBLOCK = 0x800 117 IN_NONBLOCK = 0x800
117 IOCTL_VM_SOCKETS_GET_LOCAL_CID = 0x7b9 118 IOCTL_VM_SOCKETS_GET_LOCAL_CID = 0x7b9
119 IPV6_FLOWINFO_MASK = 0xffffff0f
120 IPV6_FLOWLABEL_MASK = 0xffff0f00
118 ISIG = 0x1 121 ISIG = 0x1
119 IUCLC = 0x200 122 IUCLC = 0x200
120 IXOFF = 0x1000 123 IXOFF = 0x1000
@@ -153,9 +156,14 @@ const (
153 NFDBITS = 0x40 156 NFDBITS = 0x40
154 NLDLY = 0x100 157 NLDLY = 0x100
155 NOFLSH = 0x80 158 NOFLSH = 0x80
159 NS_GET_MNTNS_ID = 0x8008b705
156 NS_GET_NSTYPE = 0xb703 160 NS_GET_NSTYPE = 0xb703
157 NS_GET_OWNER_UID = 0xb704 161 NS_GET_OWNER_UID = 0xb704
158 NS_GET_PARENT = 0xb702 162 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
159 NS_GET_USERNS = 0xb701 167 NS_GET_USERNS = 0xb701
160 OLCUC = 0x2 168 OLCUC = 0x2
161 ONLCR = 0x4 169 ONLCR = 0x4
@@ -232,6 +240,20 @@ const (
232 PPPIOCUNBRIDGECHAN = 0x7434 240 PPPIOCUNBRIDGECHAN = 0x7434
233 PPPIOCXFERUNIT = 0x744e 241 PPPIOCXFERUNIT = 0x744e
234 PR_SET_PTRACER_ANY = 0xffffffffffffffff 242 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
235 PTRACE_ARCH_PRCTL = 0x1e 257 PTRACE_ARCH_PRCTL = 0x1e
236 PTRACE_GETFPREGS = 0xe 258 PTRACE_GETFPREGS = 0xe
237 PTRACE_GETFPXREGS = 0x12 259 PTRACE_GETFPXREGS = 0x12
@@ -279,10 +301,13 @@ const (
279 RTC_WIE_ON = 0x700f 301 RTC_WIE_ON = 0x700f
280 RTC_WKALM_RD = 0x80287010 302 RTC_WKALM_RD = 0x80287010
281 RTC_WKALM_SET = 0x4028700f 303 RTC_WKALM_SET = 0x4028700f
304 SCM_DEVMEM_DMABUF = 0x4f
305 SCM_DEVMEM_LINEAR = 0x4e
282 SCM_TIMESTAMPING = 0x25 306 SCM_TIMESTAMPING = 0x25
283 SCM_TIMESTAMPING_OPT_STATS = 0x36 307 SCM_TIMESTAMPING_OPT_STATS = 0x36
284 SCM_TIMESTAMPING_PKTINFO = 0x3a 308 SCM_TIMESTAMPING_PKTINFO = 0x3a
285 SCM_TIMESTAMPNS = 0x23 309 SCM_TIMESTAMPNS = 0x23
310 SCM_TS_OPT_ID = 0x51
286 SCM_TXTIME = 0x3d 311 SCM_TXTIME = 0x3d
287 SCM_WIFI_STATUS = 0x29 312 SCM_WIFI_STATUS = 0x29
288 SECCOMP_IOCTL_NOTIF_ADDFD = 0x40182103 313 SECCOMP_IOCTL_NOTIF_ADDFD = 0x40182103
@@ -317,6 +342,9 @@ const (
317 SO_CNX_ADVICE = 0x35 342 SO_CNX_ADVICE = 0x35
318 SO_COOKIE = 0x39 343 SO_COOKIE = 0x39
319 SO_DETACH_REUSEPORT_BPF = 0x44 344 SO_DETACH_REUSEPORT_BPF = 0x44
345 SO_DEVMEM_DMABUF = 0x4f
346 SO_DEVMEM_DONTNEED = 0x50
347 SO_DEVMEM_LINEAR = 0x4e
320 SO_DOMAIN = 0x27 348 SO_DOMAIN = 0x27
321 SO_DONTROUTE = 0x5 349 SO_DONTROUTE = 0x5
322 SO_ERROR = 0x4 350 SO_ERROR = 0x4
vendor/golang.org/x/sys/unix/zerrors_linux_arm.go +28
@@ -108,12 +108,15 @@ const (
108 HIDIOCGRAWINFO = 0x80084803 108 HIDIOCGRAWINFO = 0x80084803
109 HIDIOCGRDESC = 0x90044802 109 HIDIOCGRDESC = 0x90044802
110 HIDIOCGRDESCSIZE = 0x80044801 110 HIDIOCGRDESCSIZE = 0x80044801
111 HIDIOCREVOKE = 0x4004480d
111 HUPCL = 0x400 112 HUPCL = 0x400
112 ICANON = 0x2 113 ICANON = 0x2
113 IEXTEN = 0x8000 114 IEXTEN = 0x8000
114 IN_CLOEXEC = 0x80000 115 IN_CLOEXEC = 0x80000
115 IN_NONBLOCK = 0x800 116 IN_NONBLOCK = 0x800
116 IOCTL_VM_SOCKETS_GET_LOCAL_CID = 0x7b9 117 IOCTL_VM_SOCKETS_GET_LOCAL_CID = 0x7b9
118 IPV6_FLOWINFO_MASK = 0xffffff0f
119 IPV6_FLOWLABEL_MASK = 0xffff0f00
117 ISIG = 0x1 120 ISIG = 0x1
118 IUCLC = 0x200 121 IUCLC = 0x200
119 IXOFF = 0x1000 122 IXOFF = 0x1000
@@ -150,9 +153,14 @@ const (
150 NFDBITS = 0x20 153 NFDBITS = 0x20
151 NLDLY = 0x100 154 NLDLY = 0x100
152 NOFLSH = 0x80 155 NOFLSH = 0x80
156 NS_GET_MNTNS_ID = 0x8008b705
153 NS_GET_NSTYPE = 0xb703 157 NS_GET_NSTYPE = 0xb703
154 NS_GET_OWNER_UID = 0xb704 158 NS_GET_OWNER_UID = 0xb704
155 NS_GET_PARENT = 0xb702 159 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
156 NS_GET_USERNS = 0xb701 164 NS_GET_USERNS = 0xb701
157 OLCUC = 0x2 165 OLCUC = 0x2
158 ONLCR = 0x4 166 ONLCR = 0x4
@@ -229,6 +237,20 @@ const (
229 PPPIOCUNBRIDGECHAN = 0x7434 237 PPPIOCUNBRIDGECHAN = 0x7434
230 PPPIOCXFERUNIT = 0x744e 238 PPPIOCXFERUNIT = 0x744e
231 PR_SET_PTRACER_ANY = 0xffffffff 239 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
232 PTRACE_GETCRUNCHREGS = 0x19 254 PTRACE_GETCRUNCHREGS = 0x19
233 PTRACE_GETFDPIC = 0x1f 255 PTRACE_GETFDPIC = 0x1f
234 PTRACE_GETFDPIC_EXEC = 0x0 256 PTRACE_GETFDPIC_EXEC = 0x0
@@ -284,10 +306,13 @@ const (
284 RTC_WIE_ON = 0x700f 306 RTC_WIE_ON = 0x700f
285 RTC_WKALM_RD = 0x80287010 307 RTC_WKALM_RD = 0x80287010
286 RTC_WKALM_SET = 0x4028700f 308 RTC_WKALM_SET = 0x4028700f
309 SCM_DEVMEM_DMABUF = 0x4f
310 SCM_DEVMEM_LINEAR = 0x4e
287 SCM_TIMESTAMPING = 0x25 311 SCM_TIMESTAMPING = 0x25
288 SCM_TIMESTAMPING_OPT_STATS = 0x36 312 SCM_TIMESTAMPING_OPT_STATS = 0x36
289 SCM_TIMESTAMPING_PKTINFO = 0x3a 313 SCM_TIMESTAMPING_PKTINFO = 0x3a
290 SCM_TIMESTAMPNS = 0x23 314 SCM_TIMESTAMPNS = 0x23
315 SCM_TS_OPT_ID = 0x51
291 SCM_TXTIME = 0x3d 316 SCM_TXTIME = 0x3d
292 SCM_WIFI_STATUS = 0x29 317 SCM_WIFI_STATUS = 0x29
293 SECCOMP_IOCTL_NOTIF_ADDFD = 0x40182103 318 SECCOMP_IOCTL_NOTIF_ADDFD = 0x40182103
@@ -322,6 +347,9 @@ const (
322 SO_CNX_ADVICE = 0x35 347 SO_CNX_ADVICE = 0x35
323 SO_COOKIE = 0x39 348 SO_COOKIE = 0x39
324 SO_DETACH_REUSEPORT_BPF = 0x44 349 SO_DETACH_REUSEPORT_BPF = 0x44
350 SO_DEVMEM_DMABUF = 0x4f
351 SO_DEVMEM_DONTNEED = 0x50
352 SO_DEVMEM_LINEAR = 0x4e
325 SO_DOMAIN = 0x27 353 SO_DOMAIN = 0x27
326 SO_DONTROUTE = 0x5 354 SO_DONTROUTE = 0x5
327 SO_ERROR = 0x4 355 SO_ERROR = 0x4
vendor/golang.org/x/sys/unix/zerrors_linux_arm64.go +30
@@ -109,15 +109,19 @@ const (
109 F_SETOWN = 0x8 109 F_SETOWN = 0x8
110 F_UNLCK = 0x2 110 F_UNLCK = 0x2
111 F_WRLCK = 0x1 111 F_WRLCK = 0x1
112 GCS_MAGIC = 0x47435300
112 HIDIOCGRAWINFO = 0x80084803 113 HIDIOCGRAWINFO = 0x80084803
113 HIDIOCGRDESC = 0x90044802 114 HIDIOCGRDESC = 0x90044802
114 HIDIOCGRDESCSIZE = 0x80044801 115 HIDIOCGRDESCSIZE = 0x80044801
116 HIDIOCREVOKE = 0x4004480d
115 HUPCL = 0x400 117 HUPCL = 0x400
116 ICANON = 0x2 118 ICANON = 0x2
117 IEXTEN = 0x8000 119 IEXTEN = 0x8000
118 IN_CLOEXEC = 0x80000 120 IN_CLOEXEC = 0x80000
119 IN_NONBLOCK = 0x800 121 IN_NONBLOCK = 0x800
120 IOCTL_VM_SOCKETS_GET_LOCAL_CID = 0x7b9 122 IOCTL_VM_SOCKETS_GET_LOCAL_CID = 0x7b9
123 IPV6_FLOWINFO_MASK = 0xffffff0f
124 IPV6_FLOWLABEL_MASK = 0xffff0f00
121 ISIG = 0x1 125 ISIG = 0x1
122 IUCLC = 0x200 126 IUCLC = 0x200
123 IXOFF = 0x1000 127 IXOFF = 0x1000
@@ -154,9 +158,14 @@ const (
154 NFDBITS = 0x40 158 NFDBITS = 0x40
155 NLDLY = 0x100 159 NLDLY = 0x100
156 NOFLSH = 0x80 160 NOFLSH = 0x80
161 NS_GET_MNTNS_ID = 0x8008b705
157 NS_GET_NSTYPE = 0xb703 162 NS_GET_NSTYPE = 0xb703
158 NS_GET_OWNER_UID = 0xb704 163 NS_GET_OWNER_UID = 0xb704
159 NS_GET_PARENT = 0xb702 164 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
160 NS_GET_USERNS = 0xb701 169 NS_GET_USERNS = 0xb701
161 OLCUC = 0x2 170 OLCUC = 0x2
162 ONLCR = 0x4 171 ONLCR = 0x4
@@ -200,6 +209,7 @@ const (
200 PERF_EVENT_IOC_SET_BPF = 0x40042408 209 PERF_EVENT_IOC_SET_BPF = 0x40042408
201 PERF_EVENT_IOC_SET_FILTER = 0x40082406 210 PERF_EVENT_IOC_SET_FILTER = 0x40082406
202 PERF_EVENT_IOC_SET_OUTPUT = 0x2405 211 PERF_EVENT_IOC_SET_OUTPUT = 0x2405
212 POE_MAGIC = 0x504f4530
203 PPPIOCATTACH = 0x4004743d 213 PPPIOCATTACH = 0x4004743d
204 PPPIOCATTCHAN = 0x40047438 214 PPPIOCATTCHAN = 0x40047438
205 PPPIOCBRIDGECHAN = 0x40047435 215 PPPIOCBRIDGECHAN = 0x40047435
@@ -235,6 +245,20 @@ const (
235 PROT_BTI = 0x10 245 PROT_BTI = 0x10
236 PROT_MTE = 0x20 246 PROT_MTE = 0x20
237 PR_SET_PTRACER_ANY = 0xffffffffffffffff 247 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
238 PTRACE_PEEKMTETAGS = 0x21 262 PTRACE_PEEKMTETAGS = 0x21
239 PTRACE_POKEMTETAGS = 0x22 263 PTRACE_POKEMTETAGS = 0x22
240 PTRACE_SYSEMU = 0x1f 264 PTRACE_SYSEMU = 0x1f
@@ -275,10 +299,13 @@ const (
275 RTC_WIE_ON = 0x700f 299 RTC_WIE_ON = 0x700f
276 RTC_WKALM_RD = 0x80287010 300 RTC_WKALM_RD = 0x80287010
277 RTC_WKALM_SET = 0x4028700f 301 RTC_WKALM_SET = 0x4028700f
302 SCM_DEVMEM_DMABUF = 0x4f
303 SCM_DEVMEM_LINEAR = 0x4e
278 SCM_TIMESTAMPING = 0x25 304 SCM_TIMESTAMPING = 0x25
279 SCM_TIMESTAMPING_OPT_STATS = 0x36 305 SCM_TIMESTAMPING_OPT_STATS = 0x36
280 SCM_TIMESTAMPING_PKTINFO = 0x3a 306 SCM_TIMESTAMPING_PKTINFO = 0x3a
281 SCM_TIMESTAMPNS = 0x23 307 SCM_TIMESTAMPNS = 0x23
308 SCM_TS_OPT_ID = 0x51
282 SCM_TXTIME = 0x3d 309 SCM_TXTIME = 0x3d
283 SCM_WIFI_STATUS = 0x29 310 SCM_WIFI_STATUS = 0x29
284 SECCOMP_IOCTL_NOTIF_ADDFD = 0x40182103 311 SECCOMP_IOCTL_NOTIF_ADDFD = 0x40182103
@@ -313,6 +340,9 @@ const (
313 SO_CNX_ADVICE = 0x35 340 SO_CNX_ADVICE = 0x35
314 SO_COOKIE = 0x39 341 SO_COOKIE = 0x39
315 SO_DETACH_REUSEPORT_BPF = 0x44 342 SO_DETACH_REUSEPORT_BPF = 0x44
343 SO_DEVMEM_DMABUF = 0x4f
344 SO_DEVMEM_DONTNEED = 0x50
345 SO_DEVMEM_LINEAR = 0x4e
316 SO_DOMAIN = 0x27 346 SO_DOMAIN = 0x27
317 SO_DONTROUTE = 0x5 347 SO_DONTROUTE = 0x5
318 SO_ERROR = 0x4 348 SO_ERROR = 0x4
vendor/golang.org/x/sys/unix/zerrors_linux_loong64.go +28
@@ -109,12 +109,15 @@ const (
109 HIDIOCGRAWINFO = 0x80084803 109 HIDIOCGRAWINFO = 0x80084803
110 HIDIOCGRDESC = 0x90044802 110 HIDIOCGRDESC = 0x90044802
111 HIDIOCGRDESCSIZE = 0x80044801 111 HIDIOCGRDESCSIZE = 0x80044801
112 HIDIOCREVOKE = 0x4004480d
112 HUPCL = 0x400 113 HUPCL = 0x400
113 ICANON = 0x2 114 ICANON = 0x2
114 IEXTEN = 0x8000 115 IEXTEN = 0x8000
115 IN_CLOEXEC = 0x80000 116 IN_CLOEXEC = 0x80000
116 IN_NONBLOCK = 0x800 117 IN_NONBLOCK = 0x800
117 IOCTL_VM_SOCKETS_GET_LOCAL_CID = 0x7b9 118 IOCTL_VM_SOCKETS_GET_LOCAL_CID = 0x7b9
119 IPV6_FLOWINFO_MASK = 0xffffff0f
120 IPV6_FLOWLABEL_MASK = 0xffff0f00
118 ISIG = 0x1 121 ISIG = 0x1
119 IUCLC = 0x200 122 IUCLC = 0x200
120 IXOFF = 0x1000 123 IXOFF = 0x1000
@@ -154,9 +157,14 @@ const (
154 NFDBITS = 0x40 157 NFDBITS = 0x40
155 NLDLY = 0x100 158 NLDLY = 0x100
156 NOFLSH = 0x80 159 NOFLSH = 0x80
160 NS_GET_MNTNS_ID = 0x8008b705
157 NS_GET_NSTYPE = 0xb703 161 NS_GET_NSTYPE = 0xb703
158 NS_GET_OWNER_UID = 0xb704 162 NS_GET_OWNER_UID = 0xb704
159 NS_GET_PARENT = 0xb702 163 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
160 NS_GET_USERNS = 0xb701 168 NS_GET_USERNS = 0xb701
161 OLCUC = 0x2 169 OLCUC = 0x2
162 ONLCR = 0x4 170 ONLCR = 0x4
@@ -233,6 +241,20 @@ const (
233 PPPIOCUNBRIDGECHAN = 0x7434 241 PPPIOCUNBRIDGECHAN = 0x7434
234 PPPIOCXFERUNIT = 0x744e 242 PPPIOCXFERUNIT = 0x744e
235 PR_SET_PTRACER_ANY = 0xffffffffffffffff 243 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
236 PTRACE_SYSEMU = 0x1f 258 PTRACE_SYSEMU = 0x1f
237 PTRACE_SYSEMU_SINGLESTEP = 0x20 259 PTRACE_SYSEMU_SINGLESTEP = 0x20
238 RLIMIT_AS = 0x9 260 RLIMIT_AS = 0x9
@@ -271,10 +293,13 @@ const (
271 RTC_WIE_ON = 0x700f 293 RTC_WIE_ON = 0x700f
272 RTC_WKALM_RD = 0x80287010 294 RTC_WKALM_RD = 0x80287010
273 RTC_WKALM_SET = 0x4028700f 295 RTC_WKALM_SET = 0x4028700f
296 SCM_DEVMEM_DMABUF = 0x4f
297 SCM_DEVMEM_LINEAR = 0x4e
274 SCM_TIMESTAMPING = 0x25 298 SCM_TIMESTAMPING = 0x25
275 SCM_TIMESTAMPING_OPT_STATS = 0x36 299 SCM_TIMESTAMPING_OPT_STATS = 0x36
276 SCM_TIMESTAMPING_PKTINFO = 0x3a 300 SCM_TIMESTAMPING_PKTINFO = 0x3a
277 SCM_TIMESTAMPNS = 0x23 301 SCM_TIMESTAMPNS = 0x23
302 SCM_TS_OPT_ID = 0x51
278 SCM_TXTIME = 0x3d 303 SCM_TXTIME = 0x3d
279 SCM_WIFI_STATUS = 0x29 304 SCM_WIFI_STATUS = 0x29
280 SECCOMP_IOCTL_NOTIF_ADDFD = 0x40182103 305 SECCOMP_IOCTL_NOTIF_ADDFD = 0x40182103
@@ -309,6 +334,9 @@ const (
309 SO_CNX_ADVICE = 0x35 334 SO_CNX_ADVICE = 0x35
310 SO_COOKIE = 0x39 335 SO_COOKIE = 0x39
311 SO_DETACH_REUSEPORT_BPF = 0x44 336 SO_DETACH_REUSEPORT_BPF = 0x44
337 SO_DEVMEM_DMABUF = 0x4f
338 SO_DEVMEM_DONTNEED = 0x50
339 SO_DEVMEM_LINEAR = 0x4e
312 SO_DOMAIN = 0x27 340 SO_DOMAIN = 0x27
313 SO_DONTROUTE = 0x5 341 SO_DONTROUTE = 0x5
314 SO_ERROR = 0x4 342 SO_ERROR = 0x4
vendor/golang.org/x/sys/unix/zerrors_linux_mips.go +28
@@ -108,12 +108,15 @@ const (
108 HIDIOCGRAWINFO = 0x40084803 108 HIDIOCGRAWINFO = 0x40084803
109 HIDIOCGRDESC = 0x50044802 109 HIDIOCGRDESC = 0x50044802
110 HIDIOCGRDESCSIZE = 0x40044801 110 HIDIOCGRDESCSIZE = 0x40044801
111 HIDIOCREVOKE = 0x8004480d
111 HUPCL = 0x400 112 HUPCL = 0x400
112 ICANON = 0x2 113 ICANON = 0x2
113 IEXTEN = 0x100 114 IEXTEN = 0x100
114 IN_CLOEXEC = 0x80000 115 IN_CLOEXEC = 0x80000
115 IN_NONBLOCK = 0x80 116 IN_NONBLOCK = 0x80
116 IOCTL_VM_SOCKETS_GET_LOCAL_CID = 0x200007b9 117 IOCTL_VM_SOCKETS_GET_LOCAL_CID = 0x200007b9
118 IPV6_FLOWINFO_MASK = 0xfffffff
119 IPV6_FLOWLABEL_MASK = 0xfffff
117 ISIG = 0x1 120 ISIG = 0x1
118 IUCLC = 0x200 121 IUCLC = 0x200
119 IXOFF = 0x1000 122 IXOFF = 0x1000
@@ -150,9 +153,14 @@ const (
150 NFDBITS = 0x20 153 NFDBITS = 0x20
151 NLDLY = 0x100 154 NLDLY = 0x100
152 NOFLSH = 0x80 155 NOFLSH = 0x80
156 NS_GET_MNTNS_ID = 0x4008b705
153 NS_GET_NSTYPE = 0x2000b703 157 NS_GET_NSTYPE = 0x2000b703
154 NS_GET_OWNER_UID = 0x2000b704 158 NS_GET_OWNER_UID = 0x2000b704
155 NS_GET_PARENT = 0x2000b702 159 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
156 NS_GET_USERNS = 0x2000b701 164 NS_GET_USERNS = 0x2000b701
157 OLCUC = 0x2 165 OLCUC = 0x2
158 ONLCR = 0x4 166 ONLCR = 0x4
@@ -229,6 +237,20 @@ const (
229 PPPIOCUNBRIDGECHAN = 0x20007434 237 PPPIOCUNBRIDGECHAN = 0x20007434
230 PPPIOCXFERUNIT = 0x2000744e 238 PPPIOCXFERUNIT = 0x2000744e
231 PR_SET_PTRACER_ANY = 0xffffffff 239 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
232 PTRACE_GETFPREGS = 0xe 254 PTRACE_GETFPREGS = 0xe
233 PTRACE_GET_THREAD_AREA = 0x19 255 PTRACE_GET_THREAD_AREA = 0x19
234 PTRACE_GET_THREAD_AREA_3264 = 0xc4 256 PTRACE_GET_THREAD_AREA_3264 = 0xc4
@@ -277,10 +299,13 @@ const (
277 RTC_WIE_ON = 0x2000700f 299 RTC_WIE_ON = 0x2000700f
278 RTC_WKALM_RD = 0x40287010 300 RTC_WKALM_RD = 0x40287010
279 RTC_WKALM_SET = 0x8028700f 301 RTC_WKALM_SET = 0x8028700f
302 SCM_DEVMEM_DMABUF = 0x4f
303 SCM_DEVMEM_LINEAR = 0x4e
280 SCM_TIMESTAMPING = 0x25 304 SCM_TIMESTAMPING = 0x25
281 SCM_TIMESTAMPING_OPT_STATS = 0x36 305 SCM_TIMESTAMPING_OPT_STATS = 0x36
282 SCM_TIMESTAMPING_PKTINFO = 0x3a 306 SCM_TIMESTAMPING_PKTINFO = 0x3a
283 SCM_TIMESTAMPNS = 0x23 307 SCM_TIMESTAMPNS = 0x23
308 SCM_TS_OPT_ID = 0x51
284 SCM_TXTIME = 0x3d 309 SCM_TXTIME = 0x3d
285 SCM_WIFI_STATUS = 0x29 310 SCM_WIFI_STATUS = 0x29
286 SECCOMP_IOCTL_NOTIF_ADDFD = 0x80182103 311 SECCOMP_IOCTL_NOTIF_ADDFD = 0x80182103
@@ -315,6 +340,9 @@ const (
315 SO_CNX_ADVICE = 0x35 340 SO_CNX_ADVICE = 0x35
316 SO_COOKIE = 0x39 341 SO_COOKIE = 0x39
317 SO_DETACH_REUSEPORT_BPF = 0x44 342 SO_DETACH_REUSEPORT_BPF = 0x44
343 SO_DEVMEM_DMABUF = 0x4f
344 SO_DEVMEM_DONTNEED = 0x50
345 SO_DEVMEM_LINEAR = 0x4e
318 SO_DOMAIN = 0x1029 346 SO_DOMAIN = 0x1029
319 SO_DONTROUTE = 0x10 347 SO_DONTROUTE = 0x10
320 SO_ERROR = 0x1007 348 SO_ERROR = 0x1007
vendor/golang.org/x/sys/unix/zerrors_linux_mips64.go +28
@@ -108,12 +108,15 @@ const (
108 HIDIOCGRAWINFO = 0x40084803 108 HIDIOCGRAWINFO = 0x40084803
109 HIDIOCGRDESC = 0x50044802 109 HIDIOCGRDESC = 0x50044802
110 HIDIOCGRDESCSIZE = 0x40044801 110 HIDIOCGRDESCSIZE = 0x40044801
111 HIDIOCREVOKE = 0x8004480d
111 HUPCL = 0x400 112 HUPCL = 0x400
112 ICANON = 0x2 113 ICANON = 0x2
113 IEXTEN = 0x100 114 IEXTEN = 0x100
114 IN_CLOEXEC = 0x80000 115 IN_CLOEXEC = 0x80000
115 IN_NONBLOCK = 0x80 116 IN_NONBLOCK = 0x80
116 IOCTL_VM_SOCKETS_GET_LOCAL_CID = 0x200007b9 117 IOCTL_VM_SOCKETS_GET_LOCAL_CID = 0x200007b9
118 IPV6_FLOWINFO_MASK = 0xfffffff
119 IPV6_FLOWLABEL_MASK = 0xfffff
117 ISIG = 0x1 120 ISIG = 0x1
118 IUCLC = 0x200 121 IUCLC = 0x200
119 IXOFF = 0x1000 122 IXOFF = 0x1000
@@ -150,9 +153,14 @@ const (
150 NFDBITS = 0x40 153 NFDBITS = 0x40
151 NLDLY = 0x100 154 NLDLY = 0x100
152 NOFLSH = 0x80 155 NOFLSH = 0x80
156 NS_GET_MNTNS_ID = 0x4008b705
153 NS_GET_NSTYPE = 0x2000b703 157 NS_GET_NSTYPE = 0x2000b703
154 NS_GET_OWNER_UID = 0x2000b704 158 NS_GET_OWNER_UID = 0x2000b704
155 NS_GET_PARENT = 0x2000b702 159 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
156 NS_GET_USERNS = 0x2000b701 164 NS_GET_USERNS = 0x2000b701
157 OLCUC = 0x2 165 OLCUC = 0x2
158 ONLCR = 0x4 166 ONLCR = 0x4
@@ -229,6 +237,20 @@ const (
229 PPPIOCUNBRIDGECHAN = 0x20007434 237 PPPIOCUNBRIDGECHAN = 0x20007434
230 PPPIOCXFERUNIT = 0x2000744e 238 PPPIOCXFERUNIT = 0x2000744e
231 PR_SET_PTRACER_ANY = 0xffffffffffffffff 239 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
232 PTRACE_GETFPREGS = 0xe 254 PTRACE_GETFPREGS = 0xe
233 PTRACE_GET_THREAD_AREA = 0x19 255 PTRACE_GET_THREAD_AREA = 0x19
234 PTRACE_GET_THREAD_AREA_3264 = 0xc4 256 PTRACE_GET_THREAD_AREA_3264 = 0xc4
@@ -277,10 +299,13 @@ const (
277 RTC_WIE_ON = 0x2000700f 299 RTC_WIE_ON = 0x2000700f
278 RTC_WKALM_RD = 0x40287010 300 RTC_WKALM_RD = 0x40287010
279 RTC_WKALM_SET = 0x8028700f 301 RTC_WKALM_SET = 0x8028700f
302 SCM_DEVMEM_DMABUF = 0x4f
303 SCM_DEVMEM_LINEAR = 0x4e
280 SCM_TIMESTAMPING = 0x25 304 SCM_TIMESTAMPING = 0x25
281 SCM_TIMESTAMPING_OPT_STATS = 0x36 305 SCM_TIMESTAMPING_OPT_STATS = 0x36
282 SCM_TIMESTAMPING_PKTINFO = 0x3a 306 SCM_TIMESTAMPING_PKTINFO = 0x3a
283 SCM_TIMESTAMPNS = 0x23 307 SCM_TIMESTAMPNS = 0x23
308 SCM_TS_OPT_ID = 0x51
284 SCM_TXTIME = 0x3d 309 SCM_TXTIME = 0x3d
285 SCM_WIFI_STATUS = 0x29 310 SCM_WIFI_STATUS = 0x29
286 SECCOMP_IOCTL_NOTIF_ADDFD = 0x80182103 311 SECCOMP_IOCTL_NOTIF_ADDFD = 0x80182103
@@ -315,6 +340,9 @@ const (
315 SO_CNX_ADVICE = 0x35 340 SO_CNX_ADVICE = 0x35
316 SO_COOKIE = 0x39 341 SO_COOKIE = 0x39
317 SO_DETACH_REUSEPORT_BPF = 0x44 342 SO_DETACH_REUSEPORT_BPF = 0x44
343 SO_DEVMEM_DMABUF = 0x4f
344 SO_DEVMEM_DONTNEED = 0x50
345 SO_DEVMEM_LINEAR = 0x4e
318 SO_DOMAIN = 0x1029 346 SO_DOMAIN = 0x1029
319 SO_DONTROUTE = 0x10 347 SO_DONTROUTE = 0x10
320 SO_ERROR = 0x1007 348 SO_ERROR = 0x1007
vendor/golang.org/x/sys/unix/zerrors_linux_mips64le.go +28
@@ -108,12 +108,15 @@ const (
108 HIDIOCGRAWINFO = 0x40084803 108 HIDIOCGRAWINFO = 0x40084803
109 HIDIOCGRDESC = 0x50044802 109 HIDIOCGRDESC = 0x50044802
110 HIDIOCGRDESCSIZE = 0x40044801 110 HIDIOCGRDESCSIZE = 0x40044801
111 HIDIOCREVOKE = 0x8004480d
111 HUPCL = 0x400 112 HUPCL = 0x400
112 ICANON = 0x2 113 ICANON = 0x2
113 IEXTEN = 0x100 114 IEXTEN = 0x100
114 IN_CLOEXEC = 0x80000 115 IN_CLOEXEC = 0x80000
115 IN_NONBLOCK = 0x80 116 IN_NONBLOCK = 0x80
116 IOCTL_VM_SOCKETS_GET_LOCAL_CID = 0x200007b9 117 IOCTL_VM_SOCKETS_GET_LOCAL_CID = 0x200007b9
118 IPV6_FLOWINFO_MASK = 0xffffff0f
119 IPV6_FLOWLABEL_MASK = 0xffff0f00
117 ISIG = 0x1 120 ISIG = 0x1
118 IUCLC = 0x200 121 IUCLC = 0x200
119 IXOFF = 0x1000 122 IXOFF = 0x1000
@@ -150,9 +153,14 @@ const (
150 NFDBITS = 0x40 153 NFDBITS = 0x40
151 NLDLY = 0x100 154 NLDLY = 0x100
152 NOFLSH = 0x80 155 NOFLSH = 0x80
156 NS_GET_MNTNS_ID = 0x4008b705
153 NS_GET_NSTYPE = 0x2000b703 157 NS_GET_NSTYPE = 0x2000b703
154 NS_GET_OWNER_UID = 0x2000b704 158 NS_GET_OWNER_UID = 0x2000b704
155 NS_GET_PARENT = 0x2000b702 159 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
156 NS_GET_USERNS = 0x2000b701 164 NS_GET_USERNS = 0x2000b701
157 OLCUC = 0x2 165 OLCUC = 0x2
158 ONLCR = 0x4 166 ONLCR = 0x4
@@ -229,6 +237,20 @@ const (
229 PPPIOCUNBRIDGECHAN = 0x20007434 237 PPPIOCUNBRIDGECHAN = 0x20007434
230 PPPIOCXFERUNIT = 0x2000744e 238 PPPIOCXFERUNIT = 0x2000744e
231 PR_SET_PTRACER_ANY = 0xffffffffffffffff 239 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
232 PTRACE_GETFPREGS = 0xe 254 PTRACE_GETFPREGS = 0xe
233 PTRACE_GET_THREAD_AREA = 0x19 255 PTRACE_GET_THREAD_AREA = 0x19
234 PTRACE_GET_THREAD_AREA_3264 = 0xc4 256 PTRACE_GET_THREAD_AREA_3264 = 0xc4
@@ -277,10 +299,13 @@ const (
277 RTC_WIE_ON = 0x2000700f 299 RTC_WIE_ON = 0x2000700f
278 RTC_WKALM_RD = 0x40287010 300 RTC_WKALM_RD = 0x40287010
279 RTC_WKALM_SET = 0x8028700f 301 RTC_WKALM_SET = 0x8028700f
302 SCM_DEVMEM_DMABUF = 0x4f
303 SCM_DEVMEM_LINEAR = 0x4e
280 SCM_TIMESTAMPING = 0x25 304 SCM_TIMESTAMPING = 0x25
281 SCM_TIMESTAMPING_OPT_STATS = 0x36 305 SCM_TIMESTAMPING_OPT_STATS = 0x36
282 SCM_TIMESTAMPING_PKTINFO = 0x3a 306 SCM_TIMESTAMPING_PKTINFO = 0x3a
283 SCM_TIMESTAMPNS = 0x23 307 SCM_TIMESTAMPNS = 0x23
308 SCM_TS_OPT_ID = 0x51
284 SCM_TXTIME = 0x3d 309 SCM_TXTIME = 0x3d
285 SCM_WIFI_STATUS = 0x29 310 SCM_WIFI_STATUS = 0x29
286 SECCOMP_IOCTL_NOTIF_ADDFD = 0x80182103 311 SECCOMP_IOCTL_NOTIF_ADDFD = 0x80182103
@@ -315,6 +340,9 @@ const (
315 SO_CNX_ADVICE = 0x35 340 SO_CNX_ADVICE = 0x35
316 SO_COOKIE = 0x39 341 SO_COOKIE = 0x39
317 SO_DETACH_REUSEPORT_BPF = 0x44 342 SO_DETACH_REUSEPORT_BPF = 0x44
343 SO_DEVMEM_DMABUF = 0x4f
344 SO_DEVMEM_DONTNEED = 0x50
345 SO_DEVMEM_LINEAR = 0x4e
318 SO_DOMAIN = 0x1029 346 SO_DOMAIN = 0x1029
319 SO_DONTROUTE = 0x10 347 SO_DONTROUTE = 0x10
320 SO_ERROR = 0x1007 348 SO_ERROR = 0x1007
vendor/golang.org/x/sys/unix/zerrors_linux_mipsle.go +28
@@ -108,12 +108,15 @@ const (
108 HIDIOCGRAWINFO = 0x40084803 108 HIDIOCGRAWINFO = 0x40084803
109 HIDIOCGRDESC = 0x50044802 109 HIDIOCGRDESC = 0x50044802
110 HIDIOCGRDESCSIZE = 0x40044801 110 HIDIOCGRDESCSIZE = 0x40044801
111 HIDIOCREVOKE = 0x8004480d
111 HUPCL = 0x400 112 HUPCL = 0x400
112 ICANON = 0x2 113 ICANON = 0x2
113 IEXTEN = 0x100 114 IEXTEN = 0x100
114 IN_CLOEXEC = 0x80000 115 IN_CLOEXEC = 0x80000
115 IN_NONBLOCK = 0x80 116 IN_NONBLOCK = 0x80
116 IOCTL_VM_SOCKETS_GET_LOCAL_CID = 0x200007b9 117 IOCTL_VM_SOCKETS_GET_LOCAL_CID = 0x200007b9
118 IPV6_FLOWINFO_MASK = 0xffffff0f
119 IPV6_FLOWLABEL_MASK = 0xffff0f00
117 ISIG = 0x1 120 ISIG = 0x1
118 IUCLC = 0x200 121 IUCLC = 0x200
119 IXOFF = 0x1000 122 IXOFF = 0x1000
@@ -150,9 +153,14 @@ const (
150 NFDBITS = 0x20 153 NFDBITS = 0x20
151 NLDLY = 0x100 154 NLDLY = 0x100
152 NOFLSH = 0x80 155 NOFLSH = 0x80
156 NS_GET_MNTNS_ID = 0x4008b705
153 NS_GET_NSTYPE = 0x2000b703 157 NS_GET_NSTYPE = 0x2000b703
154 NS_GET_OWNER_UID = 0x2000b704 158 NS_GET_OWNER_UID = 0x2000b704
155 NS_GET_PARENT = 0x2000b702 159 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
156 NS_GET_USERNS = 0x2000b701 164 NS_GET_USERNS = 0x2000b701
157 OLCUC = 0x2 165 OLCUC = 0x2
158 ONLCR = 0x4 166 ONLCR = 0x4
@@ -229,6 +237,20 @@ const (
229 PPPIOCUNBRIDGECHAN = 0x20007434 237 PPPIOCUNBRIDGECHAN = 0x20007434
230 PPPIOCXFERUNIT = 0x2000744e 238 PPPIOCXFERUNIT = 0x2000744e
231 PR_SET_PTRACER_ANY = 0xffffffff 239 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
232 PTRACE_GETFPREGS = 0xe 254 PTRACE_GETFPREGS = 0xe
233 PTRACE_GET_THREAD_AREA = 0x19 255 PTRACE_GET_THREAD_AREA = 0x19
234 PTRACE_GET_THREAD_AREA_3264 = 0xc4 256 PTRACE_GET_THREAD_AREA_3264 = 0xc4
@@ -277,10 +299,13 @@ const (
277 RTC_WIE_ON = 0x2000700f 299 RTC_WIE_ON = 0x2000700f
278 RTC_WKALM_RD = 0x40287010 300 RTC_WKALM_RD = 0x40287010
279 RTC_WKALM_SET = 0x8028700f 301 RTC_WKALM_SET = 0x8028700f
302 SCM_DEVMEM_DMABUF = 0x4f
303 SCM_DEVMEM_LINEAR = 0x4e
280 SCM_TIMESTAMPING = 0x25 304 SCM_TIMESTAMPING = 0x25
281 SCM_TIMESTAMPING_OPT_STATS = 0x36 305 SCM_TIMESTAMPING_OPT_STATS = 0x36
282 SCM_TIMESTAMPING_PKTINFO = 0x3a 306 SCM_TIMESTAMPING_PKTINFO = 0x3a
283 SCM_TIMESTAMPNS = 0x23 307 SCM_TIMESTAMPNS = 0x23
308 SCM_TS_OPT_ID = 0x51
284 SCM_TXTIME = 0x3d 309 SCM_TXTIME = 0x3d
285 SCM_WIFI_STATUS = 0x29 310 SCM_WIFI_STATUS = 0x29
286 SECCOMP_IOCTL_NOTIF_ADDFD = 0x80182103 311 SECCOMP_IOCTL_NOTIF_ADDFD = 0x80182103
@@ -315,6 +340,9 @@ const (
315 SO_CNX_ADVICE = 0x35 340 SO_CNX_ADVICE = 0x35
316 SO_COOKIE = 0x39 341 SO_COOKIE = 0x39
317 SO_DETACH_REUSEPORT_BPF = 0x44 342 SO_DETACH_REUSEPORT_BPF = 0x44
343 SO_DEVMEM_DMABUF = 0x4f
344 SO_DEVMEM_DONTNEED = 0x50
345 SO_DEVMEM_LINEAR = 0x4e
318 SO_DOMAIN = 0x1029 346 SO_DOMAIN = 0x1029
319 SO_DONTROUTE = 0x10 347 SO_DONTROUTE = 0x10
320 SO_ERROR = 0x1007 348 SO_ERROR = 0x1007
vendor/golang.org/x/sys/unix/zerrors_linux_ppc.go +28
@@ -108,12 +108,15 @@ const (
108 HIDIOCGRAWINFO = 0x40084803 108 HIDIOCGRAWINFO = 0x40084803
109 HIDIOCGRDESC = 0x50044802 109 HIDIOCGRDESC = 0x50044802
110 HIDIOCGRDESCSIZE = 0x40044801 110 HIDIOCGRDESCSIZE = 0x40044801
111 HIDIOCREVOKE = 0x8004480d
111 HUPCL = 0x4000 112 HUPCL = 0x4000
112 ICANON = 0x100 113 ICANON = 0x100
113 IEXTEN = 0x400 114 IEXTEN = 0x400
114 IN_CLOEXEC = 0x80000 115 IN_CLOEXEC = 0x80000
115 IN_NONBLOCK = 0x800 116 IN_NONBLOCK = 0x800
116 IOCTL_VM_SOCKETS_GET_LOCAL_CID = 0x200007b9 117 IOCTL_VM_SOCKETS_GET_LOCAL_CID = 0x200007b9
118 IPV6_FLOWINFO_MASK = 0xfffffff
119 IPV6_FLOWLABEL_MASK = 0xfffff
117 ISIG = 0x80 120 ISIG = 0x80
118 IUCLC = 0x1000 121 IUCLC = 0x1000
119 IXOFF = 0x400 122 IXOFF = 0x400
@@ -152,9 +155,14 @@ const (
152 NL3 = 0x300 155 NL3 = 0x300
153 NLDLY = 0x300 156 NLDLY = 0x300
154 NOFLSH = 0x80000000 157 NOFLSH = 0x80000000
158 NS_GET_MNTNS_ID = 0x4008b705
155 NS_GET_NSTYPE = 0x2000b703 159 NS_GET_NSTYPE = 0x2000b703
156 NS_GET_OWNER_UID = 0x2000b704 160 NS_GET_OWNER_UID = 0x2000b704
157 NS_GET_PARENT = 0x2000b702 161 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
158 NS_GET_USERNS = 0x2000b701 166 NS_GET_USERNS = 0x2000b701
159 OLCUC = 0x4 167 OLCUC = 0x4
160 ONLCR = 0x2 168 ONLCR = 0x2
@@ -232,6 +240,20 @@ const (
232 PPPIOCXFERUNIT = 0x2000744e 240 PPPIOCXFERUNIT = 0x2000744e
233 PROT_SAO = 0x10 241 PROT_SAO = 0x10
234 PR_SET_PTRACER_ANY = 0xffffffff 242 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
235 PTRACE_GETEVRREGS = 0x14 257 PTRACE_GETEVRREGS = 0x14
236 PTRACE_GETFPREGS = 0xe 258 PTRACE_GETFPREGS = 0xe
237 PTRACE_GETREGS64 = 0x16 259 PTRACE_GETREGS64 = 0x16
@@ -332,10 +354,13 @@ const (
332 RTC_WIE_ON = 0x2000700f 354 RTC_WIE_ON = 0x2000700f
333 RTC_WKALM_RD = 0x40287010 355 RTC_WKALM_RD = 0x40287010
334 RTC_WKALM_SET = 0x8028700f 356 RTC_WKALM_SET = 0x8028700f
357 SCM_DEVMEM_DMABUF = 0x4f
358 SCM_DEVMEM_LINEAR = 0x4e
335 SCM_TIMESTAMPING = 0x25 359 SCM_TIMESTAMPING = 0x25
336 SCM_TIMESTAMPING_OPT_STATS = 0x36 360 SCM_TIMESTAMPING_OPT_STATS = 0x36
337 SCM_TIMESTAMPING_PKTINFO = 0x3a 361 SCM_TIMESTAMPING_PKTINFO = 0x3a
338 SCM_TIMESTAMPNS = 0x23 362 SCM_TIMESTAMPNS = 0x23
363 SCM_TS_OPT_ID = 0x51
339 SCM_TXTIME = 0x3d 364 SCM_TXTIME = 0x3d
340 SCM_WIFI_STATUS = 0x29 365 SCM_WIFI_STATUS = 0x29
341 SECCOMP_IOCTL_NOTIF_ADDFD = 0x80182103 366 SECCOMP_IOCTL_NOTIF_ADDFD = 0x80182103
@@ -370,6 +395,9 @@ const (
370 SO_CNX_ADVICE = 0x35 395 SO_CNX_ADVICE = 0x35
371 SO_COOKIE = 0x39 396 SO_COOKIE = 0x39
372 SO_DETACH_REUSEPORT_BPF = 0x44 397 SO_DETACH_REUSEPORT_BPF = 0x44
398 SO_DEVMEM_DMABUF = 0x4f
399 SO_DEVMEM_DONTNEED = 0x50
400 SO_DEVMEM_LINEAR = 0x4e
373 SO_DOMAIN = 0x27 401 SO_DOMAIN = 0x27
374 SO_DONTROUTE = 0x5 402 SO_DONTROUTE = 0x5
375 SO_ERROR = 0x4 403 SO_ERROR = 0x4
vendor/golang.org/x/sys/unix/zerrors_linux_ppc64.go +28
@@ -108,12 +108,15 @@ const (
108 HIDIOCGRAWINFO = 0x40084803 108 HIDIOCGRAWINFO = 0x40084803
109 HIDIOCGRDESC = 0x50044802 109 HIDIOCGRDESC = 0x50044802
110 HIDIOCGRDESCSIZE = 0x40044801 110 HIDIOCGRDESCSIZE = 0x40044801
111 HIDIOCREVOKE = 0x8004480d
111 HUPCL = 0x4000 112 HUPCL = 0x4000
112 ICANON = 0x100 113 ICANON = 0x100
113 IEXTEN = 0x400 114 IEXTEN = 0x400
114 IN_CLOEXEC = 0x80000 115 IN_CLOEXEC = 0x80000
115 IN_NONBLOCK = 0x800 116 IN_NONBLOCK = 0x800
116 IOCTL_VM_SOCKETS_GET_LOCAL_CID = 0x200007b9 117 IOCTL_VM_SOCKETS_GET_LOCAL_CID = 0x200007b9
118 IPV6_FLOWINFO_MASK = 0xfffffff
119 IPV6_FLOWLABEL_MASK = 0xfffff
117 ISIG = 0x80 120 ISIG = 0x80
118 IUCLC = 0x1000 121 IUCLC = 0x1000
119 IXOFF = 0x400 122 IXOFF = 0x400
@@ -152,9 +155,14 @@ const (
152 NL3 = 0x300 155 NL3 = 0x300
153 NLDLY = 0x300 156 NLDLY = 0x300
154 NOFLSH = 0x80000000 157 NOFLSH = 0x80000000
158 NS_GET_MNTNS_ID = 0x4008b705
155 NS_GET_NSTYPE = 0x2000b703 159 NS_GET_NSTYPE = 0x2000b703
156 NS_GET_OWNER_UID = 0x2000b704 160 NS_GET_OWNER_UID = 0x2000b704
157 NS_GET_PARENT = 0x2000b702 161 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
158 NS_GET_USERNS = 0x2000b701 166 NS_GET_USERNS = 0x2000b701
159 OLCUC = 0x4 167 OLCUC = 0x4
160 ONLCR = 0x2 168 ONLCR = 0x2
@@ -232,6 +240,20 @@ const (
232 PPPIOCXFERUNIT = 0x2000744e 240 PPPIOCXFERUNIT = 0x2000744e
233 PROT_SAO = 0x10 241 PROT_SAO = 0x10
234 PR_SET_PTRACER_ANY = 0xffffffffffffffff 242 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
235 PTRACE_GETEVRREGS = 0x14 257 PTRACE_GETEVRREGS = 0x14
236 PTRACE_GETFPREGS = 0xe 258 PTRACE_GETFPREGS = 0xe
237 PTRACE_GETREGS64 = 0x16 259 PTRACE_GETREGS64 = 0x16
@@ -336,10 +358,13 @@ const (
336 RTC_WIE_ON = 0x2000700f 358 RTC_WIE_ON = 0x2000700f
337 RTC_WKALM_RD = 0x40287010 359 RTC_WKALM_RD = 0x40287010
338 RTC_WKALM_SET = 0x8028700f 360 RTC_WKALM_SET = 0x8028700f
361 SCM_DEVMEM_DMABUF = 0x4f
362 SCM_DEVMEM_LINEAR = 0x4e
339 SCM_TIMESTAMPING = 0x25 363 SCM_TIMESTAMPING = 0x25
340 SCM_TIMESTAMPING_OPT_STATS = 0x36 364 SCM_TIMESTAMPING_OPT_STATS = 0x36
341 SCM_TIMESTAMPING_PKTINFO = 0x3a 365 SCM_TIMESTAMPING_PKTINFO = 0x3a
342 SCM_TIMESTAMPNS = 0x23 366 SCM_TIMESTAMPNS = 0x23
367 SCM_TS_OPT_ID = 0x51
343 SCM_TXTIME = 0x3d 368 SCM_TXTIME = 0x3d
344 SCM_WIFI_STATUS = 0x29 369 SCM_WIFI_STATUS = 0x29
345 SECCOMP_IOCTL_NOTIF_ADDFD = 0x80182103 370 SECCOMP_IOCTL_NOTIF_ADDFD = 0x80182103
@@ -374,6 +399,9 @@ const (
374 SO_CNX_ADVICE = 0x35 399 SO_CNX_ADVICE = 0x35
375 SO_COOKIE = 0x39 400 SO_COOKIE = 0x39
376 SO_DETACH_REUSEPORT_BPF = 0x44 401 SO_DETACH_REUSEPORT_BPF = 0x44
402 SO_DEVMEM_DMABUF = 0x4f
403 SO_DEVMEM_DONTNEED = 0x50
404 SO_DEVMEM_LINEAR = 0x4e
377 SO_DOMAIN = 0x27 405 SO_DOMAIN = 0x27
378 SO_DONTROUTE = 0x5 406 SO_DONTROUTE = 0x5
379 SO_ERROR = 0x4 407 SO_ERROR = 0x4
vendor/golang.org/x/sys/unix/zerrors_linux_ppc64le.go +28
@@ -108,12 +108,15 @@ const (
108 HIDIOCGRAWINFO = 0x40084803 108 HIDIOCGRAWINFO = 0x40084803
109 HIDIOCGRDESC = 0x50044802 109 HIDIOCGRDESC = 0x50044802
110 HIDIOCGRDESCSIZE = 0x40044801 110 HIDIOCGRDESCSIZE = 0x40044801
111 HIDIOCREVOKE = 0x8004480d
111 HUPCL = 0x4000 112 HUPCL = 0x4000
112 ICANON = 0x100 113 ICANON = 0x100
113 IEXTEN = 0x400 114 IEXTEN = 0x400
114 IN_CLOEXEC = 0x80000 115 IN_CLOEXEC = 0x80000
115 IN_NONBLOCK = 0x800 116 IN_NONBLOCK = 0x800
116 IOCTL_VM_SOCKETS_GET_LOCAL_CID = 0x200007b9 117 IOCTL_VM_SOCKETS_GET_LOCAL_CID = 0x200007b9
118 IPV6_FLOWINFO_MASK = 0xffffff0f
119 IPV6_FLOWLABEL_MASK = 0xffff0f00
117 ISIG = 0x80 120 ISIG = 0x80
118 IUCLC = 0x1000 121 IUCLC = 0x1000
119 IXOFF = 0x400 122 IXOFF = 0x400
@@ -152,9 +155,14 @@ const (
152 NL3 = 0x300 155 NL3 = 0x300
153 NLDLY = 0x300 156 NLDLY = 0x300
154 NOFLSH = 0x80000000 157 NOFLSH = 0x80000000
158 NS_GET_MNTNS_ID = 0x4008b705
155 NS_GET_NSTYPE = 0x2000b703 159 NS_GET_NSTYPE = 0x2000b703
156 NS_GET_OWNER_UID = 0x2000b704 160 NS_GET_OWNER_UID = 0x2000b704
157 NS_GET_PARENT = 0x2000b702 161 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
158 NS_GET_USERNS = 0x2000b701 166 NS_GET_USERNS = 0x2000b701
159 OLCUC = 0x4 167 OLCUC = 0x4
160 ONLCR = 0x2 168 ONLCR = 0x2
@@ -232,6 +240,20 @@ const (
232 PPPIOCXFERUNIT = 0x2000744e 240 PPPIOCXFERUNIT = 0x2000744e
233 PROT_SAO = 0x10 241 PROT_SAO = 0x10
234 PR_SET_PTRACER_ANY = 0xffffffffffffffff 242 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
235 PTRACE_GETEVRREGS = 0x14 257 PTRACE_GETEVRREGS = 0x14
236 PTRACE_GETFPREGS = 0xe 258 PTRACE_GETFPREGS = 0xe
237 PTRACE_GETREGS64 = 0x16 259 PTRACE_GETREGS64 = 0x16
@@ -336,10 +358,13 @@ const (
336 RTC_WIE_ON = 0x2000700f 358 RTC_WIE_ON = 0x2000700f
337 RTC_WKALM_RD = 0x40287010 359 RTC_WKALM_RD = 0x40287010
338 RTC_WKALM_SET = 0x8028700f 360 RTC_WKALM_SET = 0x8028700f
361 SCM_DEVMEM_DMABUF = 0x4f
362 SCM_DEVMEM_LINEAR = 0x4e
339 SCM_TIMESTAMPING = 0x25 363 SCM_TIMESTAMPING = 0x25
340 SCM_TIMESTAMPING_OPT_STATS = 0x36 364 SCM_TIMESTAMPING_OPT_STATS = 0x36
341 SCM_TIMESTAMPING_PKTINFO = 0x3a 365 SCM_TIMESTAMPING_PKTINFO = 0x3a
342 SCM_TIMESTAMPNS = 0x23 366 SCM_TIMESTAMPNS = 0x23
367 SCM_TS_OPT_ID = 0x51
343 SCM_TXTIME = 0x3d 368 SCM_TXTIME = 0x3d
344 SCM_WIFI_STATUS = 0x29 369 SCM_WIFI_STATUS = 0x29
345 SECCOMP_IOCTL_NOTIF_ADDFD = 0x80182103 370 SECCOMP_IOCTL_NOTIF_ADDFD = 0x80182103
@@ -374,6 +399,9 @@ const (
374 SO_CNX_ADVICE = 0x35 399 SO_CNX_ADVICE = 0x35
375 SO_COOKIE = 0x39 400 SO_COOKIE = 0x39
376 SO_DETACH_REUSEPORT_BPF = 0x44 401 SO_DETACH_REUSEPORT_BPF = 0x44
402 SO_DEVMEM_DMABUF = 0x4f
403 SO_DEVMEM_DONTNEED = 0x50
404 SO_DEVMEM_LINEAR = 0x4e
377 SO_DOMAIN = 0x27 405 SO_DOMAIN = 0x27
378 SO_DONTROUTE = 0x5 406 SO_DONTROUTE = 0x5
379 SO_ERROR = 0x4 407 SO_ERROR = 0x4
vendor/golang.org/x/sys/unix/zerrors_linux_riscv64.go +28
@@ -108,12 +108,15 @@ const (
108 HIDIOCGRAWINFO = 0x80084803 108 HIDIOCGRAWINFO = 0x80084803
109 HIDIOCGRDESC = 0x90044802 109 HIDIOCGRDESC = 0x90044802
110 HIDIOCGRDESCSIZE = 0x80044801 110 HIDIOCGRDESCSIZE = 0x80044801
111 HIDIOCREVOKE = 0x4004480d
111 HUPCL = 0x400 112 HUPCL = 0x400
112 ICANON = 0x2 113 ICANON = 0x2
113 IEXTEN = 0x8000 114 IEXTEN = 0x8000
114 IN_CLOEXEC = 0x80000 115 IN_CLOEXEC = 0x80000
115 IN_NONBLOCK = 0x800 116 IN_NONBLOCK = 0x800
116 IOCTL_VM_SOCKETS_GET_LOCAL_CID = 0x7b9 117 IOCTL_VM_SOCKETS_GET_LOCAL_CID = 0x7b9
118 IPV6_FLOWINFO_MASK = 0xffffff0f
119 IPV6_FLOWLABEL_MASK = 0xffff0f00
117 ISIG = 0x1 120 ISIG = 0x1
118 IUCLC = 0x200 121 IUCLC = 0x200
119 IXOFF = 0x1000 122 IXOFF = 0x1000
@@ -150,9 +153,14 @@ const (
150 NFDBITS = 0x40 153 NFDBITS = 0x40
151 NLDLY = 0x100 154 NLDLY = 0x100
152 NOFLSH = 0x80 155 NOFLSH = 0x80
156 NS_GET_MNTNS_ID = 0x8008b705
153 NS_GET_NSTYPE = 0xb703 157 NS_GET_NSTYPE = 0xb703
154 NS_GET_OWNER_UID = 0xb704 158 NS_GET_OWNER_UID = 0xb704
155 NS_GET_PARENT = 0xb702 159 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
156 NS_GET_USERNS = 0xb701 164 NS_GET_USERNS = 0xb701
157 OLCUC = 0x2 165 OLCUC = 0x2
158 ONLCR = 0x4 166 ONLCR = 0x4
@@ -229,6 +237,20 @@ const (
229 PPPIOCUNBRIDGECHAN = 0x7434 237 PPPIOCUNBRIDGECHAN = 0x7434
230 PPPIOCXFERUNIT = 0x744e 238 PPPIOCXFERUNIT = 0x744e
231 PR_SET_PTRACER_ANY = 0xffffffffffffffff 239 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
232 PTRACE_GETFDPIC = 0x21 254 PTRACE_GETFDPIC = 0x21
233 PTRACE_GETFDPIC_EXEC = 0x0 255 PTRACE_GETFDPIC_EXEC = 0x0
234 PTRACE_GETFDPIC_INTERP = 0x1 256 PTRACE_GETFDPIC_INTERP = 0x1
@@ -268,10 +290,13 @@ const (
268 RTC_WIE_ON = 0x700f 290 RTC_WIE_ON = 0x700f
269 RTC_WKALM_RD = 0x80287010 291 RTC_WKALM_RD = 0x80287010
270 RTC_WKALM_SET = 0x4028700f 292 RTC_WKALM_SET = 0x4028700f
293 SCM_DEVMEM_DMABUF = 0x4f
294 SCM_DEVMEM_LINEAR = 0x4e
271 SCM_TIMESTAMPING = 0x25 295 SCM_TIMESTAMPING = 0x25
272 SCM_TIMESTAMPING_OPT_STATS = 0x36 296 SCM_TIMESTAMPING_OPT_STATS = 0x36
273 SCM_TIMESTAMPING_PKTINFO = 0x3a 297 SCM_TIMESTAMPING_PKTINFO = 0x3a
274 SCM_TIMESTAMPNS = 0x23 298 SCM_TIMESTAMPNS = 0x23
299 SCM_TS_OPT_ID = 0x51
275 SCM_TXTIME = 0x3d 300 SCM_TXTIME = 0x3d
276 SCM_WIFI_STATUS = 0x29 301 SCM_WIFI_STATUS = 0x29
277 SECCOMP_IOCTL_NOTIF_ADDFD = 0x40182103 302 SECCOMP_IOCTL_NOTIF_ADDFD = 0x40182103
@@ -306,6 +331,9 @@ const (
306 SO_CNX_ADVICE = 0x35 331 SO_CNX_ADVICE = 0x35
307 SO_COOKIE = 0x39 332 SO_COOKIE = 0x39
308 SO_DETACH_REUSEPORT_BPF = 0x44 333 SO_DETACH_REUSEPORT_BPF = 0x44
334 SO_DEVMEM_DMABUF = 0x4f
335 SO_DEVMEM_DONTNEED = 0x50
336 SO_DEVMEM_LINEAR = 0x4e
309 SO_DOMAIN = 0x27 337 SO_DOMAIN = 0x27
310 SO_DONTROUTE = 0x5 338 SO_DONTROUTE = 0x5
311 SO_ERROR = 0x4 339 SO_ERROR = 0x4
vendor/golang.org/x/sys/unix/zerrors_linux_s390x.go +28
@@ -108,12 +108,15 @@ const (
108 HIDIOCGRAWINFO = 0x80084803 108 HIDIOCGRAWINFO = 0x80084803
109 HIDIOCGRDESC = 0x90044802 109 HIDIOCGRDESC = 0x90044802
110 HIDIOCGRDESCSIZE = 0x80044801 110 HIDIOCGRDESCSIZE = 0x80044801
111 HIDIOCREVOKE = 0x4004480d
111 HUPCL = 0x400 112 HUPCL = 0x400
112 ICANON = 0x2 113 ICANON = 0x2
113 IEXTEN = 0x8000 114 IEXTEN = 0x8000
114 IN_CLOEXEC = 0x80000 115 IN_CLOEXEC = 0x80000
115 IN_NONBLOCK = 0x800 116 IN_NONBLOCK = 0x800
116 IOCTL_VM_SOCKETS_GET_LOCAL_CID = 0x7b9 117 IOCTL_VM_SOCKETS_GET_LOCAL_CID = 0x7b9
118 IPV6_FLOWINFO_MASK = 0xfffffff
119 IPV6_FLOWLABEL_MASK = 0xfffff
117 ISIG = 0x1 120 ISIG = 0x1
118 IUCLC = 0x200 121 IUCLC = 0x200
119 IXOFF = 0x1000 122 IXOFF = 0x1000
@@ -150,9 +153,14 @@ const (
150 NFDBITS = 0x40 153 NFDBITS = 0x40
151 NLDLY = 0x100 154 NLDLY = 0x100
152 NOFLSH = 0x80 155 NOFLSH = 0x80
156 NS_GET_MNTNS_ID = 0x8008b705
153 NS_GET_NSTYPE = 0xb703 157 NS_GET_NSTYPE = 0xb703
154 NS_GET_OWNER_UID = 0xb704 158 NS_GET_OWNER_UID = 0xb704
155 NS_GET_PARENT = 0xb702 159 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
156 NS_GET_USERNS = 0xb701 164 NS_GET_USERNS = 0xb701
157 OLCUC = 0x2 165 OLCUC = 0x2
158 ONLCR = 0x4 166 ONLCR = 0x4
@@ -229,6 +237,20 @@ const (
229 PPPIOCUNBRIDGECHAN = 0x7434 237 PPPIOCUNBRIDGECHAN = 0x7434
230 PPPIOCXFERUNIT = 0x744e 238 PPPIOCXFERUNIT = 0x744e
231 PR_SET_PTRACER_ANY = 0xffffffffffffffff 239 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
232 PTRACE_DISABLE_TE = 0x5010 254 PTRACE_DISABLE_TE = 0x5010
233 PTRACE_ENABLE_TE = 0x5009 255 PTRACE_ENABLE_TE = 0x5009
234 PTRACE_GET_LAST_BREAK = 0x5006 256 PTRACE_GET_LAST_BREAK = 0x5006
@@ -340,10 +362,13 @@ const (
340 RTC_WIE_ON = 0x700f 362 RTC_WIE_ON = 0x700f
341 RTC_WKALM_RD = 0x80287010 363 RTC_WKALM_RD = 0x80287010
342 RTC_WKALM_SET = 0x4028700f 364 RTC_WKALM_SET = 0x4028700f
365 SCM_DEVMEM_DMABUF = 0x4f
366 SCM_DEVMEM_LINEAR = 0x4e
343 SCM_TIMESTAMPING = 0x25 367 SCM_TIMESTAMPING = 0x25
344 SCM_TIMESTAMPING_OPT_STATS = 0x36 368 SCM_TIMESTAMPING_OPT_STATS = 0x36
345 SCM_TIMESTAMPING_PKTINFO = 0x3a 369 SCM_TIMESTAMPING_PKTINFO = 0x3a
346 SCM_TIMESTAMPNS = 0x23 370 SCM_TIMESTAMPNS = 0x23
371 SCM_TS_OPT_ID = 0x51
347 SCM_TXTIME = 0x3d 372 SCM_TXTIME = 0x3d
348 SCM_WIFI_STATUS = 0x29 373 SCM_WIFI_STATUS = 0x29
349 SECCOMP_IOCTL_NOTIF_ADDFD = 0x40182103 374 SECCOMP_IOCTL_NOTIF_ADDFD = 0x40182103
@@ -378,6 +403,9 @@ const (
378 SO_CNX_ADVICE = 0x35 403 SO_CNX_ADVICE = 0x35
379 SO_COOKIE = 0x39 404 SO_COOKIE = 0x39
380 SO_DETACH_REUSEPORT_BPF = 0x44 405 SO_DETACH_REUSEPORT_BPF = 0x44
406 SO_DEVMEM_DMABUF = 0x4f
407 SO_DEVMEM_DONTNEED = 0x50
408 SO_DEVMEM_LINEAR = 0x4e
381 SO_DOMAIN = 0x27 409 SO_DOMAIN = 0x27
382 SO_DONTROUTE = 0x5 410 SO_DONTROUTE = 0x5
383 SO_ERROR = 0x4 411 SO_ERROR = 0x4
vendor/golang.org/x/sys/unix/zerrors_linux_sparc64.go +28
@@ -112,12 +112,15 @@ const (
112 HIDIOCGRAWINFO = 0x40084803 112 HIDIOCGRAWINFO = 0x40084803
113 HIDIOCGRDESC = 0x50044802 113 HIDIOCGRDESC = 0x50044802
114 HIDIOCGRDESCSIZE = 0x40044801 114 HIDIOCGRDESCSIZE = 0x40044801
115 HIDIOCREVOKE = 0x8004480d
115 HUPCL = 0x400 116 HUPCL = 0x400
116 ICANON = 0x2 117 ICANON = 0x2
117 IEXTEN = 0x8000 118 IEXTEN = 0x8000
118 IN_CLOEXEC = 0x400000 119 IN_CLOEXEC = 0x400000
119 IN_NONBLOCK = 0x4000 120 IN_NONBLOCK = 0x4000
120 IOCTL_VM_SOCKETS_GET_LOCAL_CID = 0x200007b9 121 IOCTL_VM_SOCKETS_GET_LOCAL_CID = 0x200007b9
122 IPV6_FLOWINFO_MASK = 0xfffffff
123 IPV6_FLOWLABEL_MASK = 0xfffff
121 ISIG = 0x1 124 ISIG = 0x1
122 IUCLC = 0x200 125 IUCLC = 0x200
123 IXOFF = 0x1000 126 IXOFF = 0x1000
@@ -155,9 +158,14 @@ const (
155 NFDBITS = 0x40 158 NFDBITS = 0x40
156 NLDLY = 0x100 159 NLDLY = 0x100
157 NOFLSH = 0x80 160 NOFLSH = 0x80
161 NS_GET_MNTNS_ID = 0x4008b705
158 NS_GET_NSTYPE = 0x2000b703 162 NS_GET_NSTYPE = 0x2000b703
159 NS_GET_OWNER_UID = 0x2000b704 163 NS_GET_OWNER_UID = 0x2000b704
160 NS_GET_PARENT = 0x2000b702 164 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
161 NS_GET_USERNS = 0x2000b701 169 NS_GET_USERNS = 0x2000b701
162 OLCUC = 0x2 170 OLCUC = 0x2
163 ONLCR = 0x4 171 ONLCR = 0x4
@@ -234,6 +242,20 @@ const (
234 PPPIOCUNBRIDGECHAN = 0x20007434 242 PPPIOCUNBRIDGECHAN = 0x20007434
235 PPPIOCXFERUNIT = 0x2000744e 243 PPPIOCXFERUNIT = 0x2000744e
236 PR_SET_PTRACER_ANY = 0xffffffffffffffff 244 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
237 PTRACE_GETFPAREGS = 0x14 259 PTRACE_GETFPAREGS = 0x14
238 PTRACE_GETFPREGS = 0xe 260 PTRACE_GETFPREGS = 0xe
239 PTRACE_GETFPREGS64 = 0x19 261 PTRACE_GETFPREGS64 = 0x19
@@ -331,10 +353,13 @@ const (
331 RTC_WIE_ON = 0x2000700f 353 RTC_WIE_ON = 0x2000700f
332 RTC_WKALM_RD = 0x40287010 354 RTC_WKALM_RD = 0x40287010
333 RTC_WKALM_SET = 0x8028700f 355 RTC_WKALM_SET = 0x8028700f
356 SCM_DEVMEM_DMABUF = 0x58
357 SCM_DEVMEM_LINEAR = 0x57
334 SCM_TIMESTAMPING = 0x23 358 SCM_TIMESTAMPING = 0x23
335 SCM_TIMESTAMPING_OPT_STATS = 0x38 359 SCM_TIMESTAMPING_OPT_STATS = 0x38
336 SCM_TIMESTAMPING_PKTINFO = 0x3c 360 SCM_TIMESTAMPING_PKTINFO = 0x3c
337 SCM_TIMESTAMPNS = 0x21 361 SCM_TIMESTAMPNS = 0x21
362 SCM_TS_OPT_ID = 0x5a
338 SCM_TXTIME = 0x3f 363 SCM_TXTIME = 0x3f
339 SCM_WIFI_STATUS = 0x25 364 SCM_WIFI_STATUS = 0x25
340 SECCOMP_IOCTL_NOTIF_ADDFD = 0x80182103 365 SECCOMP_IOCTL_NOTIF_ADDFD = 0x80182103
@@ -417,6 +442,9 @@ const (
417 SO_CNX_ADVICE = 0x37 442 SO_CNX_ADVICE = 0x37
418 SO_COOKIE = 0x3b 443 SO_COOKIE = 0x3b
419 SO_DETACH_REUSEPORT_BPF = 0x47 444 SO_DETACH_REUSEPORT_BPF = 0x47
445 SO_DEVMEM_DMABUF = 0x58
446 SO_DEVMEM_DONTNEED = 0x59
447 SO_DEVMEM_LINEAR = 0x57
420 SO_DOMAIN = 0x1029 448 SO_DOMAIN = 0x1029
421 SO_DONTROUTE = 0x10 449 SO_DONTROUTE = 0x10
422 SO_ERROR = 0x1007 450 SO_ERROR = 0x1007
vendor/golang.org/x/sys/unix/zerrors_zos_s390x.go +2
@@ -581,6 +581,8 @@ const (
581 AT_EMPTY_PATH = 0x1000 581 AT_EMPTY_PATH = 0x1000
582 AT_REMOVEDIR = 0x200 582 AT_REMOVEDIR = 0x200
583 RENAME_NOREPLACE = 1 << 0 583 RENAME_NOREPLACE = 1 << 0
584 ST_RDONLY = 1
585 ST_NOSUID = 2
584) 586)
585 587
586const ( 588const (
vendor/golang.org/x/sys/unix/zsyscall_darwin_amd64.go +20
@@ -841,6 +841,26 @@ var libc_pthread_fchdir_np_trampoline_addr uintptr
841 841
842// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT 842// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
843 843
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
844func sendfile(infd int, outfd int, offset int64, len *int64, hdtr unsafe.Pointer, flags int) (err error) { 864func sendfile(infd int, outfd int, offset int64, len *int64, hdtr unsafe.Pointer, flags int) (err error) {
845 _, _, e1 := syscall_syscall6(libc_sendfile_trampoline_addr, uintptr(infd), uintptr(outfd), uintptr(offset), uintptr(unsafe.Pointer(len)), uintptr(hdtr), uintptr(flags)) 865 _, _, e1 := syscall_syscall6(libc_sendfile_trampoline_addr, uintptr(infd), uintptr(outfd), uintptr(offset), uintptr(unsafe.Pointer(len)), uintptr(hdtr), uintptr(flags))
846 if e1 != 0 { 866 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
248GLOBL ·libc_pthread_fchdir_np_trampoline_addr(SB), RODATA, $8 248GLOBL ·libc_pthread_fchdir_np_trampoline_addr(SB), RODATA, $8
249DATA ·libc_pthread_fchdir_np_trampoline_addr(SB)/8, $libc_pthread_fchdir_np_trampoline<>(SB) 249DATA ·libc_pthread_fchdir_np_trampoline_addr(SB)/8, $libc_pthread_fchdir_np_trampoline<>(SB)
250 250
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
251TEXT libc_sendfile_trampoline<>(SB),NOSPLIT,$0-0 256TEXT libc_sendfile_trampoline<>(SB),NOSPLIT,$0-0
252 JMP libc_sendfile(SB) 257 JMP libc_sendfile(SB)
253GLOBL ·libc_sendfile_trampoline_addr(SB), RODATA, $8 258GLOBL ·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
841 841
842// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT 842// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
843 843
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
844func sendfile(infd int, outfd int, offset int64, len *int64, hdtr unsafe.Pointer, flags int) (err error) { 864func sendfile(infd int, outfd int, offset int64, len *int64, hdtr unsafe.Pointer, flags int) (err error) {
845 _, _, e1 := syscall_syscall6(libc_sendfile_trampoline_addr, uintptr(infd), uintptr(outfd), uintptr(offset), uintptr(unsafe.Pointer(len)), uintptr(hdtr), uintptr(flags)) 865 _, _, e1 := syscall_syscall6(libc_sendfile_trampoline_addr, uintptr(infd), uintptr(outfd), uintptr(offset), uintptr(unsafe.Pointer(len)), uintptr(hdtr), uintptr(flags))
846 if e1 != 0 { 866 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
248GLOBL ·libc_pthread_fchdir_np_trampoline_addr(SB), RODATA, $8 248GLOBL ·libc_pthread_fchdir_np_trampoline_addr(SB), RODATA, $8
249DATA ·libc_pthread_fchdir_np_trampoline_addr(SB)/8, $libc_pthread_fchdir_np_trampoline<>(SB) 249DATA ·libc_pthread_fchdir_np_trampoline_addr(SB)/8, $libc_pthread_fchdir_np_trampoline<>(SB)
250 250
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
251TEXT libc_sendfile_trampoline<>(SB),NOSPLIT,$0-0 256TEXT libc_sendfile_trampoline<>(SB),NOSPLIT,$0-0
252 JMP libc_sendfile(SB) 257 JMP libc_sendfile(SB)
253GLOBL ·libc_sendfile_trampoline_addr(SB), RODATA, $8 258GLOBL ·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) {
592 592
593// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT 593// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
594 594
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
595func ClockNanosleep(clockid int32, flags int, request *Timespec, remain *Timespec) (err error) { 605func ClockNanosleep(clockid int32, flags int, request *Timespec, remain *Timespec) (err error) {
596 _, _, e1 := Syscall6(SYS_CLOCK_NANOSLEEP, uintptr(clockid), uintptr(flags), uintptr(unsafe.Pointer(request)), uintptr(unsafe.Pointer(remain)), 0, 0) 606 _, _, e1 := Syscall6(SYS_CLOCK_NANOSLEEP, uintptr(clockid), uintptr(flags), uintptr(unsafe.Pointer(request)), uintptr(unsafe.Pointer(remain)), 0, 0)
597 if e1 != 0 { 607 if e1 != 0 {
@@ -971,23 +981,6 @@ func Getpriority(which int, who int) (prio int, err error) {
971 981
972// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT 982// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
973 983
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
991func Getrusage(who int, rusage *Rusage) (err error) { 984func Getrusage(who int, rusage *Rusage) (err error) {
992 _, _, e1 := RawSyscall(SYS_GETRUSAGE, uintptr(who), uintptr(unsafe.Pointer(rusage)), 0) 985 _, _, e1 := RawSyscall(SYS_GETRUSAGE, uintptr(who), uintptr(unsafe.Pointer(rusage)), 0)
993 if e1 != 0 { 986 if e1 != 0 {
vendor/golang.org/x/sys/unix/zsyscall_solaris_amd64.go +114
@@ -141,6 +141,16 @@ import (
141//go:cgo_import_dynamic libc_getpeername getpeername "libsocket.so" 141//go:cgo_import_dynamic libc_getpeername getpeername "libsocket.so"
142//go:cgo_import_dynamic libc_setsockopt setsockopt "libsocket.so" 142//go:cgo_import_dynamic libc_setsockopt setsockopt "libsocket.so"
143//go:cgo_import_dynamic libc_recvfrom recvfrom "libsocket.so" 143//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"
144//go:cgo_import_dynamic libc_port_create port_create "libc.so" 154//go:cgo_import_dynamic libc_port_create port_create "libc.so"
145//go:cgo_import_dynamic libc_port_associate port_associate "libc.so" 155//go:cgo_import_dynamic libc_port_associate port_associate "libc.so"
146//go:cgo_import_dynamic libc_port_dissociate port_dissociate "libc.so" 156//go:cgo_import_dynamic libc_port_dissociate port_dissociate "libc.so"
@@ -280,6 +290,16 @@ import (
280//go:linkname procgetpeername libc_getpeername 290//go:linkname procgetpeername libc_getpeername
281//go:linkname procsetsockopt libc_setsockopt 291//go:linkname procsetsockopt libc_setsockopt
282//go:linkname procrecvfrom libc_recvfrom 292//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
283//go:linkname procport_create libc_port_create 303//go:linkname procport_create libc_port_create
284//go:linkname procport_associate libc_port_associate 304//go:linkname procport_associate libc_port_associate
285//go:linkname procport_dissociate libc_port_dissociate 305//go:linkname procport_dissociate libc_port_dissociate
@@ -420,6 +440,16 @@ var (
420 procgetpeername, 440 procgetpeername,
421 procsetsockopt, 441 procsetsockopt,
422 procrecvfrom, 442 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,
423 procport_create, 453 procport_create,
424 procport_associate, 454 procport_associate,
425 procport_dissociate, 455 procport_dissociate,
@@ -2029,6 +2059,90 @@ func recvfrom(fd int, p []byte, flags int, from *RawSockaddrAny, fromlen *_Sockl
2029 2059
2030// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT 2060// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
2031 2061
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
2032func port_create() (n int, err error) { 2146func port_create() (n int, err error) {
2033 r0, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procport_create)), 0, 0, 0, 0, 0, 0, 0) 2147 r0, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procport_create)), 0, 0, 0, 0, 0, 0, 0)
2034 n = int(r0) 2148 n = int(r0)
vendor/golang.org/x/sys/unix/zsysnum_linux_386.go +4
@@ -458,4 +458,8 @@ const (
458 SYS_LSM_SET_SELF_ATTR = 460 458 SYS_LSM_SET_SELF_ATTR = 460
459 SYS_LSM_LIST_MODULES = 461 459 SYS_LSM_LIST_MODULES = 461
460 SYS_MSEAL = 462 460 SYS_MSEAL = 462
461 SYS_SETXATTRAT = 463
462 SYS_GETXATTRAT = 464
463 SYS_LISTXATTRAT = 465
464 SYS_REMOVEXATTRAT = 466
461) 465)
vendor/golang.org/x/sys/unix/zsysnum_linux_amd64.go +5
@@ -341,6 +341,7 @@ const (
341 SYS_STATX = 332 341 SYS_STATX = 332
342 SYS_IO_PGETEVENTS = 333 342 SYS_IO_PGETEVENTS = 333
343 SYS_RSEQ = 334 343 SYS_RSEQ = 334
344 SYS_URETPROBE = 335
344 SYS_PIDFD_SEND_SIGNAL = 424 345 SYS_PIDFD_SEND_SIGNAL = 424
345 SYS_IO_URING_SETUP = 425 346 SYS_IO_URING_SETUP = 425
346 SYS_IO_URING_ENTER = 426 347 SYS_IO_URING_ENTER = 426
@@ -380,4 +381,8 @@ const (
380 SYS_LSM_SET_SELF_ATTR = 460 381 SYS_LSM_SET_SELF_ATTR = 460
381 SYS_LSM_LIST_MODULES = 461 382 SYS_LSM_LIST_MODULES = 461
382 SYS_MSEAL = 462 383 SYS_MSEAL = 462
384 SYS_SETXATTRAT = 463
385 SYS_GETXATTRAT = 464
386 SYS_LISTXATTRAT = 465
387 SYS_REMOVEXATTRAT = 466
383) 388)
vendor/golang.org/x/sys/unix/zsysnum_linux_arm.go +4
@@ -422,4 +422,8 @@ const (
422 SYS_LSM_SET_SELF_ATTR = 460 422 SYS_LSM_SET_SELF_ATTR = 460
423 SYS_LSM_LIST_MODULES = 461 423 SYS_LSM_LIST_MODULES = 461
424 SYS_MSEAL = 462 424 SYS_MSEAL = 462
425 SYS_SETXATTRAT = 463
426 SYS_GETXATTRAT = 464
427 SYS_LISTXATTRAT = 465
428 SYS_REMOVEXATTRAT = 466
425) 429)
vendor/golang.org/x/sys/unix/zsysnum_linux_arm64.go +5 −1
@@ -85,7 +85,7 @@ const (
85 SYS_SPLICE = 76 85 SYS_SPLICE = 76
86 SYS_TEE = 77 86 SYS_TEE = 77
87 SYS_READLINKAT = 78 87 SYS_READLINKAT = 78
88 SYS_FSTATAT = 79 88 SYS_NEWFSTATAT = 79
89 SYS_FSTAT = 80 89 SYS_FSTAT = 80
90 SYS_SYNC = 81 90 SYS_SYNC = 81
91 SYS_FSYNC = 82 91 SYS_FSYNC = 82
@@ -325,4 +325,8 @@ const (
325 SYS_LSM_SET_SELF_ATTR = 460 325 SYS_LSM_SET_SELF_ATTR = 460
326 SYS_LSM_LIST_MODULES = 461 326 SYS_LSM_LIST_MODULES = 461
327 SYS_MSEAL = 462 327 SYS_MSEAL = 462
328 SYS_SETXATTRAT = 463
329 SYS_GETXATTRAT = 464
330 SYS_LISTXATTRAT = 465
331 SYS_REMOVEXATTRAT = 466
328) 332)
vendor/golang.org/x/sys/unix/zsysnum_linux_loong64.go +6
@@ -84,6 +84,8 @@ const (
84 SYS_SPLICE = 76 84 SYS_SPLICE = 76
85 SYS_TEE = 77 85 SYS_TEE = 77
86 SYS_READLINKAT = 78 86 SYS_READLINKAT = 78
87 SYS_NEWFSTATAT = 79
88 SYS_FSTAT = 80
87 SYS_SYNC = 81 89 SYS_SYNC = 81
88 SYS_FSYNC = 82 90 SYS_FSYNC = 82
89 SYS_FDATASYNC = 83 91 SYS_FDATASYNC = 83
@@ -319,4 +321,8 @@ const (
319 SYS_LSM_SET_SELF_ATTR = 460 321 SYS_LSM_SET_SELF_ATTR = 460
320 SYS_LSM_LIST_MODULES = 461 322 SYS_LSM_LIST_MODULES = 461
321 SYS_MSEAL = 462 323 SYS_MSEAL = 462
324 SYS_SETXATTRAT = 463
325 SYS_GETXATTRAT = 464
326 SYS_LISTXATTRAT = 465
327 SYS_REMOVEXATTRAT = 466
322) 328)
vendor/golang.org/x/sys/unix/zsysnum_linux_mips.go +4
@@ -442,4 +442,8 @@ const (
442 SYS_LSM_SET_SELF_ATTR = 4460 442 SYS_LSM_SET_SELF_ATTR = 4460
443 SYS_LSM_LIST_MODULES = 4461 443 SYS_LSM_LIST_MODULES = 4461
444 SYS_MSEAL = 4462 444 SYS_MSEAL = 4462
445 SYS_SETXATTRAT = 4463
446 SYS_GETXATTRAT = 4464
447 SYS_LISTXATTRAT = 4465
448 SYS_REMOVEXATTRAT = 4466
445) 449)
vendor/golang.org/x/sys/unix/zsysnum_linux_mips64.go +4
@@ -372,4 +372,8 @@ const (
372 SYS_LSM_SET_SELF_ATTR = 5460 372 SYS_LSM_SET_SELF_ATTR = 5460
373 SYS_LSM_LIST_MODULES = 5461 373 SYS_LSM_LIST_MODULES = 5461
374 SYS_MSEAL = 5462 374 SYS_MSEAL = 5462
375 SYS_SETXATTRAT = 5463
376 SYS_GETXATTRAT = 5464
377 SYS_LISTXATTRAT = 5465
378 SYS_REMOVEXATTRAT = 5466
375) 379)
vendor/golang.org/x/sys/unix/zsysnum_linux_mips64le.go +4
@@ -372,4 +372,8 @@ const (
372 SYS_LSM_SET_SELF_ATTR = 5460 372 SYS_LSM_SET_SELF_ATTR = 5460
373 SYS_LSM_LIST_MODULES = 5461 373 SYS_LSM_LIST_MODULES = 5461
374 SYS_MSEAL = 5462 374 SYS_MSEAL = 5462
375 SYS_SETXATTRAT = 5463
376 SYS_GETXATTRAT = 5464
377 SYS_LISTXATTRAT = 5465
378 SYS_REMOVEXATTRAT = 5466
375) 379)
vendor/golang.org/x/sys/unix/zsysnum_linux_mipsle.go +4
@@ -442,4 +442,8 @@ const (
442 SYS_LSM_SET_SELF_ATTR = 4460 442 SYS_LSM_SET_SELF_ATTR = 4460
443 SYS_LSM_LIST_MODULES = 4461 443 SYS_LSM_LIST_MODULES = 4461
444 SYS_MSEAL = 4462 444 SYS_MSEAL = 4462
445 SYS_SETXATTRAT = 4463
446 SYS_GETXATTRAT = 4464
447 SYS_LISTXATTRAT = 4465
448 SYS_REMOVEXATTRAT = 4466
445) 449)
vendor/golang.org/x/sys/unix/zsysnum_linux_ppc.go +4
@@ -449,4 +449,8 @@ const (
449 SYS_LSM_SET_SELF_ATTR = 460 449 SYS_LSM_SET_SELF_ATTR = 460
450 SYS_LSM_LIST_MODULES = 461 450 SYS_LSM_LIST_MODULES = 461
451 SYS_MSEAL = 462 451 SYS_MSEAL = 462
452 SYS_SETXATTRAT = 463
453 SYS_GETXATTRAT = 464
454 SYS_LISTXATTRAT = 465
455 SYS_REMOVEXATTRAT = 466
452) 456)
vendor/golang.org/x/sys/unix/zsysnum_linux_ppc64.go +4
@@ -421,4 +421,8 @@ const (
421 SYS_LSM_SET_SELF_ATTR = 460 421 SYS_LSM_SET_SELF_ATTR = 460
422 SYS_LSM_LIST_MODULES = 461 422 SYS_LSM_LIST_MODULES = 461
423 SYS_MSEAL = 462 423 SYS_MSEAL = 462
424 SYS_SETXATTRAT = 463
425 SYS_GETXATTRAT = 464
426 SYS_LISTXATTRAT = 465
427 SYS_REMOVEXATTRAT = 466
424) 428)
vendor/golang.org/x/sys/unix/zsysnum_linux_ppc64le.go +4
@@ -421,4 +421,8 @@ const (
421 SYS_LSM_SET_SELF_ATTR = 460 421 SYS_LSM_SET_SELF_ATTR = 460
422 SYS_LSM_LIST_MODULES = 461 422 SYS_LSM_LIST_MODULES = 461
423 SYS_MSEAL = 462 423 SYS_MSEAL = 462
424 SYS_SETXATTRAT = 463
425 SYS_GETXATTRAT = 464
426 SYS_LISTXATTRAT = 465
427 SYS_REMOVEXATTRAT = 466
424) 428)
vendor/golang.org/x/sys/unix/zsysnum_linux_riscv64.go +5 −1
@@ -84,7 +84,7 @@ const (
84 SYS_SPLICE = 76 84 SYS_SPLICE = 76
85 SYS_TEE = 77 85 SYS_TEE = 77
86 SYS_READLINKAT = 78 86 SYS_READLINKAT = 78
87 SYS_FSTATAT = 79 87 SYS_NEWFSTATAT = 79
88 SYS_FSTAT = 80 88 SYS_FSTAT = 80
89 SYS_SYNC = 81 89 SYS_SYNC = 81
90 SYS_FSYNC = 82 90 SYS_FSYNC = 82
@@ -326,4 +326,8 @@ const (
326 SYS_LSM_SET_SELF_ATTR = 460 326 SYS_LSM_SET_SELF_ATTR = 460
327 SYS_LSM_LIST_MODULES = 461 327 SYS_LSM_LIST_MODULES = 461
328 SYS_MSEAL = 462 328 SYS_MSEAL = 462
329 SYS_SETXATTRAT = 463
330 SYS_GETXATTRAT = 464
331 SYS_LISTXATTRAT = 465
332 SYS_REMOVEXATTRAT = 466
329) 333)
vendor/golang.org/x/sys/unix/zsysnum_linux_s390x.go +4
@@ -387,4 +387,8 @@ const (
387 SYS_LSM_SET_SELF_ATTR = 460 387 SYS_LSM_SET_SELF_ATTR = 460
388 SYS_LSM_LIST_MODULES = 461 388 SYS_LSM_LIST_MODULES = 461
389 SYS_MSEAL = 462 389 SYS_MSEAL = 462
390 SYS_SETXATTRAT = 463
391 SYS_GETXATTRAT = 464
392 SYS_LISTXATTRAT = 465
393 SYS_REMOVEXATTRAT = 466
390) 394)
vendor/golang.org/x/sys/unix/zsysnum_linux_sparc64.go +4
@@ -400,4 +400,8 @@ const (
400 SYS_LSM_SET_SELF_ATTR = 460 400 SYS_LSM_SET_SELF_ATTR = 460
401 SYS_LSM_LIST_MODULES = 461 401 SYS_LSM_LIST_MODULES = 461
402 SYS_MSEAL = 462 402 SYS_MSEAL = 462
403 SYS_SETXATTRAT = 463
404 SYS_GETXATTRAT = 464
405 SYS_LISTXATTRAT = 465
406 SYS_REMOVEXATTRAT = 466
403) 407)
vendor/golang.org/x/sys/unix/ztypes_darwin_amd64.go +73
@@ -306,6 +306,19 @@ type XVSockPgen struct {
306 306
307type _Socklen uint32 307type _Socklen uint32
308 308
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
309type Xucred struct { 322type Xucred struct {
310 Version uint32 323 Version uint32
311 Uid uint32 324 Uid uint32
@@ -449,11 +462,14 @@ type FdSet struct {
449 462
450const ( 463const (
451 SizeofIfMsghdr = 0x70 464 SizeofIfMsghdr = 0x70
465 SizeofIfMsghdr2 = 0xa0
452 SizeofIfData = 0x60 466 SizeofIfData = 0x60
467 SizeofIfData64 = 0x80
453 SizeofIfaMsghdr = 0x14 468 SizeofIfaMsghdr = 0x14
454 SizeofIfmaMsghdr = 0x10 469 SizeofIfmaMsghdr = 0x10
455 SizeofIfmaMsghdr2 = 0x14 470 SizeofIfmaMsghdr2 = 0x14
456 SizeofRtMsghdr = 0x5c 471 SizeofRtMsghdr = 0x5c
472 SizeofRtMsghdr2 = 0x5c
457 SizeofRtMetrics = 0x38 473 SizeofRtMetrics = 0x38
458) 474)
459 475
@@ -467,6 +483,20 @@ type IfMsghdr struct {
467 Data IfData 483 Data IfData
468} 484}
469 485
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
470type IfData struct { 500type IfData struct {
471 Type uint8 501 Type uint8
472 Typelen uint8 502 Typelen uint8
@@ -499,6 +529,34 @@ type IfData struct {
499 Reserved2 uint32 529 Reserved2 uint32
500} 530}
501 531
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
502type IfaMsghdr struct { 560type IfaMsghdr struct {
503 Msglen uint16 561 Msglen uint16
504 Version uint8 562 Version uint8
@@ -544,6 +602,21 @@ type RtMsghdr struct {
544 Rmx RtMetrics 602 Rmx RtMetrics
545} 603}
546 604
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
547type RtMetrics struct { 620type RtMetrics struct {
548 Locks uint32 621 Locks uint32
549 Mtu uint32 622 Mtu uint32
vendor/golang.org/x/sys/unix/ztypes_darwin_arm64.go +73
@@ -306,6 +306,19 @@ type XVSockPgen struct {
306 306
307type _Socklen uint32 307type _Socklen uint32
308 308
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
309type Xucred struct { 322type Xucred struct {
310 Version uint32 323 Version uint32
311 Uid uint32 324 Uid uint32
@@ -449,11 +462,14 @@ type FdSet struct {
449 462
450const ( 463const (
451 SizeofIfMsghdr = 0x70 464 SizeofIfMsghdr = 0x70
465 SizeofIfMsghdr2 = 0xa0
452 SizeofIfData = 0x60 466 SizeofIfData = 0x60
467 SizeofIfData64 = 0x80
453 SizeofIfaMsghdr = 0x14 468 SizeofIfaMsghdr = 0x14
454 SizeofIfmaMsghdr = 0x10 469 SizeofIfmaMsghdr = 0x10
455 SizeofIfmaMsghdr2 = 0x14 470 SizeofIfmaMsghdr2 = 0x14
456 SizeofRtMsghdr = 0x5c 471 SizeofRtMsghdr = 0x5c
472 SizeofRtMsghdr2 = 0x5c
457 SizeofRtMetrics = 0x38 473 SizeofRtMetrics = 0x38
458) 474)
459 475
@@ -467,6 +483,20 @@ type IfMsghdr struct {
467 Data IfData 483 Data IfData
468} 484}
469 485
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
470type IfData struct { 500type IfData struct {
471 Type uint8 501 Type uint8
472 Typelen uint8 502 Typelen uint8
@@ -499,6 +529,34 @@ type IfData struct {
499 Reserved2 uint32 529 Reserved2 uint32
500} 530}
501 531
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
502type IfaMsghdr struct { 560type IfaMsghdr struct {
503 Msglen uint16 561 Msglen uint16
504 Version uint8 562 Version uint8
@@ -544,6 +602,21 @@ type RtMsghdr struct {
544 Rmx RtMetrics 602 Rmx RtMetrics
545} 603}
546 604
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
547type RtMetrics struct { 620type RtMetrics struct {
548 Locks uint32 621 Locks uint32
549 Mtu uint32 622 Mtu uint32
vendor/golang.org/x/sys/unix/ztypes_freebsd_386.go +1
@@ -625,6 +625,7 @@ const (
625 POLLRDNORM = 0x40 625 POLLRDNORM = 0x40
626 POLLWRBAND = 0x100 626 POLLWRBAND = 0x100
627 POLLWRNORM = 0x4 627 POLLWRNORM = 0x4
628 POLLRDHUP = 0x4000
628) 629)
629 630
630type CapRights struct { 631type CapRights struct {
vendor/golang.org/x/sys/unix/ztypes_freebsd_amd64.go +1
@@ -630,6 +630,7 @@ const (
630 POLLRDNORM = 0x40 630 POLLRDNORM = 0x40
631 POLLWRBAND = 0x100 631 POLLWRBAND = 0x100
632 POLLWRNORM = 0x4 632 POLLWRNORM = 0x4
633 POLLRDHUP = 0x4000
633) 634)
634 635
635type CapRights struct { 636type CapRights struct {
vendor/golang.org/x/sys/unix/ztypes_freebsd_arm.go +1
@@ -616,6 +616,7 @@ const (
616 POLLRDNORM = 0x40 616 POLLRDNORM = 0x40
617 POLLWRBAND = 0x100 617 POLLWRBAND = 0x100
618 POLLWRNORM = 0x4 618 POLLWRNORM = 0x4
619 POLLRDHUP = 0x4000
619) 620)
620 621
621type CapRights struct { 622type CapRights struct {
vendor/golang.org/x/sys/unix/ztypes_freebsd_arm64.go +1
@@ -610,6 +610,7 @@ const (
610 POLLRDNORM = 0x40 610 POLLRDNORM = 0x40
611 POLLWRBAND = 0x100 611 POLLWRBAND = 0x100
612 POLLWRNORM = 0x4 612 POLLWRNORM = 0x4
613 POLLRDHUP = 0x4000
613) 614)
614 615
615type CapRights struct { 616type CapRights struct {
vendor/golang.org/x/sys/unix/ztypes_freebsd_riscv64.go +1
@@ -612,6 +612,7 @@ const (
612 POLLRDNORM = 0x40 612 POLLRDNORM = 0x40
613 POLLWRBAND = 0x100 613 POLLWRBAND = 0x100
614 POLLWRNORM = 0x4 614 POLLWRNORM = 0x4
615 POLLRDHUP = 0x4000
615) 616)
616 617
617type CapRights struct { 618type CapRights struct {
vendor/golang.org/x/sys/unix/ztypes_linux.go +184 −44
@@ -87,31 +87,35 @@ type StatxTimestamp struct {
87} 87}
88 88
89type Statx_t struct { 89type Statx_t struct {
90 Mask uint32 90 Mask uint32
91 Blksize uint32 91 Blksize uint32
92 Attributes uint64 92 Attributes uint64
93 Nlink uint32 93 Nlink uint32
94 Uid uint32 94 Uid uint32
95 Gid uint32 95 Gid uint32
96 Mode uint16 96 Mode uint16
97 _ [1]uint16 97 _ [1]uint16
98 Ino uint64 98 Ino uint64
99 Size uint64 99 Size uint64
100 Blocks uint64 100 Blocks uint64
101 Attributes_mask uint64 101 Attributes_mask uint64
102 Atime StatxTimestamp 102 Atime StatxTimestamp
103 Btime StatxTimestamp 103 Btime StatxTimestamp
104 Ctime StatxTimestamp 104 Ctime StatxTimestamp
105 Mtime StatxTimestamp 105 Mtime StatxTimestamp
106 Rdev_major uint32 106 Rdev_major uint32
107 Rdev_minor uint32 107 Rdev_minor uint32
108 Dev_major uint32 108 Dev_major uint32
109 Dev_minor uint32 109 Dev_minor uint32
110 Mnt_id uint64 110 Mnt_id uint64
111 Dio_mem_align uint32 111 Dio_mem_align uint32
112 Dio_offset_align uint32 112 Dio_offset_align uint32
113 Subvol uint64 113 Subvol uint64
114 _ [11]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
115} 119}
116 120
117type Fsid struct { 121type Fsid struct {
@@ -516,6 +520,29 @@ type TCPInfo struct {
516 Total_rto_time uint32 520 Total_rto_time uint32
517} 521}
518 522
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
519type CanFilter struct { 546type CanFilter struct {
520 Id uint32 547 Id uint32
521 Mask uint32 548 Mask uint32
@@ -557,6 +584,7 @@ const (
557 SizeofICMPv6Filter = 0x20 584 SizeofICMPv6Filter = 0x20
558 SizeofUcred = 0xc 585 SizeofUcred = 0xc
559 SizeofTCPInfo = 0xf8 586 SizeofTCPInfo = 0xf8
587 SizeofTCPCCInfo = 0x14
560 SizeofCanFilter = 0x8 588 SizeofCanFilter = 0x8
561 SizeofTCPRepairOpt = 0x8 589 SizeofTCPRepairOpt = 0x8
562) 590)
@@ -1724,12 +1752,6 @@ const (
1724 IFLA_IPVLAN_UNSPEC = 0x0 1752 IFLA_IPVLAN_UNSPEC = 0x0
1725 IFLA_IPVLAN_MODE = 0x1 1753 IFLA_IPVLAN_MODE = 0x1
1726 IFLA_IPVLAN_FLAGS = 0x2 1754 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
1733 IFLA_NETKIT_UNSPEC = 0x0 1755 IFLA_NETKIT_UNSPEC = 0x0
1734 IFLA_NETKIT_PEER_INFO = 0x1 1756 IFLA_NETKIT_PEER_INFO = 0x1
1735 IFLA_NETKIT_PRIMARY = 0x2 1757 IFLA_NETKIT_PRIMARY = 0x2
@@ -1768,6 +1790,7 @@ const (
1768 IFLA_VXLAN_DF = 0x1d 1790 IFLA_VXLAN_DF = 0x1d
1769 IFLA_VXLAN_VNIFILTER = 0x1e 1791 IFLA_VXLAN_VNIFILTER = 0x1e
1770 IFLA_VXLAN_LOCALBYPASS = 0x1f 1792 IFLA_VXLAN_LOCALBYPASS = 0x1f
1793 IFLA_VXLAN_LABEL_POLICY = 0x20
1771 IFLA_GENEVE_UNSPEC = 0x0 1794 IFLA_GENEVE_UNSPEC = 0x0
1772 IFLA_GENEVE_ID = 0x1 1795 IFLA_GENEVE_ID = 0x1
1773 IFLA_GENEVE_REMOTE = 0x2 1796 IFLA_GENEVE_REMOTE = 0x2
@@ -1797,6 +1820,8 @@ const (
1797 IFLA_GTP_ROLE = 0x4 1820 IFLA_GTP_ROLE = 0x4
1798 IFLA_GTP_CREATE_SOCKETS = 0x5 1821 IFLA_GTP_CREATE_SOCKETS = 0x5
1799 IFLA_GTP_RESTART_COUNT = 0x6 1822 IFLA_GTP_RESTART_COUNT = 0x6
1823 IFLA_GTP_LOCAL = 0x7
1824 IFLA_GTP_LOCAL6 = 0x8
1800 IFLA_BOND_UNSPEC = 0x0 1825 IFLA_BOND_UNSPEC = 0x0
1801 IFLA_BOND_MODE = 0x1 1826 IFLA_BOND_MODE = 0x1
1802 IFLA_BOND_ACTIVE_SLAVE = 0x2 1827 IFLA_BOND_ACTIVE_SLAVE = 0x2
@@ -1829,6 +1854,7 @@ const (
1829 IFLA_BOND_AD_LACP_ACTIVE = 0x1d 1854 IFLA_BOND_AD_LACP_ACTIVE = 0x1d
1830 IFLA_BOND_MISSED_MAX = 0x1e 1855 IFLA_BOND_MISSED_MAX = 0x1e
1831 IFLA_BOND_NS_IP6_TARGET = 0x1f 1856 IFLA_BOND_NS_IP6_TARGET = 0x1f
1857 IFLA_BOND_COUPLED_CONTROL = 0x20
1832 IFLA_BOND_AD_INFO_UNSPEC = 0x0 1858 IFLA_BOND_AD_INFO_UNSPEC = 0x0
1833 IFLA_BOND_AD_INFO_AGGREGATOR = 0x1 1859 IFLA_BOND_AD_INFO_AGGREGATOR = 0x1
1834 IFLA_BOND_AD_INFO_NUM_PORTS = 0x2 1860 IFLA_BOND_AD_INFO_NUM_PORTS = 0x2
@@ -1897,6 +1923,7 @@ const (
1897 IFLA_HSR_SEQ_NR = 0x5 1923 IFLA_HSR_SEQ_NR = 0x5
1898 IFLA_HSR_VERSION = 0x6 1924 IFLA_HSR_VERSION = 0x6
1899 IFLA_HSR_PROTOCOL = 0x7 1925 IFLA_HSR_PROTOCOL = 0x7
1926 IFLA_HSR_INTERLINK = 0x8
1900 IFLA_STATS_UNSPEC = 0x0 1927 IFLA_STATS_UNSPEC = 0x0
1901 IFLA_STATS_LINK_64 = 0x1 1928 IFLA_STATS_LINK_64 = 0x1
1902 IFLA_STATS_LINK_XSTATS = 0x2 1929 IFLA_STATS_LINK_XSTATS = 0x2
@@ -1949,6 +1976,15 @@ const (
1949 IFLA_DSA_MASTER = 0x1 1976 IFLA_DSA_MASTER = 0x1
1950) 1977)
1951 1978
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
1952const ( 1988const (
1953 NF_INET_PRE_ROUTING = 0x0 1989 NF_INET_PRE_ROUTING = 0x0
1954 NF_INET_LOCAL_IN = 0x1 1990 NF_INET_LOCAL_IN = 0x1
@@ -2486,7 +2522,7 @@ type XDPMmapOffsets struct {
2486type XDPUmemReg struct { 2522type XDPUmemReg struct {
2487 Addr uint64 2523 Addr uint64
2488 Len uint64 2524 Len uint64
2489 Chunk_size uint32 2525 Size uint32
2490 Headroom uint32 2526 Headroom uint32
2491 Flags uint32 2527 Flags uint32
2492 Tx_metadata_len uint32 2528 Tx_metadata_len uint32
@@ -2558,8 +2594,8 @@ const (
2558 SOF_TIMESTAMPING_BIND_PHC = 0x8000 2594 SOF_TIMESTAMPING_BIND_PHC = 0x8000
2559 SOF_TIMESTAMPING_OPT_ID_TCP = 0x10000 2595 SOF_TIMESTAMPING_OPT_ID_TCP = 0x10000
2560 2596
2561 SOF_TIMESTAMPING_LAST = 0x10000 2597 SOF_TIMESTAMPING_LAST = 0x20000
2562 SOF_TIMESTAMPING_MASK = 0x1ffff 2598 SOF_TIMESTAMPING_MASK = 0x3ffff
2563 2599
2564 SCM_TSTAMP_SND = 0x0 2600 SCM_TSTAMP_SND = 0x0
2565 SCM_TSTAMP_SCHED = 0x1 2601 SCM_TSTAMP_SCHED = 0x1
@@ -3505,7 +3541,7 @@ type Nhmsg struct {
3505type NexthopGrp struct { 3541type NexthopGrp struct {
3506 Id uint32 3542 Id uint32
3507 Weight uint8 3543 Weight uint8
3508 Resvd1 uint8 3544 High uint8
3509 Resvd2 uint16 3545 Resvd2 uint16
3510} 3546}
3511 3547
@@ -3766,7 +3802,7 @@ const (
3766 ETHTOOL_MSG_PSE_GET = 0x24 3802 ETHTOOL_MSG_PSE_GET = 0x24
3767 ETHTOOL_MSG_PSE_SET = 0x25 3803 ETHTOOL_MSG_PSE_SET = 0x25
3768 ETHTOOL_MSG_RSS_GET = 0x26 3804 ETHTOOL_MSG_RSS_GET = 0x26
3769 ETHTOOL_MSG_USER_MAX = 0x2b 3805 ETHTOOL_MSG_USER_MAX = 0x2d
3770 ETHTOOL_MSG_KERNEL_NONE = 0x0 3806 ETHTOOL_MSG_KERNEL_NONE = 0x0
3771 ETHTOOL_MSG_STRSET_GET_REPLY = 0x1 3807 ETHTOOL_MSG_STRSET_GET_REPLY = 0x1
3772 ETHTOOL_MSG_LINKINFO_GET_REPLY = 0x2 3808 ETHTOOL_MSG_LINKINFO_GET_REPLY = 0x2
@@ -3806,7 +3842,7 @@ const (
3806 ETHTOOL_MSG_MODULE_NTF = 0x24 3842 ETHTOOL_MSG_MODULE_NTF = 0x24
3807 ETHTOOL_MSG_PSE_GET_REPLY = 0x25 3843 ETHTOOL_MSG_PSE_GET_REPLY = 0x25
3808 ETHTOOL_MSG_RSS_GET_REPLY = 0x26 3844 ETHTOOL_MSG_RSS_GET_REPLY = 0x26
3809 ETHTOOL_MSG_KERNEL_MAX = 0x2b 3845 ETHTOOL_MSG_KERNEL_MAX = 0x2e
3810 ETHTOOL_FLAG_COMPACT_BITSETS = 0x1 3846 ETHTOOL_FLAG_COMPACT_BITSETS = 0x1
3811 ETHTOOL_FLAG_OMIT_REPLY = 0x2 3847 ETHTOOL_FLAG_OMIT_REPLY = 0x2
3812 ETHTOOL_FLAG_STATS = 0x4 3848 ETHTOOL_FLAG_STATS = 0x4
@@ -3814,7 +3850,7 @@ const (
3814 ETHTOOL_A_HEADER_DEV_INDEX = 0x1 3850 ETHTOOL_A_HEADER_DEV_INDEX = 0x1
3815 ETHTOOL_A_HEADER_DEV_NAME = 0x2 3851 ETHTOOL_A_HEADER_DEV_NAME = 0x2
3816 ETHTOOL_A_HEADER_FLAGS = 0x3 3852 ETHTOOL_A_HEADER_FLAGS = 0x3
3817 ETHTOOL_A_HEADER_MAX = 0x3 3853 ETHTOOL_A_HEADER_MAX = 0x4
3818 ETHTOOL_A_BITSET_BIT_UNSPEC = 0x0 3854 ETHTOOL_A_BITSET_BIT_UNSPEC = 0x0
3819 ETHTOOL_A_BITSET_BIT_INDEX = 0x1 3855 ETHTOOL_A_BITSET_BIT_INDEX = 0x1
3820 ETHTOOL_A_BITSET_BIT_NAME = 0x2 3856 ETHTOOL_A_BITSET_BIT_NAME = 0x2
@@ -3951,7 +3987,7 @@ const (
3951 ETHTOOL_A_COALESCE_RATE_SAMPLE_INTERVAL = 0x17 3987 ETHTOOL_A_COALESCE_RATE_SAMPLE_INTERVAL = 0x17
3952 ETHTOOL_A_COALESCE_USE_CQE_MODE_TX = 0x18 3988 ETHTOOL_A_COALESCE_USE_CQE_MODE_TX = 0x18
3953 ETHTOOL_A_COALESCE_USE_CQE_MODE_RX = 0x19 3989 ETHTOOL_A_COALESCE_USE_CQE_MODE_RX = 0x19
3954 ETHTOOL_A_COALESCE_MAX = 0x1c 3990 ETHTOOL_A_COALESCE_MAX = 0x1e
3955 ETHTOOL_A_PAUSE_UNSPEC = 0x0 3991 ETHTOOL_A_PAUSE_UNSPEC = 0x0
3956 ETHTOOL_A_PAUSE_HEADER = 0x1 3992 ETHTOOL_A_PAUSE_HEADER = 0x1
3957 ETHTOOL_A_PAUSE_AUTONEG = 0x2 3993 ETHTOOL_A_PAUSE_AUTONEG = 0x2
@@ -3995,11 +4031,11 @@ const (
3995 ETHTOOL_A_CABLE_RESULT_UNSPEC = 0x0 4031 ETHTOOL_A_CABLE_RESULT_UNSPEC = 0x0
3996 ETHTOOL_A_CABLE_RESULT_PAIR = 0x1 4032 ETHTOOL_A_CABLE_RESULT_PAIR = 0x1
3997 ETHTOOL_A_CABLE_RESULT_CODE = 0x2 4033 ETHTOOL_A_CABLE_RESULT_CODE = 0x2
3998 ETHTOOL_A_CABLE_RESULT_MAX = 0x2 4034 ETHTOOL_A_CABLE_RESULT_MAX = 0x3
3999 ETHTOOL_A_CABLE_FAULT_LENGTH_UNSPEC = 0x0 4035 ETHTOOL_A_CABLE_FAULT_LENGTH_UNSPEC = 0x0
4000 ETHTOOL_A_CABLE_FAULT_LENGTH_PAIR = 0x1 4036 ETHTOOL_A_CABLE_FAULT_LENGTH_PAIR = 0x1
4001 ETHTOOL_A_CABLE_FAULT_LENGTH_CM = 0x2 4037 ETHTOOL_A_CABLE_FAULT_LENGTH_CM = 0x2
4002 ETHTOOL_A_CABLE_FAULT_LENGTH_MAX = 0x2 4038 ETHTOOL_A_CABLE_FAULT_LENGTH_MAX = 0x3
4003 ETHTOOL_A_CABLE_TEST_NTF_STATUS_UNSPEC = 0x0 4039 ETHTOOL_A_CABLE_TEST_NTF_STATUS_UNSPEC = 0x0
4004 ETHTOOL_A_CABLE_TEST_NTF_STATUS_STARTED = 0x1 4040 ETHTOOL_A_CABLE_TEST_NTF_STATUS_STARTED = 0x1
4005 ETHTOOL_A_CABLE_TEST_NTF_STATUS_COMPLETED = 0x2 4041 ETHTOOL_A_CABLE_TEST_NTF_STATUS_COMPLETED = 0x2
@@ -4082,6 +4118,107 @@ type EthtoolDrvinfo struct {
4082 Regdump_len uint32 4118 Regdump_len uint32
4083} 4119}
4084 4120
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
4085type ( 4222type (
4086 HIDRawReportDescriptor struct { 4223 HIDRawReportDescriptor struct {
4087 Size uint32 4224 Size uint32
@@ -4263,6 +4400,7 @@ const (
4263type LandlockRulesetAttr struct { 4400type LandlockRulesetAttr struct {
4264 Access_fs uint64 4401 Access_fs uint64
4265 Access_net uint64 4402 Access_net uint64
4403 Scoped uint64
4266} 4404}
4267 4405
4268type LandlockPathBeneathAttr struct { 4406type LandlockPathBeneathAttr struct {
@@ -4609,7 +4747,7 @@ const (
4609 NL80211_ATTR_MAC_HINT = 0xc8 4747 NL80211_ATTR_MAC_HINT = 0xc8
4610 NL80211_ATTR_MAC_MASK = 0xd7 4748 NL80211_ATTR_MAC_MASK = 0xd7
4611 NL80211_ATTR_MAX_AP_ASSOC_STA = 0xca 4749 NL80211_ATTR_MAX_AP_ASSOC_STA = 0xca
4612 NL80211_ATTR_MAX = 0x14a 4750 NL80211_ATTR_MAX = 0x14d
4613 NL80211_ATTR_MAX_CRIT_PROT_DURATION = 0xb4 4751 NL80211_ATTR_MAX_CRIT_PROT_DURATION = 0xb4
4614 NL80211_ATTR_MAX_CSA_COUNTERS = 0xce 4752 NL80211_ATTR_MAX_CSA_COUNTERS = 0xce
4615 NL80211_ATTR_MAX_MATCH_SETS = 0x85 4753 NL80211_ATTR_MAX_MATCH_SETS = 0x85
@@ -5213,7 +5351,7 @@ const (
5213 NL80211_FREQUENCY_ATTR_GO_CONCURRENT = 0xf 5351 NL80211_FREQUENCY_ATTR_GO_CONCURRENT = 0xf
5214 NL80211_FREQUENCY_ATTR_INDOOR_ONLY = 0xe 5352 NL80211_FREQUENCY_ATTR_INDOOR_ONLY = 0xe
5215 NL80211_FREQUENCY_ATTR_IR_CONCURRENT = 0xf 5353 NL80211_FREQUENCY_ATTR_IR_CONCURRENT = 0xf
5216 NL80211_FREQUENCY_ATTR_MAX = 0x20 5354 NL80211_FREQUENCY_ATTR_MAX = 0x21
5217 NL80211_FREQUENCY_ATTR_MAX_TX_POWER = 0x6 5355 NL80211_FREQUENCY_ATTR_MAX_TX_POWER = 0x6
5218 NL80211_FREQUENCY_ATTR_NO_10MHZ = 0x11 5356 NL80211_FREQUENCY_ATTR_NO_10MHZ = 0x11
5219 NL80211_FREQUENCY_ATTR_NO_160MHZ = 0xc 5357 NL80211_FREQUENCY_ATTR_NO_160MHZ = 0xc
@@ -5381,7 +5519,7 @@ const (
5381 NL80211_MNTR_FLAG_CONTROL = 0x3 5519 NL80211_MNTR_FLAG_CONTROL = 0x3
5382 NL80211_MNTR_FLAG_COOK_FRAMES = 0x5 5520 NL80211_MNTR_FLAG_COOK_FRAMES = 0x5
5383 NL80211_MNTR_FLAG_FCSFAIL = 0x1 5521 NL80211_MNTR_FLAG_FCSFAIL = 0x1
5384 NL80211_MNTR_FLAG_MAX = 0x6 5522 NL80211_MNTR_FLAG_MAX = 0x7
5385 NL80211_MNTR_FLAG_OTHER_BSS = 0x4 5523 NL80211_MNTR_FLAG_OTHER_BSS = 0x4
5386 NL80211_MNTR_FLAG_PLCPFAIL = 0x2 5524 NL80211_MNTR_FLAG_PLCPFAIL = 0x2
5387 NL80211_MPATH_FLAG_ACTIVE = 0x1 5525 NL80211_MPATH_FLAG_ACTIVE = 0x1
@@ -6036,3 +6174,5 @@ type SockDiagReq struct {
6036 Family uint8 6174 Family uint8
6037 Protocol uint8 6175 Protocol uint8
6038} 6176}
6177
6178const RTM_NEWNVLAN = 0x70
vendor/golang.org/x/sys/unix/ztypes_linux_riscv64.go +33
@@ -727,6 +727,37 @@ const (
727 RISCV_HWPROBE_EXT_ZBA = 0x8 727 RISCV_HWPROBE_EXT_ZBA = 0x8
728 RISCV_HWPROBE_EXT_ZBB = 0x10 728 RISCV_HWPROBE_EXT_ZBB = 0x10
729 RISCV_HWPROBE_EXT_ZBS = 0x20 729 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
730 RISCV_HWPROBE_KEY_CPUPERF_0 = 0x5 761 RISCV_HWPROBE_KEY_CPUPERF_0 = 0x5
731 RISCV_HWPROBE_MISALIGNED_UNKNOWN = 0x0 762 RISCV_HWPROBE_MISALIGNED_UNKNOWN = 0x0
732 RISCV_HWPROBE_MISALIGNED_EMULATED = 0x1 763 RISCV_HWPROBE_MISALIGNED_EMULATED = 0x1
@@ -734,4 +765,6 @@ const (
734 RISCV_HWPROBE_MISALIGNED_FAST = 0x3 765 RISCV_HWPROBE_MISALIGNED_FAST = 0x3
735 RISCV_HWPROBE_MISALIGNED_UNSUPPORTED = 0x4 766 RISCV_HWPROBE_MISALIGNED_UNSUPPORTED = 0x4
736 RISCV_HWPROBE_MISALIGNED_MASK = 0x7 767 RISCV_HWPROBE_MISALIGNED_MASK = 0x7
768 RISCV_HWPROBE_KEY_ZICBOZ_BLOCK_SIZE = 0x6
769 RISCV_HWPROBE_WHICH_CPUS = 0x1
737) 770)
vendor/golang.org/x/sys/unix/ztypes_zos_s390x.go +6
@@ -377,6 +377,12 @@ type Flock_t struct {
377 Pid int32 377 Pid int32
378} 378}
379 379
380type F_cnvrt struct {
381 Cvtcmd int32
382 Pccsid int16
383 Fccsid int16
384}
385
380type Termios struct { 386type Termios struct {
381 Cflag uint32 387 Cflag uint32
382 Iflag uint32 388 Iflag uint32
vendor/golang.org/x/sys/windows/dll_windows.go +6 −7
@@ -43,8 +43,8 @@ type DLL struct {
43// LoadDLL loads DLL file into memory. 43// LoadDLL loads DLL file into memory.
44// 44//
45// Warning: using LoadDLL without an absolute path name is subject to 45// Warning: using LoadDLL without an absolute path name is subject to
46// DLL preloading attacks. To safely load a system DLL, use LazyDLL 46// DLL preloading attacks. To safely load a system DLL, use [NewLazySystemDLL],
47// with System set to true, or use LoadLibraryEx directly. 47// or use [LoadLibraryEx] directly.
48func LoadDLL(name string) (dll *DLL, err error) { 48func LoadDLL(name string) (dll *DLL, err error) {
49 namep, err := UTF16PtrFromString(name) 49 namep, err := UTF16PtrFromString(name)
50 if err != nil { 50 if err != nil {
@@ -65,7 +65,7 @@ func LoadDLL(name string) (dll *DLL, err error) {
65 return d, nil 65 return d, nil
66} 66}
67 67
68// MustLoadDLL is like LoadDLL but panics if load operation failes. 68// MustLoadDLL is like LoadDLL but panics if load operation fails.
69func MustLoadDLL(name string) *DLL { 69func MustLoadDLL(name string) *DLL {
70 d, e := LoadDLL(name) 70 d, e := LoadDLL(name)
71 if e != nil { 71 if e != nil {
@@ -271,6 +271,9 @@ func (d *LazyDLL) NewProc(name string) *LazyProc {
271} 271}
272 272
273// NewLazyDLL creates new LazyDLL associated with DLL file. 273// 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].
274func NewLazyDLL(name string) *LazyDLL { 277func NewLazyDLL(name string) *LazyDLL {
275 return &LazyDLL{Name: name} 278 return &LazyDLL{Name: name}
276} 279}
@@ -410,7 +413,3 @@ func loadLibraryEx(name string, system bool) (*DLL, error) {
410 } 413 }
411 return &DLL{Name: name, Handle: h}, nil 414 return &DLL{Name: name, Handle: h}, nil
412} 415}
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 {
168//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 168//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
169//sys ConnectNamedPipe(pipe Handle, overlapped *Overlapped) (err error) 169//sys ConnectNamedPipe(pipe Handle, overlapped *Overlapped) (err error)
170//sys DisconnectNamedPipe(pipe Handle) (err error) 170//sys DisconnectNamedPipe(pipe Handle) (err error)
171//sys GetNamedPipeClientProcessId(pipe Handle, clientProcessID *uint32) (err error)
172//sys GetNamedPipeServerProcessId(pipe Handle, serverProcessID *uint32) (err error)
171//sys GetNamedPipeInfo(pipe Handle, flags *uint32, outSize *uint32, inSize *uint32, maxInstances *uint32) (err error) 173//sys GetNamedPipeInfo(pipe Handle, flags *uint32, outSize *uint32, inSize *uint32, maxInstances *uint32) (err error)
172//sys GetNamedPipeHandleState(pipe Handle, state *uint32, curInstances *uint32, maxCollectionCount *uint32, collectDataTimeout *uint32, userName *uint16, maxUserNameSize uint32) (err error) = GetNamedPipeHandleStateW 174//sys GetNamedPipeHandleState(pipe Handle, state *uint32, curInstances *uint32, maxCollectionCount *uint32, collectDataTimeout *uint32, userName *uint16, maxUserNameSize uint32) (err error) = GetNamedPipeHandleStateW
173//sys SetNamedPipeHandleState(pipe Handle, state *uint32, maxCollectionCount *uint32, collectDataTimeout *uint32) (err error) = SetNamedPipeHandleState 175//sys SetNamedPipeHandleState(pipe Handle, state *uint32, maxCollectionCount *uint32, collectDataTimeout *uint32) (err error) = SetNamedPipeHandleState
@@ -313,6 +315,10 @@ func NewCallbackCDecl(fn interface{}) uintptr {
313//sys SetConsoleMode(console Handle, mode uint32) (err error) = kernel32.SetConsoleMode 315//sys SetConsoleMode(console Handle, mode uint32) (err error) = kernel32.SetConsoleMode
314//sys GetConsoleScreenBufferInfo(console Handle, info *ConsoleScreenBufferInfo) (err error) = kernel32.GetConsoleScreenBufferInfo 316//sys GetConsoleScreenBufferInfo(console Handle, info *ConsoleScreenBufferInfo) (err error) = kernel32.GetConsoleScreenBufferInfo
315//sys setConsoleCursorPosition(console Handle, position uint32) (err error) = kernel32.SetConsoleCursorPosition 317//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
316//sys WriteConsole(console Handle, buf *uint16, towrite uint32, written *uint32, reserved *byte) (err error) = kernel32.WriteConsoleW 322//sys WriteConsole(console Handle, buf *uint16, towrite uint32, written *uint32, reserved *byte) (err error) = kernel32.WriteConsoleW
317//sys ReadConsole(console Handle, buf *uint16, toread uint32, read *uint32, inputControl *byte) (err error) = kernel32.ReadConsoleW 323//sys ReadConsole(console Handle, buf *uint16, toread uint32, read *uint32, inputControl *byte) (err error) = kernel32.ReadConsoleW
318//sys resizePseudoConsole(pconsole Handle, size uint32) (hr error) = kernel32.ResizePseudoConsole 324//sys resizePseudoConsole(pconsole Handle, size uint32) (hr error) = kernel32.ResizePseudoConsole
@@ -721,20 +727,12 @@ func DurationSinceBoot() time.Duration {
721} 727}
722 728
723func Ftruncate(fd Handle, length int64) (err error) { 729func Ftruncate(fd Handle, length int64) (err error) {
724 curoffset, e := Seek(fd, 0, 1) 730 type _FILE_END_OF_FILE_INFO struct {
725 if e != nil { 731 EndOfFile int64
726 return e
727 }
728 defer Seek(fd, curoffset, 0)
729 _, e = Seek(fd, length, 0)
730 if e != nil {
731 return e
732 } 732 }
733 e = SetEndOfFile(fd) 733 var info _FILE_END_OF_FILE_INFO
734 if e != nil { 734 info.EndOfFile = length
735 return e 735 return SetFileInformationByHandle(fd, FileEndOfFileInfo, (*byte)(unsafe.Pointer(&info)), uint32(unsafe.Sizeof(info)))
736 }
737 return nil
738} 736}
739 737
740func Gettimeofday(tv *Timeval) (err error) { 738func Gettimeofday(tv *Timeval) (err error) {
@@ -890,6 +888,11 @@ const socket_error = uintptr(^uint32(0))
890//sys GetACP() (acp uint32) = kernel32.GetACP 888//sys GetACP() (acp uint32) = kernel32.GetACP
891//sys MultiByteToWideChar(codePage uint32, dwFlags uint32, str *byte, nstr int32, wchar *uint16, nwchar int32) (nwrite int32, err error) = kernel32.MultiByteToWideChar 889//sys MultiByteToWideChar(codePage uint32, dwFlags uint32, str *byte, nstr int32, wchar *uint16, nwchar int32) (nwrite int32, err error) = kernel32.MultiByteToWideChar
892//sys getBestInterfaceEx(sockaddr unsafe.Pointer, pdwBestIfIndex *uint32) (errcode error) = iphlpapi.GetBestInterfaceEx 890//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
893 896
894// For testing: clients can set this flag to force 897// For testing: clients can set this flag to force
895// creation of IPv6 sockets to return EAFNOSUPPORT. 898// creation of IPv6 sockets to return EAFNOSUPPORT.
@@ -1681,13 +1684,16 @@ func (s NTStatus) Error() string {
1681// do not use NTUnicodeString, and instead UTF16PtrFromString should be used for 1684// do not use NTUnicodeString, and instead UTF16PtrFromString should be used for
1682// the more common *uint16 string type. 1685// the more common *uint16 string type.
1683func NewNTUnicodeString(s string) (*NTUnicodeString, error) { 1686func NewNTUnicodeString(s string) (*NTUnicodeString, error) {
1684 var u NTUnicodeString 1687 s16, err := UTF16FromString(s)
1685 s16, err := UTF16PtrFromString(s)
1686 if err != nil { 1688 if err != nil {
1687 return nil, err 1689 return nil, err
1688 } 1690 }
1689 RtlInitUnicodeString(&u, s16) 1691 n := uint16(len(s16) * 2)
1690 return &u, nil 1692 return &NTUnicodeString{
1693 Length: n - 2, // subtract 2 bytes for the NULL terminator
1694 MaximumLength: n,
1695 Buffer: &s16[0],
1696 }, nil
1691} 1697}
1692 1698
1693// Slice returns a uint16 slice that aliases the data in the NTUnicodeString. 1699// 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 (
176 WAIT_FAILED = 0xFFFFFFFF 176 WAIT_FAILED = 0xFFFFFFFF
177 177
178 // Access rights for process. 178 // Access rights for process.
179 PROCESS_ALL_ACCESS = 0xFFFF
179 PROCESS_CREATE_PROCESS = 0x0080 180 PROCESS_CREATE_PROCESS = 0x0080
180 PROCESS_CREATE_THREAD = 0x0002 181 PROCESS_CREATE_THREAD = 0x0002
181 PROCESS_DUP_HANDLE = 0x0040 182 PROCESS_DUP_HANDLE = 0x0040
@@ -1060,6 +1061,7 @@ const (
1060 SIO_GET_EXTENSION_FUNCTION_POINTER = IOC_INOUT | IOC_WS2 | 6 1061 SIO_GET_EXTENSION_FUNCTION_POINTER = IOC_INOUT | IOC_WS2 | 6
1061 SIO_KEEPALIVE_VALS = IOC_IN | IOC_VENDOR | 4 1062 SIO_KEEPALIVE_VALS = IOC_IN | IOC_VENDOR | 4
1062 SIO_UDP_CONNRESET = IOC_IN | IOC_VENDOR | 12 1063 SIO_UDP_CONNRESET = IOC_IN | IOC_VENDOR | 12
1064 SIO_UDP_NETRESET = IOC_IN | IOC_VENDOR | 15
1063 1065
1064 // cf. http://support.microsoft.com/default.aspx?scid=kb;en-us;257460 1066 // cf. http://support.microsoft.com/default.aspx?scid=kb;en-us;257460
1065 1067
@@ -2202,6 +2204,132 @@ const (
2202 IfOperStatusLowerLayerDown = 7 2204 IfOperStatusLowerLayerDown = 7
2203) 2205)
2204 2206
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
2205// Console related constants used for the mode parameter to SetConsoleMode. See 2333// Console related constants used for the mode parameter to SetConsoleMode. See
2206// https://docs.microsoft.com/en-us/windows/console/setconsolemode for details. 2334// https://docs.microsoft.com/en-us/windows/console/setconsolemode for details.
2207 2335
vendor/golang.org/x/sys/windows/zsyscall_windows.go +109
@@ -181,10 +181,15 @@ var (
181 procDnsRecordListFree = moddnsapi.NewProc("DnsRecordListFree") 181 procDnsRecordListFree = moddnsapi.NewProc("DnsRecordListFree")
182 procDwmGetWindowAttribute = moddwmapi.NewProc("DwmGetWindowAttribute") 182 procDwmGetWindowAttribute = moddwmapi.NewProc("DwmGetWindowAttribute")
183 procDwmSetWindowAttribute = moddwmapi.NewProc("DwmSetWindowAttribute") 183 procDwmSetWindowAttribute = moddwmapi.NewProc("DwmSetWindowAttribute")
184 procCancelMibChangeNotify2 = modiphlpapi.NewProc("CancelMibChangeNotify2")
184 procGetAdaptersAddresses = modiphlpapi.NewProc("GetAdaptersAddresses") 185 procGetAdaptersAddresses = modiphlpapi.NewProc("GetAdaptersAddresses")
185 procGetAdaptersInfo = modiphlpapi.NewProc("GetAdaptersInfo") 186 procGetAdaptersInfo = modiphlpapi.NewProc("GetAdaptersInfo")
186 procGetBestInterfaceEx = modiphlpapi.NewProc("GetBestInterfaceEx") 187 procGetBestInterfaceEx = modiphlpapi.NewProc("GetBestInterfaceEx")
187 procGetIfEntry = modiphlpapi.NewProc("GetIfEntry") 188 procGetIfEntry = modiphlpapi.NewProc("GetIfEntry")
189 procGetIfEntry2Ex = modiphlpapi.NewProc("GetIfEntry2Ex")
190 procGetUnicastIpAddressEntry = modiphlpapi.NewProc("GetUnicastIpAddressEntry")
191 procNotifyIpInterfaceChange = modiphlpapi.NewProc("NotifyIpInterfaceChange")
192 procNotifyUnicastIpAddressChange = modiphlpapi.NewProc("NotifyUnicastIpAddressChange")
188 procAddDllDirectory = modkernel32.NewProc("AddDllDirectory") 193 procAddDllDirectory = modkernel32.NewProc("AddDllDirectory")
189 procAssignProcessToJobObject = modkernel32.NewProc("AssignProcessToJobObject") 194 procAssignProcessToJobObject = modkernel32.NewProc("AssignProcessToJobObject")
190 procCancelIo = modkernel32.NewProc("CancelIo") 195 procCancelIo = modkernel32.NewProc("CancelIo")
@@ -247,7 +252,9 @@ var (
247 procGetCommandLineW = modkernel32.NewProc("GetCommandLineW") 252 procGetCommandLineW = modkernel32.NewProc("GetCommandLineW")
248 procGetComputerNameExW = modkernel32.NewProc("GetComputerNameExW") 253 procGetComputerNameExW = modkernel32.NewProc("GetComputerNameExW")
249 procGetComputerNameW = modkernel32.NewProc("GetComputerNameW") 254 procGetComputerNameW = modkernel32.NewProc("GetComputerNameW")
255 procGetConsoleCP = modkernel32.NewProc("GetConsoleCP")
250 procGetConsoleMode = modkernel32.NewProc("GetConsoleMode") 256 procGetConsoleMode = modkernel32.NewProc("GetConsoleMode")
257 procGetConsoleOutputCP = modkernel32.NewProc("GetConsoleOutputCP")
251 procGetConsoleScreenBufferInfo = modkernel32.NewProc("GetConsoleScreenBufferInfo") 258 procGetConsoleScreenBufferInfo = modkernel32.NewProc("GetConsoleScreenBufferInfo")
252 procGetCurrentDirectoryW = modkernel32.NewProc("GetCurrentDirectoryW") 259 procGetCurrentDirectoryW = modkernel32.NewProc("GetCurrentDirectoryW")
253 procGetCurrentProcessId = modkernel32.NewProc("GetCurrentProcessId") 260 procGetCurrentProcessId = modkernel32.NewProc("GetCurrentProcessId")
@@ -273,8 +280,10 @@ var (
273 procGetMaximumProcessorCount = modkernel32.NewProc("GetMaximumProcessorCount") 280 procGetMaximumProcessorCount = modkernel32.NewProc("GetMaximumProcessorCount")
274 procGetModuleFileNameW = modkernel32.NewProc("GetModuleFileNameW") 281 procGetModuleFileNameW = modkernel32.NewProc("GetModuleFileNameW")
275 procGetModuleHandleExW = modkernel32.NewProc("GetModuleHandleExW") 282 procGetModuleHandleExW = modkernel32.NewProc("GetModuleHandleExW")
283 procGetNamedPipeClientProcessId = modkernel32.NewProc("GetNamedPipeClientProcessId")
276 procGetNamedPipeHandleStateW = modkernel32.NewProc("GetNamedPipeHandleStateW") 284 procGetNamedPipeHandleStateW = modkernel32.NewProc("GetNamedPipeHandleStateW")
277 procGetNamedPipeInfo = modkernel32.NewProc("GetNamedPipeInfo") 285 procGetNamedPipeInfo = modkernel32.NewProc("GetNamedPipeInfo")
286 procGetNamedPipeServerProcessId = modkernel32.NewProc("GetNamedPipeServerProcessId")
278 procGetOverlappedResult = modkernel32.NewProc("GetOverlappedResult") 287 procGetOverlappedResult = modkernel32.NewProc("GetOverlappedResult")
279 procGetPriorityClass = modkernel32.NewProc("GetPriorityClass") 288 procGetPriorityClass = modkernel32.NewProc("GetPriorityClass")
280 procGetProcAddress = modkernel32.NewProc("GetProcAddress") 289 procGetProcAddress = modkernel32.NewProc("GetProcAddress")
@@ -347,8 +356,10 @@ var (
347 procSetCommMask = modkernel32.NewProc("SetCommMask") 356 procSetCommMask = modkernel32.NewProc("SetCommMask")
348 procSetCommState = modkernel32.NewProc("SetCommState") 357 procSetCommState = modkernel32.NewProc("SetCommState")
349 procSetCommTimeouts = modkernel32.NewProc("SetCommTimeouts") 358 procSetCommTimeouts = modkernel32.NewProc("SetCommTimeouts")
359 procSetConsoleCP = modkernel32.NewProc("SetConsoleCP")
350 procSetConsoleCursorPosition = modkernel32.NewProc("SetConsoleCursorPosition") 360 procSetConsoleCursorPosition = modkernel32.NewProc("SetConsoleCursorPosition")
351 procSetConsoleMode = modkernel32.NewProc("SetConsoleMode") 361 procSetConsoleMode = modkernel32.NewProc("SetConsoleMode")
362 procSetConsoleOutputCP = modkernel32.NewProc("SetConsoleOutputCP")
352 procSetCurrentDirectoryW = modkernel32.NewProc("SetCurrentDirectoryW") 363 procSetCurrentDirectoryW = modkernel32.NewProc("SetCurrentDirectoryW")
353 procSetDefaultDllDirectories = modkernel32.NewProc("SetDefaultDllDirectories") 364 procSetDefaultDllDirectories = modkernel32.NewProc("SetDefaultDllDirectories")
354 procSetDllDirectoryW = modkernel32.NewProc("SetDllDirectoryW") 365 procSetDllDirectoryW = modkernel32.NewProc("SetDllDirectoryW")
@@ -1602,6 +1613,14 @@ func DwmSetWindowAttribute(hwnd HWND, attribute uint32, value unsafe.Pointer, si
1602 return 1613 return
1603} 1614}
1604 1615
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
1605func GetAdaptersAddresses(family uint32, flags uint32, reserved uintptr, adapterAddresses *IpAdapterAddresses, sizePointer *uint32) (errcode error) { 1624func GetAdaptersAddresses(family uint32, flags uint32, reserved uintptr, adapterAddresses *IpAdapterAddresses, sizePointer *uint32) (errcode error) {
1606 r0, _, _ := syscall.Syscall6(procGetAdaptersAddresses.Addr(), 5, uintptr(family), uintptr(flags), uintptr(reserved), uintptr(unsafe.Pointer(adapterAddresses)), uintptr(unsafe.Pointer(sizePointer)), 0) 1625 r0, _, _ := syscall.Syscall6(procGetAdaptersAddresses.Addr(), 5, uintptr(family), uintptr(flags), uintptr(reserved), uintptr(unsafe.Pointer(adapterAddresses)), uintptr(unsafe.Pointer(sizePointer)), 0)
1607 if r0 != 0 { 1626 if r0 != 0 {
@@ -1634,6 +1653,46 @@ func GetIfEntry(pIfRow *MibIfRow) (errcode error) {
1634 return 1653 return
1635} 1654}
1636 1655
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
1637func AddDllDirectory(path *uint16) (cookie uintptr, err error) { 1696func AddDllDirectory(path *uint16) (cookie uintptr, err error) {
1638 r0, _, e1 := syscall.Syscall(procAddDllDirectory.Addr(), 1, uintptr(unsafe.Pointer(path)), 0, 0) 1697 r0, _, e1 := syscall.Syscall(procAddDllDirectory.Addr(), 1, uintptr(unsafe.Pointer(path)), 0, 0)
1639 cookie = uintptr(r0) 1698 cookie = uintptr(r0)
@@ -2162,6 +2221,15 @@ func GetComputerName(buf *uint16, n *uint32) (err error) {
2162 return 2221 return
2163} 2222}
2164 2223
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
2165func GetConsoleMode(console Handle, mode *uint32) (err error) { 2233func GetConsoleMode(console Handle, mode *uint32) (err error) {
2166 r1, _, e1 := syscall.Syscall(procGetConsoleMode.Addr(), 2, uintptr(console), uintptr(unsafe.Pointer(mode)), 0) 2234 r1, _, e1 := syscall.Syscall(procGetConsoleMode.Addr(), 2, uintptr(console), uintptr(unsafe.Pointer(mode)), 0)
2167 if r1 == 0 { 2235 if r1 == 0 {
@@ -2170,6 +2238,15 @@ func GetConsoleMode(console Handle, mode *uint32) (err error) {
2170 return 2238 return
2171} 2239}
2172 2240
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
2173func GetConsoleScreenBufferInfo(console Handle, info *ConsoleScreenBufferInfo) (err error) { 2250func GetConsoleScreenBufferInfo(console Handle, info *ConsoleScreenBufferInfo) (err error) {
2174 r1, _, e1 := syscall.Syscall(procGetConsoleScreenBufferInfo.Addr(), 2, uintptr(console), uintptr(unsafe.Pointer(info)), 0) 2251 r1, _, e1 := syscall.Syscall(procGetConsoleScreenBufferInfo.Addr(), 2, uintptr(console), uintptr(unsafe.Pointer(info)), 0)
2175 if r1 == 0 { 2252 if r1 == 0 {
@@ -2371,6 +2448,14 @@ func GetModuleHandleEx(flags uint32, moduleName *uint16, module *Handle) (err er
2371 return 2448 return
2372} 2449}
2373 2450
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
2374func GetNamedPipeHandleState(pipe Handle, state *uint32, curInstances *uint32, maxCollectionCount *uint32, collectDataTimeout *uint32, userName *uint16, maxUserNameSize uint32) (err error) { 2459func GetNamedPipeHandleState(pipe Handle, state *uint32, curInstances *uint32, maxCollectionCount *uint32, collectDataTimeout *uint32, userName *uint16, maxUserNameSize uint32) (err error) {
2375 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) 2460 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)
2376 if r1 == 0 { 2461 if r1 == 0 {
@@ -2387,6 +2472,14 @@ func GetNamedPipeInfo(pipe Handle, flags *uint32, outSize *uint32, inSize *uint3
2387 return 2472 return
2388} 2473}
2389 2474
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
2390func GetOverlappedResult(handle Handle, overlapped *Overlapped, done *uint32, wait bool) (err error) { 2483func GetOverlappedResult(handle Handle, overlapped *Overlapped, done *uint32, wait bool) (err error) {
2391 var _p0 uint32 2484 var _p0 uint32
2392 if wait { 2485 if wait {
@@ -3038,6 +3131,14 @@ func SetCommTimeouts(handle Handle, timeouts *CommTimeouts) (err error) {
3038 return 3131 return
3039} 3132}
3040 3133
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
3041func setConsoleCursorPosition(console Handle, position uint32) (err error) { 3142func setConsoleCursorPosition(console Handle, position uint32) (err error) {
3042 r1, _, e1 := syscall.Syscall(procSetConsoleCursorPosition.Addr(), 2, uintptr(console), uintptr(position), 0) 3143 r1, _, e1 := syscall.Syscall(procSetConsoleCursorPosition.Addr(), 2, uintptr(console), uintptr(position), 0)
3043 if r1 == 0 { 3144 if r1 == 0 {
@@ -3054,6 +3155,14 @@ func SetConsoleMode(console Handle, mode uint32) (err error) {
3054 return 3155 return
3055} 3156}
3056 3157
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
3057func SetCurrentDirectory(path *uint16) (err error) { 3166func SetCurrentDirectory(path *uint16) (err error) {
3058 r1, _, e1 := syscall.Syscall(procSetCurrentDirectoryW.Addr(), 1, uintptr(unsafe.Pointer(path)), 0, 0) 3167 r1, _, e1 := syscall.Syscall(procSetCurrentDirectoryW.Addr(), 1, uintptr(unsafe.Pointer(path)), 0, 0)
3059 if r1 == 0 { 3168 if r1 == 0 {
vendor/modules.txt +14 −13
@@ -8,17 +8,18 @@ github.com/Microsoft/go-winio/pkg/guid
8# github.com/aymanbagabas/go-osc52/v2 v2.0.1 8# github.com/aymanbagabas/go-osc52/v2 v2.0.1
9## explicit; go 1.16 9## explicit; go 1.16
10github.com/aymanbagabas/go-osc52/v2 10github.com/aymanbagabas/go-osc52/v2
11# github.com/charmbracelet/bubbletea v1.1.1 11# github.com/charmbracelet/bubbletea v1.3.3
12## explicit; go 1.18 12## explicit; go 1.18
13github.com/charmbracelet/bubbletea 13github.com/charmbracelet/bubbletea
14# github.com/charmbracelet/lipgloss v0.13.0 14# github.com/charmbracelet/lipgloss v1.0.0
15## explicit; go 1.18 15## explicit; go 1.18
16github.com/charmbracelet/lipgloss 16github.com/charmbracelet/lipgloss
17# github.com/charmbracelet/x/ansi v0.2.3 17# github.com/charmbracelet/x/ansi v0.8.0
18## explicit; go 1.18 18## explicit; go 1.18
19github.com/charmbracelet/x/ansi 19github.com/charmbracelet/x/ansi
20github.com/charmbracelet/x/ansi/kitty
20github.com/charmbracelet/x/ansi/parser 21github.com/charmbracelet/x/ansi/parser
21# github.com/charmbracelet/x/term v0.2.0 22# github.com/charmbracelet/x/term v0.2.1
22## explicit; go 1.18 23## explicit; go 1.18
23github.com/charmbracelet/x/term 24github.com/charmbracelet/x/term
24# github.com/erikgeiser/coninput v0.0.0-20211004153227-1c3628e74d0f 25# github.com/erikgeiser/coninput v0.0.0-20211004153227-1c3628e74d0f
@@ -33,10 +34,6 @@ github.com/go-toast/toast
33# github.com/godbus/dbus/v5 v5.1.0 34# github.com/godbus/dbus/v5 v5.1.0
34## explicit; go 1.12 35## explicit; go 1.12
35github.com/godbus/dbus/v5 36github.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
40# github.com/lucasb-eyer/go-colorful v1.2.0 37# github.com/lucasb-eyer/go-colorful v1.2.0
41## explicit; go 1.12 38## explicit; go 1.12
42github.com/lucasb-eyer/go-colorful 39github.com/lucasb-eyer/go-colorful
@@ -46,7 +43,7 @@ github.com/mattn/go-isatty
46# github.com/mattn/go-localereader v0.0.1 43# github.com/mattn/go-localereader v0.0.1
47## explicit 44## explicit
48github.com/mattn/go-localereader 45github.com/mattn/go-localereader
49# github.com/mattn/go-runewidth v0.0.15 46# github.com/mattn/go-runewidth v0.0.16
50## explicit; go 1.9 47## explicit; go 1.9
51github.com/mattn/go-runewidth 48github.com/mattn/go-runewidth
52# github.com/muesli/ansi v0.0.0-20230316100256-276c6243b2f6 49# github.com/muesli/ansi v0.0.0-20230316100256-276c6243b2f6
@@ -68,16 +65,20 @@ github.com/rivo/uniseg
68# github.com/tadvi/systray v0.0.0-20190226123456-11a2b8fa57af 65# github.com/tadvi/systray v0.0.0-20190226123456-11a2b8fa57af
69## explicit 66## explicit
70github.com/tadvi/systray 67github.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
72## explicit; go 1.18 73## explicit; go 1.18
73golang.org/x/sync/errgroup 74golang.org/x/sync/errgroup
74# golang.org/x/sys v0.24.0 75# golang.org/x/sys v0.30.0
75## explicit; go 1.18 76## explicit; go 1.18
76golang.org/x/sys/unix 77golang.org/x/sys/unix
77golang.org/x/sys/windows 78golang.org/x/sys/windows
78golang.org/x/sys/windows/registry 79golang.org/x/sys/windows/registry
79# golang.org/x/text v0.14.0 80# golang.org/x/text v0.3.8
80## explicit; go 1.18 81## explicit; go 1.17
81golang.org/x/text/transform 82golang.org/x/text/transform
82# gopkg.in/natefinch/npipe.v2 v2.0.0-20160621034901-c1b8fa8bdcce 83# gopkg.in/natefinch/npipe.v2 v2.0.0-20160621034901-c1b8fa8bdcce
83## explicit 84## explicit