Grid Sage Forums

Grid Sage Forums

  • November 23, 2024, 02:39:05 AM
  • Welcome, Guest
Please login or register.

Login with username, password and session length
Advanced search  

News:

LINKS: Website | Steam | Wiki

Author Topic: Hard wrap for ANSI mode  (Read 5723 times)

DiamondTroller

  • Unaware
  • *
  • Posts: 6
    • View Profile
Hard wrap for ANSI mode
« on: December 26, 2023, 04:10:18 PM »

Hello,
Still like this awesome project. Thought maybe you could add few features, which I think might be useful to wider ANSI mode usage.
I wanted to use the ANSI mode for a discord message, but since the large company oversimplifies everything they make, it's borked as you can see in the image:


This is what editing the message looks like:


While original in Rex looks like this:


The main issue is that 80 col soft wrapping doesn't work, so there could be an option for hard wrapping(explicitly inserting newlines) and if hard wrapping's implemented then the Rex files could be in arbitrary width rather than 80 cols only. I totally would understand if you consider making such an option out of scope, but https://www.gridsagegames.com/forums/index.php?topic=1104 uses hard wrapping too, and I think it would still be pretty useful outside of discord too.

Also, I'm wondering what does ^[[?33h do :P, did a quick search on the webz, but didn't find anything.
« Last Edit: December 26, 2023, 04:14:53 PM by DiamondTroller »
Logged

Kyzrati

  • Administrator
  • True Cogmind
  • *****
  • Posts: 4477
    • View Profile
    • Cogmind
Re: Hard wrap for ANSI mode
« Reply #1 on: December 26, 2023, 11:07:08 PM »

Also, I'm wondering what does ^[[?33h do :P, did a quick search on the webz, but didn't find anything.
"?33h" presumably sets 80x25 color text mode. According to the ANSI standard I believe this should be represented as ?3h, but in all the sample .ans files I was given at the time, ?33h was used instead (no idea why xD), so I coded for that... I don't use .ans myself so I only implemented it based on the initial requests according to the resources I was provided and what I could look up :P

Seems to have worked out okay over the years so far.

Discord seems like an interesting use case :)

Though yeah not super compatible. It won't be able to properly display the full .ans output anyway because they don't account for the file header (as you can see there). This is what I got when I edited it out, having drawn in RP the same thing you did:



Though newlines are indeed a problem with different window widths.

Quote
there could be an option for hard wrapping
And how is that presumed to work? More specifically, what defines when and where we want to add these newlines? Basically just check backwards from the end of each line and force an early linefeed after the last space that contains anything (character or background color). Maybe possible.

Also we can see that Discord uses non-standard background colors, although I guess if you just modified REXPaint's palette to match the list they're using you'd end up WYSIWYG in that regard.

In the end unless there's more of a need for it, I'm not super interested in building something directly compatible with Discord right now, especially since their own support is relatively new and could change. (Mainly referring to, for example, automatically removing the header.)

I do hope to release a new REXPaint version perhaps next month, though.

Quote
files could be in arbitrary width rather than 80 cols only
Yeah it was just made to adhere to the standard size used so that it could be compatible with other software and the most frequent use cases.
Logged
Josh Ge, Developer - Dev Blog | @GridSageGames | Patreon

DiamondTroller

  • Unaware
  • *
  • Posts: 6
    • View Profile
Re: Hard wrap for ANSI mode
« Reply #2 on: December 27, 2023, 09:35:00 AM »

Thank you for the quick reply!

there could be an option for hard wrapping
And how is that presumed to work?
Yeah adding the newline when the horizontal line ends. See how the aforementioned tool does it.


But I decided to do some research on my own, found out about PabloDraw and through it found out about https://16colo.rs and from looking through couple packs, it truly seems that every .ans file has their own format, so having something that everyone will like is almost impossible. If I will find time, I will maybe write a small tool for Discord.
Logged

Kyzrati

  • Administrator
  • True Cogmind
  • *****
  • Posts: 4477
    • View Profile
    • Cogmind
Re: Hard wrap for ANSI mode
« Reply #3 on: December 28, 2023, 06:40:35 AM »

Yeah I recall researching that there's not really a good strong standard for it, so just went with what I had.

I can add hard wrapping to the next version if you need it, though now I'm wondering if that should just be default behavior, or should I bother with making it a separate option? Would making it the default perhaps mess other people up? Heh, so many questions, and the lack of a standardized way to handle it is kind of annoying...
Logged
Josh Ge, Developer - Dev Blog | @GridSageGames | Patreon

DiamondTroller

  • Unaware
  • *
  • Posts: 6
    • View Profile
Re: Hard wrap for ANSI mode
« Reply #4 on: December 28, 2023, 02:01:52 PM »

My first usecase was Discord, but second one that I wanted to use ANSI mode for was to create files, which I could print on my termemu and see the pretty pictures(and adding them to MOTD so my operating systems professor sees it :) ). This use benefits from hardwrapping too, the termemu I use(kitty) doesn't seem to understand softwrapping escape codes either.

 Will this ruin ANSI mode for others? I'm not sure, I did try opening hardwrapped files with removed headers in PabloDraw, and it looked like it was viewing them correctly iirc, but the behaviour could be tested on other older editors too.
Logged

Kyzrati

  • Administrator
  • True Cogmind
  • *****
  • Posts: 4477
    • View Profile
    • Cogmind
Re: Hard wrap for ANSI mode
« Reply #5 on: January 01, 2024, 09:42:45 PM »

Mmm, in that case maybe as an option would be the safest thing to do, especially since I'm not well versed in, or making personal use of, any of the ANSI-specific side of things.
Logged
Josh Ge, Developer - Dev Blog | @GridSageGames | Patreon

Kyzrati

  • Administrator
  • True Cogmind
  • *****
  • Posts: 4477
    • View Profile
    • Cogmind
Re: Hard wrap for ANSI mode
« Reply #6 on: January 01, 2024, 11:58:39 PM »

Aright I've added an option to enable a hard wrap for .ans exports.

Heres a patch you can try out and let me know how it works (should be able to just overwrite the standard download's .exe).

To use it you'll have to enable ansHardWrap=1 in the cfg file.

The earlier test comes out as


Edit: Patch removed, feature now included by default in REXPaint 1.7.
« Last Edit: January 09, 2024, 09:03:46 PM by Kyzrati »
Logged
Josh Ge, Developer - Dev Blog | @GridSageGames | Patreon

DiamondTroller

  • Unaware
  • *
  • Posts: 6
    • View Profile
Re: Hard wrap for ANSI mode
« Reply #7 on: January 23, 2024, 02:29:44 AM »

Awesome stuff, thank you for the work!
Logged