Skip to content

Commit

Permalink
new feature: added new default columns naming method option
Browse files Browse the repository at this point in the history
  • Loading branch information
Samuel Linclau committed Oct 21, 2015
1 parent d75727a commit 84260ec
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 8 deletions.
17 changes: 11 additions & 6 deletions lib/column-name.coffee
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@

module.exports =
columnName = (index) ->
base = 'A B C D E F G H I J K L M N O P Q R S T U V W X Y Z'.split(' ')
if atom.config.get('tablr.defaultColumnNamingMethod') == 'numeric'
(1+index) + ''
else if atom.config.get('tablr.defaultColumnNamingMethod') == 'numericZeroBased'
index + ''
else
base = 'A B C D E F G H I J K L M N O P Q R S T U V W X Y Z'.split(' ')

quotient = Math.floor(index / 26)
quotient = Math.floor(index / 26)

if quotient > 0
columnName(quotient - 1) + base[index % 26]
else
base[index % 26]
if quotient > 0
columnName(quotient - 1) + base[index % 26]
else
base[index % 26]
6 changes: 5 additions & 1 deletion lib/tablr.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -73,11 +73,15 @@ module.exports =
type: 'boolean'
default: true
description: 'When copying from a table to paste the content in a text editor this setting will make each cell appear as if they were created from different selections.'

supportedCsvExtensions:
type: 'array'
default: ['csv', 'tsv']
description: 'The extensions for which the CSV opener will be used.'
defaultColumnNamingMethod:
type: 'string'
default: 'alphabetic'
enum: ['alphabetic', 'numeric', 'numericZeroBased']
description: 'When file has no header, select the default naming method for the columns. `alphabetic` means use A, B,..., Z, AA, AB.. `numeric` is for simple numbers, ie 1,2.. `numericZeroBased` is similar as numeric, except that it starts numbering from 0 instead of 1'

activate: ({csvConfig}) ->
@csvConfig = new CSVConfig(csvConfig)
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "tablr",
"main": "./lib/tablr",
"version": "0.5.1",
"version": "0.5.2",
"description": "Edit CSV files using a table editor",
"repository": "https://github.com/abe33/atom-tablr",
"license": "MIT",
Expand Down

0 comments on commit 84260ec

Please sign in to comment.