Skip to content

Commit

Permalink
Version bump: 1.2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
tigrawap committed Jun 13, 2018
1 parent d405cf7 commit f1d770e
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 22 deletions.
10 changes: 6 additions & 4 deletions cmd/slit/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,16 @@ import (
"io"
"os"

"context"
"time"

flag "github.com/ogier/pflag"
"github.com/tigrawap/slit"
"github.com/tigrawap/slit/filters"
"github.com/tigrawap/slit/logging"
"context"
"time"
)

const VERSION = "1.1.6"
const VERSION = "1.2.0"

var (
outPath string
Expand Down Expand Up @@ -96,7 +97,8 @@ func main() {
}

func tryDirectOutputIfShort(s *slit.Slit, ctx context.Context, durationMs int) bool {
localCtx, _ := context.WithTimeout(ctx, time.Duration(durationMs)*time.Millisecond)
localCtx, cancel := context.WithTimeout(ctx, time.Duration(durationMs)*time.Millisecond)
defer cancel()
if s.CanFitDisplay(localCtx) {
file := s.GetFile()
file.Seek(0, io.SeekStart)
Expand Down
36 changes: 18 additions & 18 deletions slit.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ import (
"sync"
"syscall"

"github.com/nsf/termbox-go"
"github.com/tigrawap/slit/filters"
"github.com/tigrawap/slit/logging"
"github.com/tigrawap/slit/utils"
"github.com/nsf/termbox-go"
)

func init() {
Expand Down Expand Up @@ -57,13 +57,13 @@ func (c *Config) isStdinRead() bool {

// Slit is a configured instance of the pager, ready to be displayed
type Slit struct {
wg sync.WaitGroup
ctx context.Context
cancel context.CancelFunc
file *os.File
isCacheFile bool // if true, file will be removed on shutdown
fetcher *Fetcher
initialised bool
wg sync.WaitGroup
ctx context.Context
cancel context.CancelFunc
file *os.File
isCacheFile bool // if true, file will be removed on shutdown
fetcher *Fetcher
initialised bool
}

// Returns input file, original or cache file when reading from stdin
Expand All @@ -90,7 +90,7 @@ func (s *Slit) Init() {

// Invoke the Slit UI
func (s *Slit) Display() {
if ! s.initialised {
if !s.initialised {
s.Init()
}

Expand Down Expand Up @@ -149,7 +149,7 @@ func NewFromStream(ch chan string) (*Slit, error) {

s.wg.Add(1)
go func() {
for _ = range time.Tick(100*time.Millisecond) {
for _ = range time.Tick(100 * time.Millisecond) {
lock.Lock()
w.Flush()
lock.Unlock()
Expand Down Expand Up @@ -268,22 +268,22 @@ FORLOOP:
case <-ctx.Done():
return false
case line, isOpen := <-lines:
if ! isOpen {
if config.stdin && !config.isStdinRead(){
if !isOpen {
if config.stdin && !config.isStdinRead() {
select {
case <- ctx.Done():
return false
case <- time.After(10 * time.Millisecond):
lines = s.fetcher.Get(localCtx, line.Pos)
continue FORLOOP
case <-ctx.Done():
return false
case <-time.After(10 * time.Millisecond):
lines = s.fetcher.Get(localCtx, line.Pos)
continue FORLOOP
}
}
break FORLOOP
}
lineLen := len(line.Str.Runes)
if lineLen > 0 {
parsedLineCount += lineLen / w
}else{
} else {
parsedLineCount++
}
mod := lineLen % w
Expand Down

0 comments on commit f1d770e

Please sign in to comment.