GtkTextView can't wrap line - c

Hello I'm using Gtk on C, I need to have a GtkTextView in the middle of my window with many other widgets, I can't make the widget wrap lines. This is a very annoying behavior, anyone have any idea of what am I missing? This is the code I'm using to set it's properties:
gtk_text_view_set_left_margin(GTK_TEXT_VIEW(commentsTextView),20);
gtk_text_view_set_right_margin(GTK_TEXT_VIEW(commentsTextView),290);
gtk_text_view_set_wrap_mode(GTK_TEXT_VIEW(commentsTextView),GTK_WRAP_WORD);
gtk_text_view_set_pixels_inside_wrap(GTK_TEXT_VIEW(commentsTextView),0);
gtk_widget_set_size_request(commentsTextView,300,300);
Edit:
I solved this in a different way, still the problem remains unsolved :S

Did you put your text view into a GtkScrolledWindow?

You also need to make sure there are spaces in your text if you want the wrapping to occur on words. If there are no spaces in your string that is inserted into the text view gtk won't know where 1 word ends and the other begins.
If you want the text to wrap on a string without spaces you could use GTK_WRAP_CHAR in place of GTK_WRAP_WORD.

Related

How to stop Windows Forms label text from rearranging itself

Today I tried using Windows Forms for the first time, which went pretty smoothly until I tried setting the text of a label to "0 lines", which was displayed as "lines 0" in the actual program. I tried a couple of other inputs for the Text property, and it seems the leading number in the label is always moved to the back. I couldn't find any property in the label describing some sort of numerical formatting, so I was wondering were this rearranging came from and what I could do to disable it. Thanks in advance!
screenshot of the input
screenshot of the result
As CodeCaster said in their comment, I simply had to change the RightToLeft property.

Manual word-wrap in RichTextBox

I need to create RichTextBox in Windows Forms, which will have maximum 18 characters in a row and maximum 6 rows. The problem with RichTextBox is when you write very long word, it is displayed in two rows, but it is treated like one row. For example:
This is
supercalifragilist
icexpialidocious
This is a text with two lines.
My first approach was to create own class, which was inheriting from RichTextBox and override OnTextChanged. It was nicely done, but I totally forgot about word-wrap. So I implemented word-wrapping in my approach.
Algorithm is pretty simple: when text changes, split it by 'space' and 'new line' characters. Then I'm counting how many characters were entered in a row, and if there is space for word, I place it in this row. When there is no space for word, I'm creating new line.
And annoying part: now it have some bugs, which I don't know how to solve. Let's assume user has written 18-characters long word. He has a cursor after last character. And now:
He can press Return, to manually make new line character, which always should be in this place.
He can press space to start writing new word.
He can continue to write other characters for this word.
In each scenario he will end up with 18-characters long word and 'new line' character. I don't know how to detect, what he wanted to do. And please keep in mind that user can place cursor everywhere and edit the text he has entered previously.
I know I can create custom string class (inheriting from string) or keep list of entered words, but implementing this will be painful and code will start to be unreadable.
Any ideas how to do this better?
I figured it out. My other idea was to use StringReader and read whole text character by character, but it was also very buggy and painful to implement.
The best way is to not change the default behaviour of RichTextBox. I'm not splitting the text, I'm not checking if there is a space for word in line. My RichTextBox has fixed size and I'm okay with that. There is no problem with 18 characters in row, but the problem is with counting lines, because it's not that simple like counting new line characters.
The reason I wanted to change the behaviour is because later I must send this text line by line. Manually counting how many words fit in one line and dynamically create lines seemed to be easy, but it was to buggy.
RichTextBox has very useful method GetLineFromCharIndex. I'm able to determine how many actual lines I have, by passing Text.Count() to it. Now I have two time shorter code than before and it seems there are no bigger bugs. Sending the text line by line it's not so easy, because I needed to manually count in which line I am, when reading characters, but overall, it was more acceptable then previous solution.

ToolTip works very slow for long text (2000+ chars)

We need to use the built-in WinForms tooltip control to display a very long tooltip (about 4000 characters) for one of our controls. But if we do so, the form freezes for a minute or two when we place the mouse pointer into the target control to see the tip. And nothing happens after that.
We experimented and detected that the standard tooltip starts to work very slow when it has about 2000 chars, and the situation becomes much worse when we increase the number of chars. Is it a known issue, and is there any workaround for it? Please, don't suggest to trim the tip text - we need to display the string as is.
When you assign a string of text to a ToolTip, part of the process of drawing it involves calls to USP10.dll which handles Unicode layout of characters on screen. I was able to see this by looking at the stack trace while the program was freezing. The performance of this layout is terrible for long strings.
Disabling Visual Styles for the application (commenting out EnableVisualStyles()) fixed the problem - the tooltip displays immediately, though this is not an optimal solution.
I kept looking and found this page which indicates the problem may be linked to layout of long strings where word-wrap is necessary. By inserting line breaks into the tooltip text, I found that the string displayed immediately. So, if you can determine where to insert the line breaks manually, the ToolTip should display quickly.
What about using another Tooltip , i.e. HtmlToolip?

Give linespace in extjs grid content

I have a grid containing name and value columns. In value column I want content to have line spaces in between. I'm loading it from the grid store.It seems that "\n" and "\r\n" is not working in extjs.
Plz help me on this.
Escape sequence will not work. Moreover, why exactly do you need extra line space? If you think you need to forcefully add them, one way is to introduce <br/> in your content. Here is an example.

Symbols, Special character display issue in wpf

In WPF text block, I want to display special characters like diamond (♦) etc. It is displaying fine in some systems and in some systems, it is displaying a plain box instead of the symbol.
Can somebody help me to resolve this issue.
Thanks in Advance.
-Elangovan.
When you want "special characters" you should probably use images instead of depending on fonts. For one thing, you have no guarantee that the user will have the font you use.

Resources