Skip to content

Added Rich Text to SimpleTextArea!!!!#1654

Open
abb2k wants to merge 27 commits intogeode-sdk:mainfrom
abb2k:v5
Open

Added Rich Text to SimpleTextArea!!!!#1654
abb2k wants to merge 27 commits intogeode-sdk:mainfrom
abb2k:v5

Conversation

@abb2k
Copy link

@abb2k abb2k commented Jan 28, 2026

HIII :D:D:DD

ive wanted this for a while now so i decided to make it myself :D you can now add rich text keys into a SimpleTextArea! :D

you can do so by using registerRichTextKey on your SimpleTextArea to add a key and tell it

  • what the main key string is
  • how will it use the given value and convert it to something you can use later for whatever, and the agility to tell if the key is invalid if you want
  • what will the key do to a CCFontSprite
  • what text will be inserted into the keys place after its replaced!

i think this is really cool and i hope u like what i made :D
this might not be the best implementation but u can polish it if you want ofc !!!! i tried my best :D (if you think i did anything wrong or bad i would be happy if you told me i wanna learn!! :D)

@abb2k
Copy link
Author

abb2k commented Jan 28, 2026

(also i didnt try this on any platform other than windows so idk if this works on others but i think it should be fine :))

@xblazegmd
Copy link
Contributor

Also, imo it would be convenient if there was a separate type of TextArea specifically for rich text, kinda like MDTextArea which is a text area with Markdown support.

Especially since now the SimpleTextArea isn’t simple anymore lol.

@abb2k
Copy link
Author

abb2k commented Jan 28, 2026

alrighty i committed changes yay :D

* @param applyToSprite Function to apply the parsed value to a font sprite (optional)
* @param stringAddition Function to add a new string at the point where the key is (optional)
*/
RichTextKey(std::string key, geode::Function<Result<T>(const std::string& value)> validCheck, geode::Function<void(const T& value, cocos2d::CCFontSprite* sprite)> applyToSprite = NULL, geode::Function<std::string(const T& value)> stringAddition = NULL)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe this constructor could get cleaned up a bit?

RichTextKey(
    std::string key,
    geode::Function<Result<T>(const std::string& value)> validCheck,
    geode::Function<void(const T& value, cocos2d::CCFontSprite* sprite)> applyToSprite = NULL,
    geode::Function<std::string(const T& value)> stringAddition = NULL
)

And also, idk how to feel about applyToSprite and stringAddition both having NULL as a default value.

I would have personally defined it something like:

RichTextKey(
    std::string key,
    geode::Function<Result<T>(const std::string& value)> validCheck,
) : m_key(std::move(key)), m_validCheck(std::move(validCheck)) {}

