Remove unused textinputbuffer.{c,h}

This commit is contained in:
Gymnasiast 2018-02-01 11:48:32 +01:00 committed by Michael Steenbeek
parent 1b2c1a4d83
commit 6c49d45266
3 changed files with 0 additions and 180 deletions

View File

@ -375,7 +375,6 @@
F76C85E11EC4E88300FA49E2 /* MemoryStream.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F76C838C1EC4E7CC00FA49E2 /* MemoryStream.cpp */; };
F76C85E41EC4E88300FA49E2 /* Path.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F76C838F1EC4E7CC00FA49E2 /* Path.cpp */; };
F76C85E71EC4E88300FA49E2 /* String.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F76C83921EC4E7CC00FA49E2 /* String.cpp */; };
F76C85EB1EC4E88300FA49E2 /* textinputbuffer.c in Sources */ = {isa = PBXBuildFile; fileRef = F76C83961EC4E7CC00FA49E2 /* textinputbuffer.c */; };
F76C85EE1EC4E88300FA49E2 /* Zip.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F76C83991EC4E7CC00FA49E2 /* Zip.cpp */; };
F76C85F41EC4E88300FA49E2 /* DrawingFast.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F76C83A01EC4E7CC00FA49E2 /* DrawingFast.cpp */; };
F76C85F91EC4E88300FA49E2 /* Image.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F76C83A51EC4E7CC00FA49E2 /* Image.cpp */; };
@ -1244,8 +1243,6 @@
F76C83931EC4E7CC00FA49E2 /* String.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = String.hpp; sourceTree = "<group>"; };
F76C83941EC4E7CC00FA49E2 /* StringBuilder.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = StringBuilder.hpp; sourceTree = "<group>"; };
F76C83951EC4E7CC00FA49E2 /* StringReader.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = StringReader.hpp; sourceTree = "<group>"; };
F76C83961EC4E7CC00FA49E2 /* textinputbuffer.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = textinputbuffer.c; sourceTree = "<group>"; };
F76C83971EC4E7CC00FA49E2 /* textinputbuffer.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = textinputbuffer.h; sourceTree = "<group>"; };
F76C83981EC4E7CC00FA49E2 /* Util.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = Util.hpp; sourceTree = "<group>"; };
F76C83991EC4E7CC00FA49E2 /* Zip.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = Zip.cpp; sourceTree = "<group>"; };
F76C839A1EC4E7CC00FA49E2 /* Zip.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = Zip.h; sourceTree = "<group>"; };
@ -1983,8 +1980,6 @@
F76C83931EC4E7CC00FA49E2 /* String.hpp */,
F76C83941EC4E7CC00FA49E2 /* StringBuilder.hpp */,
F76C83951EC4E7CC00FA49E2 /* StringReader.hpp */,
F76C83961EC4E7CC00FA49E2 /* textinputbuffer.c */,
F76C83971EC4E7CC00FA49E2 /* textinputbuffer.h */,
F76C83981EC4E7CC00FA49E2 /* Util.hpp */,
F76C83991EC4E7CC00FA49E2 /* Zip.cpp */,
F76C839A1EC4E7CC00FA49E2 /* Zip.h */,
@ -3450,7 +3445,6 @@
F76C85E11EC4E88300FA49E2 /* MemoryStream.cpp in Sources */,
F76C85E41EC4E88300FA49E2 /* Path.cpp in Sources */,
F76C85E71EC4E88300FA49E2 /* String.cpp in Sources */,
F76C85EB1EC4E88300FA49E2 /* textinputbuffer.c in Sources */,
F76C85EE1EC4E88300FA49E2 /* Zip.cpp in Sources */,
F76C85F41EC4E88300FA49E2 /* DrawingFast.cpp in Sources */,
F76C85F91EC4E88300FA49E2 /* Image.cpp in Sources */,

View File

