Table of Contents
AREA-TC CODING COMMENTS
In this page we will expose all the technologies
used to create area-tc.
This is for promoting REBOL programing langage as well as keep a track for us developers on what were our technologies selection and why we choosed them and why not we choosed another way. Of course this page can help too any people to understand better our code and so make their own enhancements in it.
Change log
Notes on area-tc-03-menu.r rev 49
This is a fork of the initial project.
We integrate the ctx-menu made by Cyphre and adapted by Shadwolf.
This sophisticated menu bar is set to remplace the initial ugly buttons.
To save space the related code of the ctx-menu is proded in compressed mode (LMFC).
The remaining of the code is based on the area-tc-03.r rev.39
Why a fork?
I made this fork because this is a developpement test stage. As it's very specific I prefere do another file dedicated to this issue. In the incomming weeks once I'm sure this addition doesn't impact negatively the remaining project and that the
initial Code from Cyphre is fully adapted to area-tc needs area-tc-menu.r will be merge to area-tc-03.r project.
I will take this oportunity to make a clean code version of area-tc at the same time.
Notes on area-tc-03.r rev 38
- Selection copy / cut / paste / delete
- Selection is copied to /from the OS clipboard allowing you to tranfert
copied selections to another software.
- bold / normal text font style (ctrl+B)
- Save disply text to a file (ctrl+S)
- Open File (ctrl+O)
- New document (ctrl+N)
Notes on area-tc-03.r rev 31
- Cursor blinking motion
- Handeling of timer event for handling many things to come and for handeling the text cursor blinking.
- Auto indentation of text. When you hit the enter key at the end of a line
then the text cursor instead of returning to the begin of the new line, it
goes directly to the previous starting text position in the previous line.
It insert the equivalent needed spaces at the begining of the new line too.
- the text size can grow and shrink now using CTRL+L (shrink) and CTRL+P (grow)
Notes on area-tc-03.r rev 27
(see timeline rev 25 for the source diff)
- default system/view/caret system remove
- mouse and keyboard test selection as been added
- open-fie is now integrated to area-tc style
- Cursor text motions many bugs fixed
- Memory use by the style as been decreased alot the
and the memory use reduction is even better with extrem
large number of line file loaded
for example before a 9,4K lines scrip loaded in area-tc
was using 30Mo and now it use at most 15.4 Mo
A 600 lines script was using 22Mo and now it uses only
11.2 Mo
- jump word systeme is available now using ctrl+left or
ctrl+right the cursor text moves directly to the next word in the
line
- end and home keys are supported
-resize of the area is supported
Notes on area-tc-03.r rev 15
- Insert new line from existing lines. Allowing line splitting
- Remove line. allowing lines merging
- Enhancement of the rendering process. According to cyphre remarks we remplaced fill-pen and text-vectorial AGG instructions by pen and text anti-aliased. This provide a hudge gain in performance we passeed from 16 to 32 Ms to 0 to 16 ms for the rendering process
- Addition of the H-scroll
- H-Scroll and V-scroll have been rededigned using transparent body shapes to allow them to better integrate to the visual area without bothering the text reding
- Text Cursor have been tamed. The cursor nows moves only in the text area in a line and doesn't wander around anywhere
- When the widget starts with no text loaded and we clic in the text area that doesn't crash the program
- Mouse wheel scrolling have been fixed
Script content:
Main functions are :
build-data:
This function take the initial content of the text and split it into lines then store it into
area-tc/data.
The intial text is loaded from the file submited by the open-file function.
render-text:
This function is called any time we need to draw or refresh the visual text.
To reduce the rendering processing time this function only works on the content that needs to be refresh.
colorize:
This function take a line of plain text passed by render-text and out pour the colorise equivalent for this line.
This function is initially base on the color-code made by Carl Sassenrath in his script color-code.r
This function detect invalid text and manage the display warning message "invalid". For example it will warn you when you forget to close a string like this : "a string.
area-tc:
Area-tc is the custom face of type box used to display the text with syntax color.
area-tc is mainly used for display and mouse/keyboard events processing.
in area-tc/feel we can find most of the adapted to the situation calls to render-text function.
To put it simply each keybord key insertion or page-up/down , key left, right, up, down or mouse/wheel actions is linked to a call to render-text function.
map-inner and insert-event are related to offer drag and mouse whell support
Code Evolution history:
In the first version of this project the rendering processing was:
Call to the function open-file wich was reading the file content and passe the full content
to the function color-code then to the function render-text.
The color-code function was using parse calls to fill a block containing [ color "string of text"] items (that was TDM format enherited from Coccinelle's area-tdm.r script). Color-code was initially an adaptation of the color-code.r script by Carl Sassenrath (Rebol inventor) adapted humbly by myself to output instead of HTML data TDM format data in a block!.
Once the data block with color and string of was created another function named create-ascii-tab was called to output a new data structure where the data were organised into [letter_position letter letter_color]. Of course the main role of this function was to split each line of text into letter to calculate precisely the position of all the letter in a line retrieving the corresponding color information introduced by color-code.
Once the ascii-tab content was created the render-text function was called to create the area-tc/effect/draw block using draw/AGG dialect instructions.
At that time there where no key-board and mouse event handling and the render-text function was creating a
draw/AGG block of instructions for the whole document content.
The need of the atomisation of the text into letter and the précise calculation of all the letter position was in that time mandatory because I was using aria font and not fixed-font.
With Maxim and Steeve we first intended to enhance this rendering process and give a really basic
way to scroll the text using the mouse wheel (code provided by maxim), so Maxim and Steeve mixed ideas
to enhance the rendering process. for example no need to atomise the string in letters and to calculate each
position of each of them. USing Fixed-fonts then no need to bother with this state.
Obviously this algorithm was slow and inadapted to the main goal rendering real time edited text.(the first
loading rendering pass was made in 110 ms now in day it's done in 15 miliseconds )
Steeve joined the project first by giving enhancement suggestion to the existing rendering process [plein text from file -> tdm -> ascii-tab -> draw-block]. But as he had better ideas on the rendering
chain process he renewed completly the rendering process dividing by around 10 the rendering time needed.
So the conceptor of the actual rendering process is Steeve who reused part of my iniatial ideas (like using color-code process wich is now named colorize) but Steeve rally made this project go light speed.
Steeve improved ans simplified completly the redering process which opens the field to the realisation
of the main goal REAL-TIME text edition colorisation at light speed.
Steeve made 100% of the actual work. He made the sharp rendering process which is able to feet any needs
from keyboard/mouse event.
So now the rendering process made by steeve is:
we call open-file the content of the file is read then passed to build-data function.
build-data function slipts the text into lines then each "visible lines" is converted into
draw/agg instructions which are store intot areat-tc/effect/draw.
The converion of the visible lines into draw/agg instructions is allowed by the calls of the render-text and
the colorize functions. render-text takes each line of text store intot area-tc/data and call colorize to output the draw/AGG instructions according to the line content. render-text works only on the new things needed to be displayed isuing a shear index system. This part in render-text is the most brilliant idea Steeve provided to this project really. It make the way i was handling the rendering process completly dumb.
At that time the rendering process was using translate fill-pen and text-vectiorial set of Draw/agg instructions.
We choose those AGG instructions to have to skip the need to calculate real offset position provided to the draw/AGG text instruction. byt Cyphre explained us that using pen+text anti-aliased the rendering process time in the AGG/draw internal layer would be decreased alot (15 / 32 ms to 0/16 ms)
But text vectorial + fill-pen was given text display bug at the AGG inner precessing level (internal to the REVOL/View VM so no way to solve this by our own)
The default system/view/caret has been inhibited using a code submiteed by Anton.
Since then the text slection of large portion of text seems to be smoother.
The screen caps bellow will explain what have been removed.
before anton's proposition
after anton's proposition
When it comes to event handling in the REBOL/View 2.7.6.3.1 unexpected sometime unexpected events are sent.
For example when Steeve implemented the timer event handling to be able to make the cursor blink. Then
it broke the mouse down + mouse motion text selection by making the slection disapears any time the timer event was received. This was due to inexpected sent of Key event at the same momment as the timer event was emited.
Most of this work have been done in 2 days (from april 4th 2009 to april 6th 2009) this demonstrate how rebol is rally shaped for this kind of projects. Ask any C/C++ or Java developers how many time it will takes to him to write a widget Color-text as accurate as is area-tc-03.r rev 15 is. I bet you all you want that it's more than 3 days (of course using an external library that do the job already like scintilla or gtk+ is not allowed :P. Only drawing library is allowed to be use)
The futur
Area-tc will become an all purpose text rendering widget. Providing to this widget a formated document (HTML, MakeDoc?, etc...) and a rendering rule, you will be able to render smoothly any kind of documents. It'll be also possible to use several area-tc to render different aspects of your document.
For example:
the first area-tc provide the document with syntax color and the second area-tc provide a list "click and go" of the functions defined in the document.
LAST NEWS
feb 22, 2010:
The solution found works i'm trying my best to make area-tc as accurate as possible. Without the display and cursor bugs.
So i'm preparing 1 relase of the are-tc widget and 1 release of the viva-rebol project.
february 2010: I'm working hard on finding a solution to viva-rebol/area-tc display/cursor "bugs" on windows 7.
I though during a looooong time that the problems in viva-rebol were comming from the REBOL 2 virtual machine. Doing dev tests i dug out a strange thing.
An old version of area-tc without the disply/cursor bugs on windows 7 AMAZING !!!
I need more testing to understand fully why we get this.
january 2010:
Since september 2009 the developpement of area-tc and viva-rebol are suspended.
First we go little time to move the project on and we make an apology for that.
Second we face problems dealing with fonts on all other OS than widowsXP. We hardly try to get those problems solved.
As the screenshot up shows, the rendering is a bit small (that's the case with windowsXP too) and the fae cursor calculation insert text not at the place it should be their is some bug there that wasn't existing under windowsXP and we notice that probleme on linux, vista, windows7.
Credits
Thank to all the contributors from far to close who had this dream of having a 100% draw/AGG real time editing widget a reality.
- Shadwolf
- Steeve
- Maxim
- Anton
- Carl Sassenrath
- Cyphre
- Coccinelle
- AltMe

