tsoding / boomer

Zoomer application for Linux
MIT License
439 stars 39 forks source link

Expand config handling #35

Closed SolitudeSF closed 4 years ago

SolitudeSF commented 4 years ago

If no config file specified reads config from ${XDG_CONFIG_DIR:-~/.config}/boomer/config. Also now config parsing is performed automatically according to object fields.

In current state macro expands to following code:

case normIdent(key)
of "scrollspeed":
  result.scrollSpeed = parseFloat(value)
of "dragvelocityfactor":
  result.dragVelocityFactor = parseFloat(value)
of "dragfriction":
  result.dragFriction = parseFloat(value)
of "scalefriction":
  result.scaleFriction = parseFloat(value)
of "fps":
  result.fps = parseInt(value)
else:
  raise
    var e`gensym340155: owned(ref CatchableError)
    new(e`gensym340155)
    e`gensym340155.msg = "Unknown config key " & key
    e`gensym340155.parent = nil
    e`gensym340155

Which is almost exactly the same as handwritten one, except identifiers are compared style insensitively, so you dont have to follow exact field naming in the config. Also value are automatically parsed to int/float and additional handling can be added as needed.

rexim commented 4 years ago

@SolitudeSF noice! Thank you so much for the contribution! We will take a look at it on the next boomer stream to educate ourselves! :ok_hand:

rexim commented 4 years ago

@SolitudeSF thank you so much for the contribution!