andmarti1424 / sc-im

sc-im - Spreadsheet Calculator Improvised -- An ncurses spreadsheet program for terminal
Other
4.85k stars 207 forks source link

Error loading save files with custom colors using :define_color or DEFINE_COLOR #795

Closed starconomy closed 1 year ago

starconomy commented 1 year ago

First, thank you for making sc-im. It is fantastic I hope more will stumble upon it and find it useful as I did.

After using :define_color and then :cell_color to add a custom background color to a cell, I am not able to open the spreadsheet without getting an error for an undefined color. The man page states for custom color, "to make this take effect every time sc-im is started, you can add it to $HOME/.config/sc-im/scimrc" However, even after adding the color to scimrc E.g., DEFINE_COLOR "skyblue" 75 50 200 there is still an error loading the sheet.

Steps to reproduce on version 0.8.3:

  1. create a new spreadsheet and define a custom color :define_color "skyblue" 75 50 200

  2. update a cell to use the custom color and save and quit :cellcolor "bg=skyblue fg=WHITE"

  3. update and add the custom color to scimrc DEFINE_COLOR "skyblue" 75 50 200

  4. open the spreadsheet you just saved and it will throw an error that the color "skyblue" is not defined.

The could it completely incorrect but it appears that load_rc() is called after load_file() in main() suggesting that the custom colors would not be loaded until after an attempt is made to load a save?

Regardless, as a new user, it is somewhat confusing that custom colors are not saved in a file by default. I was able to manually add DEFINE_COLOR commands to a save file and load it without errors but the DEFINE_COLOR commands are lost whenever sc-im saves the file back out. Is there a challenge that makes writing out DEFINE_COLOR commands to each save file not desirable or possible?

andmarti1424 commented 1 year ago

Hello @starconomy This was fixed today. Please update to latest commit on dev branch and retry. Regarding saving user defined colors... PR are welcome!