howl-editor / howl

The Howl Editor
http://howl.io
Other
712 stars 68 forks source link

How to set new themes? #205

Closed tastyminerals closed 8 years ago

tastyminerals commented 8 years ago

I am reading through the docs right now and cannot find any references about themes or how to set them.

How to set a different theme in Howl?

abaez commented 8 years ago

It's not written as far as I could find, but you can do it like so:

-- init.moon
import config from howl
config.theme = "Monokai"

You can find the name in line 6 of the init.moon file.

shalabhc commented 8 years ago

To change the theme without a restart run this command (i.e. press alt_x and then type the following command as is):

set theme=

The autocomplete will help you pick a new theme. Once you like a theme, you can put it in your init.moon for permanent setting.

nilnor commented 8 years ago

I added an example of the interactive way of doing it to the manual, along with a screenshot: http://howl.io/doc/manual/configuration.html#configuration-variables. Have a look @tastyminerals, hopefully it makes it a little bit clearer!

tastyminerals commented 8 years ago

I see, thanks. One thing though. Neither "Monokai" nor "Steinom" are available when set via ~/.howl/init.moon

import config
config.theme = "Steinom"

Howl crashes with *error in 'signal activate' callback handler: ../lib/howl/config.moon:180: Illegal option 'Steinom' for 'theme'

Using howl 0.3-2.

nilnor commented 8 years ago

Ah, thanks for the version information. Both Steinom and Monokai are new in 0.4, so you should upgrade to the latest release first.

shalabhc commented 8 years ago

As a related issue, Howl should probably not crash when an invalid theme is specified - maybe just show an error and load a default theme?

abaez commented 8 years ago

hey @shalabhc,

You can always add yourself a quick check to make sure the theme is reverted to default:

-- init.moon
import ui, config from howl

safe_theme = (theme) ->
  if ui.theme.all[theme]
    theme
  else
    "Monokai"

config.theme = safe_theme "Some theme that doesn't exist"
nilnor commented 8 years ago

Well, to be fair it does not crash but refuses to start if there are errors in the user configuration file. I don't think it makes sense to silently ignore the error (even with a logged warning) - better then to abort early so the error can be dealt with. From an API perspective I think it makes sense to provide an error for an invalid value, silently swallowing errors seems like a much worse alternative.

If one is often switching between branches/versions where this would be a commonly occurring problem then @abaez's snippet does the job and would be a better alternative than some generically ignoring some errors.

abaez commented 8 years ago

@nilnor agreed. Only wrote it out to simplify his case. I follow on the same procedure of getting errors out of the way first.

However, I also think that for anything under howl.config, howl should be stating an error occurred and then follow with the revert to default configurations, like in textadept.

shalabhc commented 8 years ago

Cool, thanks.

Hmm, maybe this should a feature of config. Something like config.safe_assign 'name', value - which reverts the value if there's an error while setting the new value.

On Thu, Jun 2, 2016 at 10:40 AM, Alejandro Baez notifications@github.com wrote:

hey @shalabhc https://github.com/shalabhc,

You can always add yourself a quick check to make sure the theme is reverted to default:

-- init.moonimport ui, config from howl

safe_theme = (theme) -> if ui.theme.all[theme] theme else "Monokai"

config.theme = safe_theme "Some theme that doesn't exist"

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/howl-editor/howl/issues/205#issuecomment-223366022, or mute the thread https://github.com/notifications/unsubscribe/AGvU-cbPThhsrt9d3BNczx6dRMsx_R-Bks5qHxWCgaJpZM4IsAx0 .

shalabhc commented 8 years ago

@nilnor - due to wifi issues I replied before reading your message. In general I agree with your reasoning, but note that in this case my editor is rendered unusable so how am I now to fix the init.moon :wink:

Hmm, I suppose I could just use the 'dont load init.moon' feature. Then it just needs to be better documented.

nilnor commented 8 years ago

Well I can be swayed towards making the user config loading proceed even with errors, if we display the error prominently after startup.

In that case I suggest just proceeding with the current state at the time of the error, I don't see how it would be any better to revert any earlier customization, it's likely to be the other way around it seems.

shalabhc commented 8 years ago

Forked the issue under discussion to #208.