Adds a new file
(&mut self)
| 105 | |
| 106 | /// Adds a new file |
| 107 | fn new_line(&mut self) { |
| 108 | // increment the current row |
| 109 | self.row_positon += 1; |
| 110 | |
| 111 | // reset the column positon |
| 112 | self.column_position = 0; |
| 113 | |
| 114 | // scroll the view if there is no more free rows |
| 115 | if self.row_positon == BUFFER_HEIGHT { |
| 116 | for row in 1..BUFFER_HEIGHT { |
| 117 | for col in 0..BUFFER_WIDTH { |
| 118 | let buffer = self.buffer(); |
| 119 | let character = buffer.chars[row][col].read(); |
| 120 | buffer.chars[row - 1][col].write(character); |
| 121 | } |
| 122 | } |
| 123 | |
| 124 | // clear the last row |
| 125 | self.clear_row(BUFFER_HEIGHT - 1); |
| 126 | |
| 127 | // positon the cursor on the last row |
| 128 | self.row_positon -= 1; |
| 129 | } |
| 130 | } |
| 131 | |
| 132 | /// Clear a full row |
| 133 | fn clear_row(&mut self, row: usize) { |
no test coverage detected