Nested numeric lists that include number of parent list item

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

Nested numeric lists that include number of parent list item

Bob Sneidar via use-livecode
Hi all,

I am working with nested lists in LiveCode using listStyle and listDepth.
When using a "numeric" listStyle I get this output in a field:

1. asdf ajsdf asf
       1. adsfasdfasdf
              1. asdfasdfasdf

I would like to get the following output but I'm not seeing a property that
enables it. Am I missing something or is not possible using listStyle and
listDepth?

1. asdf ajsdf asf
       1.1. adsfasdfasdf
              1.1.1. asdfasdfasdf

--
Trevor DeVore
ScreenSteps
www.screensteps.com
_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: Nested numeric lists that include number of parent list item

Bob Sneidar via use-livecode
Trevor.
I am helping You??
I don't see anything in the dictionary about progressive indentation. Never used any of these, but it looks like you have to roll your own.
Craig


-----Original Message-----
From: Trevor DeVore via use-livecode <[hidden email]>
To: How to use LiveCode <[hidden email]>
Cc: Trevor DeVore <[hidden email]>
Sent: Tue, Feb 11, 2020 4:31 pm
Subject: Nested numeric lists that include number of parent list item

Hi all,

I am working with nested lists in LiveCode using listStyle and listDepth.
When using a "numeric" listStyle I get this output in a field:

1. asdf ajsdf asf
      1. adsfasdfasdf
              1. asdfasdfasdf

I would like to get the following output but I'm not seeing a property that
enables it. Am I missing something or is not possible using listStyle and
listDepth?

1. asdf ajsdf asf
      1.1. adsfasdfasdf
              1.1.1. asdfasdfasdf

--
Trevor DeVore
ScreenSteps
www.screensteps.com
_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: Nested numeric lists that include number of parent list item

Bob Sneidar via use-livecode
In reply to this post by Bob Sneidar via use-livecode
I am not aware that listStyle decimal can show other then 1. No further sub numbering.

However one could hack it. Although I know you are not particularly fond of those hacks...

The code assumes that the listStyle of a field is set (any) will be "skip" afterwards and list depth is also set.


----------------------------------
on mouseUp
   local tDepthValue, tTab, tDepth, tLastDepthValue
   local tIndex, tLeadingSpaces
   lock screen
   put space & space into tLeadingSpaces
   put numToCodePoint(9) into tTab -- not used

   put 0 into tDepthValue
   put 0 into tLastDepthValue

   set the listStyle of line 1 to -1 of field 1 to "skip"

   repeat with i = 1 to the number of lines of field 1
      if line i of field 1 is empty then next repeat
      put the listDepth of line i of field 1 into tDepth
      add 1 to item tDepth of tDepthValue
      if tDepth < the number of items of tLastDepthValue then
         delete item tDepth + 1 to -1 of tDepthValue
      end if
      put tDepthValue into tIndex
      replace comma with "." in tIndex
      put "." after tIndex
      put tIndex & tLeadingSpaces before line i of field 1
      put tDepthValue into tLastDepthValue
   end repeat
end mouseUp
------------------------------------

to remove the hack

---------------------------------
on mouseUp
   set the itemDelimiter to "." & space & space
   lock screen
   repeat with i = 1 to the number of lines of field 1
      if the number of items of line i of field 1 > 1 then
         delete item 1 of line i of field 1
      end if
   end repeat
   unlock screen
end mouseUp
---------------------------------

It prepends the text with a decimal index. I started with tab as separator but it does not look well. Now it is two spaces. One could use non-breaking spaces as separators.

Kind regards
Bernd



>Trevor wrote


>I would like to get the following output but I'm not seeing a property that
>enables it. Am I missing something or is not possible using listStyle and
>listDepth?

>1. asdf ajsdf asf
>       1.1. adsfasdfasdf
>              1.1.1. asdfasdfasdf


_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: Nested numeric lists that include number of parent list item

Bob Sneidar via use-livecode
On Tue, Feb 11, 2020 at 7:11 PM Niggemann, Bernd via use-livecode <
[hidden email]> wrote:

