Revision: 4511 http://sourceforge.net/p/vexi/code/4511 Author: clrg Date: 2013-04-16 02:27:53 +0000 (Tue, 16 Apr 2013) Log Message: ----------- WIP (nearly ready)
Modified Paths: -------------- branches/org.vexi-vexi.widgets_editrefactor/src_main/org/vexi/lib/text/edit.t branches/org.vexi-vexi.widgets_editrefactor/src_main/org/vexi/lib/text/line.t Modified: branches/org.vexi-vexi.widgets_editrefactor/src_main/org/vexi/lib/text/edit.t =================================================================== --- branches/org.vexi-vexi.widgets_editrefactor/src_main/org/vexi/lib/text/edit.t 2013-04-14 08:08:33 UTC (rev 4510) +++ branches/org.vexi-vexi.widgets_editrefactor/src_main/org/vexi/lib/text/edit.t 2013-04-16 02:27:53 UTC (rev 4511) @@ -21,17 +21,55 @@ var cursor = 0; var selectFrom = null; + // test + cursor = 10; + selectFrom = 480; + selectTo = 500; - - const addLine = function(str, line_num) { + const addLineUI = function(line_num, from_i, to_i, highlight, offset_i) { + const str = v_text.substring(from_i, to_i); const line_y = line_height * line_num; const b = new lib.line(); + b.text = str; b.minheight = line_height; - b.x = 0; + b.x = offset_i == null ? 0 : vexi.ui.font.width(font, fontsize, v_text.substring(offset_i, from_i)); b.y = line_y; + if (highlight) b.highlight = true; add(b); } + + const addLine = function(line_num) { + + const n1 = line_markers[2 * line_num]; + const n2 = line_markers[2 * line_num + 1]; + + if (selectFrom == null or selectFrom > n2 or n1 >= selectTo) { + // no selection or selection outside of range + addLineUI(line_num, n1, n2); + } else if (n1 >= selectFrom) { + // selection starts before this line + if (n2 > selectTo) { + // selection ends on this line + addLineUI(line_num, n1, selectTo, true); + addLineUI(line_num, selectTo, n2, false, n1); + } else { + // selection encompasses whole line + addLineUI(line_num, n1, n2, true); + } + } else if (selectFrom >= n1 and n2 > selectFrom) { + // selection starts on this line + addLineUI(line_num, n1, selectFrom); + if (n2 > selectTo) { + // selection ends on this line + addLineUI(line_num, selectFrom, selectTo, true, n1); + addLineUI(line_num, selectTo, n2, false, n1); + } else { + // selection ends after this line + addLineUI(line_num, selectFrom, n2, true, n1); + } + } + } const max = vexi.math.max; const floor = vexi.math.floor; @@ -40,9 +78,7 @@ var line = max(0, floor((from_y - line_height) / line_height)); const to = from_y + height; while ((to > line * line_height) and (line_count > line)) { - const n1 = line_markers[2 * line]; - const n2 = line_markers[2 * line + 1]; - addLine(v_text.substring(n1, n2)+" ", line); + addLine(line); line++; } } @@ -381,9 +417,7 @@ // move cursor left case "left": case "C-left": - if (unselectLeft()) { - return; - } + if (unselectLeft()) return; case "LEFT": case "C-LEFT": break; @@ -399,9 +433,7 @@ // move cursor up case "up": case "C-up": - if (unselectLeft()) { - return; - } + if (unselectLeft()) return; case "UP": case "C-UP": break; @@ -409,9 +441,7 @@ // move cursor down case "down": case "C-down": - if (unselectRight()) { - return; - } + if (unselectRight()) return; case "DOWN": case "C-DOWN": break; @@ -419,11 +449,15 @@ // move cursor to start of line case "home": case "HOME": + locateCursor(0, cursor_y); break; // move cursor to end of line case "end": case "END": + locateCursor(0, cursor_y + line_height); + cursor--; + placeCursor(); } reflowText(); Modified: branches/org.vexi-vexi.widgets_editrefactor/src_main/org/vexi/lib/text/line.t =================================================================== --- branches/org.vexi-vexi.widgets_editrefactor/src_main/org/vexi/lib/text/line.t 2013-04-14 08:08:33 UTC (rev 4510) +++ branches/org.vexi-vexi.widgets_editrefactor/src_main/org/vexi/lib/text/line.t 2013-04-16 02:27:53 UTC (rev 4511) @@ -1,5 +1,16 @@ <!-- Copyright 2013 - see COPYING for details [LGPL] --> -<vexi xmlns:ui="vexi://ui"> - <ui:box shrink="true" /> +<vexi xmlns:ui="vexi://ui" + xmlns="vexi.theme"> + + <ui:box shrink="true"> + thisbox.highlight ++= static.highlightWrite; + </ui:box> + + static.highlightWrite = function(v) { + cascade = v; + trapee.fill = v ? .settings..fill_selected : null; + trapee.textcolor = v ? .settings..textcolor_selected : .settings..textcolor; + } + </vexi> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. ------------------------------------------------------------------------------ Precog is a next-generation analytics platform capable of advanced analytics on semi-structured data. The platform includes APIs for building apps and a phenomenal toolset for data science. Developers can use our toolset for easy data analysis & visualization. Get a free account! http://www2.precog.com/precogplatform/slashdotnewsletter _______________________________________________ Vexi-svn mailing list Vexi-svn@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/vexi-svn