Giter Club home page Giter Club logo

kod's Introduction

kod (WIP)

GoDoc

kod screenshot

kod aims to be a fast and modern terminal code-editor. It is inspired by both vim & micro. It's built using xi-editor as backend.

Goals:

  • Performance, it should never freeze or be slow
  • Modes for efficient editing, similar to vim
  • Plugins (via xi-core, an example is xi-syntect-plugin which is shown in the picture above)
  • Modular, uses xi-editor as backend

Non-goals:

  • Maintain a huge platform support (like vim), it will be supported by the major platforms and architectures

Installation

kod expects xi-core to be set in your $PATH. For more information how to build xi-core, please have a look at xi-editor's github page.

Once xi-core is available you should be able to install with following

 go get -u -v github.com/linde12/kod

To ensure that kod is available, run which kod. It prints kod path in GO binary. If you see kod not found, you need to add your $GOPATH/bin to PATH

TODO

  • Unmarshal known JSON requests into structs, partially done
  • Implement update method
  • Read viewHeight lines and fill buffer
  • Refactor away unused code(e.g. lineArray, buffer_reader, cursor)
  • Add (very) basic editing functionality
  • Add vertical scrolling
  • Add horizontal scrolling
  • Indentation (local, xi doesn't fully support yet AFAIK)
  • Respect alpha value in ARGB
  • Cleanup view and inputhandler
  • Find(search) in file
  • Support multiple cursors
  • Make editor runnable outside current CWD
  • Display line numbers/gutter (very basic)
  • A lot of other things...

License

MIT

kod's People

Contributors

emigr2k1 avatar jantb avatar kant avatar lihram avatar linde12 avatar matttproud avatar rxx avatar sjoshid avatar willmadison avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

kod's Issues

Fix the "update" case in linecache.go and remove the addLines method

We're not entirely sure when "update" is called, but i'm guessing it's when e.g. a third party plugin will do some changes to the code. E.g. syntect.

Essentially it's not sure whether "update" works or not and we want to remove the use of the addLines method so that we can remove it completely.

Add build instructions

It would help people who doesn't have any previous experience with Go (like me!) but want to get started quickly and try this project.

Only partial text gets pasted

When copying some text from outside and pasting it in kod, some characters and words are skipped.

Does anyone face a similar problem? I tried this with gnome-terminal and xterm with latest commit on xi core repository (xi-editor/xi-editor@25d2a72).

Add license

Kod right now doesn't have a license. So, if i'm not wrong, legally kod is not libre software 😢

Keybindings

I have tried editor today and have some further issues to implement.
I didn't find them on exisiting issues and main README TODO list

  • Add doc for keybindings at README/wiki
  • Add ability to print keybindings from editor
  • Configure keybinding map style(vim, emacs, basic)
  • Allow to customize any keybinding from user config file.

feat: user configs

As mentioned by @emigr2k1 in #24 we should probably implement some kind of user configuration. My view on this is that we rely on Xi's configuration system and simply request the configuration when kod starts.

Gutter line numbers are wrongly displayed

On startup we show line numbers for the full height of the editor, but once the users moves the cursor the line numbers update to only extend to the length of the document.

We should only display line numbers for the lines, not the whole window.

Doesn't build as per the README's instructions

user@machine ~ $ git clone https://github.com/linde12/kod.git
[...]
user@machine ~ $ cd kod
user@machine ~/kod $ which xi-core
/home/user/.cargo/bin/xi-core
user@machine ~/kod $ go build
kod.go:10:2: cannot find package "github.com/linde12/kod/editor" in any of:
	/usr/lib64/golang/src/github.com/linde12/kod/editor (from $GOROOT)
	/home/user/go/src/github.com/linde12/kod/editor (from $GOPATH)
user@machine ~/kod $

Are the instructions missing anything or am I doing something wrong?

stupid question

installation went smoothly, kudos for that.

now I have numbered lines, and I can type, but that's it. Oh, the cursor keys work too.

but ... I need a howto for dummies: key combination to e.g. save, quit, mark-copy-paste, etc. ?

not even Ctrl-c does anything anymore.

thanks!

Binary fails to execute on macOS

After getting and building the application, this happens after trying to execute the built executable:

panic: runtime error: index out of range

goroutine 1 [running]:
github.com/linde12/kod/editor.(*Editor).Start(0xc42007e3c0)
        /Users/daniel/src/golang/src/github.com/linde12/kod/editor/editor.go:139 +0x6f2
main.main()
        /Users/daniel/src/golang/src/kod/kod.go:42 +0x23f

Go version: go version go1.9.3 darwin/amd64 (installed via Homebrew)

add gutter/line numbers

I tried adding this within the buffer part of the views, but it was kind of hairy to keep adding offsets depending on the width of the gutter.

I think it's better to have the gutter as a separate view, just like the topbar and bottombar.

linecache invalidation is not up to date with xi-core

The core introduced a breaking change and i haven't had the time to update kod yet.

I think this can be fixed somewhere in the ApplyUpdate method in editor/linecache.go

There are a few editors which have implemented this already. I believe xi-tui(rust) amongst other should work with the latest version. There is also some documentation about this in the xi-editor project.

Vertical scrolling not working

Using MacOS Mojave, ITerm and default MacOS terminal.

If I write lines until they fill the viewport I cannot see the new lines. Kod still receives my input because if I delete the first lines I can see what I wrote.

Video

I can work on it. I just need a clue about why it doesn't work on mac because I see that it works on linux (I suppose, by looking at the screenshot in README.md)

compiling xi-core

How did you get xi-core ? It seems its rust based... ?

Could ou ad somethng to the readme.

BTW this looks really nice. The way the RPC works is super clean.

kod not found in path

/Users/maverick/xi-editor/rust/target/debug/xi-core:/Users/maverick/go¬/bin:/Users/maverick/go/bin:/Users/maverick/.cargo/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Library/TeX/texbin:/usr/local/go/bin:/opt/X11/bin¬:/Users/maverick/Library/Android/sdk/tools:/Users/maverick/Library/Android/sdk/platform-tools

Above is my $PATH, but every time I run kod it tells me that "xi-core" is not in PATH. Not sure what is the problem. From my understanding of exec.LookPath, this should not be happening, as it should be checking $PATH

I am on MacOS.

Change to bufio.NewReader(c.rw) instead of bufio.NewScanner(c.rw) in connection.go

Scanner has a line size limit.
From the docs of scanner
// Programs that need more control over error handling or large tokens, or must run sequential scans on a reader, should use bufio.Reader instead

This is the error thrown when the line from xi-code is too long:
ErrTooLong = errors.New("bufio.Scanner: token too long")

I can work on the issue

Build Problems

I'm new to go, so I don't know if this is a bug or my own ignorance, but when I run

go get github.com/linde12/kod

I get the following error:

gocode/src/github.com/linde12/kod/kod.go:10:2: local import "./editor" in non-local package

And I don't know where to go from there.

bump tcell to v1.1.0

Fixes use with termite and possibly other terminals.

Fix is easy, attached is an example patch (but feel free to ignore and handle otherwise) which does what you'd expect :).

Text only renders before cursor when launched from Powershell

Built on Windows and opened the same file (kod.go) in both Visual Studio Code and kod launched from Powershell. The screenshot is from the builtin terminal in VS Code, but I get the same result in a standalone Powershell window.

In the following screenshot the cursor is in the same position in both panes, on line 16 (15 in kod). You can see that the rest of the file past the cursor does not render in kod. The entire file is rendered on first load, but as soon as the cursor is moved the rest of the file disappears.

Additionally, there is noticeable flicker whenever the cursor moves.

image

only works in xterm

kod startup failes with terminal entry not found in st even before telling me that I forgot the file name. I tried xterm, where it works as expected, and urxvt, where it starts but has lots of rendering issues.
I didn't try fancy GTK or QT based terminal emulators.

UPDATE: Related to gdamore/tcell#118 . As soon as I change $TERM accordingly, it works.

Closing with Ctrl+Q makes the terminal glitch

When you use Ctrl+Q to close Kod, the terminal looks bad. So bad.
Using F1 works as expected.

Video showing what I mean

Here when you press F1 Kod calls close() and then kod finishes the editor.
Here But when you press Ctrl+Q, Kod only calls os.Exit()

I can send a pull request., but I would like to know how it should be done.

If I'm not wrong, F1 is to exit the whole editor and Ctrl+Q is to close the current view but for now we can only have 1 view, right? If so, do you think that they should do the same thing until Kod supports multiple views (if it will)?

Error executing ko

Hi,
I'm trying to run kod like ./kod sample which gives me the following. I'm new to xi-editor, kod and Go. Am I missing something?

panic: runtime error: invalid memory address or nil pointer dereference
[signal 0xb code=0x1 addr=0x0 pc=0x4821df]

goroutine 1 [running]:
panic(0x5e6000, 0xc82000e130)
/usr/lib/go-1.6/src/runtime/panic.go:481 +0x3e6
github.com/linde12/kod/editor.(*InputHandler).Insert(0x0, 0xc820430018, 0x1)
$HOME/Documents/xi-kod/src/github.com/linde12/kod/editor/inputhandler.go:77 +0x36f
github.com/linde12/kod/editor.(*View).HandleEvent(0xc8202383c0, 0x7f76ed79e7e8, 0xc82000b4e0)
$HOME/Documents/xi-kod/src/github.com/linde12/kod/editor/view.go:140 +0xe5
github.com/linde12/kod/editor.(*Editor).handleEvent(0xc8200147d0, 0x7f76ed79e7e8, 0xc82000b4e0)
$HOME/Documents/xi-kod/src/github.com/linde12/kod/editor/editor.go:50 +0xcf
github.com/linde12/kod/editor.(*Editor).Start(0xc8200147d0)
$HOME/Documents/xi-kod/src/github.com/linde12/kod/editor/editor.go:188 +0x58a
main.main()
$HOME/Documents/xi-kod/src/github.com/linde12/kod/kod.go:42 +0x42d

Separate default keybinds per platform

The default keybinds to move per word, move to the start/end of line, etc. Are different in each platform, at least on windows and mac.

If Kod is still going to use "normal" keybinds (arrows to move, ctrl-s to save), it should make sense to make the default keybinds the same of their respective platforms. This should be impossible for mac because of "cmd" key but "ctrl" could be used instead.

This shouldn't be hard to do, at least until there is another way to handle input like a vim-like plugin.

Need some sort of file handling interface

  • Starting kod without arguments could mean "create new document".
  • When inside of of kod, there could be an interface similar to vim's, i.e. typing "Esc, :" gets you into command mode, then "w" writes the file or "q" exits kod, "wq" writes first, then exits, or similar.

Right-to-left languages seem to be unhandled

When trying to write RTL languages such as Arabic or Aramaic (the two I happen to be working with regularly, didn't try an unconnected one like Hebraic), it looks like this:

image

The expected result would be like what e.g. gxi displays:

image

Note that in the second screenshot, some will argue that the RTL languages should not be aligned to the left edge of the window. I disagree partly. That's good behaviour for documents that are RTL only but mostly, in a text editor, one will be working with LTR/RTL-mixed documents, where it's much less confusing to have a main direction, so the above is actually really nice and shows that xi-core itself doesn't seem to have a problem with it.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.