Giter VIP home page Giter VIP logo

em's Introduction

em

A remake of the ed text editor in Go, because that seemed like an important thing to have.

Usage

Actually using ed

Authors

Max Timkovich and Esgorhannoth

License

em is licensed under the Simplified BSD License.

em's People

Contributors

esgorhannoth avatar mtimkovich avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar

Forkers

esgorhannoth

em's Issues

Implement g command

g/re/p

  • Also requires implementing the / command to go to the next result.

"Write" saves to "w" filename

In

func (e *Editor) Write(start, end int, cmd rune, text string) {
    args := strings.Split(text, " ")

    if len(args) > 1 {
        e.filename = args[0]
    }

it should be

e.filename = args[1]

Otherwise it saves to "w" file (command name)

Only one warning on closing modified file

Is it by design that isModified sets e.modified to false after first warning?

func (e *Editor) isModified() bool {
    if e.modified {
        e.Error("warning: file modified")
        e.modified = false
        return true
    } else {
        return false
    }
}

And I guess it should be "warning: buffer modified" because file is not modified yet.

Commands fail when no file is open

When starting ./em with no argument I get some strange errors:

i
?
h
?
q
?

The only way to execute a command on an empty file is to prefix it with 1,0

1,0q
bash> _

My guess is that NewEditor() should initialize e.line to 1.

'Enter' to go to next line

Original ed has this useful feature. You just hit Enter and it is assumed that you want +1,+1p.

Replacing this snipper in Parse:

    if len(text) == 0 {
        e.Error("invalid address")
        return 0, 0, ""
    }

with this:

    if len(text) == 0 {
	  if (e.line + 1 >= e.buffer.Len()) {
              e.Error("invalid address")
              return 0, 0, ""
	  } else {
              return e.line+1, e.line+1, "p"
	  }
    }

creates just that effect.

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.