2018-04-15 06:06:57 +08:00
|
|
|
// Copyright 2018 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.
|
|
|
|
|
2018-03-28 03:20:05 +08:00
|
|
|
package termbox
|
|
|
|
|
|
|
|
// cell_options.go converts termdash cell options to the termbox format.
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/mum4k/termdash/cell"
|
2018-04-05 11:02:43 +08:00
|
|
|
tbx "github.com/nsf/termbox-go"
|
2018-03-28 03:20:05 +08:00
|
|
|
)
|
|
|
|
|
|
|
|
// cellColor converts termdash cell color to the termbox format.
|
2019-01-14 10:53:26 +08:00
|
|
|
func cellColor(c cell.Color) tbx.Attribute {
|
|
|
|
return tbx.Attribute(c)
|
2018-03-28 03:20:05 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
// cellOptsToFg converts the cell options to the termbox foreground attribute.
|
2019-01-14 10:53:26 +08:00
|
|
|
func cellOptsToFg(opts *cell.Options) tbx.Attribute {
|
2018-03-28 03:20:05 +08:00
|
|
|
return cellColor(opts.FgColor)
|
|
|
|
}
|
|
|
|
|
|
|
|
// cellOptsToBg converts the cell options to the termbox background attribute.
|
2019-01-14 10:53:26 +08:00
|
|
|
func cellOptsToBg(opts *cell.Options) tbx.Attribute {
|
2018-03-28 03:20:05 +08:00
|
|
|
return cellColor(opts.BgColor)
|
|
|
|
}
|