Page 1 of 1

[Implemented] New flag for EditorGadget: #PB_Editor_WordWrap

Posted: Mon Oct 04, 2010 7:06 pm
by Shardik
It would be nice to have a flag for activating word wrap in the EditorGadget.
My code in a cross platform project looks something alike:

Code: Select all

CompilerSelect #PB_Compiler_OS
  CompilerCase #PB_OS_Linux
    gtk_text_view_set_wrap_mode_(GadgetID(#EditorGadget), #GTK_WRAP_WORD)
  CompilerCase #PB_OS_MacOS
    ImportC ""
      GetControlProperty(Control, PropertyCreator, PropertyTag, BufferSize, *ActualSize, *PropertyBuffer)
      TXNSetTXNObjectControls(TXNObject, ClearAll, ControlCount, ControlTags, ControlData)
    EndImport

    Define TXNObject.L
    Dim ControlTag.L(0)
    Dim ControlData.L(0)

    ControlTag(0) = 'wwrs' ; kTXNWordWrapStateTag
    ControlData(0) = 0     ; kTXNAutoWrap

    If GetControlProperty(GadgetID(#EditorGadget), 'PURE', 'TXOB', 4, 0, @TXNObject) = 0
      TXNSetTXNObjectControls(TXNObject, #False, 1, @ControlTag(0), @ControlData(0))
    EndIf
  CompilerCase #PB_OS_Windows
    SendMessage_(GadgetID(#EditorGadget), #EM_SETTARGETDEVICE, 0, 0)
CompilerEndSelect

Re: New flag for EditorGadget: #PB_Editor_WordWrap

Posted: Thu Oct 07, 2010 4:55 pm
by Rook Zimbabwe
I think it would be a gadget attribute
SetGadgetAttribute(#PB_WordWrap, 1)

I think it exists in windows AAAPI but I do not think it doess in Linux or Mac

Apparently in windows there is a default wordwrap function but it does not wrap??? Iss it turned off?

in API:
An application sends the EM_SETWORDBREAKPROC message to an edit control to replace the default wordwrap function with an application-defined wordwrap function.

EM_SETWORDBREAKPROC
wParam = 0; // not used; must be zero
lParam = (LPARAM)(EDITWORDBREAKPROC)ewbprc; // function address


Parameters

ewbprc

Value of lParam. Specifies the address of the application-defined wordwrap function. For more information about breaking lines, see the description of the EditWordBreakProc callback function.



Return Values

This message does not return a value.

Remarks

A wordwrap function scans a text buffer that contains text to be sent to the screen, looking for the first word that does not fit on the current screen line. The wordwrap function places this word at the beginning of the next line on the screen.
A wordwrap function defines the point at which Windows should break a line of text for multiline edit controls, usually at a space character that separates two words. Either a multiline or a single-line edit control might call this function when the user presses arrow keys in combination with the CTRL key to move the caret to the next word or previous word. The default wordwrap function breaks a line of text at a space character. The application-defined function may define the wordwrap to occur at a hyphen or a character other than the space character.

Re: New flag for EditorGadget: #PB_Editor_WordWrap

Posted: Fri Oct 08, 2010 11:40 am
by Shardik
@Rook Zimbabwe,

did you try my code example? It activates word wrap in the EditorGadget on Windows, Linux
and MacOS. I posted it so Fred or freak don't have to do too much research on it when trying to
implement it in PureBasic... :roll:

I would suggest using the flag #PB_Editor_WordWrap as a constant in creating an EditorGadget
like this:

Code: Select all

EditorGadget(0, 10, 10, 200, 80, #PB_Editor_WordWrap)

Re: New flag for EditorGadget: #PB_Editor_WordWrap

Posted: Thu Oct 14, 2010 5:58 am
by USCode
Yes please! +1

Re: New flag for EditorGadget: #PB_Editor_WordWrap

Posted: Thu Oct 14, 2010 7:34 am
by blueznl
#PB_Editor_WordWrap but then also please another flag #PB_Editor_TabOut to change the [Tab] behaviour.

Re: New flag for EditorGadget: #PB_Editor_WordWrap

Posted: Sat Oct 30, 2010 11:56 pm
by Jihugen
Thanks a lot Shardik for this line, I was looking for it in the Win SDK but it finding it wasn't so obvious.

Code: Select all

SendMessage_(GadgetID(#EditorGadget), #EM_SETTARGETDEVICE, 0, 0)
There is currently no PB gadget with both word wrap and scrollbars (TextGadget (ie. static control) clips the text when it does not fit, other gadgets don't use word warp).
So +1 for this feature.

Re: New flag for EditorGadget: #PB_Editor_WordWrap

Posted: Mon Jun 11, 2012 7:44 pm
by Tenaja
+1 for this... its a shame we must use a ScintillaGadget if we want these features without rolling our own.