@ -1,130 +0,0 @@
#pragma region Copyright (c) 2014-2017 OpenRCT2 Developers
/*****************************************************************************
* OpenRCT2, an open source clone of Roller Coaster Tycoon 2.
*
* OpenRCT2 is the work of many authors, a full list can be found in contributors.md
* For more information, visit https://github.com/OpenRCT2/OpenRCT2
*
* OpenRCT2 is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* A full copy of the GNU General Public License can be found in licence.txt
*****************************************************************************/
#pragma endregion
#include "../localisation/Localisation.h"
#include "textinputbuffer.h"
void textinputbuffer_init(textinputbuffer * tib, utf8 * buffer, size_t size)
{
assert(buffer != NULL);
assert(size > 0);
tib->buffer = buffer;
tib->max_size = size - 1;
tib->current_size = strlen(buffer);
tib->selection_offset = tib->current_size;
tib->selection_size = 0;
textinputbuffer_recalculate_length(tib);
}
void textinputbuffer_clear(textinputbuffer * tib)
{
tib->buffer[0] = 0;
tib->current_size = 0;
tib->length = 0;
tib->selection_offset = 0;
tib->selection_size = 0;
}
void textinputbuffer_remove_selected(textinputbuffer * tib)
{
utf8 * targetShiftPtr = tib->buffer + tib->selection_offset;
utf8 * sourceShiftPtr = targetShiftPtr + tib->selection_size;
size_t shiftSize = tib->current_size - tib->selection_offset - tib->selection_size + 1;
memmove(targetShiftPtr, sourceShiftPtr, shiftSize);
tib->selection_size = 0;
textinputbuffer_recalculate_length(tib);
}
void textinputbuffer_insert_codepoint(textinputbuffer * tib, uint32 codepoint)
{
size_t codepointLength = utf8_get_codepoint_length(codepoint);
size_t remainingSize = tib->max_size - tib->current_size;
if (codepointLength <= remainingSize) {
utf8 * insertPtr = tib->buffer + tib->selection_offset;
if (tib->selection_offset < tib->current_size) {
// Shift bytes (including null terminator) right to make room for new codepoint
utf8 * targetShiftPtr = insertPtr + codepointLength;
size_t shiftSize = tib->current_size - tib->selection_offset + 1;
memmove(targetShiftPtr, insertPtr, shiftSize);
} else {
// Character is appended onto the end, so set byte after it to null terminator
tib->buffer[tib->current_size + codepointLength] = 0;
}
utf8_write_codepoint(insertPtr, codepoint);
tib->selection_offset += codepointLength;
tib->current_size += codepointLength;
tib->length++;
}
}
void textinputbuffer_insert(textinputbuffer * tib, const utf8 * source)
{
const utf8 *ch = source;
uint32 codepoint;
while ((codepoint = utf8_get_next(ch, &ch)) != 0) {
textinputbuffer_insert_codepoint(tib, codepoint);
}
}
void textinputbuffer_cursor_left(textinputbuffer * tib)
{
size_t selectionOffset = tib->selection_offset;
if (selectionOffset > 0) {
const utf8 * ch = tib->buffer + selectionOffset;
do {
ch--;
selectionOffset--;
} while (!utf8_is_codepoint_start(ch) && selectionOffset > 0);
tib->selection_offset = selectionOffset;
}
}
void textinputbuffer_cursor_right(textinputbuffer * tib)
{
size_t selectionOffset = tib->selection_offset;
size_t selectionMaxOffset = tib->current_size;
if (selectionOffset < selectionMaxOffset) {
const utf8 * ch = tib->buffer + selectionOffset;
do {
ch++;
selectionOffset++;
} while (!utf8_is_codepoint_start(ch) && selectionOffset < selectionMaxOffset);
tib->selection_size = tib->selection_size - (selectionOffset - tib->selection_offset);
tib->selection_offset = selectionOffset;
}
}
void textinputbuffer_cursor_home(textinputbuffer * tib)
{
tib->selection_offset = 0;
}
void textinputbuffer_cursor_end(textinputbuffer * tib)
{
tib->selection_offset = tib->current_size;
}
void textinputbuffer_recalculate_length(textinputbuffer * tib)
{
tib->current_size = strlen(tib->buffer);
tib->length = utf8_length(tib->buffer);
}

View File

@ -1,44 +0,0 @@
#pragma region Copyright (c) 2014-2017 OpenRCT2 Developers
/*****************************************************************************
* OpenRCT2, an open source clone of Roller Coaster Tycoon 2.
*
* OpenRCT2 is the work of many authors, a full list can be found in contributors.md
* For more information, visit https://github.com/OpenRCT2/OpenRCT2
*
* OpenRCT2 is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* A full copy of the GNU General Public License can be found in licence.txt
*****************************************************************************/
#pragma endregion
#ifndef _TEXTINPUTBUFFER_H_
#define _TEXTINPUTBUFFER_H_
#include "../common.h"
typedef struct textinputbuffer {
utf8 * buffer;
size_t max_size; // Maximum number of bytes (excluding null terminator)
size_t current_size; // Number of bytes (excluding null terminator)
uint32 length; // Number of codepoints
size_t selection_offset; // Selection start, in bytes
size_t selection_size; // Selection length in bytes
} textinputbuffer;
void textinputbuffer_init(textinputbuffer * tib, utf8 * buffer, size_t size);
void textinputbuffer_clear(textinputbuffer * tib);
void textinputbuffer_remove_selected(textinputbuffer * tib);
void textinputbuffer_insert_codepoint(textinputbuffer * tib, uint32 codepoint);
void textinputbuffer_insert(textinputbuffer * tib, const utf8 * source);
void textinputbuffer_cursor_left(textinputbuffer * tib);
void textinputbuffer_cursor_right(textinputbuffer * tib);
void textinputbuffer_cursor_home(textinputbuffer * tib);
void textinputbuffer_cursor_end(textinputbuffer * tib);
void textinputbuffer_recalculate_length(textinputbuffer * tib);
#endif