Feature #12033
implement EDITOR:CONVERT-TO-OFFSET
Status:
New
Priority:
Normal
Assignee:
-
Target version:
-
Start date:
Due date:
% Done:
0%
billable:
No
vendor_id:
GCD
case_num:
version_reported:
version_resolved:
reviewer:
production:
No
env_name:
topics:
History
#1 Updated by Greg Shah about 1 month ago
Implement EDITOR:CONVERT-TO-OFFSET¶
Project: User Interface
Problem¶
CONVERT-TO-OFFSET(line, column) returns the character offset in an editor's text for a line and column position, counting the lines as the editor wraps them. FWD has the lexer keyword only: there is no conversion mapping and no runtime method. The gap marking records it as None / None.
A common use is word-wrapping long text for a report. The text is put into an editor that is never shown on screen, only displayed to a stream, and each wrapped line is extracted in turn:
DISPLAY STREAM s ed WITH FRAME f_dummy.
DO i = 1 TO ed:NUM-LINES IN FRAME f_dummy:
ASSIGN iFrom = ed:CONVERT-TO-OFFSET(i, 1)
iTo = ed:CONVERT-TO-OFFSET(i + 1, 1).
ed:SET-SELECTION(iFrom, iTo).
PUT STREAM s UNFORMATTED ed:SELECTION-TEXT SKIP.
END.
Work¶
- Implement
CONVERT-TO-OFFSETon the editor widget, mapping a line and column position to a 1-based character offset over the wrapped text, with the 4GL's rules for word wrap, the editor's width and font, and line ends. - Establish and match the OpenEdge result for a line or column out of range, the last line, an empty editor, and an editor with
WORD-WRAPfalse. - Add the conversion mapping for the method, for static and handle-based references.
- Check that the whole pattern above works, including on an editor that has been displayed only to a stream and never realized on screen:
NUM-LINES,SET-SELECTIONandSELECTION-TEXTmust give the 4GL's results there too. - Update the gap marking.
Testcases¶
With an OpenEdge baseline:- the pattern above over text with long words, short words, embedded line breaks and trailing spaces, at several editor widths;
- out-of-range arguments;
- an editor realized on screen and one displayed only to a stream.