06-15-2011 7:07 AM
Hi,
I am using cl_gui_textedit this class to have text editor in my application,
when i enter some text like:
this is first line
this is second line
this is last line.
editor is automatically taking this as
this is first line
this is second line
this is last line.
it is not considering the empty lines or line breaks, for setting the texts i am using method set_text_asstream method.
please suggest what to be done inorder to have lines in editor.
06-15-2011 12:21 PM
Hello Kranthi,
The method SET_TEXT_AS_STREAM( ) expects the caller to provide the "\r" & "\n" i.e., Carriage Return(CR) & Line Feed(LF) respectively.
So the idea is to add an additional CRLF for the blank lines.
Check the code snippet below:
DATA: lt_text_stream TYPE STANDARD TABLE OF char32,
lv_string TYPE string.
* Populate the text stream
APPEND 'this is first line' TO lt_text_stream. "Text Line
APPEND cl_abap_char_utilities=>cr_lf TO lt_text_stream. "Line Feed
APPEND cl_abap_char_utilities=>cr_lf TO lt_text_stream. "Blank Line
APPEND 'this is second line' TO lt_text_stream. "Text Line
APPEND cl_abap_char_utilities=>cr_lf TO lt_text_stream. "Line Feed
APPEND cl_abap_char_utilities=>cr_lf TO lt_text_stream. "Blank Line
APPEND 'this is last line' TO lt_text_stream. "Text Line
APPEND cl_abap_char_utilities=>cr_lf TO lt_text_stream. "Line Feed
* Concatenate the text lines into a string
CONCATENATE LINES OF lt_text_stream INTO lv_string.
* Send the text stream to the Text Editor
text_view->set_textstream(
EXPORTING
text = lv_string
EXCEPTIONS
error_cntl_call_method = 1
not_supported_by_gui = 2
OTHERS = 3
).
IF sy-subrc <> 0.
"Error handling
ENDIF.
I was having indentation issues with SET_TEXT_AS_STREAM( ) so i've used the SET_TEXTSTREAM( ). In both the cases you've to add an extra CRLF to get the blank lines.
Hope i'm clear.
BR,
Suhas
PS: Internally the method SET_TEXT_AS_STREAM( ) calls SET_TEXTSTREAM( ) based on some condition!
06-15-2011 12:21 PM
Hello Kranthi,
The method SET_TEXT_AS_STREAM( ) expects the caller to provide the "\r" & "\n" i.e., Carriage Return(CR) & Line Feed(LF) respectively.
So the idea is to add an additional CRLF for the blank lines.
Check the code snippet below:
DATA: lt_text_stream TYPE STANDARD TABLE OF char32,
lv_string TYPE string.
* Populate the text stream
APPEND 'this is first line' TO lt_text_stream. "Text Line
APPEND cl_abap_char_utilities=>cr_lf TO lt_text_stream. "Line Feed
APPEND cl_abap_char_utilities=>cr_lf TO lt_text_stream. "Blank Line
APPEND 'this is second line' TO lt_text_stream. "Text Line
APPEND cl_abap_char_utilities=>cr_lf TO lt_text_stream. "Line Feed
APPEND cl_abap_char_utilities=>cr_lf TO lt_text_stream. "Blank Line
APPEND 'this is last line' TO lt_text_stream. "Text Line
APPEND cl_abap_char_utilities=>cr_lf TO lt_text_stream. "Line Feed
* Concatenate the text lines into a string
CONCATENATE LINES OF lt_text_stream INTO lv_string.
* Send the text stream to the Text Editor
text_view->set_textstream(
EXPORTING
text = lv_string
EXCEPTIONS
error_cntl_call_method = 1
not_supported_by_gui = 2
OTHERS = 3
).
IF sy-subrc <> 0.
"Error handling
ENDIF.
I was having indentation issues with SET_TEXT_AS_STREAM( ) so i've used the SET_TEXTSTREAM( ). In both the cases you've to add an extra CRLF to get the blank lines.
Hope i'm clear.
BR,
Suhas
PS: Internally the method SET_TEXT_AS_STREAM( ) calls SET_TEXTSTREAM( ) based on some condition!
06-16-2011 10:04 AM
06-15-2011 5:01 PM
Hello Kranthi Kumar,
It should work fine. It is working fine for me.
You have tp make sure to use the below attributes(cl_gui_textedit=>wordwrap_at_fixed_position for wordwrap_mode ) while calling the create object:-
create calls constructor, which initializes, creats and links
TextEdit Control
CREATE OBJECT g_editor
EXPORTING
parent = g_editor_container
wordwrap_mode =
cl_gui_textedit=>wordwrap_off
cl_gui_textedit=>wordwrap_at_fixed_position
cl_gui_textedit=>WORDWRAP_AT_WINDOWBORDER
wordwrap_position = line_length
wordwrap_to_linebreak_mode = cl_gui_textedit=>true.
Also make sure to use the below method (get_text_as_r3table) to get the data back from the text editor:-
retrieve table from control
CALL METHOD g_editor->get_text_as_r3table
IMPORTING
table = g_inputtable[].
Hope this answers your question.
Thanks,
Greetson