Changeset 3277


Ignore:
Timestamp:
03/12/09 03:41:21 (3 years ago)
Author:
jquelin
Message:

defining settings in an array

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Padre/lib/Padre/Config.pm

    r3275 r3277  
    4545    }; 
    4646 
    47  
    48  
    49  
    50  
    5147##################################################################### 
    5248# Settings Specification 
     
    5551# and where the configuration system should resolve them to. 
    5652 
    57 # The identity of the user (simplistic initial version) 
    58 setting( 
    59     # Initially, this must be ascii only 
    60     name    => 'identity_name', 
    61     type    => $ASCII, 
    62     store   => $HUMAN, 
    63     default => '', 
    64 ); 
    65 setting( 
    66     name    => 'identity_email', 
    67     type    => $ASCII, 
    68     store   => $HUMAN, 
    69     default => '', 
    70 ); 
    71  
    72  
    73 # for Module::Starter 
    74 setting( 
    75     name    => 'license', 
    76     type    => $ASCII, 
    77     store   => $HUMAN, 
    78     default => '', 
    79 ); 
    80 setting( 
    81     name    => 'builder', 
    82     type    => $ASCII, 
    83     store   => $HUMAN, 
    84     default => '', 
    85 ); 
    86 setting( 
    87     name    => 'module_start_directory', 
    88     type    => $ASCII, 
    89     store   => $HUMAN, 
    90     default => '', 
    91 ); 
    92  
    93  
    94 # Indent Settings 
    95 # Allow projects to forcefully override personal settings 
    96 setting( 
    97     name    => 'editor_indent_auto', 
    98     type    => $BOOLEAN, 
    99     store   => $HUMAN, 
    100     default => 1, 
    101 ); 
    102 setting( 
    103     name    => 'editor_indent_tab', 
    104     type    => $BOOLEAN, 
    105     store   => $HUMAN, 
    106     default => 1, 
    107 ); 
    108 setting( 
    109     name    => 'editor_indent_tab_width', 
    110     type    => $POSINT, 
    111     store   => $HUMAN, 
    112     default => 8, 
    113 ); 
    114 setting( 
    115     name    => 'editor_indent_width', 
    116     type    => $POSINT, 
    117     store   => $HUMAN, 
    118     default => 8, 
    119 ); 
    120  
    121 # Pages and Panels 
    122 setting( 
     53my %settings = ( 
     54human => [ 
     55    # for each setting, add an array ref: 
     56    # [ $setting_name, $setting_type, $setting_default ] 
     57 
     58    # -- user identity (simplistic initial version) 
     59    [ 'identity_name',  $ASCII, '' ],  # Initially, this must be ascii only 
     60    [ 'identity_email', $ASCII, '' ], 
     61     
     62    # -- for module::starter 
     63    [ 'license',                $ASCII, '' ], 
     64    [ 'builder',                $ASCII, '' ], 
     65    [ 'module_start_directory', $ASCII, '' ], 
     66     
     67    # -- indent settings 
     68    # allow projects to forcefully override personal settings 
     69    [ 'editor_indent_auto',      $BOOLEAN, 1 ], 
     70    [ 'editor_indent_tab',       $BOOLEAN, 1 ], 
     71    [ 'editor_indent_tab_width', $POSINT,  8 ], 
     72    [ 'editor_indent_width',     $POSINT,  8 ], 
     73     
     74    # -- pages and panels 
    12375    # startup mode, if no files given on the command line this can be 
    12476    #   new        - a new empty buffer 
    12577    #   nothing    - nothing to open 
    12678    #   last       - the files that were open last time 
    127     name    => 'main_startup', 
    128     type    => $ASCII, 
    129     store   => $HUMAN, 
    130     default => 'new', 
    131 ); 
    132 setting( 
    133     name    => 'main_lockinterface', 
    134     type    => $BOOLEAN, 
    135     store   => $HUMAN, 
    136     default => 1, 
    137 ); 
    138 setting( 
    139     name    => 'main_functions', 
    140     type    => $BOOLEAN, 
    141     store   => $HUMAN, 
    142     default => 0, 
    143 ); 
    144 setting( 
    145     name    => 'main_functions_order', 
    146     type    => $ASCII, 
    147     store   => $HUMAN, 
    148     default => 'alphabetical', 
    149 ); 
    150 setting( 
    151     name    => 'main_outline', 
    152     type    => $BOOLEAN, 
    153     store   => $HUMAN, 
    154     default => 0, 
    155 ); 
    156 setting( 
    157     name    => 'main_directory', 
    158     type    => $BOOLEAN, 
    159     store   => $HUMAN, 
    160     default => 0, 
    161 ); 
    162 setting( 
    163     name    => 'main_output', 
    164     type    => $BOOLEAN, 
    165     store   => $HUMAN, 
    166     default => 0, 
    167 ); 
    168 setting( 
    169     name    => 'main_output_ansi', 
    170     type    => $BOOLEAN, 
    171     store   => $HUMAN, 
    172     default => 1, 
    173 ); 
    174 setting( 
    175     name    => 'main_syntaxcheck', 
    176     type    => $BOOLEAN, 
    177     store   => $HUMAN, 
    178     default => 0, 
    179 ); 
    180 setting( 
    181     name    => 'main_errorlist', 
    182     type    => $BOOLEAN, 
    183     store   => $HUMAN, 
    184     default => 0, 
    185 ); 
    186 setting( 
    187     name    => 'main_statusbar', 
    188     type    => $BOOLEAN, 
    189     store   => $HUMAN, 
    190     default => 1, 
    191 ); 
    192  
    193 # Editor settings 
    194 setting( 
    195     name    => 'editor_font', 
    196     type    => $ASCII, 
    197     store   => $HUMAN, 
    198     default => '', 
    199 ); 
    200 setting( 
    201     name    => 'editor_linenumbers', 
    202     type    => $BOOLEAN, 
    203     store   => $HUMAN, 
    204     default => 1, 
    205 ); 
    206 setting( 
    207     name    => 'editor_eol', 
    208     type    => $BOOLEAN, 
    209     store   => $HUMAN, 
    210     default => 0, 
    211 ); 
    212 setting( 
    213     name    => 'editor_whitespace', 
    214     type    => $BOOLEAN, 
    215     store   => $HUMAN, 
    216     default => 0, 
    217 ); 
    218 setting( 
    219     name    => 'editor_indentationguides', 
    220     type    => $BOOLEAN, 
    221     store   => $HUMAN, 
    222     default => 0, 
    223 ); 
    224 setting( 
    225     name    => 'editor_calltips', 
    226     type    => $BOOLEAN, 
    227     store   => $HUMAN, 
    228     default => 0, 
    229 ); 
    230 setting( 
    231     name    => 'editor_autoindent', 
    232     type    => $ASCII, 
    233     store   => $HUMAN, 
    234     default => 'deep', 
    235 ); 
    236 setting( 
    237     name    => 'editor_folding', 
    238     type    => $BOOLEAN, 
    239     store   => $HUMAN, 
    240     default => 0, 
    241 ); 
    242 setting( 
    243     name    => 'editor_currentline', 
    244     type    => $BOOLEAN, 
    245     store   => $HUMAN, 
    246     default => 1, 
    247 ); 
    248 setting( 
    249     name    => 'editor_currentline_color', 
    250     type    => $ASCII, 
    251     store   => $HUMAN, 
    252     default => 'FFFF04', 
    253 ); 
    254 setting( 
    255     name    => 'editor_beginner', 
    256     type    => $BOOLEAN, 
    257     store   => $HUMAN, 
    258     default => 1, 
    259 ); 
    260 setting( 
    261     name    => 'editor_wordwrap', 
    262     type    => $BOOLEAN, 
    263     store   => $HUMAN, 
    264     default => 0, 
    265 ); 
    266 setting( 
    267     name    => 'find_case', 
    268     type    => $BOOLEAN, 
    269     store   => $HUMAN, 
    270     default => 1, 
    271 ); 
    272 setting( 
    273     name    => 'find_regex', 
    274     type    => $BOOLEAN, 
    275     store   => $HUMAN, 
    276     default => 0, 
    277 ); 
    278 setting( 
    279     name    => 'find_reverse', 
    280     type    => $BOOLEAN, 
    281     store   => $HUMAN, 
    282     default => 0, 
    283 ); 
    284 setting( 
    285     name    => 'find_first', 
    286     type    => $BOOLEAN, 
    287     store   => $HUMAN, 
    288     default => 0, 
    289 ); 
    290 setting( 
    291     name    => 'find_nohidden', 
    292     type    => $BOOLEAN, 
    293     store   => $HUMAN, 
    294     default => 1, 
    295 ); 
    296 setting( 
    297     name    => 'find_quick', 
    298     type    => $BOOLEAN, 
    299     store   => $HUMAN, 
    300     default => 0, 
    301 ); 
    302 setting( 
    303     name    => 'ppi_highlight', 
    304     type    => $BOOLEAN, 
    305     store   => $HUMAN, 
    306     default => 0, 
    307 ); 
    308 setting( 
    309     name    => 'ppi_highlight_limit', 
    310     type    => $POSINT, 
    311     store   => $HUMAN, 
    312     default => 2000, 
    313 ); 
    314  
    315 # Behaviour Tuning 
    316 setting( 
    317     # When running a script from the application some of the files might have not been saved yet. 
    318     # There are several option what to do before running the script 
    319     # none - don's save anything 
     79    [ 'main_startup',         $ASCII,   'new'          ], 
     80    [ 'main_lockinterface',   $BOOLEAN, 1              ], 
     81    [ 'main_functions',       $BOOLEAN, 0              ], 
     82    [ 'main_functions_order', $ASCII,   'alphabetical' ], 
     83    [ 'main_outline',         $BOOLEAN, 0              ], 
     84    [ 'main_directory',       $BOOLEAN, 0              ], 
     85    [ 'main_output',          $BOOLEAN, 0              ], 
     86    [ 'main_output_ansi',     $BOOLEAN, 1              ], 
     87    [ 'main_syntaxcheck',     $BOOLEAN, 0              ], 
     88    [ 'main_errorlist',       $BOOLEAN, 0              ], 
     89    [ 'main_statusbar',       $BOOLEAN, 1              ], 
     90     
     91    # -- editor settings 
     92    [ 'editor_font',              $ASCII,   ''       ], 
     93    [ 'editor_linenumbers',       $BOOLEAN, 1        ], 
     94    [ 'editor_eol',               $BOOLEAN, 0        ], 
     95    [ 'editor_whitespace',        $BOOLEAN, 0        ], 
     96    [ 'editor_indentationguides', $BOOLEAN, 0        ], 
     97    [ 'editor_calltips',          $BOOLEAN, 0        ], 
     98    [ 'editor_autoindent',        $ASCII,   'deep'   ], 
     99    [ 'editor_folding',           $BOOLEAN, 0        ], 
     100    [ 'editor_currentline',       $BOOLEAN, 1        ], 
     101    [ 'editor_currentline_color', $ASCII,   'FFFF04' ], 
     102    [ 'editor_beginner',          $BOOLEAN, 1        ], 
     103    [ 'editor_wordwrap',          $BOOLEAN, 0        ], 
     104    [ 'find_case',                $BOOLEAN, 1        ], 
     105    [ 'find_regex',               $BOOLEAN, 0        ], 
     106    [ 'find_reverse',             $BOOLEAN, 0        ], 
     107    [ 'find_first',               $BOOLEAN, 0        ], 
     108    [ 'find_nohidden',            $BOOLEAN, 1        ], 
     109    [ 'find_quick',               $BOOLEAN, 0        ], 
     110    [ 'ppi_highlight',            $BOOLEAN, 1        ], 
     111    [ 'ppi_highlight_limit',      $POSINT,  2000     ], 
     112     
     113    # -- behaviour tuning 
     114    # When running a script from the application some of the files might have 
     115    # not been saved yet. There are several option what to do before running the 
     116    # script: 
     117    # none - don't save anything 
    320118    # same - save the file in the current buffer 
    321119    # all_files - all the files (but not buffers that have no filenames) 
    322120    # all_buffers - all the buffers even if they don't have a name yet 
    323     name    => 'run_save', 
    324     type    => $ASCII, 
    325     store   => $HUMAN, 
    326     default => 'same', 
     121    [ 'run_save',              $ASCII,   'same' ], 
     122    # move of stacktrace to run menu: will be removed (run_stacktrace) 
     123    [ 'run_stacktrace',        $BOOLEAN, 0      ], 
     124    [ 'autocomplete_brackets', $BOOLEAN, 0      ], 
     125    # by default use background threads unless profiling 
     126    # TODO - Make the default actually change 
     127    [ 'threads',               $BOOLEAN, 1      ], 
     128    [ 'locale',                $ASCII,   ''     ], 
     129    [ 'locale_perldiag',       $ASCII,   ''     ], 
     130    [ 'experimental',          $BOOLEAN, 0      ], 
     131], 
     132host => [ 
     133    # for each setting, add an array ref: 
     134    # [ $setting_name, $setting_type, $setting_default ] 
     135 
     136    # -- color data 
     137    # since it's in local files, it has to be a host-specific setting 
     138    [ 'editor_style', $ASCII, 'default' ], 
     139     
     140    # -- window geometry 
     141    [ 'main_maximized', $BOOLEAN, 0   ], 
     142    [ 'main_top',       $INTEGER, 40  ], 
     143    [ 'main_left',      $INTEGER, 20  ], 
     144    [ 'main_width',     $POSINT,  600 ], 
     145    [ 'main_height',    $POSINT,  400 ], 
     146], 
    327147); 
    328 # Move of stacktrace to run menu: will be removed (run_stacktrace) 
    329 setting( 
    330     name    => 'run_stacktrace', 
    331     type    => $BOOLEAN, 
    332     store   => $HUMAN, 
    333     default => 0, 
     148my %store = ( 
     149    human => $HUMAN, 
     150    host  => $HOST, 
    334151); 
    335 setting( 
    336     name    => 'autocomplete_brackets', 
    337     type    => $BOOLEAN, 
    338     store   => $HUMAN, 
    339     default => 0, 
    340 ); 
    341 setting( 
    342     # By default use background threads unless profiling 
    343     # TODO - Make the default actually change 
    344     name    => 'threads', 
    345     type    => $BOOLEAN, 
    346     store   => $HUMAN, 
    347     default => 1, 
    348 ); 
    349 setting( 
    350     name    => 'locale', 
    351     type    => $ASCII, 
    352     store   => $HUMAN, 
    353     default => '', 
    354 ); 
    355 setting( 
    356     name    => 'locale_perldiag', 
    357     type    => $ASCII, 
    358     store   => $HUMAN, 
    359     default => '', 
    360 ); 
    361 setting( 
    362     name    => 'experimental', 
    363     type    => $BOOLEAN, 
    364     store   => $HUMAN, 
    365     default => 0, 
    366 ); 
    367  
    368 # Because the colour data is in local files, 
    369 # it has to be a host-specific setting. 
    370 setting( 
    371     name    => 'editor_style', 
    372     type    => $ASCII, 
    373     store   => $HOST, 
    374     default => 'default', 
    375 ); 
    376  
    377 # Window geometry 
    378 setting( 
    379     name    => 'main_maximized', 
    380     type    => $BOOLEAN, 
    381     store   => $HOST, 
    382     default => 0, 
    383 ); 
    384 setting( 
    385     name    => 'main_top', 
    386     type    => $INTEGER, 
    387     store   => $HOST, 
    388     default => 40, 
    389 ); 
    390 setting( 
    391     name    => 'main_left', 
    392     type    => $INTEGER, 
    393     store   => $HOST, 
    394     default => 20, 
    395 ); 
    396 setting( 
    397     name    => 'main_width', 
    398     type    => $POSINT, 
    399     store   => $HOST, 
    400     default => 600, 
    401 ); 
    402 setting( 
    403     name    => 'main_height', 
    404     type    => $POSINT, 
    405     store   => $HOST, 
    406     default => 400, 
    407 ); 
    408  
    409  
     152foreach my $type ( keys %settings ) { 
     153    my $settings = $settings{$type}; 
     154    my $store    = $store{$type}; 
     155    foreach my $setting ( @$settings ) { 
     156        my ($name, $type, $default) = @$setting; 
     157        setting( 
     158            name    => $name, 
     159            type    => $type, 
     160            store   => $store, 
     161            default => $default, 
     162        ); 
     163    } 
     164} 
    410165 
    411166 
Note: See TracChangeset for help on using the changeset viewer.