Sixdsn / terra-terminal

Terra is a GTK+3.0 based terminal emulator with useful user interface, it also supports multiple terminals with splitting screen horizontally or vertically. New features have been added since September 2013. It's a pretty new and experimental project, if you want to contribute just checkout and try.
GNU General Public License v3.0
7 stars 3 forks source link

Drop INI file format in favor of YAML #83

Closed SchnWalter closed 9 years ago

SchnWalter commented 9 years ago

At the moment we need to base64 encode the select_by_word setting in the settings file.

        if option == 'select_by_word':
            return b64decode(value)

I would like to suggest switching to YAML in the future for storing the user settings.

This will allow us to have nested settings in the future and remove the base64 encoding.

For example we could have a session manager that store the state of windows, tabs, and layouts. And we could load them directly no need for code like:

        for section in ConfigManager.get_sections():
            if section.find('layout-screen-') != 0:
                continue

            if ConfigManager.get_conf(section, 'enabled'):
                TerraHandler.Wins.create_app(section)

We could have something like:

        for screen in ConfigManager.screens:
            if not screen['disabled']:
                TerraHandler.windows.create_app(screen)
SchnWalter commented 9 years ago

And we could also have these:

[layout-screen-0]
hide-tab-bar = False
hide-tab-bar-fullscreen = False
vertical-position = 150
horizontal-position = 150
width = 1280
height = 1024
fullscreen = False
disabled = False

[layout-Tabs-0-0]
name = Terminal 1
disabled = False

[layout-Child-0-0-0]
id = 0
parent = 0
axis = v
pos = -1
prog = /bin/bash
pwd = /home/user

Like:

screens:
  - hide-tab-bar: False
    hide-tab-bar-fullscreen: False
    vertical-position: 150
    horizontal-position: 150
    width: 1280
    height: 1024
    fullscreen: False
    disabled: False
    tabs:
      - name: Terminal 1
        disabled: False
        child-0:
          id: 0
          parent: 0
          axis: v
          pos: -1
          prog: /bin/bash
          pwd: /home/user

Or something similar.

Sixdsn commented 9 years ago

I agree ini format is not efficient. We must take care about the multiscreens/multiwindows hierarchy too. Why Yaml rather than Json? Json like format are used by some window managers

SchnWalter commented 9 years ago

I find YAML easier to modify from terminal based editors, I've played with it before and... actually, as I said before, I already have a new YAML based Manager, I can commit it in a branch so you can take a look. :)

Sixdsn commented 9 years ago

If it's ready to launch then we will go with YAML ;) yep do another PR fot it

SchnWalter commented 9 years ago

I just have the manager, it's not a drop in replacement... yet. First I want to move those UI related *callback* methods out of the configuration manager and into the TerraHandler or somewhere where it is better suited. Then I also need to figure out how exactly the screen/tab/layout settings work.

Hmm... I just realized, I could add the existing methods (get_conf, set_conf), and then we don't have to move every usage of the ConfigManager to cleaner code.

Sixdsn commented 9 years ago

Agree with the callback move. about the layout:

so you can have multiple screen each screen containing a least a tab containing at least a child

SchnWalter commented 9 years ago

I gues the string "layout" seems to be overloaded. It seems to be present in far to many places... I guess this is what confused me.

I suggest using "layout" only when talking about the position of VTE Terminals inside a tab. And have the screen use "position" or something else.

Sixdsn commented 9 years ago

the section titles are based on their hierarchy in main.cfg you might have a part of old versions of your config in it. try to clean it completly, create your new configuration in terrra and check main.cfg again

SchnWalter commented 9 years ago

I just realized that the yaml parser is not in in the python core. It requires PyYAML. If you are OK with adding that dependency, we could go with yaml. But, as I said, I only suggested yaml because there are less quotes and commas to deal with, and no trailing commas that will break the syntax.

But I just tried the JSON parser which is in python core, and I literally had to change only the 4 lines. The import line and the two lines responsible for reading and writing to the file and one for catching the read errors.

P.S. Looks like the ConfigParser has been renamed to configparser in PY3.

Sixdsn commented 9 years ago

It's up to you, the fact that json is in the python core is a plus but as terra already has dependencies i don't mind to have one more to get a more comprehensive config file.

PS: Yup i saw that when i was working on the python3 compat for terra but right now it's not important as you changed all shebang's to use python2

SchnWalter commented 9 years ago

Fixed in PR #101