mirror of
https://github.com/aljazceru/njump.git
synced 2025-12-17 06:14:22 +01:00
bring in HarfbuzzShaper into code as a function so we can modify it.
This commit is contained in:
17
utils.go
17
utils.go
@@ -5,6 +5,7 @@ import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"hash/maphash"
|
||||
"html"
|
||||
"html/template"
|
||||
"math/rand"
|
||||
@@ -12,6 +13,7 @@ import (
|
||||
"regexp"
|
||||
"strings"
|
||||
"time"
|
||||
"unsafe"
|
||||
|
||||
"github.com/microcosm-cc/bluemonday"
|
||||
"golang.org/x/exp/slices"
|
||||
@@ -516,3 +518,18 @@ func maxIndex(slice []int) int {
|
||||
}
|
||||
return maxIndex
|
||||
}
|
||||
|
||||
// clamp ensures val is in the inclusive range [low,high].
|
||||
func clamp(val, low, high int) int {
|
||||
if val < low {
|
||||
return low
|
||||
}
|
||||
if val > high {
|
||||
return high
|
||||
}
|
||||
return val
|
||||
}
|
||||
|
||||
func pointerHasher[V any](_ maphash.Seed, k *V) uint64 {
|
||||
return uint64(uintptr(unsafe.Pointer(k)))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user