aoloe / atom-autotype

Atom package for scriptable autotyping of text, one character at a time.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

atom-autotype package

Scriptable autotyping of text, one character at a time.

A screenshot of your package

I use it in combination with:

Status

This package is not yet complete nor fully tested.

This Readme and the code need some cleanup.

Features

  • The text in the clipboard is typed one character at a time
  • The indents are ignored and recreated according the current settings
  • You can give commands by including them in {% ... %}
  • The commands are inspired by Vi, are listed below and are separated by a dash (-).
  • The commands list must be on its own line. If you don't want it to start a new line add a dash (-) to its starting tag: {%- ... %}

List of commands

The commands are inspired by VI. Here is a list of the commands and the the matching atom actions called:

  • ``: insertText()
  • ``: insertNewLine()
  • ``: delete()
  • ``: backspace()
  • ``: upperCase() --> gu?
  • ``: lowerCase()
  • O: insertNewlineAbove()
  • o: insertNewlineBelow()
  • ``: deleteToBeginningOfWord()
  • ``: deleteToEndOfWord()
  • ``: deleteToEndOfLine()
  • ``: deleteToBeginningOfLine()
  • ``: deleteLine()
  • gg: moveToTop()
  • G: moveToBottom()
  • j: moveDown([lineCount])
  • ``: moveLeft([columnCount])
  • ``: moveRight([columnCount])
  • ^: moveToFirstCharacterOfLine()
  • 0: moveToBeginningOfLine()
  • $: moveToEndOfLine()
  • ``: moveToBeginningOfWord()
  • ``: moveToEndOfWord()
  • ``: getSelectedText()
  • ``: selectUp([rowCount])
  • ``: selectDown([rowCount])
  • ``: selectLeft([columnCount])
  • ``: selectRight([columnCount])
  • ``: selectToBeginningOfLine()
  • ``: selectToFirstCharacterOfLine()
  • ``: selectToEndOfLine()
  • ``: selectToBeginningOfWord()
  • ``: selectToEndOfWord()
  • ``: selectToPreviousWordBoundary()
  • ``: selectToNextWordBoundary()
  • ``: selectToBeginningOfNextWord()
  • ``: copySelectedText()
  • ``: cutSelectedText()
  • ``: pasteText([options])

Further commands to be defined:

Usage

As an example, copy the following script (a small Lua snippet):

for i = 0, 100 do
end
{%- O %}
    print("abc")
{%- G %}

Create a file with the .lua extension and run the script with ctrl-alt-a

The result will be:

First, two lines are written

for i = 0, 10 do
end

Then a new line is created above the current one:

{%- O %}

The cursor now is in the new empty line, where the print() command is rendered:

print("abc")

The line is indented following the current context.

Finally, the cursor goes to the end of the file:

{%- G %}

Options

You can set a few options by adding them at in the first line of the script:

{= "delay":200 =}

Stopping the script

The script can be stopped at any time by pressing the Esc key.

Testing outside of Atom

https://blog.david-reid.com/2016/04/16/command-line-babel/

$ npm install --save-dev babel-cli
$ npm install --save-dev babel-preset-es2015

then you can run the script as

$ ./node_modules/.bin/babel-node --presets es2015 test

References and notes

Todo

  • remove "atom" from the internal names (atom-autotype)
  • add a (optional?) delay between the commands ({%-+, where both - and + are optional)
  • add two possible parameters for the commands:
    • +: separator for the parameter of the command
    • *: repeating the command
  • create another package that calls this script and the screen cast one...
  • create a new package for setting up the environment:
  • create an own (simpler) pane recorder
    • without the tabs
    • block the recording if the pane is too big
    • code:
      pane = atom.workspace.getActivePane()
      paneElement = atom.views.getView(pane)
      r = paneElement.getBoundingClientRect()
      // r.left, r.top,  r.right - r.left, r.bottom - r.top
  • see if we can tweak/get https://github.com/lexcast/screen-recorder to also have a "textarea" mode

About

Atom package for scriptable autotyping of text, one character at a time.

License:MIT License


Languages

Language:JavaScript 100.0%