Code Monkey home page Code Monkey logo

noter's Introduction

๐Ÿ“ noter

My blog posts:


A text editor for macOS. Built using the Ebitengine game engine.

It's a little bit like nano.

A screenshot of the editor running. It looks like nano. It has a text file called 'A Bird, came down the Walk' opened.

Shortcuts

Highlight with (shift + arrow key).

Swap lines with option + (up)/(down).

Command +

  • (z) undo
  • (f) search
  • (a) select all
  • (c) copy
  • (x) cut
  • (v) paste
  • (x) save
  • (q) quit without saving
  • (left)/(right) skips to start/end of line
  • (up)/(down) skip to start/end of document

Development

Run the editor go run github.com/healeycodes/noter/cmd/noter -- "A Bird, came down the Walk.txt"

Build

Build go build ./cmd/noter

Run the editor ./noter "A Bird, came down the Walk.txt"

Tests

go test .

Roadmap

  • More tests
  • Implement redo?

noter's People

Contributors

ezrec avatar healeycodes avatar

Stargazers

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

Watchers

 avatar  avatar

Forkers

ezrec

noter's Issues

Add keyboard input tests

Add a test that covers input/actions/movement controls and checks the output is correct.

Perhaps we can manually call the update function:

noter/editor.go

Line 743 in 472737f

func (e *Editor) Update() error {

And mock out ebiten.IsKeyPressed?

This would have really helped with edge cases in #9

Add key-repeat functionality.

If a non-meta key is held down, repeat it after a time delay.

Default to a delay of 500ms, then the held down key is repeated every 30ms thereafter.

Unsolicited advice

Hey, I read your blog post on the editor, as Hajime Hoshi shared it on the discord chat. I follow the development of Ebitengine fairly closely, and I wanted to share a few tips and ideas that you may find useful / interesting, even if you are unlikely to implement most of them. Using an issue for this feels a bit wrong, but you can just close it without remorse, no problem, this is only meant to be informative for you or other people that may want to do something similar or take things one step further.

  • Proper font rendering requires proper layout: you need to take into account the display DPI if you want to do any kind of sharp text rendering. This can be done by taking ebiten.DeviceScaleFactor() into account and applying it on the Layout() function. While many Ebitengine examples do this, you can also check this article that goes more in depth explaining it. It also touches on LayoutF, which can be fairly important for an application such as a text editor.
  • Pixel fonts are tricky: even if you are using high DPI, making pixel fonts look sharp can still be hard. In particular, the standard font DPI used is 72, but CSS uses 96 instead. For this reason, many fonts are designed with that in mind, and certain point sizes are likely to look better or worse. There are two tricks to solve this: either try both 72 and 96 DPIs when creating a font face to see what looks best, or apply a 3/4 or 4/3 factor (never remember which one of the two) when computing the font size.
  • Efficient GPU usage: since Ebitengine v2.5.0 (still in alpha), draw calls are optimized when no draw commands happen. This means you can use ebiten.SetScreenClearedEveryFrame(false) and avoid doing anything in the Draw() function unless necessary. This will make a massive difference in power usage, and for an application that's idle most of the time, this is a very big deal. It's still not as efficient as regular GUI frameworks, which skip buffer swaps altogether and often don't have a fixed timestep update loop called regularly, but it's still a massive improvement.

Maybe changing to vectorial fonts now is too bothersome, and you are probably doing this only for fun and learning, but wanted to share anyway! Have fun with Ebitengine!

Keyboard movement updates

  • PageUp/PageDown should move by page.
  • Cursor down at bottom of visible page should scroll up by single line, not page.
  • Cursor up at top of visible page should scroll down by single line, not page.
  • Home should go to beginning of line.
  • End should go to end of line.

Licensing

I'm interested in contributing an adaptation of your editor, to make it a library that can be more easily pulled into another Ebitengine application.

Can you add a license to this code, so that it's clearer in how it can be used?

I prefer MIT and BSD-3 Clause myself, as Go is a statically linked language that doesn't play well with mixing in GPL libraries, but of course it's up to you.

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.