Skip to content

Commit

Permalink
Refactored modes, insert -> command
Browse files Browse the repository at this point in the history
  • Loading branch information
mrusme committed Apr 4, 2021
1 parent 8ad7c96 commit 8194c52
Show file tree
Hide file tree
Showing 2 changed files with 68 additions and 11 deletions.
63 changes: 60 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,15 @@
Gomphotherium (*/ˌɡɒmfəˈθɪəriəm/*; "welded beast"), a command line Mastodon
client.


## Description

Gomphotherium is a Mastodon client for the command line, offering a CLI as well
as a TUI with a usage similar to [rainbowstream](rainbowstream).

[rainbowstream]: https://github.com/orakaro/rainbowstream


## Installation

Download a binary from the [releases][releases] page. MacOS, Linux, Windows,
Expand All @@ -23,10 +25,65 @@ make

[releases]: https://github.com/mrusme/gomphotherium/releases

## CLI

TODO
## User Manual


### Authentication

To authenticate with your Mastodon instance, run the following command and
follow the instructions:

```sh
gomphotherium authenticate https://YOUR-MASTODON-SERVER-URL-HERE.com
```

## TUI

### CLI

TODO


### TUI

Launch the TUI with the following command:

```sh
gomphotherium tui
```

**Note:** If you haven't exported the required environment variables that were
shown to you during the [Authentication][#authentication], please do so first
or use the CLI flags (`gomphotherium -h`) instead.


#### Modes

The TUI can be operated in two modes: **Normal** and **Command**.

In **Normal** mode no interaction is possible apart from scrolling and
refreshing the timeline and quitting Gomphotherium. The shortcuts can be looked
up on the [cheatsheet](#cheatsheet)

In **Command** mode, the command input becomes available and scrolling the
timeline is not possible anymore. Commands can then be issued to interact with
the Mastodon instance.


#### Cheatsheet


##### Shortcuts

`Ctrl+Q`: Quit Gomphotherium

`Ctrl+R`: Refresh timeline

`i`: Enter **Command** mode (while in **Normal** mode)

`Esc`: Leave **Command** mode (while in **Command** mode)


##### Commands


16 changes: 8 additions & 8 deletions tui/tui.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import (
type ModeType int
const (
NormalMode ModeType = 1
InsertMode = 2
CommandMode = 2
)

type TUIOptions struct {
Expand Down Expand Up @@ -90,13 +90,13 @@ func TUI(tuiCore TUICore) {
return nil
case tcell.KeyRune:
switch event.Rune() {
case 'i':
if tuiCore.EnterInsertMode() == true {
case ':':
if tuiCore.EnterCommandMode() == true {
return nil
}
}
case tcell.KeyEscape:
if tuiCore.ExitInsertMode(false) == true {
if tuiCore.ExitCommandMode(false) == true {
return nil
}
case tcell.KeyCtrlQ:
Expand All @@ -112,7 +112,7 @@ func TUI(tuiCore TUICore) {
tuiCore.UpdateTimeline(true)

if tuiCore.Mode == 0 {
tuiCore.ExitInsertMode(true)
tuiCore.ExitCommandMode(true)
}

tuiCore.App.Draw()
Expand Down Expand Up @@ -193,7 +193,7 @@ func (tuiCore *TUICore) UpdateTimeline(scrollToEnd bool) bool {
return true
}

func (tuiCore *TUICore) EnterInsertMode() bool {
func (tuiCore *TUICore) EnterCommandMode() bool {
if tuiCore.CmdLine.Box.HasFocus() == false {
tuiCore.App.SetFocus(tuiCore.CmdLine)
tuiCore.CmdLine.SetLabelColor(tcell.ColorTeal)
Expand All @@ -202,14 +202,14 @@ func (tuiCore *TUICore) EnterInsertMode() bool {
tuiCore.CmdLine.
SetLabel(tuiCore.Prompt)

tuiCore.Mode = InsertMode
tuiCore.Mode = CommandMode
return true
}

return false
}

func (tuiCore *TUICore) ExitInsertMode(force bool) bool {
func (tuiCore *TUICore) ExitCommandMode(force bool) bool {
if tuiCore.CmdLine.Box.HasFocus() == true || force == true {
tuiCore.App.SetFocus(tuiCore.Stream)
tuiCore.CmdLine.SetLabelColor(tcell.ColorDefault)
Expand Down

0 comments on commit 8194c52

Please sign in to comment.