Odilitime 5 years ago
parent
commit
b391325d4b
  1. 10
      src/graphics/components/DocumentComponent.cpp
  2. 1
      src/graphics/components/DocumentComponent.h
  3. 2
      src/graphics/components/InputComponent.cpp
  4. 5
      src/graphics/opengl/Window.cpp

10
src/graphics/components/DocumentComponent.cpp

@ -28,7 +28,7 @@ std::pair<size_t, size_t> getLine(std::string text, int findLine) { @@ -28,7 +28,7 @@ std::pair<size_t, size_t> getLine(std::string text, int findLine) {
while(pos != std::string::npos) {
lPos = pos;
pos = text.find("\r", lPos + 1);
if (line == findLine) {
if (line == static_cast<unsigned int>(findLine)) {
//std::cout << "lPos: " << lPos << " pos: " << pos << " line: " << line << std::endl;
//std::cout << "DocumentComponent.getLine start " << (lPos + line + 1) << " end " << (pos == std::string::npos ? text.length() : (lPos + pos)) << std::endl;
return std::make_pair(lPos + line + 1, pos == std::string::npos ? text.length() : (lPos + pos));
@ -190,12 +190,12 @@ DocumentComponent::DocumentComponent(const float rawX, const float rawY, const f @@ -190,12 +190,12 @@ DocumentComponent::DocumentComponent(const float rawX, const float rawY, const f
//std::pair<int, int> lineData = getLine(focusedInputComponent->value, 0);
focusedInputComponent->cursorCharY++;
size_t lines = getNumberOfLines(focusedInputComponent->getValue());
if (focusedInputComponent->cursorCharY > lines) {
if (focusedInputComponent->cursorCharY > static_cast<int>(lines)) {
focusedInputComponent->cursorCharY = lines;
focusedInputComponent->cursorCharX = focusedInputComponent->getValue().length();
}
} else {
focusedInputComponent->cursorCharX = static_cast<size_t>(focusedInputComponent->getValue().size());
focusedInputComponent->cursorCharX = focusedInputComponent->getValue().size();
}
*/
focusedInputComponent->updateCursor(0, 1);
@ -221,11 +221,11 @@ DocumentComponent::DocumentComponent(const float rawX, const float rawY, const f @@ -221,11 +221,11 @@ DocumentComponent::DocumentComponent(const float rawX, const float rawY, const f
} else if (key == GLFW_KEY_RIGHT) {
/*
focusedInputComponent->cursorCharX++;
if (focusedInputComponent->cursorCharX > focusedInputComponent->getValue().size()) {
if (focusedInputComponent->cursorCharX > static_cast<int>(focusedInputComponent->getValue().size())) {
if (focusedInputComponent->multiLine) {
focusedInputComponent->cursorCharY++;
size_t lines = getNumberOfLines(focusedInputComponent->getValue());
if (focusedInputComponent->cursorCharY > lines) {
if (focusedInputComponent->cursorCharY > static_cast<int>(lines)) {
focusedInputComponent->cursorCharY = lines;
} else {;
focusedInputComponent->cursorCharX = 0;

1
src/graphics/components/DocumentComponent.h

@ -11,6 +11,7 @@ @@ -11,6 +11,7 @@
#include "../../WebResource.h"
std::pair<size_t, size_t> getLine(std::string text, int findLine);
size_t getNumberOfLines(std::string text);
// document is scrollable until multicomponent
class DocumentComponent : public MultiComponent {

2
src/graphics/components/InputComponent.cpp

@ -412,7 +412,7 @@ void InputComponent::updateCursor(int mX, int mY) { @@ -412,7 +412,7 @@ void InputComponent::updateCursor(int mX, int mY) {
//std::cout << "InputComponent::updateCursor - text[" << this->value << "]" << std::endl;
//std::pair<int, int> lineData = getLine(this->text.getValue(), this->cursorCharY);
//std::cout << "InputComponent::updateCursor - line " << this->cursorCharY << " starts at " << lineData.first << std::endl;
//size_t pos = lineData.first + this->cursorCharX;
//size_t pos = static_cast<size_t>(lineData.first + this->cursorCharX);
//std::cout << "InputComponent::updateCursor - cx " << this->cursorCharX << " starts at value pos " << pos << std::endl;
//if (pos < this->text.getValue().size()) {

5
src/graphics/opengl/Window.cpp

@ -507,7 +507,7 @@ bool Window::initGLFW() { @@ -507,7 +507,7 @@ bool Window::initGLFW() {
if (action == GLFW_RELEASE || action == GLFW_REPEAT) {
if (key == GLFW_KEY_V && action == GLFW_RELEASE && mods == attentionMod) {
const char* clipBoard = glfwGetClipboardString(thiz->window);
for(int i=0; i < strlen(clipBoard); i++) {
for(unsigned int i=0; i < strlen(clipBoard); i++) {
inputComponent->addChar(clipBoard[i]);
}
//inputComponent->setValue(std::string(clipBoard));
@ -545,6 +545,9 @@ bool Window::initGLFW() { @@ -545,6 +545,9 @@ bool Window::initGLFW() {
case GLFW_KEY_RIGHT_BRACKET: key='}'; break;
case GLFW_KEY_GRAVE_ACCENT: key='~'; break;
case GLFW_KEY_0: key=')'; break;
default:
// a key we don't care about atm
break;
}
} else {
// no shift or caplocks

Loading…
Cancel
Save