Character Spacing in Fl_Text_Editor?

已查看 29 次
跳至第一个未读帖子

Svets

未读,
2016年6月24日 20:48:172016/6/24
收件人 fltk.general
I am trying to space data in a Fl_Text_Editor so I have definite column start and end points in my data.  I want each column to line up with the row above it line over line.
The problem I am having is that characters have different widths. So,,, if I do the below, line over line, the 11 is narrower in the Fl_Text_Editor  than the width 
of 8 and the character width of the 1's throws off all my other column positions.  Is there a way to correct this in the Fl_Text_Editor or Fl_Text_Buffer?  

I think what I need is to have fixed width characters so a character representing the number 1 is the same width as a number 8.

I can see Fl_Text_Display::wrap_mode but I can't figure out how to use it.  Is this the right function to use and if so how is it used to achieve the result I am trying to 
achieve.

88.7532
11.7532

Thanks again.. 

Svets

未读,
2016年6月25日 02:37:052016/6/25
收件人 fltk.general
Solved this with Fl_Browser and Fl_Multi_Browser.  Should have used this from the start.
I'm not sure this can be achieved with Fl_Text_Editor.

Albrecht Schlosser

未读,
2016年6月25日 08:42:462016/6/25
收件人 fltkg...@googlegroups.com
On 25.06.2016 08:37 Svets wrote:
> Solved this with Fl_Browser and Fl_Multi_Browser. Should have used this
> from the start.

Great, if this is okay for you.

> I'm not sure this can be achieved with Fl_Text_Editor.

You'd need to use a fixed width (aka mono spaced) font, such as Courier.
There is at least one mono spaced built into FLTK, probably FL_COURIER.

You might also want to take a look at test/editor.cxx that uses a fixed
font for normal text editing but proportional font(s) for comments etc.
(open a C source file with the editor demo, and you'll see...).

Brian Tilley

未读,
2016年6月25日 18:30:582016/6/25
收件人 fltkg...@googlegroups.com

On Saturday, 25 June 2016, Albrecht Schlosser wrote

You'd need to use a fixed width (aka mono spaced) font, such as Courier. There is at least one mono spaced built into FLTK, probably FL_COURIER.

--

 Courier isn't a particularly nice font. But you can replace it using something like...

int fonts_loaded = Fl::set_fonts(NULL);
If (fonts_loaded != 0)
{
    Fl::set_font(FL_COURIER, "Lucida Console);
}

Which is a better font, but still fixed width like courier. 

Svets

未读,
2016年6月26日 00:11:592016/6/26
收件人 fltk.general

Thank you both!   That worked brilliantly.  I wanted to use a text editor from the beginning but couldn't get around this problem.  Thanks for the suggestions.
I ended up going for just plain FL_COURIER..  The editor example was helpful.
回复全部
回复作者
转发
0 个新帖子