Skip to content

Commit

Permalink
macro: renamed the project from micro
Browse files Browse the repository at this point in the history
licensed under MIT

renamed because I wanted a separated configuration
so ~/.config/macro seemed reasonable

this fork is just a custom baked micro editor
and I just share its code

please do not report bugs to upstream
as those might be mine
  • Loading branch information
shkschneider committed Jan 28, 2024
1 parent 4d34a48 commit 6c65660
Show file tree
Hide file tree
Showing 45 changed files with 1,361 additions and 4,343 deletions.
7 changes: 2 additions & 5 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
.DS_Store

micro
macro
!cmd/micro
!cmd/macro
binaries/
tmp.sh
test/
Expand All @@ -12,8 +13,4 @@ test.txt
log.txt
*.old
benchmark_results*
tools/build-version
tools/build-date
tools/info-plist
tools/vscode-tests/
*.hdr
1,272 changes: 1,272 additions & 0 deletions LICENSE

Large diffs are not rendered by default.

1,306 changes: 0 additions & 1,306 deletions LICENSE-THIRD-PARTY

This file was deleted.

44 changes: 19 additions & 25 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,51 +1,45 @@
.PHONY: runtime build generate build-quick

VERSION = $(shell GOOS=$(shell go env GOHOSTOS) GOARCH=$(shell go env GOHOSTARCH) \
go run tools/build-version.go)
NAME = macro
VERSION = $(shell git describe --tags)
HASH = $(shell git rev-parse --short HEAD)
DATE = $(shell GOOS=$(shell go env GOHOSTOS) GOARCH=$(shell go env GOHOSTARCH) \
go run tools/build-date.go)
ADDITIONAL_GO_LINKER_FLAGS = $(shell GOOS=$(shell go env GOHOSTOS) \
GOARCH=$(shell go env GOHOSTARCH) \
go run tools/info-plist.go "$(shell go env GOOS)" "$(VERSION)")
DATE = $(shell date +%F)
ADDITIONAL_GO_LINKER_FLAGS = $(shell GOOS=$(shell go env GOHOSTOS) GOARCH=$(shell go env GOHOSTARCH))
GOBIN ?= $(shell go env GOPATH)/bin
GOVARS = -X github.com/zyedidia/micro/v2/internal/util.Version=$(VERSION) -X github.com/zyedidia/micro/v2/internal/util.CommitHash=$(HASH) -X 'github.com/zyedidia/micro/v2/internal/util.CompileDate=$(DATE)'
DEBUGVAR = -X github.com/zyedidia/micro/v2/internal/util.Debug=ON
VSCODE_TESTS_BASE_URL = 'https://raw.githubusercontent.com/microsoft/vscode/e6a45f4242ebddb7aa9a229f85555e8a3bd987e2/src/vs/editor/test/common/model/'

all: build
@echo
@file ./$(NAME)

update:
@git remote add upstream https://github.com/zyedidia/micro 2>/dev/null
git pull --rebase upstream $(shell git rev-parse --abbrev-ref HEAD)

build: generate build-quick

build-quick:
go build -trimpath -ldflags "-s -w $(GOVARS) $(ADDITIONAL_GO_LINKER_FLAGS)" ./cmd/micro
go build -trimpath -ldflags "-s -w $(GOVARS) $(ADDITIONAL_GO_LINKER_FLAGS)" ./internal/bin/$(NAME)

build-dbg:
go build -trimpath -ldflags "-s -w $(ADDITIONAL_GO_LINKER_FLAGS) $(DEBUGVAR)" ./cmd/micro
go build -trimpath -ldflags "-s -w $(ADDITIONAL_GO_LINKER_FLAGS) $(DEBUGVAR)" ./internal/bin/$(NAME)

build-tags: fetch-tags generate
go build -trimpath -ldflags "-s -w $(GOVARS) $(ADDITIONAL_GO_LINKER_FLAGS)" ./cmd/micro
go build -trimpath -ldflags "-s -w $(GOVARS) $(ADDITIONAL_GO_LINKER_FLAGS)" ./internal/bin/$(NAME)

build-all: build

