Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7.0.0
with:
go-version: '1.17'
go-version: '1.25'
- run: go build ./...
env:
GOOS: windows
Expand All @@ -30,5 +30,5 @@ jobs:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7.0.0
with:
go-version: '1.17'
go-version: '1.25'
- run: go test ./...
12 changes: 7 additions & 5 deletions csi_entry_state.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package ansiterm

import "slices"

type csiEntryState struct {
baseState
}
Expand All @@ -13,11 +15,11 @@ func (csiState csiEntryState) Handle(b byte) (s state, e error) {
}

switch {
case sliceContains(alphabetics, b):
case slices.Contains(alphabetics, b):
return csiState.parser.ground, nil
case sliceContains(csiCollectables, b):
case slices.Contains(csiCollectables, b):
return csiState.parser.csiParam, nil
case sliceContains(executors, b):
case slices.Contains(executors, b):
return csiState, csiState.parser.execute()
}

Expand All @@ -33,9 +35,9 @@ func (csiState csiEntryState) Transition(s state) error {
return csiState.parser.csiDispatch()
case csiState.parser.csiParam:
switch {
case sliceContains(csiParams, csiState.parser.context.currentChar):
case slices.Contains(csiParams, csiState.parser.context.currentChar):
_ = csiState.parser.collectParam()
case sliceContains(intermeds, csiState.parser.context.currentChar):
case slices.Contains(intermeds, csiState.parser.context.currentChar):
_ = csiState.parser.collectInter()
}
}
Expand Down
8 changes: 5 additions & 3 deletions csi_param_state.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package ansiterm

import "slices"

type csiParamState struct {
baseState
}
Expand All @@ -13,11 +15,11 @@ func (csiState csiParamState) Handle(b byte) (s state, e error) {
}

switch {
case sliceContains(alphabetics, b):
case slices.Contains(alphabetics, b):
return csiState.parser.ground, nil
case sliceContains(csiCollectables, b):
case slices.Contains(csiCollectables, b):
return csiState, csiState.parser.collectParam()
case sliceContains(executors, b):
case slices.Contains(executors, b):
return csiState, csiState.parser.execute()
}

Expand Down
8 changes: 5 additions & 3 deletions escape_intermediate_state.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package ansiterm

import "slices"

type escapeIntermediateState struct {
baseState
}
Expand All @@ -12,11 +14,11 @@ func (escState escapeIntermediateState) Handle(b byte) (s state, e error) {
}

switch {
case sliceContains(intermeds, b):
case slices.Contains(intermeds, b):
return escState, escState.parser.collectInter()
case sliceContains(executors, b):
case slices.Contains(executors, b):
return escState, escState.parser.execute()
case sliceContains(escapeIntermediateToGroundBytes, b):
case slices.Contains(escapeIntermediateToGroundBytes, b):
return escState.parser.ground, nil
}

Expand Down
8 changes: 5 additions & 3 deletions escape_state.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package ansiterm

import "slices"

type escapeState struct {
baseState
}
Expand All @@ -16,11 +18,11 @@ func (escState escapeState) Handle(b byte) (s state, e error) {
return escState.parser.csiEntry, nil
case b == ANSI_OSC_STRING_ENTRY:
return escState.parser.oscString, nil
case sliceContains(executors, b):
case slices.Contains(executors, b):
return escState, escState.parser.execute()
case sliceContains(escapeToGroundBytes, b):
case slices.Contains(escapeToGroundBytes, b):
return escState.parser.ground, nil
case sliceContains(intermeds, b):
case slices.Contains(intermeds, b):
return escState.parser.escapeIntermediate, nil
}

Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module github.com/Azure/go-ansiterm

go 1.17
go 1.25.0

require golang.org/x/sys v0.1.0
6 changes: 4 additions & 2 deletions ground_state.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package ansiterm

import "slices"

type groundState struct {
baseState
}
Expand All @@ -13,10 +15,10 @@ func (gs groundState) Handle(b byte) (s state, e error) {
}

switch {
case sliceContains(printables, b):
case slices.Contains(printables, b):
return gs, gs.parser.print()

case sliceContains(executors, b):
case slices.Contains(executors, b):
return gs, gs.parser.execute()
}

