Zachary Yedidia [Wed, 8 Jun 2016 22:49:08 +0000 (18:49 -0400)]
Add support for tabs
Merge branch 'tabbar'
This branch adds support for having multiple tabs open, each viewing one
file. Use CtrlT to open a new tab empty tab and then CtrlO to open a
file in that tab. Use can also just open multiple files from the command
line: `micro file1.txt file2.txt ...`. Use Ctrl-] and Ctrl-\ to move
between the tabs, or simply click them with the mouse.
Zachary Yedidia [Wed, 8 Jun 2016 14:21:27 +0000 (10:21 -0400)]
Fix multiline remove in lineArray
I forgot that when you remove lines[n] then lines[n+1] becomes lines[n]
so to remove the range lines[a:b] you need to remove lines[a] for a-b
times. In this case we should delete lines[start.Y + 1] over and over
instead of removing lines[i] because i is contantly increasing.
Zachary Yedidia [Thu, 2 Jun 2016 17:01:13 +0000 (13:01 -0400)]
Add simple way to save with sudo if you forgot to open micro with sudo
If you are editing a read-only file and forgot to open micro with sudo
so you could write to it, when saving the file, micro will now give you
the option to save with sudo.
This little hack is used by vim users to achieve the same behavior, but
micro makes it nicer to use. Here is an explanation for how it works:
http://stackoverflow.com/questions/2600783/how-does-the-vim-write-with-sudo-trick-work
JT Olds [Wed, 1 Jun 2016 22:06:37 +0000 (16:06 -0600)]
chainable actions and flexible modifiers
Doesn't work quite right yet, but the idea is to support
arbitrary modifiers without having to hardcode in all the permutations
of alt/shift/ctrl for every key, along with chainable actions,
so this can be configured:
Zachary Yedidia [Tue, 31 May 2016 21:23:08 +0000 (17:23 -0400)]
Screen redraw optimization
We don't have to clear the screen every time, we only have to make sure
that we erase the rest of the line that used to be on the current line.
We can still optimize a bit more by finding the longest line and drawing
to that length, but using the full width is fine for now.
Zachary Yedidia [Tue, 31 May 2016 01:01:40 +0000 (21:01 -0400)]
Allow changes from external programs to be undone
We use a diff to be able to transform the buffer into an arbitrary
string (usually when we reread the file after an external program such
as gofmt has changed it) and still preserve undo/redo.
Zachary Yedidia [Mon, 30 May 2016 17:38:50 +0000 (13:38 -0400)]
Add support for user-created commands
Plugins can now create their own commands using the `MakeCommand`
function. Plugins can also now create their own keybindings with the
`BindKey` function. See the go plugin for an example of `MakeCommand`.
Zachary Yedidia [Sat, 28 May 2016 21:29:49 +0000 (17:29 -0400)]
Add `savecursor` option
This adds the `savecursor` option which will remember where the cursor
was when the file was closed and put it back when the file is opened
again. The option is off by default so that people aren't confused as to
why the cursor isn't at the start of a file when they open it.
This commit also adds a more general ability to serialize a buffer so
various components can be saved (which could also be useful for persistent
undo).
Zachary Yedidia [Sat, 28 May 2016 15:32:09 +0000 (11:32 -0400)]
Refactor and clean up
This commit puts in place the ability for multiple views (splits).
This commit also removes the editor bindings so that all bindings can be
rebound by the user.
I also added some more comments
Zachary Yedidia [Sun, 22 May 2016 19:33:40 +0000 (15:33 -0400)]
Add ability to bind alt keys
This lets you bind keys like Alt-b or Alt-f.
This commit also adds some new default keybindings in emacs style, so
alt-a is beginning of line and alt-e is end etc...
Zachary Yedidia [Sun, 22 May 2016 19:01:02 +0000 (15:01 -0400)]
Store cursor and eventhandler in buffer instead of view
This is better design because the cursor and eventhandler are things the
buffer should know about directly but the view shouldn't. This should
make it easier to add persistent undo or location saving between
sessions (see #107).