Refactor in LineWrap operations enums and structs, moved everything into linewrap.hpp.

Revisiting some old code, the Map Editor, many things are not properly layouted, I might fix it later, for the moment a few minor fixes.
Fix build output and app output highlighting.
Fix isStopSelChar used in UITextInput for text selection (double click).
This commit is contained in:
Martín Lucas Golini
2026-01-21 00:03:01 -03:00
parent 46f13af278
commit faedaa43f4
17 changed files with 256 additions and 225 deletions

View File

@@ -0,0 +1,45 @@
#pragma once
#include <eepp/config.hpp>
#include <eepp/graphics/fontstyleconfig.hpp>
#include <vector>
namespace EE::Graphics {
enum class LineWrapMode { NoWrap, Letter, Word };
enum class LineWrapType { Viewport, LineBreakingColumn };
struct LineWrapInfo {
std::vector<Int64> wraps;
Float paddingStart{ 0 };
};
class EE_API LineWrap {
public:
static LineWrapMode toLineWrapMode( std::string mode );
static std::string fromLineWrapMode( LineWrapMode mode );
static LineWrapType toLineWrapType( std::string type );
static std::string fromLineWrapType( LineWrapType type );
static LineWrapInfo
computeLineBreaks( const String::View& string, const FontStyleConfig& fontStyle, Float maxWidth,
LineWrapMode mode, bool keepIndentation, Uint32 tabWidth = 4,
Float whiteSpaceWidth = 0.f /* 0 = should calculate it */,
Uint32 textHints = TextHints::None, bool tabStops = false,
Float initialXOffset = 0.f );
static LineWrapInfo computeLineBreaks( const String& string, const FontStyleConfig& fontStyle,
Float maxWidth, LineWrapMode mode, bool keepIndentation,
Uint32 tabWidth = 4, Float whiteSpaceWidth = 0.f,
Uint32 textHints = TextHints::None,
bool tabStops = false, Float initialXOffset = 0.f );
static Float computeOffsets( const String::View& string, const FontStyleConfig& fontStyle,
Uint32 tabWidth, Float maxWidth = 0.f, bool tabStops = false );
};
} // namespace EE::Graphics

View File

@@ -3,6 +3,7 @@
#include <eepp/graphics/font.hpp>
#include <eepp/graphics/fontstyleconfig.hpp>
#include <eepp/graphics/linewrap.hpp>
#include <eepp/graphics/pixeldensity.hpp>
#include <eepp/graphics/textlayout.hpp>
#include <eepp/graphics/texttransform.hpp>

View File

@@ -2,6 +2,7 @@
#define EE_UI_DOCUMENTVIEW_HPP
#include <eepp/graphics/fontstyleconfig.hpp>
#include <eepp/graphics/linewrap.hpp>
#include <eepp/ui/doc/textdocument.hpp>
#include <eepp/ui/doc/textposition.hpp>
#include <optional>
@@ -11,10 +12,6 @@ using namespace EE::UI::Doc;
namespace EE { namespace UI { namespace Doc {
enum class LineWrapMode { NoWrap, Letter, Word };
enum class LineWrapType { Viewport, LineBreakingColumn };
enum class VisibleIndex : Int64 { first = 0, invalid = std::numeric_limits<Int64>::max() };
inline VisibleIndex visibleIndexOffset( VisibleIndex idx, Int64 offset ) {
@@ -24,14 +21,6 @@ inline VisibleIndex visibleIndexOffset( VisibleIndex idx, Int64 offset ) {
class EE_API DocumentView {
public:
static LineWrapMode toLineWrapMode( std::string mode );
static std::string fromLineWrapMode( LineWrapMode mode );
static LineWrapType toLineWrapType( std::string type );
static std::string fromLineWrapType( LineWrapType type );
struct Config {
LineWrapMode mode{ LineWrapMode::NoWrap };
bool keepIndentation{ true };
@@ -45,11 +34,6 @@ class EE_API DocumentView {
bool operator!=( const Config& other ) { return !( *this == other ); }
};
struct LineWrapInfo {
std::vector<Int64> wraps;
Float paddingStart{ 0 };
};
struct VisibleLineInfo {
VisibleIndex visibleIndex{ VisibleIndex::invalid };
Float paddingStart{ 0 };
@@ -61,28 +45,12 @@ class EE_API DocumentView {
TextRange range;
};
static LineWrapInfo
computeLineBreaks( const String::View& string, const FontStyleConfig& fontStyle, Float maxWidth,
LineWrapMode mode, bool keepIndentation, Uint32 tabWidth = 4,
Float whiteSpaceWidth = 0.f /* 0 = should calculate it */,
Uint32 textHints = TextHints::None, bool tabStops = false,
Float initialXOffset = 0.f );
static LineWrapInfo computeLineBreaks( const String& string, const FontStyleConfig& fontStyle,
Float maxWidth, LineWrapMode mode, bool keepIndentation,
Uint32 tabWidth = 4, Float whiteSpaceWidth = 0.f,
Uint32 textHints = TextHints::None,
bool tabStops = false, Float initialXOffset = 0.f );
static LineWrapInfo computeLineBreaks( const TextDocument& doc, size_t line,
const FontStyleConfig& fontStyle, Float maxWidth,
LineWrapMode mode, bool keepIndentation,
Uint32 tabWidth = 4, Float whiteSpaceWidth = 0.f,
bool tabStops = false, Float initialXOffset = 0.f );
static Float computeOffsets( const String::View& string, const FontStyleConfig& fontStyle,
Uint32 tabWidth, Float maxWidth = 0.f, bool tabStops = false );
DocumentView( std::shared_ptr<TextDocument> doc, FontStyleConfig fontStyle, Config config );
bool isWrapEnabled() const;

View File

@@ -479,6 +479,8 @@ class EE_API TextDocument {
const SyntaxDefinition& getSyntaxDefinition() const;
void setSyntaxDefinition( std::shared_ptr<SyntaxDefinition> definition );
void setSyntaxDefinition( const SyntaxDefinition& definition );
Uint64 getCurrentChangeId() const;