From b274b7df6f2c517137bde15bf5f8ea75b92e9f28 Mon Sep 17 00:00:00 2001 From: MikeCAT Date: Wed, 3 Aug 2022 12:17:45 +0000 Subject: [PATCH 1/2] redraw terminal before executing commands After this commit, the terminal will treat the layer id 0 as invalid. Therefore, layer.cpp is also edited not to generate layers with id 0. --- kernel/layer.cpp | 1 + kernel/terminal.cpp | 9 +++++++++ kernel/terminal.hpp | 2 +- 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/kernel/layer.cpp b/kernel/layer.cpp index 1188b7122..385988d3c 100644 --- a/kernel/layer.cpp +++ b/kernel/layer.cpp @@ -69,6 +69,7 @@ void LayerManager::SetWriter(FrameBuffer* screen) { Layer& LayerManager::NewLayer() { ++latest_id_; + if (latest_id_ == 0) ++latest_id_; return *layers_.emplace_back(new Layer{latest_id_}); } diff --git a/kernel/terminal.cpp b/kernel/terminal.cpp index 600d4a1f2..7853c0abe 100644 --- a/kernel/terminal.cpp +++ b/kernel/terminal.cpp @@ -314,6 +314,15 @@ Rectangle Terminal::InputKey( ++cursor_.y; } else { Scroll1(); + draw_area.pos = ToplevelWindow::kTopLeftMargin; + draw_area.size = window_->InnerSize(); + } + if (LayerID()) { + Message msg = MakeLayerMessage( + task_.ID(), LayerID(), LayerOperation::DrawArea, draw_area); + __asm__("cli"); + task_manager->SendMessage(1, msg); + __asm__("sti"); } ExecuteLine(); Print(">"); diff --git a/kernel/terminal.hpp b/kernel/terminal.hpp index e2204c928..5f36fe94e 100644 --- a/kernel/terminal.hpp +++ b/kernel/terminal.hpp @@ -48,7 +48,7 @@ class Terminal { private: std::shared_ptr window_; - unsigned int layer_id_; + unsigned int layer_id_{0}; Task& task_; Vector2D cursor_{0, 0}; From 993ad9015172fa4f0e91e0d0d871cc188ab0ee13 Mon Sep 17 00:00:00 2001 From: MikeCAT Date: Fri, 26 Aug 2022 11:48:40 +0000 Subject: [PATCH 2/2] remove "new layer ID is 0?" check --- kernel/layer.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/kernel/layer.cpp b/kernel/layer.cpp index 385988d3c..1188b7122 100644 --- a/kernel/layer.cpp +++ b/kernel/layer.cpp @@ -69,7 +69,6 @@ void LayerManager::SetWriter(FrameBuffer* screen) { Layer& LayerManager::NewLayer() { ++latest_id_; - if (latest_id_ == 0) ++latest_id_; return *layers_.emplace_back(new Layer{latest_id_}); }