mirror of
https://github.com/nyanotech/recombobulator
synced 2025-12-16 11:30:21 -08:00
Add an un-base64 command
This commit is contained in:
parent
a6157d0a16
commit
cd85661f8d
12
package.json
12
package.json
@ -17,7 +17,8 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"activationEvents": [
|
"activationEvents": [
|
||||||
"onCommand:recombobulator.base64"
|
"onCommand:recombobulator.base64",
|
||||||
|
"onCommand:recombobulator.unbase64"
|
||||||
],
|
],
|
||||||
"contributes": {
|
"contributes": {
|
||||||
"commands": [
|
"commands": [
|
||||||
@ -25,6 +26,11 @@
|
|||||||
"command": "recombobulator.base64",
|
"command": "recombobulator.base64",
|
||||||
"category": "Recombobulator",
|
"category": "Recombobulator",
|
||||||
"title": "base64 encode"
|
"title": "base64 encode"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"command": "recombobulator.unbase64",
|
||||||
|
"category": "Recombobulator",
|
||||||
|
"title": "base64 decode"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"menus": {
|
"menus": {
|
||||||
@ -32,6 +38,10 @@
|
|||||||
{
|
{
|
||||||
"command": "recombobulator.base64",
|
"command": "recombobulator.base64",
|
||||||
"when": "editorHasSelection"
|
"when": "editorHasSelection"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"command": "recombobulator.unbase64",
|
||||||
|
"when": "editorHasSelection"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
@ -4,6 +4,10 @@ function base64(a: string) {
|
|||||||
return Buffer.from(a).toString('base64'); // TODO - handle different character encodings
|
return Buffer.from(a).toString('base64'); // TODO - handle different character encodings
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function unbase64(a: string) {
|
||||||
|
return Buffer.from(a, 'base64').toString("utf-8"); // TODO - handle different character encodings
|
||||||
|
}
|
||||||
|
|
||||||
function applyEdit(transform: Function) {
|
function applyEdit(transform: Function) {
|
||||||
const editor = vscode.window.activeTextEditor;
|
const editor = vscode.window.activeTextEditor;
|
||||||
|
|
||||||
@ -27,4 +31,8 @@ export function activate(context: vscode.ExtensionContext) {
|
|||||||
applyEdit(base64);
|
applyEdit(base64);
|
||||||
vscode.window.showInformationMessage('base64-encoded the selection!');
|
vscode.window.showInformationMessage('base64-encoded the selection!');
|
||||||
}));
|
}));
|
||||||
|
context.subscriptions.push(vscode.commands.registerCommand('recombobulator.unbase64', () => {
|
||||||
|
applyEdit(unbase64);
|
||||||
|
vscode.window.showInformationMessage('base64-decoded the selection!');
|
||||||
|
}));
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user