Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 'use strict';
- // The module 'vscode' contains the VS Code extensibility API
- // Import the module and reference it with the alias vscode in your code below
- import * as vscode from 'vscode';
- import { ChromaApp, Color, Key } from '../chroma.cjs';
- // this method is called when your extension is activated
- // your extension is activated the very first time the command is executed
- const activeTextEditor = vscode.window.activeTextEditor;
- export function activate(context: vscode.ExtensionContext) {
- // Use the console to output diagnostic information (console.log) and errors (console.error)
- // This line of code will only be executed once when your extension is activated
- console.log('Congratulations, your extension "vimrbgg" is now active!');
- // The command has been defined in the package.json file
- // Now provide the implementation of the command with registerCommand
- // The commandId parameter must match the command field in package.js0n3
- let razor = new RazorKeys();
- let rzrCtrl = new RazorController(razor);
- vscode.window.showInformationMessage('Razor Updates !');
- let green = vscode.commands.registerCommand('extension.setLightGreen', () => {
- razor.UpdateLightsGreen();
- });
- let red = vscode.commands.registerCommand('extension.setLightRed', () => {
- razor.UpdateLightsRed();
- });
- context.subscriptions.push(razor);
- context.subscriptions.push(rzrCtrl);
- context.subscriptions.push(green);
- context.subscriptions.push(red);
- }
- // this method is called when your extension is deactivated
- export function deactivate() {
- }
- class RazorController {
- private _rzrCounter: RazorKeys;
- private _disposable: vscode.Disposable;
- private _hasCursorChanged: boolean;
- private _cursorStyle: vscode.TextEditorCursorStyle;
- constructor(razrCounter: RazorKeys) {
- this._rzrCounter = razrCounter;
- this._hasCursorChanged = false;
- this._cursorStyle = vscode.TextEditorCursorStyle.Line;
- // subscribe to selection change and editor activation events
- let subscriptions: vscode.Disposable[] = [];
- vscode.window.onDidChangeTextEditorSelection(this._onEvent, this, subscriptions);
- // vscode.window.onDidChangeActiveTextEditor(this._onEvent, this, subscriptions);
- // vscode.window.onDidChangeTextEditorOptions(this.updateEditorSettings, this, subscriptions);
- //vscode.window.onDidChangeTextEditorOptions(this._onEvent, this, subscriptions);
- // update the counter for the current file
- // this._rzrCounter.UpdateLights();
- // create a combined disposable from both event subscriptions
- this._disposable = vscode.Disposable.from(...subscriptions);
- }
- dispose() {
- this._disposable.dispose();
- }
- private _onEvent() {
- if (this._cursorStyle != vscode.window.activeTextEditor.options.cursorStyle) {
- if (vscode.window.activeTextEditor.options.cursorStyle == 1) {
- this._cursorStyle = vscode.window.activeTextEditor.options.cursorStyle;
- this._rzrCounter.SetInsertMode();
- console.log("Cursor1");
- }
- if (vscode.window.activeTextEditor.options.cursorStyle == 2) {
- this._cursorStyle = vscode.window.activeTextEditor.options.cursorStyle;
- this._rzrCounter.SetNormalMode();
- console.log("Cursor2");
- }
- if (vscode.window.activeTextEditor.options.cursorStyle == 4) {
- this._cursorStyle = vscode.window.activeTextEditor.options.cursorStyle;
- this._rzrCounter.SetVisualMode();
- console.log("Cursor2");
- }
- }
- console.log("Cursor style is " +vscode.window.activeTextEditor.options.cursorStyle);
- }
- }
- class RazorKeys {
- private app: ChromaApp;
- private _disposable: vscode.Disposable;
- private counter = 0;
- private row = 0;
- constructor() {
- this.app = new ChromaApp("AppVkr1", "appVkr2", "appVkr3");
- let subscriptions: vscode.Disposable[] = [];
- this._disposable = vscode.Disposable.from(...subscriptions);
- }
- public UpdateLights() {
- console.log("Mode Changed");
- // if(vscode.window.activeTextEditor.options.cursorStyle == 1 )
- // this.UpdateLightsGreen();
- // if(vscode.window.activeTextEditor.options.cursorStyle == 2 )
- // this.UpdateLightsRed();
- // this.app.Instance().then((instance) => {
- // instance.Keyboard.setAll(new Color(0, 255, 255));
- // instance.Keyboard.setPosition(this.row, this.counter, new Color(255, 0, 0));
- // instance.send();
- // this.counter++;
- // if (this.counter >= 10) {
- // this.counter = 0;
- // this.row++;
- // }
- // console.log("instace back promise");
- // });
- }
- public UpdateLightsGreen() {
- this.app.Instance().then((instance) => {
- instance.Keyboard.setAll(new Color(0, 255, 0));
- instance.send();
- });
- }
- public UpdateLightsRed() {
- this.app.Instance().then((instance) => {
- instance.Keyboard.setAll(new Color(255, 0, 0));
- instance.send();
- });
- }
- public SetVisualMode(){
- this.app.Instance().then((instance) => {
- instance.Keyboard.setAll(new Color(255, 50, 100));
- instance.send();
- });
- }
- public SetNormalMode(){
- this.app.Instance().then((instance) => {
- instance.Keyboard.setAll(new Color(0, 255, 0));
- instance.Keyboard.setKey([Key.H, Key.J, Key.K, Key.L], new Color(0,0,255));
- instance.send();
- });
- }
- public SetInsertMode(){
- this.app.Instance().then((instance) => {
- instance.Keyboard.setAll(new Color(255, 0, 0));
- instance.Keyboard.setPosition(0,1, new Color(0,0,255));
- instance.Keyboard.setPosition(0,3, new Color(0,0,255));
- instance.send();
- });
- }
- dispose() {
- this._disposable.dispose();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement