Search Google - Selection
This commit is contained in:
parent
b7453ff4f1
commit
21324f6ab6
BIN
type-script-helper-1.2.5.vsix
Normal file
BIN
type-script-helper-1.2.5.vsix
Normal file
Binary file not shown.
BIN
type-script-helper-1.2.6.vsix
Normal file
BIN
type-script-helper-1.2.6.vsix
Normal file
Binary file not shown.
BIN
type-script-helper-1.2.7.vsix
Normal file
BIN
type-script-helper-1.2.7.vsix
Normal file
Binary file not shown.
BIN
type-script-helper-1.2.8.vsix
Normal file
BIN
type-script-helper-1.2.8.vsix
Normal file
Binary file not shown.
@ -57,3 +57,13 @@ Added split(' group by ').join('\r\n GROUP BY ').
|
|||||||
## Working with Markdown
|
## Working with Markdown
|
||||||
|
|
||||||
### For more information
|
### For more information
|
||||||
|
|
||||||
|
### 1.2.4
|
||||||
|
-----------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
## Search Google
|
||||||
|
|
||||||
|
### 1.2.8
|
||||||
|
-----------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
## Search Google (Read Only Lines Helper)
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
"description": "Helper for VS Code in TypeScript",
|
"description": "Helper for VS Code in TypeScript",
|
||||||
"publisher": "IFX",
|
"publisher": "IFX",
|
||||||
"repository": "https://github.com/mikepharesjr/YO-VSCode/tree/master/type-script-helper",
|
"repository": "https://github.com/mikepharesjr/YO-VSCode/tree/master/type-script-helper",
|
||||||
"version": "1.2.4",
|
"version": "1.2.8",
|
||||||
"engines": {
|
"engines": {
|
||||||
"vscode": "^1.40.0"
|
"vscode": "^1.40.0"
|
||||||
},
|
},
|
||||||
@ -13,43 +13,43 @@
|
|||||||
],
|
],
|
||||||
"main": "./out/extension.js",
|
"main": "./out/extension.js",
|
||||||
"activationEvents": [
|
"activationEvents": [
|
||||||
"onCommand:helper.addCSharpComment",
|
"onCommand:readOnlyLinesHelper.searchGoogle",
|
||||||
"onCommand:helper.addVBComment",
|
"onCommand:replaceLinesHelper.addCSharpComment",
|
||||||
"onCommand:helper.convertToRegularExpression",
|
"onCommand:replaceLinesHelper.addVBComment",
|
||||||
"onCommand:helper.cutEachLine",
|
"onCommand:replaceLinesHelper.convertToRegularExpression",
|
||||||
"onCommand:helper.expandSql",
|
"onCommand:replaceLinesHelper.cutEachLine",
|
||||||
"onCommand:helper.listToListFamily",
|
"onCommand:replaceLinesHelper.expandSql",
|
||||||
"onCommand:helper.listToListWrappedComma",
|
"onCommand:replaceLinesHelper.listToListFamily",
|
||||||
"onCommand:helper.prettySql",
|
"onCommand:replaceLinesHelper.listToListWrappedComma",
|
||||||
"onCommand:helper.removeComment",
|
"onCommand:replaceLinesHelper.prettySql",
|
||||||
"onCommand:helper.searchGoogle",
|
"onCommand:replaceLinesHelper.removeComment",
|
||||||
"onCommand:helper.sortLength",
|
"onCommand:replaceLinesHelper.sortLength",
|
||||||
"onCommand:helper.sortNormal",
|
"onCommand:replaceLinesHelper.sortNormal",
|
||||||
"onCommand:helper.unwrapSql",
|
"onCommand:replaceLinesHelper.unwrapSql",
|
||||||
"onCommand:helper.wrapSqlCSharp",
|
"onCommand:replaceLinesHelper.wrapSqlCSharp",
|
||||||
"onCommand:helper.wrapSqlVB"
|
"onCommand:replaceLinesHelper.wrapSqlVB"
|
||||||
],
|
],
|
||||||
"contributes": {
|
"contributes": {
|
||||||
"commands": [
|
"commands": [
|
||||||
{ "command": "helper.addCSharpComment", "title": "Add C# Comment" },
|
{ "command": "readOnlyLinesHelper.searchGoogle", "title": "Search Google" },
|
||||||
{ "command": "helper.addVBComment", "title": "Add VB Comment" },
|
{ "command": "replaceLinesHelper.addCSharpComment", "title": "Add C# Comment" },
|
||||||
{ "command": "helper.convertToRegularExpression", "title": "Convert to Regular Expression" },
|
{ "command": "replaceLinesHelper.addVBComment", "title": "Add VB Comment" },
|
||||||
{ "command": "helper.cutEachLine", "title": "Cut each line after |||" },
|
{ "command": "replaceLinesHelper.convertToRegularExpression", "title": "Convert to Regular Expression" },
|
||||||
{ "command": "helper.expandSql", "title": "Expand Sql" },
|
{ "command": "replaceLinesHelper.cutEachLine", "title": "Cut each line after |||" },
|
||||||
{ "command": "helper.listToListFamily", "title": "List to list family (Kristy, Mike ...)" },
|
{ "command": "replaceLinesHelper.expandSql", "title": "Expand Sql" },
|
||||||
{ "command": "helper.listToListWrappedComma", "title": "List to list wrapped comma" },
|
{ "command": "replaceLinesHelper.listToListFamily", "title": "List to list family (Kristy, Mike ...)" },
|
||||||
{ "command": "helper.prettySql", "title": "Pretty Sql" },
|
{ "command": "replaceLinesHelper.listToListWrappedComma", "title": "List to list wrapped comma" },
|
||||||
{ "command": "helper.removeComment", "title": "Remove comment" },
|
{ "command": "replaceLinesHelper.prettySql", "title": "Pretty Sql" },
|
||||||
{ "command": "helper.searchGoogle", "title": "Search Google" },
|
{ "command": "replaceLinesHelper.removeComment", "title": "Remove comment" },
|
||||||
{ "command": "helper.sortLength", "title": "Sort by Length" },
|
{ "command": "replaceLinesHelper.sortLength", "title": "Sort by Length" },
|
||||||
{ "command": "helper.sortNormal", "title": "My Sort lines (ascending, case sensitive)" },
|
{ "command": "replaceLinesHelper.sortNormal", "title": "My Sort lines (ascending, case sensitive)" },
|
||||||
{ "command": "helper.unwrapSql", "title": "Un-wrap Sql" },
|
{ "command": "replaceLinesHelper.unwrapSql", "title": "Un-wrap Sql" },
|
||||||
{ "command": "helper.wrapSqlCSharp", "title": "Wrap Sql for C#" },
|
{ "command": "replaceLinesHelper.wrapSqlCSharp", "title": "Wrap Sql for C#" },
|
||||||
{ "command": "helper.wrapSqlVB", "title": "Wrap Sql for VB" }
|
{ "command": "replaceLinesHelper.wrapSqlVB", "title": "Wrap Sql for VB" }
|
||||||
],
|
],
|
||||||
"keybindings": [
|
"keybindings": [
|
||||||
{
|
{
|
||||||
"command": "helper.unwrapSql",
|
"command": "replaceLinesHelper.unwrapSql",
|
||||||
"key": "shift + f9",
|
"key": "shift + f9",
|
||||||
"when": "editorTextFocus"
|
"when": "editorTextFocus"
|
||||||
}
|
}
|
||||||
@ -57,9 +57,9 @@
|
|||||||
"menus": {
|
"menus": {
|
||||||
"editor/context": [
|
"editor/context": [
|
||||||
{
|
{
|
||||||
"command": "helper.unwrapSql",
|
"command": "replaceLinesHelper.unwrapSql",
|
||||||
"when": "editorTextFocus",
|
"when": "editorTextFocus",
|
||||||
"group": "helper@1"
|
"group": "replaceLinesHelper@1"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,8 @@
|
|||||||
// The module 'vscode' contains the VS Code extensibility API
|
// The module 'vscode' contains the VS Code extensibility API
|
||||||
// Import the module and reference it with the alias vscode in your code below
|
// Import the module and reference it with the alias vscode in your code below
|
||||||
import * as vscode from 'vscode';
|
import * as vscode from 'vscode';
|
||||||
import * as helper from './helper';
|
import * as replaceLinesHelper from './replaceLinesHelper';
|
||||||
|
import * as readOnlyLinesHelper from './readOnlyLinesHelper';
|
||||||
|
|
||||||
// this method is called when your extension is activated
|
// this method is called when your extension is activated
|
||||||
// your extension is activated the very first time the command is executed
|
// your extension is activated the very first time the command is executed
|
||||||
@ -25,21 +26,21 @@ export function activate(context: vscode.ExtensionContext) {
|
|||||||
// context.subscriptions.push(disposable);
|
// context.subscriptions.push(disposable);
|
||||||
|
|
||||||
const commands = [
|
const commands = [
|
||||||
vscode.commands.registerCommand('helper.addCSharpComment', helper.addCSharpComment),
|
vscode.commands.registerCommand('readOnlyLinesHelper.searchGoogle', readOnlyLinesHelper.searchGoogle),
|
||||||
vscode.commands.registerCommand('helper.addVBComment', helper.addVBComment),
|
vscode.commands.registerCommand('replaceLinesHelper.addCSharpComment', replaceLinesHelper.addCSharpComment),
|
||||||
vscode.commands.registerCommand('helper.convertToRegularExpression', helper.convertToRegularExpression),
|
vscode.commands.registerCommand('replaceLinesHelper.addVBComment', replaceLinesHelper.addVBComment),
|
||||||
vscode.commands.registerCommand('helper.cutEachLine', helper.cutEachLine),
|
vscode.commands.registerCommand('replaceLinesHelper.convertToRegularExpression', replaceLinesHelper.convertToRegularExpression),
|
||||||
vscode.commands.registerCommand('helper.expandSql', helper.expandSql),
|
vscode.commands.registerCommand('replaceLinesHelper.cutEachLine', replaceLinesHelper.cutEachLine),
|
||||||
vscode.commands.registerCommand('helper.listToListFamily', helper.listToListFamily),
|
vscode.commands.registerCommand('replaceLinesHelper.expandSql', replaceLinesHelper.expandSql),
|
||||||
vscode.commands.registerCommand('helper.listToListWrappedComma', helper.listToListWrappedComma),
|
vscode.commands.registerCommand('replaceLinesHelper.listToListFamily', replaceLinesHelper.listToListFamily),
|
||||||
vscode.commands.registerCommand('helper.prettySql', helper.prettySql),
|
vscode.commands.registerCommand('replaceLinesHelper.listToListWrappedComma', replaceLinesHelper.listToListWrappedComma),
|
||||||
vscode.commands.registerCommand('helper.removeComment', helper.removeComment),
|
vscode.commands.registerCommand('replaceLinesHelper.prettySql', replaceLinesHelper.prettySql),
|
||||||
vscode.commands.registerCommand('helper.searchGoogle', helper.searchGoogle),
|
vscode.commands.registerCommand('replaceLinesHelper.removeComment', replaceLinesHelper.removeComment),
|
||||||
vscode.commands.registerCommand('helper.sortLength', helper.sortLength),
|
vscode.commands.registerCommand('replaceLinesHelper.sortLength', replaceLinesHelper.sortLength),
|
||||||
vscode.commands.registerCommand('helper.sortNormal', helper.sortNormal),
|
vscode.commands.registerCommand('replaceLinesHelper.sortNormal', replaceLinesHelper.sortNormal),
|
||||||
vscode.commands.registerCommand('helper.unwrapSql', helper.unwrapSql),
|
vscode.commands.registerCommand('replaceLinesHelper.unwrapSql', replaceLinesHelper.unwrapSql),
|
||||||
vscode.commands.registerCommand('helper.wrapSqlCSharp', helper.wrapSqlCSharp),
|
vscode.commands.registerCommand('replaceLinesHelper.wrapSqlCSharp', replaceLinesHelper.wrapSqlCSharp),
|
||||||
vscode.commands.registerCommand('helper.wrapSqlVB', helper.wrapSqlVB)
|
vscode.commands.registerCommand('replaceLinesHelper.wrapSqlVB', replaceLinesHelper.wrapSqlVB)
|
||||||
];
|
];
|
||||||
|
|
||||||
commands.forEach(command => context.subscriptions.push(command));
|
commands.forEach(command => context.subscriptions.push(command));
|
||||||
|
51
type-script-helper/src/readOnlyLinesHelper.ts
Normal file
51
type-script-helper/src/readOnlyLinesHelper.ts
Normal file
@ -0,0 +1,51 @@
|
|||||||
|
import * as vscode from 'vscode';
|
||||||
|
|
||||||
|
enum LinesAction {
|
||||||
|
searchGoogle
|
||||||
|
}
|
||||||
|
|
||||||
|
function searchGoogleLogic(text: string, lines: string[]): void {
|
||||||
|
if (text.length > 0) {
|
||||||
|
vscode.env.openExternal(
|
||||||
|
vscode.Uri.parse(`https://www.google.com/search?q=${text.trim()}`)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
else if (lines.length > 0) {
|
||||||
|
vscode.env.openExternal(
|
||||||
|
vscode.Uri.parse(`https://www.google.com/search?q=${lines[0].trim()}`)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function getLines(textEditor: vscode.TextEditor, startLine: number, endLine: number) {
|
||||||
|
let results: string[] = [];
|
||||||
|
for (let i = startLine; i <= endLine; i++) {
|
||||||
|
results.push(textEditor.document.lineAt(i).text);
|
||||||
|
}
|
||||||
|
return results;
|
||||||
|
}
|
||||||
|
|
||||||
|
function linesFunction(linesAction: LinesAction): Thenable<boolean> | undefined {
|
||||||
|
const textEditor = vscode.window.activeTextEditor;
|
||||||
|
if (!textEditor) {
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
let text = '';
|
||||||
|
var startLine = 0;
|
||||||
|
var endLine = textEditor.document.lineCount - 1;
|
||||||
|
const selection = textEditor.selection;
|
||||||
|
if (!selection.isEmpty) {
|
||||||
|
startLine = selection.start.line;
|
||||||
|
endLine = selection.end.line;
|
||||||
|
let range = new vscode.Range(selection.start, selection.end)
|
||||||
|
text = textEditor.document.getText(range);
|
||||||
|
}
|
||||||
|
let lines: string[] = getLines(textEditor, startLine, endLine);
|
||||||
|
switch (linesAction) {
|
||||||
|
case LinesAction.searchGoogle: { searchGoogleLogic(text, lines); break; }
|
||||||
|
default: { throw new Error(); }
|
||||||
|
}
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
|
||||||
|
export const searchGoogle = () => linesFunction(LinesAction.searchGoogle);
|
@ -1,5 +1,4 @@
|
|||||||
import * as vscode from 'vscode';
|
import * as vscode from 'vscode';
|
||||||
import { stringify } from 'querystring';
|
|
||||||
|
|
||||||
type ArrayTransformer = (lines: string[]) => string[];
|
type ArrayTransformer = (lines: string[]) => string[];
|
||||||
type SortingAlgorithm = (a: string, b: string) => number;
|
type SortingAlgorithm = (a: string, b: string) => number;
|
||||||
@ -15,7 +14,6 @@ enum LinesAction {
|
|||||||
prettySql,
|
prettySql,
|
||||||
pdsfToFixedWidth,
|
pdsfToFixedWidth,
|
||||||
removeComment,
|
removeComment,
|
||||||
searchGoogle,
|
|
||||||
sortLength,
|
sortLength,
|
||||||
sortNormal,
|
sortNormal,
|
||||||
unwrapSql,
|
unwrapSql,
|
||||||
@ -158,14 +156,6 @@ function removeCommentLogic(lines: string[]): void {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function searchGoogleLogic(lines: string[]): void {
|
|
||||||
for (let i = 0; i < lines.length; ++i) {
|
|
||||||
vscode.env.openExternal(
|
|
||||||
vscode.Uri.parse(`https://www.google.com/search?q=${lines[i]}`)
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function makeSorter(algorithm?: SortingAlgorithm): ArrayTransformer {
|
function makeSorter(algorithm?: SortingAlgorithm): ArrayTransformer {
|
||||||
return function (lines: string[]): string[] {
|
return function (lines: string[]): string[] {
|
||||||
return lines.sort(algorithm);
|
return lines.sort(algorithm);
|
||||||
@ -276,7 +266,6 @@ function linesFunction(linesAction: LinesAction): Thenable<boolean> | undefined
|
|||||||
case LinesAction.listToListWrappedComma: { listToListWrappedCommaLogic(lines); break; }
|
case LinesAction.listToListWrappedComma: { listToListWrappedCommaLogic(lines); break; }
|
||||||
case LinesAction.prettySql: { prettySqlLogic(lines); break; }
|
case LinesAction.prettySql: { prettySqlLogic(lines); break; }
|
||||||
case LinesAction.removeComment: { removeCommentLogic(lines); break; }
|
case LinesAction.removeComment: { removeCommentLogic(lines); break; }
|
||||||
case LinesAction.searchGoogle: { searchGoogleLogic(lines); break; }
|
|
||||||
case LinesAction.sortLength: { sortLengthLogic(lines); break; }
|
case LinesAction.sortLength: { sortLengthLogic(lines); break; }
|
||||||
case LinesAction.sortNormal: { sortNormalLogic(lines); break; }
|
case LinesAction.sortNormal: { sortNormalLogic(lines); break; }
|
||||||
case LinesAction.unwrapSql: { unwrapSqlLogic(lines); break; }
|
case LinesAction.unwrapSql: { unwrapSqlLogic(lines); break; }
|
||||||
@ -297,7 +286,6 @@ export const listToListWrappedComma = () => linesFunction(LinesAction.listToList
|
|||||||
export const prettySql = () => linesFunction(LinesAction.prettySql);
|
export const prettySql = () => linesFunction(LinesAction.prettySql);
|
||||||
export const pdsfToFixedWidth = () => linesFunction(LinesAction.pdsfToFixedWidth);
|
export const pdsfToFixedWidth = () => linesFunction(LinesAction.pdsfToFixedWidth);
|
||||||
export const removeComment = () => linesFunction(LinesAction.removeComment);
|
export const removeComment = () => linesFunction(LinesAction.removeComment);
|
||||||
export const searchGoogle = () => linesFunction(LinesAction.searchGoogle);
|
|
||||||
export const sortLength = () => linesFunction(LinesAction.sortLength);
|
export const sortLength = () => linesFunction(LinesAction.sortLength);
|
||||||
export const sortNormal = () => linesFunction(LinesAction.sortNormal);
|
export const sortNormal = () => linesFunction(LinesAction.sortNormal);
|
||||||
export const unwrapSql = () => linesFunction(LinesAction.unwrapSql);
|
export const unwrapSql = () => linesFunction(LinesAction.unwrapSql);
|
Loading…
x
Reference in New Issue
Block a user