Commit Graph

31 Commits

Author SHA1 Message Date
diamondburned f8c644fa7e Allow empty texts with segments
This commit allows segments in an empty text segment to account for
segments with only an image.
2021-03-19 22:40:31 -07:00
diamondburned 24fc2c9bbb Fixed invalid types and bugs in MessageReferencer 2020-12-17 17:18:02 -08:00
diamondburned f1db8e0601 Added MessageReferencer for text.Rich
This commit added MessageReferencer for the text.Rich segments, which
allows a message to highlight a URL or text as a reference to other
messages. This could be used for replies as well as links that are
supposed to go to other messages.

The frontend gets to decide how exactly to represent the message when it
is clicked. However, as of right now, there is no API to fetch a single
message individually, so this API is limited to just within the message
buffer.
2020-12-17 17:14:21 -08:00
diamondburned 1dd36e0034 Clarified text.Imager's bound behavior
This commit clarifies text.Imager's (and therefore text.Avatarer's as
well) bound behaviors. Prior to this commit, it is unclear which end
bound an implementation should return. This commit clarifies that in
order for the image to be inlined, the start must overlap the end
bounds.

This clarification was needed in order to differentiate images to be
inlined with images to be associated with other contexts, such as
Mentioned. The inline check would therefore be very simple:

    if start == end {
        if imager := segment.AsImager(); imager != nil {
            log.Println("Segment has an inline image.")
        }
    }

Note that since there's now a way to explicitly define whether an image
is inlined or not, for implementations that can't display images, the
ImageText() should only be used if the image is actually inlined.
Therefore, the same check also applies to ImageText(). This also applies
to AvatarText().
2020-10-13 18:30:21 -07:00
diamondburned 76f5201a6f Fix text.SolidColor returning invalid color
This commit fixes the implementation of the helper function SolidColor.
It now does correctly what it says: it sets the alpha bits to 0xFF.
Prior to this, the function would override part of the color due to an
incorrect shift.
2020-10-13 16:46:18 -07:00
diamondburned 6140b5a131 Clarified text.{Imager,Avatarer}'s bound behavior
This commit clarifies text.Imager and text.Avatarer's bound behaviors.
Prior to this, the only behavior that those two interfaces have
regarding bounds is that only the starting bound matters, because images
must not substitute texts.

This commit clarifies that images are allowed complement other sections.
For example, a Mentioner can "have" an Imager by having the bounds
overlap.

These details are intentionally vaguely defined (it doesn't list any
interfaces beyond Mentioner), so implementations of either side can
implement these however they want, as long as the bounds overlap.

In the future, further clarification rules may be added if needed.
2020-10-09 00:17:58 -07:00
diamondburned 285ac6403f Added (text.Rich).IsEmpty
This commit restores the old IsEmpty API that was removed during code
generation.
2020-10-09 00:12:02 -07:00
diamondburned 819bcd3504 Clarified bitwise enum starting point; regenerate 2020-10-09 00:05:25 -07:00
diamondburned 32fa6266db Fixed Bitwise codegen being flipped 2020-10-08 23:58:58 -07:00
diamondburned 89b5ede1d8 Regenerated code to adhere to codegen header
This commit regenerates all files to adhere to the arguably-official
convention of having a standardized comment format to allow
distinguishing between written and generated files.

Refer to https://golang.org/s/generatedcode for more information.
2020-10-04 14:33:57 -07:00
diamondburned 086f987b3c Add Stringer into struct repositories
This commit adds the Stringer method representation into the repository.
The Rich struct of package text now implements Stringer and returns the
Content in plain text.

Prior to the repository commits, Rich used to have String().
2020-10-04 10:28:48 -07:00
diamondburned e2751cc260 Added helper functions in package text
This package adds back the Plain function from the old package text as
well as a new function called SolidColor that returns a new RGBA color
with the alpha bits maxed out.

These functions are there for convenience. They're also outside the
scope of the code generator and repository.
2020-10-03 21:29:15 -07:00
diamondburned 9a64b50703 Package text to use asserters; colors now RGBA
This commit regenerates package text to use asserters instead of
manually asserting structs. This is to both bring consistency to the
interfaces and prepare it for the incoming IPC additions.

