1
0
mirror of https://github.com/helix-editor/helix synced 2024-11-10 10:34:45 +01:00
helix/helix-tui/src/widgets/mod.rs
dependabot[bot] 52ced7e85f
build(deps): bump bitflags from 1.3.2 to 2.0.2 (#6387)
* build(deps): bump bitflags from 1.3.2 to 2.0.2

Bumps [bitflags](https://github.com/bitflags/bitflags) from 1.3.2 to 2.0.2.
- [Release notes](https://github.com/bitflags/bitflags/releases)
- [Changelog](https://github.com/bitflags/bitflags/blob/main/CHANGELOG.md)
- [Commits](https://github.com/bitflags/bitflags/compare/1.3.2...2.0.2)

---
updated-dependencies:
- dependency-name: bitflags
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>

* deps: Resolve bitflags 2.0 breaking changes

Bitflags 2.0 release made some breaking changes requiring some small
changes to the Helix codebase.

Almost all of the necessary changes are to manually `#[derive(..)]`
trait implementations which are no longer automatically derived for
all bitflags. All of these were previously automatically derived:

    #[derive(PartialEq, Eq, PartialOrd, Ord, Hash, Debug, Clone, Copy]

I have derived the minimum traits for each bitflag type.

The other change was to the `.bits` field. This is now a `.bits()`
method so the usage of this has been updated in the `Borders` type.

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Michael Davis <mcarsondavis@gmail.com>
2023-03-22 08:12:08 +08:00

51 lines
1.5 KiB
Rust

//! `widgets` is a collection of types that implement [`Widget`].
//!
//! All widgets are implemented using the builder pattern and are consumable objects. They are not
//! meant to be stored but used as *commands* to draw common figures in the UI.
//!
//! The available widgets are:
//! - [`Block`]
// //! - [`List`]
// //! - [`Table`]
//! - [`Paragraph`]
mod block;
// mod list;
mod paragraph;
mod reflow;
mod table;
pub use self::block::{Block, BorderType};
// pub use self::list::{List, ListItem, ListState};
pub use self::paragraph::{Paragraph, Wrap};
pub use self::table::{Cell, Row, Table, TableState};
use crate::buffer::Buffer;
use bitflags::bitflags;
use helix_view::graphics::Rect;
bitflags! {
/// Bitflags that can be composed to set the visible borders essentially on the block widget.
#[derive(Debug, PartialEq, Eq, Clone, Copy, Default)]
pub struct Borders: u8 {
/// Show the top border
const TOP = 0b0000_0001;
/// Show the right border
const RIGHT = 0b0000_0010;
/// Show the bottom border
const BOTTOM = 0b000_0100;
/// Show the left border
const LEFT = 0b0000_1000;
/// Show all borders
const ALL = Self::TOP.bits() | Self::RIGHT.bits() | Self::BOTTOM.bits() | Self::LEFT.bits();
}
}
/// Base requirements for a Widget
pub trait Widget {
/// Draws the current state of the widget in the given buffer. That the only method required to
/// implement a custom widget.
fn render(self, area: Rect, buf: &mut Buffer);
}