> I am not aware that listStyle decimal can show other then 1. No further
> sub numbering.
>
> However one could hack it. Although I know you are not particularly fond
> of those hacks...
>
> The code assumes that the listStyle of a field is set (any) will be "skip"
> afterwards and list depth is also set.
>

Thanks for the suggestion Bernd. I appreciate you taking the time. You are
right though, I'm not particularly fond of hacks in the field control when
the field is being used as a text editor (which is my use case).

Here is the reason why. When writing a text editor it doesn't take long for
the hacks to get out of hand and you end up with a control that becomes
hard to add features to and hard to perform maintenance on. In addition,
the field stops behaving or looking the way a user expects a text editor to
work. For example, if I were to add the hack for displaying nested numeric
lists I would need to add a hack for keeping track of other list styles the
user might select elsewhere in the field. I would also have to deal with
incorrect indentation for multi-line list items because the text would
appear flush with the list numbers. Then I would need to add a hack to
handle deletion of characters properly since the numbers are part of the
actual text rather than an ornament that is added by the engine. There is
this ripple effect which always makes me wish I hadn't implemented the hack
:-)

--
Trevor DeVore
ScreenSteps
www.screensteps.com
_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: Nested numeric lists that include number of parent list item

Bob Sneidar via use-livecode
Yeah, this isn't helpful either, but while we're on the shortcomings of ordered lists in Livecode if you render an alphabetically ordered list using htmlText then it is rendered as lowercase irrespective of whether you specify type='A' or type='a'. The only way to guarantee that it is right is to explicitly set the listStyle to 'upper latin' (or whatever).

Terry...

On 12/2/20, 3:13 pm, "use-livecode on behalf of Trevor DeVore via use-livecode" <[hidden email] on behalf of [hidden email]> wrote:

    On Tue, Feb 11, 2020 at 7:11 PM Niggemann, Bernd via use-livecode <
    [hidden email]> wrote:
   
    > I am not aware that listStyle decimal can show other then 1. No further
    > sub numbering.
    >
    > However one could hack it. Although I know you are not particularly fond
    > of those hacks...
    >
    > The code assumes that the listStyle of a field is set (any) will be "skip"
    > afterwards and list depth is also set.
    >
   
    Thanks for the suggestion Bernd. I appreciate you taking the time. You are
    right though, I'm not particularly fond of hacks in the field control when
    the field is being used as a text editor (which is my use case).
   
    Here is the reason why. When writing a text editor it doesn't take long for
    the hacks to get out of hand and you end up with a control that becomes
    hard to add features to and hard to perform maintenance on. In addition,
    the field stops behaving or looking the way a user expects a text editor to
    work. For example, if I were to add the hack for displaying nested numeric
    lists I would need to add a hack for keeping track of other list styles the
    user might select elsewhere in the field. I would also have to deal with
    incorrect indentation for multi-line list items because the text would
    appear flush with the list numbers. Then I would need to add a hack to
    handle deletion of characters properly since the numbers are part of the
    actual text rather than an ornament that is added by the engine. There is
    this ripple effect which always makes me wish I hadn't implemented the hack
    :-)
   
    --
    Trevor DeVore
    ScreenSteps
    www.screensteps.com
    _______________________________________________
    use-livecode mailing list
    [hidden email]
    Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
    http://lists.runrev.com/mailman/listinfo/use-livecode
   
   

_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: Nested numeric lists that include number of parent list item

Bob Sneidar via use-livecode
On Tue, Feb 11, 2020 at 11:03 PM Terry Judd via use-livecode <
[hidden email]> wrote:

> Yeah, this isn't helpful either, but while we're on the shortcomings of
> ordered lists in Livecode if you render an alphabetically ordered list
> using htmlText then it is rendered as lowercase irrespective of whether you
> specify type='A' or type='a'. The only way to guarantee that it is right is
> to explicitly set the listStyle to 'upper latin' (or whatever).


That is good to know. I convert HTML from an outside source to a styledText
array which I then assign to a field. Hopefully that isn’t affected by the
same bug since the listStyle is part of the array. I’ll make sure and test
that particular case though.

--
Trevor DeVore
ScreenSteps

>
_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode