terminal/src/Terminal.cpp

88 lines
1.4 KiB
C++
Raw Normal View History

2019-12-12 11:59:07 +01:00
//
// Created by yukun on 29.11.19.
//
2019-12-18 13:26:59 +01:00
#include <iostream>
2019-12-12 11:59:07 +01:00
#include "vkvm.hpp"
#include "Terminal.h"
std::string Terminal::getString() {
return s;
}
2019-12-18 13:26:59 +01:00
void Terminal::init(){
s = s + cursor;
}
2019-12-12 11:59:07 +01:00
void Terminal::setString(char c) {
2019-12-18 13:26:59 +01:00
// s.erase(s.end() - 1);
// s = s + c + cursor;
int i = s.find(cursor);
std::cout << i << std::endl;
std::cout<< s.length() -1 <<std::endl;
if(i < s.length() -1 ){
s= s + s[s.length() - 1];
int l = s.length() - 1;
for(; l > i + 1; l--){
s[l] = s[l-1];
}
s[i+1] = c;
}
else{
s = s + cursor;
std::cout << "else1 " + s << std::endl;
s[s.length()-2] = c;
std::cout << "else2 " + s << std::endl;
}
2019-12-12 11:59:07 +01:00
}
void Terminal::subString(){
2019-12-18 13:26:59 +01:00
// if(s.length() > 1)
// s.erase(s.end() - 1);
// s.erase(s.end() - 1);
// s = s + cursor;
int i = s.find(cursor);
s.erase(i-1, 1);
2019-12-12 11:59:07 +01:00
}
void Terminal::shiftpressed() {
status = 1;
}
void Terminal::shiftup() {
status = 0;
}
int Terminal::getstatus() {
return status;
}
2019-12-18 13:26:59 +01:00
void Terminal::moveleft(){
int i = s.find(cursor);
if(i > 0){
char c = s[i-1];
s[i-1] = cursor;
s[i] = c;
}
}
void Terminal::moveright() {
int i = s.find(cursor);
if(i < (s.length() - 1)){
char c = s[i+1];
s[i+1] = cursor;
s[i] = c;
}
}
void Terminal::movedown() {
}
void Terminal::moveup() {
}