mirror of
https://github.com/yuaotian/go-cursor-help.git
synced 2025-06-08 12:32:06 +08:00

- Enhanced build scripts for improved parallel execution and optimization flags. - Updated installation scripts for better user experience and error handling. - Modified .gitignore to include new build artifacts and IDE configurations. - Updated .goreleaser.yml for better release management and platform support. - Removed deprecated main.go file and adjusted README for clarity on installation and usage. - Added support for multiple architectures in build process, including 32-bit and 64-bit for Windows, macOS, and Linux. These changes streamline the development workflow and enhance the overall usability of the Cursor ID Modifier tool.
102 lines
2.3 KiB
Go
102 lines
2.3 KiB
Go
package ui
|
|
|
|
import (
|
|
"fmt"
|
|
"os"
|
|
"os/exec"
|
|
"runtime"
|
|
"strings"
|
|
|
|
"github.com/fatih/color"
|
|
)
|
|
|
|
// Display handles UI display operations
|
|
type Display struct {
|
|
spinner *Spinner
|
|
}
|
|
|
|
// NewDisplay creates a new display handler
|
|
func NewDisplay(spinner *Spinner) *Display {
|
|
if spinner == nil {
|
|
spinner = NewSpinner(nil)
|
|
}
|
|
return &Display{
|
|
spinner: spinner,
|
|
}
|
|
}
|
|
|
|
// ShowProgress shows a progress message with spinner
|
|
func (d *Display) ShowProgress(message string) {
|
|
d.spinner.SetMessage(message)
|
|
d.spinner.Start()
|
|
}
|
|
|
|
// StopProgress stops the progress spinner
|
|
func (d *Display) StopProgress() {
|
|
d.spinner.Stop()
|
|
}
|
|
|
|
// ClearScreen clears the terminal screen
|
|
func (d *Display) ClearScreen() error {
|
|
var cmd *exec.Cmd
|
|
if runtime.GOOS == "windows" {
|
|
cmd = exec.Command("cmd", "/c", "cls")
|
|
} else {
|
|
cmd = exec.Command("clear")
|
|
}
|
|
cmd.Stdout = os.Stdout
|
|
return cmd.Run()
|
|
}
|
|
|
|
// ShowProcessStatus shows the current process status
|
|
func (d *Display) ShowProcessStatus(message string) {
|
|
fmt.Printf("\r%s", strings.Repeat(" ", 80)) // Clear line
|
|
fmt.Printf("\r%s", color.CyanString("⚡ "+message))
|
|
}
|
|
|
|
// ShowPrivilegeError shows the privilege error message
|
|
func (d *Display) ShowPrivilegeError(errorMsg, adminMsg, sudoMsg, sudoExample string) {
|
|
red := color.New(color.FgRed, color.Bold)
|
|
yellow := color.New(color.FgYellow)
|
|
|
|
red.Println(errorMsg)
|
|
if runtime.GOOS == "windows" {
|
|
yellow.Println(adminMsg)
|
|
} else {
|
|
yellow.Printf("%s\n%s\n", sudoMsg, fmt.Sprintf(sudoExample, os.Args[0]))
|
|
}
|
|
}
|
|
|
|
// ShowSuccess shows a success message
|
|
func (d *Display) ShowSuccess(successMsg, restartMsg string) {
|
|
green := color.New(color.FgGreen, color.Bold)
|
|
yellow := color.New(color.FgYellow, color.Bold)
|
|
|
|
green.Printf("\n%s\n", successMsg)
|
|
yellow.Printf("%s\n", restartMsg)
|
|
}
|
|
|
|
// ShowError shows an error message
|
|
func (d *Display) ShowError(message string) {
|
|
red := color.New(color.FgRed, color.Bold)
|
|
red.Printf("\n%s\n", message)
|
|
}
|
|
|
|
// ShowWarning shows a warning message
|
|
func (d *Display) ShowWarning(message string) {
|
|
yellow := color.New(color.FgYellow, color.Bold)
|
|
yellow.Printf("\n%s\n", message)
|
|
}
|
|
|
|
// ShowInfo shows an info message
|
|
func (d *Display) ShowInfo(message string) {
|
|
cyan := color.New(color.FgCyan)
|
|
cyan.Printf("\n%s\n", message)
|
|
}
|
|
|
|
// ShowPrompt shows a prompt message and waits for user input
|
|
func (d *Display) ShowPrompt(message string) {
|
|
fmt.Print(message)
|
|
os.Stdout.Sync()
|
|
}
|