Re: Undo for "vi"

2014-03-18 Thread Laszlo Papp
On Tue, Mar 18, 2014 at 5:41 PM, Jody Bruchon  wrote:
> On 3/18/2014 10:51 AM, Jody Bruchon wrote:
>>
>> Out of an interest in seeing this feature, I'm looking at vi.c
>
>
> I've started implementing the "undo" function; it looks to be easier than I
> expected now that I have a feel for the way the buffer is handled and should
> add very little actual code (though obviously it will increase dynamic
> memory usage due to storing undo data somewhere.) If I manage to produce a
> working undo command, I'll send in a patch for Should I make the number of
> undo levels a tunable option via Kconfig? Perhaps via an unlimited option
> (just keep allocating undo data until OOM) and a limited one that allows a
> maximum number of undo levels to be set?

In my opinion, a starting point of X hard coded undo levels is fine
and see how it goes. I personally think it is not worth giving too
much customization right from the beginning.

Thanks for picking this up and working on this!
___
busybox mailing list
busybox@busybox.net
http://lists.busybox.net/mailman/listinfo/busybox


Re: Undo for "vi"

2014-03-18 Thread Jody Bruchon

On 3/18/2014 10:51 AM, Jody Bruchon wrote:

Out of an interest in seeing this feature, I'm looking at vi.c


I've started implementing the "undo" function; it looks to be easier 
than I expected now that I have a feel for the way the buffer is handled 
and should add very little actual code (though obviously it will 
increase dynamic memory usage due to storing undo data somewhere.) If I 
manage to produce a working undo command, I'll send in a patch for 
Should I make the number of undo levels a tunable option via Kconfig? 
Perhaps via an unlimited option (just keep allocating undo data until 
OOM) and a limited one that allows a maximum number of undo levels to be 
set?


-Jody
___
busybox mailing list
busybox@busybox.net
http://lists.busybox.net/mailman/listinfo/busybox


Re: Undo for "vi"

2014-03-18 Thread Mike Dean
I haven't worked with the code, but to me, it looks like:

1. it's stuffing a pointer to the first index into the passed in array into
q
2. it's replacing any newlines in the string with nulls
3. it's calling a colon() function to execute the command mode command
associated with the string that was passed in.

How about adding the feature of interpreting an interrupt (Control-C) as
the Esc key, just like vim does?  That's the feature I miss most, and one
of the reasons I switched our embedded Linux distro to using the full vim
instead of the Busybox one.


Mike Dean

md...@emacinc.com
http://www.emacinc.com/

Engineer
EMAC, Inc.
618-529-4525 Ext. 330
618-457-0110 Fax
2390 EMAC Way
Carbondale, Il 62901



On Tue, Mar 18, 2014 at 9:51 AM, Jody Bruchon  wrote:

> On 3/18/2014 9:24 AM, Laszlo Papp wrote:
>
>> Hi,
>>
>> do you plan to implement this feature any soon? It would be really
>> useful. Currently, it is a bit difficult to do undo in certain
>> scenarios when editing files on the embedded board.
>>
>
> Out of an interest in seeing this feature, I'm looking at vi.c and find
> that the code is not terribly well commented. For example, variables 'p'
> and 'q' are used throughout the code but no explanation of what they are
> supposed to be for or what is happening with them exists.
>
> Could someone who has worked on this code give me an idea of what this
> block of code really does?
>
> -snip-
>
> #if ENABLE_FEATURE_VI_COLON
> {
> char *p, *q;
> int n = 0;
>
> while ((p = initial_cmds[n]) != NULL) {
> do {
> q = p;
> p = strchr(q, '\n');
> if (p)
> while (*p == '\n')
> *p++ = '\0';
> if (*q)
> colon(q);
> } while (p);
> free(initial_cmds[n]);
> initial_cmds[n] = NULL;
> n++;
> }
> }
> #endif
>
> -snip-
>
>
> Thanks in advance!
> -Jody Bruchon
>
> ___
> busybox mailing list
> busybox@busybox.net
> http://lists.busybox.net/mailman/listinfo/busybox
>
___
busybox mailing list
busybox@busybox.net
http://lists.busybox.net/mailman/listinfo/busybox

Re: Undo for "vi"

2014-03-18 Thread Jody Bruchon

On 3/18/2014 9:24 AM, Laszlo Papp wrote:

Hi,

do you plan to implement this feature any soon? It would be really
useful. Currently, it is a bit difficult to do undo in certain
scenarios when editing files on the embedded board.


Out of an interest in seeing this feature, I'm looking at vi.c and find 
that the code is not terribly well commented. For example, variables 'p' 
and 'q' are used throughout the code but no explanation of what they are 
supposed to be for or what is happening with them exists.


Could someone who has worked on this code give me an idea of what this 
block of code really does?


-snip-

#if ENABLE_FEATURE_VI_COLON
{
char *p, *q;
int n = 0;

while ((p = initial_cmds[n]) != NULL) {
do {
q = p;
p = strchr(q, '\n');
if (p)
while (*p == '\n')
*p++ = '\0';
if (*q)
colon(q);
} while (p);
free(initial_cmds[n]);
initial_cmds[n] = NULL;
n++;
}
}
#endif

-snip-


Thanks in advance!
-Jody Bruchon
___
busybox mailing list
busybox@busybox.net
http://lists.busybox.net/mailman/listinfo/busybox


Re: Undo for "vi"

2014-03-18 Thread Laszlo Papp
By the way, I sent it a few months ago to the mailing list, but it has
not arrived. Any reason for that? I also tried to contact the mailing
list owner, but have never received any replies. :-(

It would be nice to avoid this in the future, so it would be nice to
know the reason. Nothing has changed in my email settings.

On Tue, Mar 18, 2014 at 1:24 PM, Laszlo Papp  wrote:
> Hi,
>
> do you plan to implement this feature any soon? It would be really
> useful. Currently, it is a bit difficult to do undo in certain
> scenarios when editing files on the embedded board.
>
> Cheers, L.
___
busybox mailing list
busybox@busybox.net
http://lists.busybox.net/mailman/listinfo/busybox


Undo for "vi"

2014-03-18 Thread Laszlo Papp
Hi,

do you plan to implement this feature any soon? It would be really
useful. Currently, it is a bit difficult to do undo in certain
scenarios when editing files on the embedded board.

Cheers, L.
___
busybox mailing list
busybox@busybox.net
http://lists.busybox.net/mailman/listinfo/busybox