ANN: FieldGroup - a simple rich text editor field.

matthias_livecode_150811 at m-r-d.de matthias_livecode_150811 at m-r-d.de
Thu Jul 23 04:31:08 EDT 2020


Hi Alex,

this is really a great contribution. Thank you very much.


-
Matthias Rebbe
Life Is Too Short For Boring Code

> Am 23.07.2020 um 02:08 schrieb Alex Tweedly via use-livecode <use-livecode at lists.runrev.com>:
> 
> I'd like to announce the Beta (i.e. v0.1) release of my simple rich text field. Currently it's not on Github or anywhere sensible - it's just on my own download site (see URL at end of this email).
> 
> I'd be happy if anyone finds it useful, and / or has feedback that might make it useful.
> 
> 
> FieldGroup - a rich text editor field for Livecode.
> 
> Actually, as the old joke goes, it's not really "rich" text, just comfortably off. :-)
> 
> That is, it supports only some fairly basic features compared to a fully-featured rich text editor.
> 
> Supported features include :
>  - multi-level undo/redo
>  - 'undo' can be reset (e.g. after 'save', or 'open')
>  - set text style of a chunk by tool button or (sample) menu
>  - undo includes text style setting
>  - simple (enclosed) tool bars with text or icon buttons - optional of course.
>  - each kind of button comes in two sizes
>  - button tool bars in any one of four placements (top,right,bottom,left)
>  - view scaling
>  - call-backs to let the app know when undo/redo are available (e.g. to adjust menus)
>  - no front scripts used.
> 
> FieldGroup is a standalone group which can be simply copy/paste'd into your own stacks, and provides a (moderately) rich set of text field features. You can have as many of these fieldgroups as you want - each is entirely self-contained.
> 
> Easy to use - handlers/functions are well documented and (I hope) straightforward to understand and use. The downloadable stack includes the group, ready to be copy/pasted, as part of a simple sample app which shows common uses.
> 
> The handler definitions are included below - this is also available in the sample app. The "fill" button ill give you text to play with, but shift-Fill will restore this document.
> 
> You can download the sample app - which includes the group you ned to copy/paste - from
> 
> https://www.tweedly.org/downloads/FieldGroupsample.livecode
> 
> This popped out from a simple app I'm writing (actually, just starting to write) so I'm sure I will realize I need more features, and they will be added. However, I do not intend it to grow to an all-singing, all-dancing word processor-like field editor - I have no need for one of those. But it might be a staring point for someone else who wants that.
> 
> -- Alex.
> 
> /Handlers/
> 
> In general, these handlers are invoked by 'dispatch'ing the message to the group. The sample app shows an example of how to structure the menu items (edit and Format menus). It also contains examples of manipulating the text (the *Exchange* button), showing different configurations of the buttons (the *Snap* button, and capturing the return messages for undo/redo being available.
> 
> /Handlers/
> 
> */fg.init/* pAConfig
> 
> Initialize the field, with an optional set of configuration parameters (see fg.configChange for details of these).
> 
> /dispatch "fg.init" to grp "fldgrp" with "textbuttonsize=large", "svgbutton=large"/
> 
> */fg.configChange/* pAConfig
> 
> Configure the settings for buttons usage, placement, size, etc.
> 
> This can be either an array, with the key/value pairs, or any number of parameters each being in the form “key=value”.
> 
> Examples:
> 
> /put "top" into tA["textbuttons"]//
> put "small" into tA["textbuttonsize"]
> dispatch "fg.configChange" to grp "fldgrp" with tA/
> 
> or
> 
> /dispatch "fg.configChange" to grp "fldgrp" with "textbuttons=top", "textbuttonsize=large"/
> 
> Parameters that can be set are:
> - textbuttons : top | bottom
> - svgbuttons : top | bottom | right | left
> - textbuttonsize : small | large
> - svgbuttonsize : small | large
> - resizing : true | false (defaults true - if FALSE then the group will not adjust for any resizing)
> 
> */fg.version/*
> 
> Returns the version of the fieldgroup.
> 
> /dispatch function "fg.version" to grp "fldgrp"//
> put "Version" && the result &CR into msg
> /
> 
> /
> /
> 
> */fg.getText/* pType
> 
> Retrieve the contents of the field.
> 
> /dispatch function "fg.getText" to grp "fldgrp" with "styledtext"/
> 
> pType is one of
> - styledtext (the default) : return the complete styledtext /array
> - text : plain text of the field/
> - htmlText : htmltext of the field
> - rtftext : rtfText of the field
> 
> */fg.resetUndoSystem/*
> 
> Resets all undo info, for example if the app does a save, and if it determins that the user should ne bot able to'undo' beyond that point, then it would call this handler.
> 
> /dispatch function "fg.version" to grp "fldgrp"//
> put the result into URL ("binfile:savedfile.txt")
> dispatch "fg.resetUndoSystem" to grp "fldgrp"/
> 
> /
> /
> 
> */fg.set.initialText/* pText
> 
> Set the initial text for the field (i.e. set the text, an reset the undo system).
> 
> /put URL ("binfile:" & sFilename) into tText//
> put arraydecode(tText) into tA
> dispatch "fg.set.initialText" to grp "fldgrp" with tA/
> 
> pText can be either an array (in which case it is the styledText to be set), or string (of simple text).
> 
> 
> *fg.replaceChunk* pChunk, pAText
> 
> Replaces the specified chunk of the field with the styledText in the array pA.
> 
> /dispatch "fg.replaceChunk" to grp "fldgrp" with tChunk, tAText/
> 
> 
> *fg.set.textStyle* pStyle, pChunk
> 
> Adds / removes the text style to the chunk of the field. If the chunk is empty, then the change is applied to the current selection.
> 
> /dispatch "fg.set.textStyle" to grp "fldgrp" with "bold"/
> 
> Note that if the all of the chunk already has the specified style, then it is removed; oitherwise it is added; therefore, if the chunk is previously "mixed" then the style is added.
> 
> /*fg.set.viewScale* pScale/
> 
> Sets the viewing scale for the field. This simply adjusts the textsize, since there is no provision for setting the text size of individual parts of the field.
> 
> /dispatch "fg.set.viewScale" to grp "fldgrp" with "+"/
> 
> pScale is one of :
> - "-" : make text smaller
> - "+" : make text larger
> - 0 : reset text to default size
> - N (< 6) : is a multiplier from default size, e.g. for apps that offer "150%" etc.
> - N (> 6): an actual text size.
> 
> //
> 
> -- end of definitions --
> 
> _______________________________________________
> use-livecode mailing list
> use-livecode at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode





More information about the use-livecode mailing list