RichTextKey(
    std::string key,
    geode::Function<Result<T>(const std::string& value)> validCheck,
    geode::Function<void(const T& value, cocos2d::CCFontSprite* sprite)> applyToSprite,
) : m_key(std::move(key), m_validCheck(std::move(validCheck)), m_applyToSprite(std::move(applyToSprite)) {}

RichTextKey(
    std::string key,
    geode::Function<Result<T>(const std::string& value)> validCheck,
    geode::Function<void(const T& value, cocos2d::CCFontSprite* sprite)> applyToSprite,
    geode::Function<std::string(const T& value)> stringAddition
) : m_key(std::move(key), m_validCheck(std::move(validCheck)), m_applyToSprite(std::move(applyToSprite)), m_stringAddition(std::move(stringAddition)) {}

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alright :D thats cool i wasent sure of what a good way of writing that was :) ill improve !

@xblazegmd
Copy link
Contributor

I still think it would be better to have a separate sorta RichTextArea with rich text formatting instead of implementing it directly into SimpleTextArea since a: it's cleaner, and b: as I said before, with rich text formatting, SimpleTextArea stops being simple lol.

Final thing I'll say is to make sure the code fits into the code styling guidelines and double check CONTRIBUTING.md while on that.

@xblazegmd
Copy link
Contributor

Also whenever I have time I can try and test it on macOS

@abb2k
Copy link
Author

abb2k commented Jan 28, 2026

Cool ty for telling me about the guidlines and stuff i didnt know about them (im noob) ill try my best to improve this code with everything in here :D will update later dw :DD

@abb2k
Copy link
Author

abb2k commented Jan 28, 2026

well ive attempted to apply some things said in the styling guidelines :D there might be more that i forgot but i still feel like the way i placed my classes or the classes themselves is messy, i dont know why :(

@abb2k
Copy link
Author

abb2k commented Jan 29, 2026

Also i never thought of SimpleTextArea as a "text area thats simple in implementation" cz it always looked so much more complex then the normal TextArea i though of it like "simple text area makes it simple for me to do whatever i want" unlike actual TextArea lol

@altalk23
Copy link
Member

altalk23 commented Jan 30, 2026

this might be better as smth that subclasses simpletextarea

@abb2k
Copy link
Author

abb2k commented Jan 31, 2026

Oof :( i really dont understand the problem with it being on the simpletextarea i think its just fine but i respect the opinion and will do something whenever i have the time ig

@altalk23 altalk23 deleted the branch geode-sdk:main January 31, 2026 20:03
@altalk23 altalk23 closed this Jan 31, 2026
@altalk23 altalk23 reopened this Jan 31, 2026
@altalk23 altalk23 deleted the branch geode-sdk:main February 1, 2026 19:22
@altalk23 altalk23 closed this Feb 1, 2026
@altalk23 altalk23 reopened this Feb 1, 2026
@altalk23 altalk23 changed the base branch from v5 to main February 1, 2026 19:26
@abb2k
Copy link
Author

abb2k commented Feb 2, 2026

there have been some updates done to SimpleTextArea that i dont really understand and making it a harder time implementing this cz idk how this works lol, whats the Impl thing you use to separate some things in SimpleTextArea? i thought i would inhairate SimpleTextArea and make a RichTextArea and do what i did before over there but i cant because the charIteration is over at the Impl, how should i go about this?

@Fleeym
Copy link
Contributor

Fleeym commented Feb 2, 2026

SimpleTextArea is now pimpl (pointer to implementation), which makes it easier for us to update the class without breaking ABI. You can read up on it pretty easily. You have to also extend SimpleTextArea's Impl struct for RichTextArea.

@xblazegmd
Copy link
Contributor

xblazegmd commented Feb 2, 2026

I want to see if I can try changing it to have in mind the pimpl changes.

I also want to see if I can try and add stuff like links for example so it can "compete" better with MDTextLayer although I want to see what @abb2k thinks abt that first.

I don't promise anything, it's just an idea I have. I want to help, but if I can't or don't have the time or if @abb2k prefers to go solo then I wont.

@abb2k
Copy link
Author

abb2k commented Feb 3, 2026

i wanna add the rich text if u wanna add links using that rich text stuff later u can :D:D

@abb2k
Copy link
Author

abb2k commented Feb 3, 2026

help 😭 😭
image

it says "incomplete type "geode::SimpleTextArea::Impl" is not allowed", i did make class Impl; in SimpleTextArea protected idk what else i should do

@xblazegmd
Copy link
Contributor

@abb2k Well I don't fully know what the issue is, I will say tho, it'll maybe help if the constructor for RichTextArea's actually defined lol.

Like the destructor's defined but not the constructor somehow

@xblazegmd
Copy link
Contributor

While on that, please resolve the merge conflicts

@abb2k
Copy link
Author

abb2k commented Feb 4, 2026

ye i resolved the merge conflicts ofc and now it builds but also now the rich text isnt working? the functions seem to run but it doesnt update the text at all :(

@xblazegmd
Copy link
Contributor

@abb2k I'll try and fix that in a bit, I'm writing this from my phone so I can't properly check the code rn

@abb2k
Copy link
Author

abb2k commented Feb 4, 2026

thats alright :) im gonna go sleep now so ill see what u do whenever i wake up :D u can do !! :D

@abb2k
Copy link
Author

abb2k commented Feb 4, 2026

Ok i fixed the issue but i dont know if this is a good fix for it or if this breaks pimpl so let me know :D

@altalk23
Copy link
Member

altalk23 commented Feb 4, 2026

still has random changes like in platform.hpp or loader for example, could you fix those too

@abb2k
Copy link
Author

abb2k commented Feb 4, 2026

image are you talking about these issues? if so i have no clue how to fix them :( but i didnt touch them so maybe i could just copy over the file thats on main or something lol

@xblazegmd
Copy link
Contributor

@abb2k I can fix those things if you want

@abb2k
Copy link
Author

abb2k commented Feb 4, 2026

ye can you fix any other issues that i know of and can fix :D:D that would be really awesome :D:D:D:D

@xblazegmd
Copy link
Contributor

I am trying to polish the pimpl stuff to try and help, part of me wishes that either the rich text formatting was still in SimpleTextArea or that RichTextArea didn't inherit from SimpleTextArea as I'm stuck trying to make RichTextArea properly inherit from SimpleTextArea while not breaking pimpl or ABI.

And considering I'm new to both pimpl and ABI... it's a nightmare. But I'll try.

@abb2k
Copy link
Author

abb2k commented Feb 4, 2026

i thought i already fixed it to work just fine :( why is it not good at this point? all we need is to fix the extra issues alk talked about

@xblazegmd
Copy link
Contributor

Really my issues are just code structuring and polish. It's functional but I just wanted to try and make the code cleaner.

@xblazegmd
Copy link
Contributor

This is not to make you feel bad or anything, I am just trying to help (it's ok if you don't want me to do anything). And tbf idk why inheritance with pimpl has to be this hard lol

@abb2k
Copy link
Author

abb2k commented Feb 5, 2026

Im not feeling bad the help is awesome i appreciate it :D what u did helped and fixed the issues alk talked about i think but now for some reason the rich text isnt working :( i didnt have time to test at all but your changes dont seem like they should break anything so idk what happened

@abb2k
Copy link
Author

abb2k commented Feb 6, 2026

alright i fixed rich text it fully works now :D (also i added a wave effect text key and a action for it i hope its ok that i added this i just think this is super duper cool :D:D:D:D)

float m_phase;
float m_baseX;
float m_baseY;
}; No newline at end of file
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what is this and why is this

~RichTextArea();

class RichImpl;
std::unique_ptr<SimpleTextAreaImpl> createImpl() override;
Copy link
Member

@altalk23 altalk23 Feb 6, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this really needed instead of just exposing protected methods to simpletextarea for richtextarea to use

if (keyDown){
for (const auto& linkCharacter : wordClicked)
{
castedImpl->m_ogColorForLink.insert({linkCharacter, linkCharacter->getColor()});
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you expose a method for this instead

@@ -0,0 +1,190 @@
#include <Geode/DefaultInclude.hpp>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

these can be just moved to simpletextarea as protected functions


using namespace geode::prelude;

class SimpleTextAreaImpl {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ideally this class should just not exist in the first place

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants