On 29/08/06, Ilya <[EMAIL PROTECTED]> wrote:
Brad Beveridge wrote: > On 26/08/06, Brad Beveridge <[EMAIL PROTECTED]> wrote: > <SNIP> >> >> Cheers >> Brad > > Hi, sorry for all the trouble :) I'm having redraw issues, where > running this code to append chars is causing strange problems. > The scenario is this (always using the code below for char output): > 1) Write a char to a buffer (line1) > 2) Write a newline (line 2) > 3) Move the cursor to the bottom of the buffer (line2 empty) > 4) Write another Char (appears in line2) > 5) Press Ctrl-L > 6) Notice that line1 has vanished. > > moving the cursor to the new blank line at the bottom of the line is > critical here. I'm sure that I'm doing something wrong, but I really > can't figure it out. > As a side note, it feels very clumsy to have to manually call "changed > line" functions when calling ml_* funcs - is there some notes I can > read about why this is? > Anyhow, here is the code I'm using to put chars in a buffer - I really > appreciate any thoughts, this feels so close to working, but I've > spend several hours trying to get it right. Very frustrating :) > > Cheers > Brad > > static void vim_append_char (buf_T target_buf, char c) > { > static char string[2] = {0}; Should not you have "= {0, 0}" here? Second element never get initialized but it could be accessed by ml_append_string.
That might be more clear perhaps, but when you initialize an array like that in C, the last element is propagated for the whole array. Cheers Brad