This commit also changed the Colorer interface to require returning a
32-bit RGBA color. Before, backends could return 24-bit RGB OR 32-bit
RGBA, but there wasn't a good way to distinguish between the two. Now,
backends must set the alpha bits to 0xFF if it's 24-bit only.
2020-10-03 15:43:05 -07:00
diamondburned 2d93bf62ea Regenerated with Backlogger and fixes 2020-09-27 20:37:27 -07:00
diamondburned f515470458 Generated code now compiles; added DO NOT EDIT 2020-09-27 19:30:36 -07:00
diamondburned 516532ee01 Repository changes; regenerated code
This commit fixes some trivial errors in the repository package. The
changes are breaking.

This commit also replaced the old cchat and text Go source code files
with ones generated straight from the repository. To regenerate, run

    go generate ./...

The code is generated using the Jennifer library. In the future, all
generated code (including package empty and the RPC library) will use
Jennifer.
2020-09-27 18:41:17 -07:00
diamondburned 4239dc47c4 Added rich.Empty
This commit adds rich.Empty for convenience. It describes an empty text
segment.
2020-09-05 19:39:34 -07:00
diamondburned 681cc520d9 Added text.Plain helper function
This function was added for convenience.
2020-08-15 14:10:53 -07:00
diamondburned 8827df937d Added MentionerAvatar and MentionedImage; clarified new behavior for Mentioner
This commit adds the MentionerAvatar and MentionedImage interfaces. This
interface gives the mentioned object an avatar or image. An example of
this would be showing a user's avatar. This allows the frontend to do
simple layouting.

The new behavior for Mentioner states that the frontends should be able
to use the highlighted segment as the mentioned object's display name.
For example, if the mentioned segment highlights "@username", then the
frontend should display "@username" as the large text.
2020-07-19 00:55:57 -07:00
diamondburned ecbd4515a2 Added Mentioner and clarifications
This commit adds the Mentioner interface. The objective is to have a
clickable mention string similar to that in Discord, that when pressed
will popup a small box containing the given user info.

In the future, Mentioner may be expanded to add Avatar capabilities, but
for now, it can be added using text segments.

This commit also clarified that segments can implement multiple
interfaces. This is done to allow segments such as Mentioner to also be
colored using Colorer.

Frontend implementations should, instead of a type switch, use multiple
if statements separately. This may introduce a lot more boilerplate code.
2020-07-07 13:26:39 -07:00
diamondburned (Forefront) 0abbf861bc Added Avatarer into package text
This commit adds Avatarer into the list of supported text segments. This
should work very similarly to Imager, except that avatars should be
rounded by the frontend.

This commit should make the text image APIs consistent with the main
cchat package.
2020-07-04 01:15:50 -07:00
diamondburned (Forefront) dfb60ac0eb text.Rich to implement Stringer; extra docs 2020-06-20 00:10:23 -07:00
diamondburned (Forefront) e953dbbcb1 Added extra methods onto Imager.
This is done instead of text substitution, as images might have contexts
and other important attributes. One such example is an emoji, which may
have worked with text substitution, but would also work with a simple
string append.
2020-06-17 20:45:30 -07:00
diamondburned (Forefront) 05b7a6a10c Specified that Images cannot do text substitution
This commit specifies that images cannot substitute a piece of text with
itself. This means that end bounds of those segments are ignored, and
images will be inserted where the start bounds point them to.

Frontends that can't actually display images should represent this
information in another way by itself. One way is to treat this as a
hyperlink that says "Image."
2020-06-17 17:34:38 -07:00
diamondburned (Forefront) ba88528a7a Removed text substitution from hyperlinks
This was done because handling text substitution would make rich text
renderers much more complex. Instead of lazily preprocessing all
segments into a list of attributes and lazily inserting them into a
new text, they would now have to account for text substitutions,
which would be overkill for a single link.

As a tradeoff, frontends that don't render rich texts and only use the
Content string will not see any URLs. Instead, it will only see the
underlying text of the URL, except without the actual hyperlink.
2020-06-17 17:02:56 -07:00
diamondburned (Forefront) d4917d2e6d Added Has to text.Attribute 2020-06-17 16:10:53 -07:00
diamondburned (Forefront) 8fdf82883a Moved package split to utils 2020-06-10 12:19:13 -07:00
diamondburned (Forefront) 66dd2b1b11 Added split package to help with completions 2020-06-10 01:12:41 -07:00
diamondburned (Forefront) 2e7c6b0098 Added blocks into richtext and AttrDim into inline attributes 2020-06-09 20:51:54 -07:00
diamondburned (Forefront) fa7f2fdca4 Fixed color hexadecimal invalid size 2020-06-03 21:15:52 -07:00
diamondburned (Forefront) 3e8f0a0921 Initial API draft 2020-05-18 23:07:22 -07:00