utils

package module
v0.0.0-...-9a33cd6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 30, 2024 License: MIT Imports: 6 Imported by: 10

README

utils - Utility Functions for ge Text Editor

utils is a package that provides various utility functions for the ge text editor.

Features

  • Includes utility functions for common tasks such as file, string manipulation, and more.
  • Provides helper functions used within the ge text editor.

Installation

To use utils in your Go project, you can simply import it as follows:

import "github.com/ge-editor/utils"

Then, you can use the utility functions provided by utils in your project.

Contributing

Contributions to utils are welcome! If you find any issues or have suggestions for improvement, please feel free to open an issue or create a pull request on the GitHub repository.

License

This package is licensed under the MIT License. See the LICENSE file for details.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AppendIfNotExists

func AppendIfNotExists(slice []string, s string, addToFront bool) []string

Add s to slice. If s exists in slice, return slice as is. Add s to the beginning of slice if addToFront is true.

func Contains

func Contains(slice []string, s string) bool

Check whether s is contained within the slice.

func ContainsAllCharacters

func ContainsAllCharacters(str, characters string) bool

Check if a string contains a specific character case insensitive

func ContainsAllCharactersCaseSensitive

func ContainsAllCharactersCaseSensitive(str, characters string) bool

Check if a string contains a specific character case sensitive

func CopyFile

func CopyFile(src, dest string) error

func Dirwalk

func Dirwalk(dir string, depth int) []string

Get the list of files in the directory

func ExistsFile

func ExistsFile(filename string) bool

func FindOverlap

func FindOverlap(range1Start, range1End, range2Start, range2End int) (int, int)

Find overlap between two ranges Range is 2 integers greater than or equal to 0

func LastPartOfPath

func LastPartOfPath(path string) string

Return last part of path Trim right side path separator and split by separator

func MaxValueIndex

func MaxValueIndex(array []int) (maxValueIndex int)

func MoveElement

func MoveElement(slice []string, index int, moveToStart bool) []string

func RemoveSymbols

func RemoveSymbols(s string) string

Remove half-width symbols from string

func RuneWidth

func RuneWidth(ch rune) int

Guess the width of the rune for console screen.

種類の説明:

  • width.Neutral: 幅が中立的である文字(例:アルファベット、数字、記号)は幅が1です。
  • width.EastAsianWide: 全角文字(例:漢字、ひらがな、カタカナ)は幅が2です。
  • width.EastAsianNarrow: 半角文字(例:英数字、一部の記号)は幅が1です。
  • width.EastAsianAmbiguous: 幅が曖昧な文字(例:一部の漢字、一部のひらがな、一部のカタカナ)は幅が2です。
  • width.EastAsianFullwidth: 全角文字(例:漢字、ひらがな、カタカナ)は幅が2です。
  • width.EastAsianHalfwidth: 半角文字(例:英数字、一部の記号)は幅が1です。

func SameFile

func SameFile(path1, path2 string) bool

func StringWidth

func StringWidth(s string) int

func Swap

func Swap[T any](a *T, b *T)

func TabWidth

func TabWidth(cursorPosition int, tabWidth int) int

func Threshold

func Threshold(maxThreshold, screenSize int) int

func WidthKindString

func WidthKindString(ch rune) string

Determine the character type and return the result string

Types

type Rect

type Rect struct {
	X      int
	Y      int
	Width  int
	Height int
}

func (Rect) FitsIn

func (r Rect) FitsIn(b Rect) bool

FitsIn checks if rectangle r fits entirely inside rectangle b.

func (Rect) Intersection

func (r Rect) Intersection(b Rect) Rect

Intersection returns the intersection rectangle of r and b. Intersection: the point or set of points where two lines or surfaces meet and cross each other.

func (Rect) IsEmpty

func (r Rect) IsEmpty() bool

func (Rect) IsValid

func (r Rect) IsValid() bool

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL