Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 26.1k
feat: add focus tracking to hide cursor when terminal loses focus#79
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Uh oh!
There was an error while loading. Please reload this page.
Changes from all commits
File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -22,6 +22,7 @@ import ( | ||
| "github.com/sst/opencode/internal/lsp/discovery" | ||
| "github.com/sst/opencode/internal/pubsub" | ||
| "github.com/sst/opencode/internal/tui" | ||
| "github.com/sst/opencode/internal/tui/util" | ||
| "github.com/sst/opencode/internal/version" | ||
| ) | ||
| @@ -92,15 +93,15 @@ to assist developers in writing, debugging, and understanding code directly from | ||
| // Check if we're in non-interactive mode | ||
| prompt, _ := cmd.Flags().GetString("prompt") | ||
| // Check for piped input if no prompt was provided via flag | ||
| if prompt == "" { | ||
| pipedInput, hasPipedInput := checkStdinPipe() | ||
| if hasPipedInput { | ||
| prompt = pipedInput | ||
| } | ||
| } | ||
| // If we have a prompt (either from flag or piped input), run in non-interactive mode | ||
| if prompt != "" { | ||
| outputFormatStr, _ := cmd.Flags().GetString("output-format") | ||
| @@ -155,6 +156,14 @@ to assist developers in writing, debugging, and understanding code directly from | ||
| // Setup the subscriptions, this will send services events to the TUI | ||
| ch, cancelSubs := setupSubscriptions(app, ctx) | ||
| // Start focus tracking | ||
| focusTracker := util.NewFocusTracker(program) | ||
| if err := focusTracker.Start(ctx); err != nil { | ||
| slog.Warn("Failed to start focus tracking", "error", err) | ||
| } else { | ||
| slog.Info("Started focus tracking") | ||
| } | ||
| // Create a context for the TUI message handler | ||
| tuiCtx, tuiCancel := context.WithCancel(ctx) | ||
| var tuiWg sync.WaitGroup | ||
| @@ -332,7 +341,7 @@ func checkStdinPipe() (string, bool) { | ||
| if err != nil { | ||
| return "", false | ||
| } | ||
ContributorAuthor There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. sorry about all of these, opencode and gofmt did that | ||
| // If we got data, return it | ||
| if len(data) > 0 { | ||
| return string(data), true | ||
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
considering asking it to avoid calling stuff "util" and just call it "focus" so
focus.NewTracker