adding elastic tabstops to a widget
- From: "Nick Gravgaard" <me nickgravgaard com>
- To: gtk-devel-list gnome org, gtk-i18n-list gnome org
- Subject: adding elastic tabstops to a widget
- Date: Tue, 19 Aug 2008 23:39:07 +0200
Hi all,
I'm trying to make a proper GTK text editing widget that supports
elastic tabstops [1] with a view to being able to use it in the near
future in a PyGTK project (a programmer's text editor), and perhaps one
day getting it added to GtkTextView or GtkSourceView.
I have something pretty close to being finished. I've developed it by
hacking the main Pango and GTK code directly rather than making new GTK
objects that inherit from the standard objects - I figured I'd get the
functionality working properly before moving the code into new files. It
consists of 2 parts:
1. Modified PangoTab structure to contain "width" (distance between tab
characters) and "contents_width" (width of text between tabs) values,
instead of "location" (distance from left margin to tab). Changed
"get_tab_pos" function in pango-layout.c to accumulate "width"s leading
up to and including a given index, instead of returning the "location"
for that index. This allows programs to just change one cell's width
without getting every leading cell's location and changing the location
of every subsequent cell on that line (IMO this makes the API easier to
use regardless of the elastic tabstop functionality), as well as letting
my elastic tabstop code cache the widths of the text betwen cells for
performance reasons (I don't want to have to recalculate it for
potentially many lines every time a character is inserted/deleted).
Note: with a bit of work I suspect my contents_width cache values could
also be used to improve the performance of conventional tabstops.
2. Modified gtktextview.c (or gtktextlayout.c - not sure which is a
better place) to get and set PangoTabs' width and contents_width values
as text is inserted/deleted etc. This makes up most of the code.
So, my questions are:
What do I do next given my goals of being able to use this stuff in a
PyGTK project and perhaps one day getting it added to GTK proper?
and
How do I make an object which inherits it's functionality from, say,
GtkSourceView, adds my functionality described in point 2 above, and
uses my modified PangoTab structure and pango-layout functionality
described in point 1?
Thanks,
Nick
[1]
http://nickgravgaard.com/elastictabstops
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]