1 Minimum Profit internals
2 ========================
4 This document describes some internal details of the mp implementation.
9 (This section documents the drawing process as of version 4.99.3).
11 To ease the application of regular expressions to the on-screen part of a
12 document, a rather complicated process is done. The document is stored in
13 memory as a simple MPDM array of scalars, one for each line.
18 first line on screen -> ! Second line !
24 last line on screen --> ! Nth line !
40 This way, normal text editing operations are very simple. But applying
41 regular expressions to these structures is impossible; to do that, the
42 visible part of the document (plus some lines above the first visible
43 one) is 'flattened' to a simple memory block. This is done by the
44 drw_prepare() function.
46 ------------------------------------------
47 string buffer -> !Second line\nThird line\n...\nNth line\n!
48 ------------------------------------------
50 ------------------------------------------
51 attribute buffer -> !0000000000000000000000000000000000000000!
52 (0: "normal") ------------------------------------------
54 This flattened memory block is really two: one holding the characters
55 (including carriage returns to separate the lines) and another holding the
56 attributes, that will be reset to the 'normal' attribute.
58 After this conversion (a slightly modified join), all syntax highlight
59 regular expressions are matched to the character buffer, but filled in the
60 attribute buffer. The different regular expressions are applied by the
61 drw_words(), drw_multiline_regex(), drw_blocks(), drw_selection() and
62 the drw_matching_paren() functions.
64 ------------------------------------------
65 string buffer -> !Second line\nThird line\n...\nNth line\n!
66 (unchanged) ------------------------------------------
68 ------------------------------------------
69 attribute buffer -> !1111110000000444440000000000005550000000!
70 ------------------------------------------
72 Once all attributes are applied to the text, a process is invoked that
73 converts the flat buffer back to an MPDM array where each element is itself
74 an array (for each line of text) of attribute / string pairs, done by the
75 mp_draw() function. This way drivers are very simplified and need only to
76 iterate the main array and draw each pair of attribute / string sequentially.
78 --- -------- --- ---------
79 first line on screen -> !1! !Second! !0! ! line\n!
80 --- -------- --- ---------
81 --- ------- --- ---------
82 !4! !Third! !0! ! line\n!
83 --- ------- --- ---------
87 --- ----- --- ---------
88 last line on screen --> !5! !Nth! !0! ! line\n!
89 --- ----- --- ---------
94 [ 1, "Second", 0, " line\n" ],
95 [ 4, "Third", 0, " line\n" ],
97 [ 5, "Nth", 0, " line\n" ]
101 Angel Ortega <angel@triptico.com>