Bruhffer¶
Copyright 2023 Ethan Christensen Copied, Guided, and Adapted from Asciimatics <https://github.com/peterbrittain/asciimatics/blob/master/asciimatics/screen.py>
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
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.
- class bruhanimate.bruhutil.bruhffer.Buffer(height, width)[source]¶
Bases:
object
Class for creating and managing a buffer
- get_buffer_changes(in_buf)[source]¶
Compare this buffer with the given buffer and yield differences.
- Parameters:
in_buf (Buffer) – The buffer to compare with.
- Yields:
Tuple[int, int, str] –
- A tuple containing the row index, column index,
and the character from the input buffer that differs.
- clear_buffer(x=0, y=0, w=None, h=None, val=' ')[source]¶
Clear a section of the buffer with a specific character.
- Parameters:
x (int) – The starting x-coordinate for the clear operation (default is 0).
y (int) – The starting y-coordinate for the clear operation (default is 0).
w (int, optional) – The width of the section to be cleared. If not specified, clears to the end of the buffer’s width.
h (int, optional) – The height of the section to be cleared. If not specified, clears to the end of the buffer’s height.
val (str) – The character to fill the cleared area with (default is a space).
- scroll(shift)[source]¶
Scroll the buffer up or down by a specified number of lines.
- Parameters:
shift (int) – The number of lines to scroll. Positive scrolls up, negative scrolls down.
- shift_line(y, shift)[source]¶
Shift the specified line to the right by a given amount. :param y: The index of the row to shift. :type y: int :param shift: The amount by which to shift the row. :type shift: int
- shift(shift)[source]¶
Shift the entire buffer to the right by a specified amount. :param shift: The amount by which to shift each row. :type shift: int
- sync_with(in_buf)[source]¶
Synchronize this buffer with another buffer. :param in_buf: The buffer to synchronize with. :type in_buf: Buffer