avahe-kellenberger / nimdow

A window manager written in Nim (In Development)
GNU General Public License v2.0
317 stars 19 forks source link

Nimdow to support "reset" escape codes #223

Closed DrunkenAlcoholic closed 6 months ago

DrunkenAlcoholic commented 7 months ago

Describe the bug This may not be a bug, however it seems that Nimdow is not supporting the "reset" escape code, "\x1b[0m"

To Reproduce Steps to reproduce the behavior:

const
  RESET: string  = "\x1b[0m"

  GREEN_FG: string  = "\x1b[38;2;104;157;106m"
  BLUE_FG:  string  = "\x1b[38;2;69;133;136m"
  ORANGE_FG: string = "\x1b[38;2;249;188;47m"
  RED_FG: string    = "\x1b[38;2;231;104;97m"
  WHITE_FG: string  = "\x1b[38;2;235;219;178m"
  BROWN_FG: string  = "\x1b[38;2;49;51;66m"

  GREEN_BG: string  = "\x1b[48;2;104;157;106m"
  BLUE_BG:  string  = "\x1b[48;2;69;133;136m"
  ORANGE_BG: string = "\x1b[48;2;249;188;47m"
  RED_BG: string    = "\x1b[48;2;231;104;97m"
  WHITE_BG: string  = "\x1b[48;2;235;219;178m"
  BROWN_BG: string  = "\x1b[48;2;49;51;66m"

  CIRCLE_GREEN_L: string  = RESET & GREEN_FG & "" & RESET & GREEN_BG
  CIRCLE_GREEN_R: string  = RESET & GREEN_FG & "" & RESET
  CIRCLE_BLUE_L: string   = RESET & BLUE_FG & "" & RESET & BLUE_BG
  CIRCLE_BLUE_R: string   = RESET & BLUE_FG & "" & RESET
  CIRCLE_ORANGE_L: string = RESET & ORANGE_FG & "" & RESET & ORANGE_BG
  CIRCLE_ORANGE_R: string = RESET & ORANGE_FG & "" & RESET
  CIRCLE_RED_L: string    = RESET & RED_FG & "" & RESET & RED_BG
  CIRCLE_RED_R: string    = RESET & RED_FG & "" & RESET
  CIRCLE_WHITE_L: string  = RESET & WHITE_FG & "" & RESET & WHITE_BG
  CIRCLE_WHITE_R: string  = RESET & WHITE_FG & "" & RESET
  CIRCLE_BROWN_L: string  = RESET & BROWN_FG & "" & RESET & BROWN_BG
  CIRCLE_BROWN_R: string  = RESET & BROWN_FG & "" & RESET

Using the above constants, push the generated string to "xsetroot -name" example below

proc setStatus(sStatus: string) = 
  discard execShellCmd("xsetroot -name " & "\"" & sStatus & "\"")

# Main loop
proc main() =
  while true:
    # create the string using themed arrows and functions
    let sStatusString = fmt"{CIRCLE_GREEN_L}{getWeather()}{CIRCLE_GREEN_R}{CIRCLE_ORANGE_L}{getBatStatus()}{CIRCLE_ORANGE_R}{CIRCLE_BLUE_L}{getMemory()}{CIRCLE_BLUE_R}{CIRCLE_RED_L}{getDateTime()}{CIRCLE_RED_R}{RESET}"
    # set the status
    setStatus(sStatusString)
    # sleep for n seconds
    sleep(UPDATE_INTERVAL * 1000)

Expected behavior I would expect the foreground and background color to reset to default color of the Nimdow bar when using "RESET" escape code, as screenshot below

Screenshots This how the result should look like(I have manually inserted escape code for same color bar back ground) screenshot3

and here it is working in the terminal using "reset" escape code image

But due to what seems to be not supporting escape code it results in this screenshot4

avahe-kellenberger commented 7 months ago

Good find, I'll work on this sometime soon