Skip to content

Commit

Permalink
Merge pull request #2 from DestructHub/dev
Browse files Browse the repository at this point in the history
Change Tui to Xmi (xi-micro) and ref about Tui
  • Loading branch information
ryukinix committed Jan 31, 2018
2 parents 032966b + 829a104 commit 3b61b11
Show file tree
Hide file tree
Showing 7 changed files with 59 additions and 56 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,6 @@ nbproject

# These are backup files generated by rustfmt
**/*.rs.bk

# ignore this shit
Cargo.lock
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ cache: cargo
before_script: (cargo install rustfmt || true)
script:
# - cargo fmt
- bash -c 'if [[ "$TRAVIS_RUST_VERSION" == "nightly" ]] ; then cargo build --features clippy ; else cargo build ; fi'
- bash -c 'if [[ "$TRAVIS_RUST_VERSION" == "nightly" ]] ; then cargo build; else cargo build ; fi'
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 4 additions & 6 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
[package]
authors = ["Corentin Henry <corentinhenry@gmail.com>"]
name = "xi-tui"
authors = ["Corentin Henry <corentinhenry@gmail.com>",
"Manoel Vilela <manoel_vilela@engineer.com>",
"Leonardo Neumann <leonardohn@null.net>"]
name = "xmi"
version = "0.1.0"

[dependencies]
Expand All @@ -12,9 +14,5 @@ log4rs = "0.7.0"
termion = "1.5.1"
tokio-core = "0.1.10"

[dependencies.clippy]
optional = true
version = "0.0.165"

[dependencies.xrl]
git = "https://github.com/little-dude/xrl"
54 changes: 28 additions & 26 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,43 +1,43 @@
# xi-tui
# xi-micro

[![Build Status](https://travis-ci.org/little-dude/xi-tui.svg?branch=master)](https://travis-ci.org/little-dude/xi-tui)
[![Build Status](https://travis-ci.org/DestructHub/xi-micro.svg?branch=master)](https://travis-ci.org/DestructHub/xi-micro)

`xi-tui` is a terminal frontend for [xi](https://github.com/google/xi-editor/).
`xi-micro` is a terminal frontend for [xi editor](https://github.com/google/xi-editor/).

It is experimental and under development, so don't expect anything magical (yet!).

This is a fork which don't have any intention to merge on the original.

## Installation

The frontend assumes that you have installed the
[core editor](https://github.com/google/xi-editor)
and is available in your PATH. The following should suffice:
The frontend assumes that you have installed the [core editor](https://github.com/google/xi-editor) and is available in your PATH. The following should suffice:

```bash
# If you want syntax highlighting, you need to download and install the syntect plugin
git clone https://github.com/google/xi-editor
cd xi-editor/rust
cd xi-editor/rust/syntect-plugin
cargo install

# if you want syntax highlighting, you need to install the syntect plugin:
cd syntect-plugin
cargo install
# You need to have ~/.cargo/bin into your PATH in order to run any Cargo installation binary
# In case you don´t have it, add `export PATH=$PATH:~/.cargo/bin` to your .bashrc (or equivalent)

# You need to add ~/.cargo/bin to your PATH
# (this is where `cargo install` places binaries).
# In your .bashrc (or equivalent), add `export PATH=$PATH:~/.cargo/bin`
# To install xi-micro, just clone the repository and install it by Cargo
git clone https://github.com/DestructHub/xi-micro
cd xi-micro
cargo install
```

Then you can clone this repository and run the frontend with
`cargo run --release -- <your_file>`.
`your_file` can be an existing file or any dummy name.
You can then run the editor using `xmi <filename>` on terminal, or, if you want to run directly from sourcecode, use `cargo run --release -- <filename>`.

## Logging

For debugging, it can be useful to have logs.
You can specify a location for log files `xi-tui` with `-l <logfile>`.
Two files will be written:
For debugging, it can be useful to have logs. You can specify a
location for log files `xmi` with `-l <logfile>`. Two files will
be written:

- `<logfile>`: all the `xi-tui` logs
- `<logfile>.rpc`: the RPC messages exchanged between the core and the frontend
- `<logfile>`: all the `xmi` logs
- `<logfile>.rpc`: the RPC messages exchanged between the core and the
frontend

## Screenshots

Expand All @@ -56,17 +56,19 @@ For now, there are only two shortcuts:

### Tabs

We assume tabs (`\t`) are 4 columns large. It that is not the case in your
terminal, the cursor position will be inaccurate. On linux, to set the `\t`
width to four spaces, do:
We assume tabs (`\t`) are 4 columns large. It that is not the case in
your terminal, the cursor position will be inaccurate. On linux, to
set the `\t` width to four spaces, do:

```
tabs -4
```

### Colors

If you have the `syntect` plugin installed, colors will be enabled by default, with two caveats:
If you have the `syntect` plugin installed, colors will be enabled by
default, with two caveats:

- you must have true colors enabled. Otherwise, some portions of text won't be displayed
- you must have true colors enabled. Otherwise, some portions of text
won't be displayed
- the default theme is for dark backgrounds
8 changes: 4 additions & 4 deletions src/main.rs
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ extern crate termion;
extern crate tokio_core;
extern crate xrl;

mod tui;
mod xmi;
mod errors;
mod terminal;
mod view;
Expand All @@ -30,7 +30,7 @@ use tokio_core::reactor::Core;
use xrl::spawn;

use errors::*;
use tui::{Tui, TuiServiceBuilder};
use xmi::{Xmi, XmiServiceBuilder};

fn configure_logs(logfile: &str) {
let tui = FileAppender::builder().build(logfile).unwrap();
Expand Down Expand Up @@ -101,7 +101,7 @@ fn run() -> Result<()> {
let mut core = Core::new().chain_err(|| "failed to create event loop")?;

info!("starting xi-core");
let (tui_builder, core_events_rx) = TuiServiceBuilder::new();
let (tui_builder, core_events_rx) = XmiServiceBuilder::new();
let (client, core_stderr) = spawn(
matches.value_of("core").unwrap_or("xi-core"),
tui_builder,
Expand All @@ -120,7 +120,7 @@ fn run() -> Result<()> {

info!("initializing the TUI");
let mut tui =
Tui::new(core.handle(), client, core_events_rx).chain_err(|| "failed initialize the TUI")?;
Xmi::new(core.handle(), client, core_events_rx).chain_err(|| "failed initialize the TUI")?;
tui.open(matches.value_of("file").unwrap_or("").to_string());
tui.set_theme("base16-eighties.dark");

Expand Down
36 changes: 18 additions & 18 deletions src/tui.rs → src/xmi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use errors::*;
use terminal::{Terminal, TerminalEvent};
use view::{View, ViewClient};

pub struct Tui {
pub struct Xmi {
pub pending_open_requests: Vec<ClientResult<(String, View)>>,
pub delayed_events: Vec<CoreEvent>,
pub views: HashMap<String, View>,
Expand All @@ -26,7 +26,7 @@ pub struct Tui {
pub styles: HashMap<u64, Style>,
}

impl Tui {
impl Xmi {
pub fn new(
handle: Handle,
client: Client,
Expand All @@ -35,7 +35,7 @@ impl Tui {
let mut styles = HashMap::new();
styles.insert(0, Default::default());

Ok(Tui {
Ok(Xmi {
events: events,
delayed_events: Vec::new(),
pending_open_requests: Vec::new(),
Expand All @@ -59,7 +59,7 @@ impl Tui {
}

fn handle_update(&mut self, update: Update) {
let Tui {
let Xmi {
ref mut views,
ref mut delayed_events,
..
Expand All @@ -71,7 +71,7 @@ impl Tui {
}

fn handle_scroll_to(&mut self, scroll_to: ScrollTo) {
let Tui {
let Xmi {
ref mut views,
ref mut delayed_events,
..
Expand All @@ -87,7 +87,7 @@ impl Tui {
}

fn handle_resize(&mut self, size: (u16, u16)) {
let Tui {
let Xmi {
ref mut views,
ref current_view,
..
Expand Down Expand Up @@ -137,7 +137,7 @@ impl Tui {

info!("process pending open requests");

let Tui {
let Xmi {
ref mut pending_open_requests,
ref mut views,
ref mut current_view,
Expand Down Expand Up @@ -223,7 +223,7 @@ impl Tui {
}

fn render(&mut self) -> Result<()> {
let Tui {
let Xmi {
ref mut views,
ref mut term,
ref current_view,
Expand All @@ -247,7 +247,7 @@ pub enum CoreEvent {
SetStyle(Style),
}

impl Future for Tui {
impl Future for Xmi {
type Item = ();
type Error = io::Error;

Expand All @@ -269,9 +269,9 @@ impl Future for Tui {
}
}

pub struct TuiService(UnboundedSender<CoreEvent>);
pub struct XmiService(UnboundedSender<CoreEvent>);

impl TuiService {
impl XmiService {
fn send_core_event(&mut self, event: CoreEvent) -> ServerResult<()> {
if let Err(e) = self.0.start_send(event) {
let e = format!("failed to send core event to TUI: {}", e);
Expand All @@ -289,7 +289,7 @@ impl TuiService {
}


impl Frontend for TuiService {
impl Frontend for XmiService {
fn update(&mut self, update: Update) -> ServerResult<()> {
self.send_core_event(CoreEvent::Update(update))
}
Expand All @@ -303,17 +303,17 @@ impl Frontend for TuiService {
}
}

pub struct TuiServiceBuilder(UnboundedSender<CoreEvent>);
pub struct XmiServiceBuilder(UnboundedSender<CoreEvent>);

impl TuiServiceBuilder {
impl XmiServiceBuilder {
pub fn new() -> (Self, UnboundedReceiver<CoreEvent>) {
let (tx, rx) = unbounded();
(TuiServiceBuilder(tx), rx)
(XmiServiceBuilder(tx), rx)
}
}

impl FrontendBuilder<TuiService> for TuiServiceBuilder {
fn build(self, _client: Client) -> TuiService {
TuiService(self.0)
impl FrontendBuilder<XmiService> for XmiServiceBuilder {
fn build(self, _client: Client) -> XmiService {
XmiService(self.0)
}
}

0 comments on commit 3b61b11

Please sign in to comment.