realisze the Linkshift and rightShift. Send a signal value -127 to the sharedmemory.

This commit is contained in:
yukun 2019-12-19 12:22:39 +01:00
parent 4cb4fcd562
commit f2db3b2d3a
2 changed files with 70 additions and 5 deletions

View File

@ -92,13 +92,24 @@ int main() {
if(vkvm::KeyCode::Arrow_Left == keycode){
terminal.moveleft();
std::cout << terminal.getString() << std::endl;
vkvm::setText(terminal.getString());
vkvm::callEvent(vkvm::EventType::RenderText);
}
if(vkvm::KeyCode::Arrow_Right == keycode){
terminal.moveright();
std::cout << terminal.getString() << std::endl;
vkvm::setText(terminal.getString());
vkvm::callEvent(vkvm::EventType::RenderText);
}
// if(vkvm::KeyCode::Arrow_Down == keycode){
// terminal.movedown();
// std::cout << terminal.getString() << std::endl;
// vkvm::setText(terminal.getString());
// vkvm::callEvent(vkvm::EventType::RenderText);
// }

View File

@ -2,6 +2,7 @@
// Created by yukun on 29.11.19.
//
#include <iostream>
#include <vector>
#include "vkvm.hpp"
#include "Terminal.h"
@ -29,9 +30,8 @@ void Terminal::setString(char c) {
}
else{
s = s + cursor;
std::cout << "else1 " + s << std::endl;
s[s.length()-2] = c;
std::cout << "else2 " + s << std::endl;
}
}
@ -41,9 +41,10 @@ void Terminal::subString(){
// s.erase(s.end() - 1);
// s.erase(s.end() - 1);
// s = s + cursor;
int i = s.find(cursor);
s.erase(i-1, 1);
if(s.length() > 1) {
int i = s.find(cursor);
s.erase(i - 1, 1);
}
}
void Terminal::shiftpressed() {
@ -79,6 +80,59 @@ void Terminal::moveright() {
}
void Terminal::movedown() {
std::string news="";
int i = s.find(cursor);
s.erase(i, 1);
std::vector<std::vector<char>> vec(100,std::vector<char>(21,0));
for(int n = 0; n < 100; n++){
if(n*21 < s.length()) {
for (int m = 0; m < 21; m++) {
int sum = n * 21 + m;
if (s[sum] != '\n') {
vec[n][m] = s[sum];
std::cout<<"vec before" + vec[n][m]<<std::endl;
}
else {
vec[n][m] = s[sum];
break;
}
}
}
else {
break;
}
}
int cursorrow = i / 21;
int cursorcolumn =i % 21;
std::cout<<"before" + std::to_string(cursorrow) + ' '+ std::to_string(cursorcolumn)<<std::endl;
if(vec[cursorrow+1].size() >= cursorcolumn){
cursorrow++;
}
else if(vec[cursorrow+1].size() >=1){
cursorrow++;
cursorcolumn = vec[cursorrow].size()-1;
}
std::cout<<"after" + std::to_string(cursorrow) + ' '+ std::to_string(cursorcolumn)<<std::endl;
for(int n = 0; n < 100; n++){
for(int m=0;m<21;m++){
if((n==cursorrow) && (m==cursorcolumn)){
news = news + cursor;
}
else if(vec[n][m] != '\n'){
std::cout<<"vec after" + vec[n][m]<<std::endl;
news = news + vec[n][m];
}
else{
news = news + vec[n][m];
break;
}
}
}
std::cout<< news<<std::endl;
}