Expand Down
8 changes: 4 additions & 4 deletions parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@ type AnsiParser struct {
oscString state
stateMap []state

logf func(string, ...interface{})
logf func(string, ...any)
}

type Option func(*AnsiParser)

func WithLogf(f func(string, ...interface{})) Option {
func WithLogf(f func(string, ...any)) Option {
return func(ap *AnsiParser) {
ap.logf = f
}
Expand All @@ -45,7 +45,7 @@ func CreateParser(initialState string, evtHandler AnsiEventHandler, opts ...Opti
logger := log.New(logFile, "", log.LstdFlags)
if ap.logf != nil {
l := ap.logf
ap.logf = func(s string, v ...interface{}) {
ap.logf = func(s string, v ...any) {
l(s, v...)
logger.Printf(s, v...)
}
Expand All @@ -55,7 +55,7 @@ func CreateParser(initialState string, evtHandler AnsiEventHandler, opts ...Opti
}

if ap.logf == nil {
ap.logf = func(string, ...interface{}) {}
ap.logf = func(string, ...any) {}
}

ap.csiEntry = csiEntryState{baseState{name: "CsiEntry", parser: ap}}
Expand Down
2 changes: 1 addition & 1 deletion parser_action_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ func getInts(params []string, minCount int, dflt int) []int {

if len(ints) < minCount {
remaining := minCount - len(ints)
for i := 0; i < remaining; i++ {
for range remaining {
ints = append(ints, dflt)
}
}
Expand Down
6 changes: 4 additions & 2 deletions states.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package ansiterm

import "slices"

type state interface {
Enter() error
Exit() error
Expand Down Expand Up @@ -32,7 +34,7 @@ func (base baseState) Handle(b byte) (s state, e error) {
return base.parser.escape, nil
case b == OSC_STRING:
return base.parser.oscString, nil
case sliceContains(toGroundBytes, b):
case slices.Contains(toGroundBytes, b):
return base.parser.ground, nil
}

Expand All @@ -52,7 +54,7 @@ func (base baseState) Transition(s state) error {
execBytes = append(execBytes, 0x99)
execBytes = append(execBytes, 0x9A)

if sliceContains(execBytes, base.parser.context.currentChar) {
if slices.Contains(execBytes, base.parser.context.currentChar) {
return base.parser.execute()
}
}
Expand Down
11 changes: 0 additions & 11 deletions utilities.go

This file was deleted.

2 changes: 1 addition & 1 deletion winterm/ansi.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// +build windows
//go:build windows

package winterm

Expand Down
6 changes: 3 additions & 3 deletions winterm/api.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// +build windows
//go:build windows

package winterm

Expand All @@ -8,7 +8,7 @@ import (
"unsafe"
)

//===========================================================================================================
// ===========================================================================================================
// IMPORTANT NOTE:
//
// The methods below make extensive use of the "unsafe" package to obtain the required pointers.
Expand All @@ -26,7 +26,7 @@ import (
// -- The value is not referenced by the method after passing the pointer to Windows
//
// See http://golang.org/doc/go1.3.
//===========================================================================================================
// ===========================================================================================================

var (
kernel32DLL = syscall.NewLazyDLL("kernel32.dll")
Expand Down
2 changes: 1 addition & 1 deletion winterm/attr_translation.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// +build windows
//go:build windows

package winterm

Expand Down
2 changes: 1 addition & 1 deletion winterm/cursor_helpers.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// +build windows
//go:build windows

package winterm

Expand Down
2 changes: 1 addition & 1 deletion winterm/erase_helpers.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// +build windows
//go:build windows

package winterm

Expand Down
2 changes: 1 addition & 1 deletion winterm/scroll_helper.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// +build windows
//go:build windows

package winterm

Expand Down
2 changes: 1 addition & 1 deletion winterm/utilities.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// +build windows
//go:build windows

package winterm

Expand Down
2 changes: 1 addition & 1 deletion winterm/win_event_handler.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// +build windows
//go:build windows

package winterm

Expand Down
Loading