install: generate
go install -ldflags "-s -w $(GOVARS) $(ADDITIONAL_GO_LINKER_FLAGS)" ./cmd/micro
go install -ldflags "-s -w $(GOVARS) $(ADDITIONAL_GO_LINKER_FLAGS)" ./internal/bin/$(NAME)
@mkdir -p ~/.local/share/applications/
cp -f ./runtime/$(NAME).desktop ~/.local/share/applications/

install-all: install

fetch-tags:
git fetch --tags

generate:
GOOS=$(shell go env GOHOSTOS) GOARCH=$(shell go env GOHOSTARCH) go generate ./runtime

testgen:
mkdir -p tools/vscode-tests
cd tools/vscode-tests && \
curl --remote-name-all $(VSCODE_TESTS_BASE_URL){editableTextModelAuto,editableTextModel,model.line}.test.ts
tsc tools/vscode-tests/*.ts > /dev/null; true
go run tools/testgen.go tools/vscode-tests/*.js > buffer_generated_test.go
mv buffer_generated_test.go internal/buffer
gofmt -w internal/buffer/buffer_generated_test.go

test:
go test ./internal/...
go test ./cmd/...
Expand All @@ -68,4 +62,4 @@ bench-compare:
benchstat -alpha 0.15 benchmark_results_baseline benchmark_results

clean:
rm -f micro
rm -f ./$(NAME)
214 changes: 41 additions & 173 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,208 +1,76 @@
# Micro
# ![Macro](runtime/macro.svg) Macro [![Go](https://img.shields.io/badge/go-391A80)](https://go.dev) [![Lua](https://img.shields.io/badge/lua-391A80)](https://lua.org)

![Micro Fork](https://img.shields.io/badge/Micro-Fork)
![Release](https://img.shields.io/github/release/zyedidia/micro.svg?label=Release)](https://github.com/zyedidia/micro/releases)
> Modeless (simple) terminal text editor done right.
**micro** is a terminal-based text editor that aims to be easy to use and intuitive, while also taking advantage of the capabilities
of modern terminals. It comes as a single, batteries-included, static binary with no dependencies; you can download and use it right now!
**macro** is a fork of the Micro editor providing a separate configuration path and additional features to suit my taste.

As its name indicates, micro aims to be somewhat of a successor to the nano editor by being easy to install and use.
It strives to be enjoyable as a full-time editor for people who prefer to work in a terminal, or those who regularly edit files over SSH.
**micro** by [Zachary Yedidia](https://github.com/zyedidia) is a terminal-based text editor that aims to be easy to use and intuitive, while also taking advantage of the capabilities of modern terminals.

Here is a picture of micro editing its source code.
Head over [Micro-Editor's website](https://micro-editor.github.io) for more informations.

![Screenshot](./assets/micro-solarized.png)
## Main features

To see more screenshots of micro, showcasing some of the default color schemes, see [here](https://micro-editor.github.io).

You can also check out the website for Micro at https://micro-editor.github.io.

## Table of Contents

- [Features](#features)
- [Installation](#installation)
- [Building from source](#building-from-source)
- [Fully static binary](#fully-static-binary)
- [macOS terminal](#macos-terminal)
- [Linux clipboard support](#linux-clipboard-support)
- [Colors and syntax highlighting](#colors-and-syntax-highlighting)
- [Usage](#usage)
- [Documentation and Help](#documentation-and-help)
- [Upstream](#upstream)

- - -

## Features

- Easy to use and install.
- No dependencies or external files are needed — just the binary you can download further down the page.
- Modeless editor: like what you're probably used to.
- Written in go, easy and fast to compile: and most likely cross-platform (where Go runs on).
- Sane defaults and keybindings (^S, ^C, ^V, ^Q…).
- Easy configuration via JSON.
- Easy plugins via Lua.
- Multiple cursors.
- Common keybindings (<kbd>Ctrl-s</kbd>, <kbd>Ctrl-c</kbd>, <kbd>Ctrl-v</kbd>, <kbd>Ctrl-z</kbd>, …).
- Keybindings can be rebound to your liking.
- Sane defaults.
- You shouldn't have to configure much out of the box (and it is extremely easy to configure).
- Splits and tabs.
- nano-like menu to help you remember the keybindings.
- Extremely good mouse support.
- This means mouse dragging to create a selection, double click to select by word, and triple click to select by line.
- Cross-platform (it should work on all the platforms Go runs on).
- Note that while Windows is supported, Mingw/Cygwin is not (see below).
- Plugin system (plugins are written in Lua).
- micro has a built-in plugin manager to automatically install, remove, and update plugins.
- Built-in diff gutter.
- Wonderful mouse support (selection, drag, double-click, triple-click…).
- Diff gutter and line numbers.
- Simple autocompletion.
- Persistent undo.
- Automatic linting and error notifications.
- Syntax highlighting for over [130 languages](runtime/syntax).
- Color scheme support.
- By default, micro comes with 16, 256, and true color themes.
- True color support (set the `MICRO_TRUECOLOR` environment variable to 1 to enable it).
- Copy and paste with the system clipboard.
- Small and simple.
- Easily configurable.
- Syntax highlighting for 100+ languages.
- Theming: color scheme support (16, 256 and true color support).
- Macros.
- Common editor features such as undo/redo, line numbers, Unicode support, soft wrapping, …

## Installation

To install micro, you can download a [prebuilt binary](https://github.com/zyedidia/micro/releases), or you can build it from source.
- Common editor features such as (persistent) undo/redo, Unicode support, soft wrapping…

If you want more information about ways to install micro, see this [wiki page](https://github.com/zyedidia/micro/wiki/Installing-Micro).

Use `micro -version` to get the version information after installing. It is only guaranteed that you are installing the most recent
stable version if you install from the prebuilt binaries, Homebrew, or Snap.

A desktop entry file and man page can be found in the [assets/packaging](https://github.com/zyedidia/micro/tree/master/assets/packaging) directory.

**Note for Linux desktop environments:**

For interfacing with the local system clipboard, the following tools need to be installed:
* For X11, `xclip` or `xsel`
* For [Wayland](https://wayland.freedesktop.org/), `wl-clipboard`

Without these tools installed, micro will use an internal clipboard for copy and paste, but it won't be accessible to external applications.

### Building from source

If your operating system does not have a binary release, but does run Go, you can build from source.
## Building from source

Make sure that you have Go version 1.16 or greater and Go modules are enabled.

```
git clone https://github.com/zyedidia/micro
git clone https://github.com/shkschneider/macro
cd micro
make build
sudo mv micro /usr/local/bin # optional
```

You could also need:

```
go get github.com/zyedidia/clipboard
go get github.com/zyedidia/tcell
go get github.com/zyedidia/micro/cmd/micro/shellwords
make build
```

The binary will be placed in the current directory and can be moved to
The binary (`./macro`) will be placed in the current directory and can be moved to
anywhere you like (for example `/usr/local/bin`).

The command `make install` will install the binary to `$GOPATH/bin` or `$GOBIN`.

You can install directly with `go get` (`go get github.com/zyedidia/micro/cmd/micro`) but this isn't
recommended because it doesn't build micro with version information (necessary for the plugin manager),
and doesn't disable debug mode.

### Fully static binary

By default, the micro binary will dynamically link with core system libraries (this is generally
recommended for security and portability). However, there is a fully static prebuilt binary that
is provided for amd64 as `linux-static.tar.gz`, and to build a fully static binary from source, run

```
CGO_ENABLED=0 make build
```

### macOS terminal

If you are using macOS, you should consider using [iTerm2](http://iterm2.com/) instead of the default terminal (Terminal.app). The iTerm2 terminal has much better mouse support as well as better handling of key events. For best keybinding behavior, choose `xterm defaults` under `Preferences->Profiles->Keys->Presets...`, and select `Esc+` for `Left Option Key` in the same menu. The newest versions also support true color.

If you still insist on using the default Mac terminal, be sure to set `Use Option key as Meta key` under
`Preferences->Profiles->Keyboard` to use <kbd>option</kbd> as <kbd>alt</kbd>.

### WSL and Windows Console

If you use micro within WSL, it is highly recommended that you use the [Windows
Terminal](https://apps.microsoft.com/store/detail/windows-terminal/9N0DX20HK701?hl=en-us&gl=us)
instead of the default Windows Console.

If you must use Windows Console for some reason, note that there is a bug in
Windows Console WSL that causes a font change whenever micro tries to access
the external clipboard via powershell. To fix this, use an internal clipboard
with `set clipboard internal` (though your system clipboard will no longer be
available in micro).

### Colors and syntax highlighting

If you open micro and it doesn't seem like syntax highlighting is working, this is probably because
you are using a terminal which does not support 256 color mode. Try changing the color scheme to `simple`
by pressing <kbd>Ctrl-e</kbd> in micro and typing `set colorscheme simple`.

If you are using the default Ubuntu terminal, to enable 256 color mode make sure your `TERM` variable is set
to `xterm-256color`.

Many of the Windows terminals don't support more than 16 colors, which means
that micro's default color scheme won't look very good. You can either set
the color scheme to `simple`, or download and configure a better terminal emulator
than the Windows default.

### Cygwin, Mingw, Plan9

Cygwin, Mingw, and Plan9 are unfortunately not officially supported. In Cygwin and Mingw, micro will often work when run using
the `winpty` utility:

```
winpty micro.exe ...
```

Micro uses the amazing [tcell library](https://github.com/gdamore/tcell), but this
means that micro is restricted to the platforms tcell supports. As a result, micro does not support
Plan9 or Cygwin (although this may change in the future). Micro also doesn't support NaCl (which is deprecated anyway).
A desktop entry file can also be found in the `runtime` directory.

## Usage

Once you have built the editor, start it by running `micro path/to/file.txt` or `micro` to open an empty buffer.

micro also supports creating buffers from `stdin`:

```sh
ip a | micro
```
- Use `macro -version` to get the verson information after installing.
- Use `macro <path/to/file>` to open a file.
- Use `macro <path/to/directory>` to browse files in this directory
(requires [fd](https://github.com/sharkdp/fd) and [fzf](https://github.com/junegunn/fzf)).
- Macro also supports creating buffers from `stdin`.

You can move the cursor around with the arrow keys and mouse.
Save with Ctrl-S, quit with Ctrl-Q.
Run (and explore) commands with Ctrl-Space.

You can also use the mouse to manipulate the text. Simply clicking and dragging
will select text. You can also double click to enable word selection, and triple
click to enable line selection.

## Documentation and Help

micro has a built-in help system which you can access by pressing <kbd>Ctrl-e</kbd> and typing `help`. Additionally, you can
view the help files here:

- [main help](https://github.com/zyedidia/micro/tree/master/runtime/help/help.md)
- [keybindings](https://github.com/zyedidia/micro/tree/master/runtime/help/keybindings.md)
- [commands](https://github.com/zyedidia/micro/tree/master/runtime/help/commands.md)
- [colors](https://github.com/zyedidia/micro/tree/master/runtime/help/colors.md)
- [options](https://github.com/zyedidia/micro/tree/master/runtime/help/options.md)
- [plugins](https://github.com/zyedidia/micro/tree/master/runtime/help/plugins.md)
**Note for Linux desktop environments:**

I also recommend reading the [tutorial](https://github.com/zyedidia/micro/tree/master/runtime/help/tutorial.md) for
a brief introduction to the more powerful configuration features micro offers.
For interfacing with the local system clipboard, the following tools need to be installed:
* For X11, `xclip` or `xsel`
* For [Wayland](https://wayland.freedesktop.org/), `wl-clipboard`
Without these tools installed, macro will use an internal clipboard for copy and paste, but it won't be accessible to external applications.

There is also an unofficial Discord, which you can join at https://discord.gg/nhWR6armnR.
## Documentation (Upstream)

## Upstream
- This is a fork of Micro by Zachary Yedidia.
- [Micro's documentation](https://github.com/zyedidia/micro/tree/master/runtime/help/help.md)

Since this is a fork, you might also want to explore ![upstream](https://img.shields.io/badge/Micro-Fork).
As for exploring the code, use `grep` extensively and start with:
[actions.go](internal/actions/actions.go)
[bufpane.go](internal/actions/bufpane.go)
[buffer.go](internal/buffer/buffer.go)

Please do NOT report any bug there you had with this fork.
Please do NOT report any bug upstream as those could be mine!
Loading

0 comments on commit 6c65660

Please sign in to comment.