Created
January 21, 2018 16:19
-
-
Save mrcsxsiq/5f122c19d298be263c44534c37606b43 to your computer and use it in GitHub Desktop.
~/.atom/packages/touchbar-utility/lib/configuration.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
exports.configuration = [{ | |
type: 'button', | |
label: '//', | |
clickDispatchAction: 'editor:toggle-line-comments', | |
}, | |
{ | |
type: 'button', | |
label: '💅', | |
clickDispatchAction: 'atom-beautify:beautify-editor' | |
}, | |
{ | |
type: 'color-picker', | |
availableColors: ['#FFFFFF', '#569FF8', '#7EBE50', '#909398', '#DDA350', '#E57470'], | |
selectedColor: '#569FF8', | |
change: (color) => { | |
// atom.notifications.addInfo(String(color)); | |
// inserts the current selected color | |
// get current cursor position | |
var cbp = atom.workspace.getActiveTextEditor().getCursorBufferPosition() | |
// check if cursor is at beginning of color hex string | |
// otherwise insert 7 spaces that will be replaced with hex string | |
var nextText = atom.workspace.getActiveTextEditor().getTextInBufferRange([ | |
[cbp.row, cbp.column], | |
[cbp.row, cbp.column + 7] | |
]) | |
const colorRegEx = new RegExp('#[A-Fa-f0-9]{6}') | |
if (!colorRegEx.test(nextText)) { | |
atom.workspace.getActiveTextEditor().insertText(' ') | |
} | |
// insert color string into next 7 range | |
atom.workspace.getActiveTextEditor().setTextInBufferRange([ | |
[cbp.row, cbp.column], | |
[cbp.row, cbp.column + 7] | |
], color) | |
// set cursor position to begin of color hex code | |
atom.workspace.getActiveTextEditor().setCursorBufferPosition(cbp) | |
} | |
}, | |
{ | |
type: 'spacer', | |
size: 'flexible' | |
}, | |
{ | |
type: 'group', | |
items: [{ | |
type: 'button', | |
label: 'Markdown', | |
clickDispatchAction: 'markdown-preview:toggle' | |
}, | |
{ | |
type: 'button', | |
label: 'GitHub', | |
clickDispatchAction: 'github:toggle-github-tab' | |
}, | |
{ | |
type: 'button', | |
label: 'Todo', | |
clickDispatchAction: 'todo-show:find-in-workspace' | |
}, | |
{ | |
type: 'button', | |
label: 'Console', | |
clickDispatchAction: 'platformio-ide-terminal:toggle' | |
} | |
] | |
} | |
] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment