MCPcopy Create free account
hub / github.com/devashishdxt/cli-table / buffer

Method buffer

cli-table/src/cell.rs:89–121  ·  view source on GitHub ↗
(
        &self,
        writer: &BufferWriter,
        available_dimension: Dimension,
        required_dimension: Dimension,
        data: &str,
    )

Source from the content-addressed store, hash-verified

87 }
88
89 fn buffer(
90 &self,
91 writer: &BufferWriter,
92 available_dimension: Dimension,
93 required_dimension: Dimension,
94 data: &str,
95 ) -> Result<Buffer> {
96 let empty_chars = match self.format.justify {
97 Justify::Left => self.format.padding.left,
98 Justify::Right => {
99 (available_dimension.width - required_dimension.width) + self.format.padding.left
100 }
101 Justify::Center => {
102 ((available_dimension.width - required_dimension.width) / 2)
103 + self.format.padding.left
104 }
105 };
106
107 let mut buffer = writer.buffer();
108 buffer.set_color(&self.color_spec())?;
109
110 for _ in 0..empty_chars {
111 write!(buffer, " ")?;
112 }
113
114 write!(buffer, "{}", data)?;
115
116 for _ in 0..(available_dimension.width - (display_width(data) + empty_chars)) {
117 write!(buffer, " ")?;
118 }
119
120 Ok(buffer)
121 }
122
123 fn top_blank_lines(
124 &self,

Callers 5

writeMethod · 0.80
supports_colorMethod · 0.80
set_colorMethod · 0.80
is_synchronousMethod · 0.80
buffersMethod · 0.80

Calls 3

display_widthFunction · 0.85
set_colorMethod · 0.80
color_specMethod · 0.45

Tested by

no test coverage detected