Adding selection support

The multiple commits are caused by me uploading code via Github. I will rebase it all before I merge. 
Missed that line while reviewing the code:

We could drop that `for-loop` entirely by using a small but nice hack using `new Array()`:

```js
if (cursor > smallestSpace) {
    str += (new Array(cursor - smallestSpace)).join(" ");
}
```

What do you think, @Liongold?