@@ -14,6 +14,7 @@ import (
14
14
15
15
"github.com/alecthomas/chroma/v2/quick"
16
16
"github.com/charmbracelet/lipgloss"
17
+ "github.com/muesli/termenv"
17
18
fn "github.com/nxtcoder17/runfile/pkg/functions"
18
19
"golang.org/x/sync/errgroup"
19
20
)
@@ -119,6 +120,10 @@ func processOutputLineByLine(writer io.Writer, reader io.Reader, prefix *string)
119
120
}
120
121
}
121
122
123
+ func isDarkTheme () bool {
124
+ return termenv .NewOutput (os .Stdout ).HasDarkBackground ()
125
+ }
126
+
122
127
func runTask (ctx Context , rf * Runfile , args runTaskArgs ) * Error {
123
128
runfilePath := fn .Must (filepath .Rel (rf .attrs .RootRunfilePath , rf .attrs .RunfilePath ))
124
129
@@ -153,7 +158,6 @@ func runTask(ctx Context, rf *Runfile, args runTaskArgs) *Error {
153
158
return formatErr (err )
154
159
}
155
160
156
- logger .Debug ("debugging env" , "pt.environ" , pt .Env , "overrides" , args .envOverrides )
157
161
for _ , command := range pt .Commands {
158
162
logger .Debug ("running command task" , "command.run" , command .Run , "parent.task" , args .taskName )
159
163
@@ -216,13 +220,20 @@ func runTask(ctx Context, rf *Runfile, args runTaskArgs) *Error {
216
220
// // }
217
221
// // processOutputLineByLine(os.Stderr, stderrR, &logPrefix)
218
222
// }()
219
- //
220
223
// }
221
224
222
- s := lipgloss .NewStyle ().BorderForeground (lipgloss .Color ("#4388cc" )).PaddingLeft (1 ).PaddingRight (1 ).Border (lipgloss .RoundedBorder (), true , true , true , true )
225
+ borderColor := "#4388cc"
226
+ if ! isDarkTheme () {
227
+ borderColor = "#3d5485"
228
+ }
229
+ s := lipgloss .NewStyle ().BorderForeground (lipgloss .Color (borderColor )).PaddingLeft (1 ).PaddingRight (1 ).Border (lipgloss .RoundedBorder (), true , true , true , true )
223
230
224
231
hlCode := new (bytes.Buffer )
225
- quick .Highlight (hlCode , strings .TrimSpace (command .Command ), "bash" , "terminal16m" , "onedark" )
232
+ colorscheme := "onedark"
233
+ if ! isDarkTheme () {
234
+ colorscheme = "monokailight"
235
+ }
236
+ quick .Highlight (hlCode , strings .TrimSpace (command .Command ), "bash" , "terminal16m" , colorscheme )
226
237
227
238
fmt .Printf ("%s\n " , s .Render (hlCode .String ()))
228
239
0 commit comments