mirror of
https://github.com/chshersh/github-tui.git
synced 2024-08-16 14:00:30 +03:00
Implement colouring of the title
This commit is contained in:
parent
0449be97f1
commit
538e5bd048
@ -19,6 +19,7 @@
|
||||
(depends
|
||||
(ocaml (>= "5.1"))
|
||||
dune
|
||||
(ANSITerminal (>= "0.8.5"))
|
||||
(cmdliner (>= "1.2.0"))
|
||||
(ezcurl (>= "0.2.4"))
|
||||
(minttea (>= "0.0.2"))
|
||||
|
@ -11,9 +11,11 @@ bug-reports: "https://github.com/chshersh/github-tui/issues"
|
||||
depends: [
|
||||
"ocaml" {>= "5.1"}
|
||||
"dune" {>= "3.12"}
|
||||
"ANSITerminal" {>= "0.8.5"}
|
||||
"cmdliner" {>= "1.2.0"}
|
||||
"ezcurl" {>= "0.2.4"}
|
||||
"minttea" {>= "0.0.2"}
|
||||
"spices"
|
||||
"odoc" {with-doc}
|
||||
]
|
||||
build: [
|
||||
|
@ -1,7 +1,7 @@
|
||||
open Cmdliner
|
||||
|
||||
let repo_arg =
|
||||
let doc = "The GitHub repository to launch." in
|
||||
let doc = "The GitHub repository to view in TUI." in
|
||||
Arg.(value & pos 0 string "NOT_SPECIFIED" & info [] ~docv:"OWNER/REPO" ~doc)
|
||||
|
||||
let gh_tui_t = Term.(const Tui.start $ repo_arg)
|
||||
|
1
lib/dune
1
lib/dune
@ -3,6 +3,7 @@
|
||||
(library
|
||||
(name github_tui)
|
||||
(libraries
|
||||
ANSITerminal
|
||||
cmdliner
|
||||
ezcurl
|
||||
minttea
|
||||
|
@ -1,3 +1,3 @@
|
||||
let app = Minttea.app ~init:Init.init ~update:Update.update ~view:View.view ()
|
||||
|
||||
let start _repo_name = Minttea.start app ~initial_model:Model.initial_model
|
||||
let start repo = Minttea.start app ~initial_model:(Model.initial_model repo)
|
@ -4,10 +4,12 @@ type tab =
|
||||
| PullRequests
|
||||
|
||||
type t =
|
||||
{ tab: tab ;
|
||||
{ repo: string ;
|
||||
tab: tab ;
|
||||
}
|
||||
|
||||
let initial_model: t =
|
||||
let initial_model repo: t =
|
||||
{
|
||||
repo ;
|
||||
tab = Code;
|
||||
}
|
@ -7,11 +7,11 @@ let update event (model: Model.t) =
|
||||
|
||||
(* if we press a digit, we switch to the corresponding tab *)
|
||||
| Event.KeyDown (Key "1") ->
|
||||
({ tab = Model.Code }, Command.Noop)
|
||||
({ model with tab = Model.Code }, Command.Noop)
|
||||
| Event.KeyDown (Key "2") ->
|
||||
({ tab = Model.Issues }, Command.Noop)
|
||||
({ model with tab = Model.Issues }, Command.Noop)
|
||||
| Event.KeyDown (Key "3") ->
|
||||
({ tab = Model.PullRequests }, Command.Noop)
|
||||
({ model with tab = Model.PullRequests }, Command.Noop)
|
||||
|
||||
(* otherwise, we do nothing *)
|
||||
| _ -> (model, Command.Noop)
|
@ -1,17 +1,20 @@
|
||||
let fmt (styles : ANSITerminal.style list) : string -> string =
|
||||
ANSITerminal.sprintf styles "%s"
|
||||
|
||||
let fmt_repo =
|
||||
fmt ANSITerminal.([Bold; green])
|
||||
|
||||
let view (model: Model.t) =
|
||||
match model.tab with
|
||||
| Code -> Format.sprintf
|
||||
{|
|
||||
Code
|
||||
let repo = fmt_repo model.repo in
|
||||
let tab =
|
||||
match model.tab with
|
||||
| Code -> "Code"
|
||||
| Issues -> "Issues"
|
||||
| PullRequests -> "Pull Requests"
|
||||
in
|
||||
Format.sprintf
|
||||
{|%s
|
||||
|
||||
|}
|
||||
| Issues -> Format.sprintf
|
||||
{|
|
||||
Issues
|
||||
%s
|
||||
|
||||
|}
|
||||
| PullRequests -> Format.sprintf
|
||||
{|
|
||||
Pull Requests
|
||||
|
||||
|}
|
||||
|} repo tab
|
Loading…
Reference in New Issue
Block a user