mirror of
https://github.com/wichtounet/thor-os.git
synced 2025-09-12 14:10:36 -04:00
Preliminary support for Ctrl+C
This commit is contained in:
parent
34161e5ac3
commit
f1df24d78a
@ -19,6 +19,8 @@ const char KEY_DOWN = 0x50;
|
||||
const char KEY_LEFT_SHIFT = 0x2A;
|
||||
const char KEY_RIGHT_SHIFT = 0x36;
|
||||
|
||||
const char KEY_LEFT_CTRL = 0x1D;
|
||||
|
||||
void install_driver();
|
||||
char get_char();
|
||||
char key_to_ascii(uint8_t key);
|
||||
|
@ -18,6 +18,7 @@ constexpr const size_t MAX_TERMINALS = 2;
|
||||
size_t active_terminal;
|
||||
|
||||
bool shift = false;
|
||||
bool ctrl = false;
|
||||
|
||||
std::array<stdio::virtual_terminal, MAX_TERMINALS> terminals;
|
||||
|
||||
@ -35,12 +36,16 @@ void stdio::virtual_terminal::send_input(char key){
|
||||
key &= ~(0x80);
|
||||
if(key == keyboard::KEY_LEFT_SHIFT || key == keyboard::KEY_RIGHT_SHIFT){
|
||||
shift = false;
|
||||
} else if(key == keyboard::KEY_LEFT_CTRL){
|
||||
ctrl = false;
|
||||
}
|
||||
}
|
||||
//Key pressed
|
||||
else {
|
||||
if(key == keyboard::KEY_LEFT_SHIFT || key == keyboard::KEY_RIGHT_SHIFT){
|
||||
shift = true;
|
||||
} else if(key == keyboard::KEY_LEFT_CTRL){
|
||||
ctrl = true;
|
||||
} else if(key == keyboard::KEY_BACKSPACE){
|
||||
if(!input_buffer.empty() || !canonical_buffer.empty()){
|
||||
print('\b');
|
||||
@ -54,9 +59,13 @@ void stdio::virtual_terminal::send_input(char key){
|
||||
: keyboard::key_to_ascii(key);
|
||||
|
||||
if(qwertz_key){
|
||||
input_buffer.push(qwertz_key);
|
||||
if(ctrl && qwertz_key == 'c'){
|
||||
input_buffer.push(200);
|
||||
} else {
|
||||
input_buffer.push(qwertz_key);
|
||||
|
||||
print(qwertz_key);
|
||||
print(qwertz_key);
|
||||
}
|
||||
|
||||
if(!input_queue.empty()){
|
||||
input_queue.wake_up();
|
||||
@ -92,7 +101,7 @@ size_t stdio::virtual_terminal::read_input(char* buffer, size_t max){
|
||||
}
|
||||
}
|
||||
|
||||
if(read > 0 && (c == '\n' || read == max)){
|
||||
if(read > 0 && (c == '\n' || c == 200 || read == max)){
|
||||
read = 0;
|
||||
while(!canonical_buffer.empty()){
|
||||
auto value = canonical_buffer.pop();
|
||||
|
@ -121,12 +121,16 @@ int main(){
|
||||
|
||||
char input_buffer[128];
|
||||
std::string current_input;
|
||||
|
||||
|
||||
print("thor> ");
|
||||
|
||||
while(true){
|
||||
auto c = read_input(input_buffer, 127);
|
||||
|
||||
if(input_buffer[c-1] == 200){
|
||||
input_buffer[c-1] = '\n';
|
||||
}
|
||||
|
||||
if(input_buffer[c-1] == '\n'){
|
||||
if(c > 1){
|
||||
input_buffer[c-1] = '\0';
|
||||
@ -174,7 +178,7 @@ int main(){
|
||||
}
|
||||
|
||||
current_input.clear();
|
||||
|
||||
|
||||
print("thor> ");
|
||||
} else {
|
||||
input_buffer[c] = '\0';
|
||||
@ -184,4 +188,4 @@ int main(){
|
||||
}
|
||||
|
||||
__builtin_unreachable();
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user