-
Notifications
You must be signed in to change notification settings - Fork 134
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #102 from mum4k/release-0-6-0
Release 0.6.0
- Loading branch information
Showing
63 changed files
with
8,063 additions
and
382 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
# Changelog | ||
|
||
All notable changes to this project are documented here. | ||
|
||
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), | ||
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). | ||
|
||
## [Unreleased] | ||
|
||
## [0.6.0] - 07-Feb-2019 | ||
|
||
### Added | ||
|
||
- The SegmentDisplay widget. | ||
- A CHANGELOG. | ||
- New line styles for borders. | ||
|
||
### Changed | ||
|
||
- Better recordings of the individual demos. | ||
|
||
### Fixed | ||
|
||
- The LineChart now has an option to change the behavior of the Y axis from | ||
zero anchored to adaptive. | ||
- Lint errors reported on the Go report card. | ||
- Widgets now correctly handle a race when new user data are supplied between | ||
calls to their Options() and Draw() methods. | ||
|
||
## [0.5.0] - 21-Jan-2019 | ||
|
||
### Added | ||
|
||
- Draw primitives for drawing circles. | ||
- The Donut widget. | ||
|
||
### Fixed | ||
|
||
- Bugfixes in the braille canvas. | ||
- Lint errors reported on the Go report card. | ||
- Flaky behavior in termdash_test. | ||
|
||
## [0.4.0] - 15-Jan-2019 | ||
|
||
### Added | ||
|
||
- 256 color support. | ||
- Variable size container splits. | ||
- A more complete demo of the functionality. | ||
|
||
### Changed | ||
|
||
- Updated documentation and README. | ||
|
||
## [0.3.0] - 13-Jan-2019 | ||
|
||
### Added | ||
|
||
- Primitives for drawing lines. | ||
- Implementation of a Braille canvas. | ||
- The LineChart widget. | ||
|
||
## [0.2.0] - 02-Jul-2018 | ||
|
||
### Added | ||
|
||
- The SparkLine widget. | ||
- The BarChart widget. | ||
- Manually triggered redraw. | ||
- Travis now checks for presence of licence headers. | ||
|
||
### Fixed | ||
|
||
- Fixing races in termdash_test. | ||
|
||
## 0.1.0 - 13-Jun-2018 | ||
|
||
### Added | ||
|
||
- Documentation of the project and its goals. | ||
- Drawing infrastructure. | ||
- Testing infrastructure. | ||
- The Gauge widget. | ||
- The Text widget. | ||
|
||
[Unreleased]: https://github.com/mum4k/termdash/compare/v0.6.0...devel | ||
[0.6.0]: https://github.com/mum4k/termdash/compare/v0.5.0...v0.6.0 | ||
[0.5.0]: https://github.com/mum4k/termdash/compare/v0.4.0...v0.5.0 | ||
[0.4.0]: https://github.com/mum4k/termdash/compare/v0.3.0...v0.4.0 | ||
[0.3.0]: https://github.com/mum4k/termdash/compare/v0.2.0...v0.3.0 | ||
[0.2.0]: https://github.com/mum4k/termdash/compare/v0.1.0...v0.2.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
// Copyright 2019 Google Inc. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
// Package attrrange simplifies tracking of attributes that apply to a range of | ||
// items. | ||
// Refer to the examples if the test file for details on usage. | ||
package attrrange | ||
|
||
import ( | ||
"fmt" | ||
"sort" | ||
) | ||
|
||
// AttrRange is a range of items that share the same attributes. | ||
type AttrRange struct { | ||
// Low is the first position where these attributes apply. | ||
Low int | ||
|
||
// High is the end of the range. The attributes apply to all items in range | ||
// Low <= b < high. | ||
High int | ||
|
||
// AttrIdx is the index of the attributes that apply to this range. | ||
AttrIdx int | ||
} | ||
|
||
// newAttrRange returns a new AttrRange instance. | ||
func newAttrRange(low, high, attrIdx int) *AttrRange { | ||
return &AttrRange{ | ||
Low: low, | ||
High: high, | ||
AttrIdx: attrIdx, | ||
} | ||
} | ||
|
||
// Tracker tracks attributes that apply to a range of items. | ||
// This object is not thread safe. | ||
type Tracker struct { | ||
// ranges maps low indices of ranges to the attribute ranges. | ||
ranges map[int]*AttrRange | ||
} | ||
|
||
// NewTracker returns a new tracker of ranges that share the same attributes. | ||
func NewTracker() *Tracker { | ||
return &Tracker{ | ||
ranges: map[int]*AttrRange{}, | ||
} | ||
} | ||
|
||
// Add adds a new range of items that share attributes with the specified | ||
// index. | ||
// The low position of the range must not overlap with low position of any | ||
// existing range. | ||
func (t *Tracker) Add(low, high, attrIdx int) error { | ||
ar := newAttrRange(low, high, attrIdx) | ||
if ar, ok := t.ranges[low]; ok { | ||
return fmt.Errorf("already have range starting on low:%d, existing:%+v", low, ar) | ||
} | ||
t.ranges[low] = ar | ||
return nil | ||
} | ||
|
||
// ForPosition returns attribute index that apply to the specified position. | ||
// Returns ErrNotFound when the requested position wasn't found in any of the | ||
// known ranges. | ||
func (t *Tracker) ForPosition(pos int) (*AttrRange, error) { | ||
if ar, ok := t.ranges[pos]; ok { | ||
return ar, nil | ||
} | ||
|
||
var keys []int | ||
for k := range t.ranges { | ||
keys = append(keys, k) | ||
} | ||
sort.Ints(keys) | ||
|
||
var res *AttrRange | ||
for _, k := range keys { | ||
ar := t.ranges[k] | ||
if ar.Low > pos { | ||
break | ||
} | ||
if ar.High > pos { | ||
res = ar | ||
} | ||
} | ||
|
||
if res == nil { | ||
return nil, fmt.Errorf("did not find attribute range for position %d", pos) | ||
} | ||
return res, nil | ||
} |
Oops, something went wrong.