Giter Club home page Giter Club logo

Comments (13)

andydotxyz avatar andydotxyz commented on May 2, 2024 2

Thanks for the thoughts. I just don't think we can make a good experience with multiple entry widgets.
Once we have a good API for handling rich text rendering it may be clearer how to manage the editing of it.
See #2074

from fyne.

andydotxyz avatar andydotxyz commented on May 2, 2024 1

In 2.1 we add the rich text APIs, but they will not be exposed through Entry until a future release, as the cursor management etc is more complex.

from fyne.

andydotxyz avatar andydotxyz commented on May 2, 2024

This is a really great suggestion and we will work toward it slowly.
The canvas text object will only ever support 1 set of styles per block of text (to keep the backends simple) but we can do lots of cool stuff in Go.

The widget.Label has recently added multi line so you can see how this is started - we add (with lots of tests) the layout code and the application of styles (through an API or a markup) which will then apply to label and entry.

I agree that this is something many toolkits lack, but it is very hard to get right and keep efficient. Let's make it happen :)

from fyne.

andydotxyz avatar andydotxyz commented on May 2, 2024

Work has also begun on the cursor handling in widget.Entry. Once that is complete we should be able to start work on how rich / marked up text be supported...

from fyne.

stuartmscott avatar stuartmscott commented on May 2, 2024

@andydotxyz I'm not sure 263a14d fixes this issue since it is concerned with select box and not entry/label. Should this issue be reopened?

from fyne.

andydotxyz avatar andydotxyz commented on May 2, 2024

Oops, that was a typo in the commit message I guess

from fyne.

carwyn avatar carwyn commented on May 2, 2024

Arguably #1447 is related to this. As mentioned there there isn't currently a mono-spaced editor widget but TextGrid is able to display mono-space. A basic example use case is a simple text editor for editing config files or perhaps as a base for a simple code editor. This would fit nicely into fynedesk much like notepad does in Windows or gedit in Gnome.

from fyne.

mrjrieke avatar mrjrieke commented on May 2, 2024

I've spent quite a lot of thought over the last few days on this because it's something I really need. I'm kind of trying to work with the existing fyne widgets to frankenstein what I need.

One idea I like is that content is represented by a giant slice(able) array of runes. Then the styling of the slice and (subslices) is determined by a separate index stack where for each entry in the stack it specifies the beginning index and ending index and the style to apply. That way, the edit content itself doesn't need to be broken up.

Another idea I had was playing with the idea of using a variant of GridWrapLayout to make this happen with unfortunately very ugly results (since gridwraplayout has fixed cell sizes). So, essentially a grid of Entry widgets that are arranged adjacently. The trick comes when you want to move the cursor transparently between the different entry boxes. :)

An enhanced wrapping HBoxLayout might work better since sub elements can be sized and even styled independently. Again problems with edit cursor movement between Edit elements.

from fyne.

mrjrieke avatar mrjrieke commented on May 2, 2024

I eagerly await the rich text solution you suggested.

from fyne.

andydotxyz avatar andydotxyz commented on May 2, 2024

Possible API that I have just been looking at:

var (
	RichTextStyleInline RichTextStyle
	RichTextStyleParagraph RichTextStyle
	RichTextStyleHeading RichTextStyle
	RichTextStyleSubHeading RichTextStyle
	RichTextStyleQuote RichTextStyle
	RichTextStyleURL RichTextURL
	RichTextStyleEmphasis RichTextStyle
)

type RichText struct {
	BaseWidget

	Segments []RichTextSegment
}

type RichTextSegment interface {
	TextRepresentation() string
	CanvasRepresentation() fyne.CanvasObject
}

type TextSegment struct { // would implement RichTextSegment, handles rendering text
	Text string
	Type RichTextStyle
}

type RichTextStyle struct {
	Alignment fyne.TextAlign
	ColorName ThemeColorName
	Inline    bool
	TextSize  float32
	TextStyle fyne.TextStyle
}

type RichTextURL struct {
	RichTextStyle
	URL url.URL
}

type HorizontalRuleSegment struct { // would implement RichTextSegment, just draws a line
}

from fyne.

niondir avatar niondir commented on May 2, 2024

I need the same.

Looking for a Scrolling box with selectable but read-only mono-spaced text for a Log View.

A feature with ScrollToLine(n int) or SetCursorToLine(n int) would be very helpful as well to guide the user to a specific line, e.g. scroll to bottom, top or a search result inside the text.

from fyne.

bon-ami avatar bon-ami commented on May 2, 2024

I've checked for many days and could not find how to set a font for a (Rich-)Text/Entry control. Can I expect for it on a future release please? Thanks.

from fyne.

andydotxyz avatar andydotxyz commented on May 2, 2024

I've checked for many days and could not find how to set a font for a (Rich-)Text/Entry control. Can I expect for it on a future release please? Thanks.

The font used in Entry matches the rest of the app and is set by the theme. To modify the styles of items inside an entry will indeed need a rich text editor, which this ticket tracks. You can see that it is currently assigned to "Cragganmore (est Sept 2022)" which is the plan as it stands.

from fyne.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.