예제 #1
0
 public void AppenedLine(int i, string newContent)
 {
     lock (EditMutex) {
         this [i].Content += newContent;
         LineUpadateEvent.Raise(this, new CodeBufferEventArgs(i));
     }
 }
예제 #2
0
 public void AppenedLine(int i, string newContent)
 {
     editMutex.EnterWriteLock();
     this [i].Content += newContent;
     editMutex.ExitWriteLock();
     LineUpadateEvent.Raise(this, new CodeBufferEventArgs(i));
 }
예제 #3
0
파일: TextBuffer.cs 프로젝트: masums/Crow
        public void UpdateLine(int i, string newContent)
        {
            editMutex.EnterWriteLock();
            int ptrL = this [i];

            buffer.Remove(ptrL, lineLength [i]);
            buffer.Insert(ptrL, newContent);
            lineLength [i] = newContent.Length;
            editMutex.ExitWriteLock();
            LineUpadateEvent.Raise(this, new TextBufferEventArgs(i));
        }
예제 #4
0
파일: TextBuffer.cs 프로젝트: masums/Crow
        public void AppenedLine(int i, string newContent)
        {
            editMutex.EnterWriteLock();
            int ptr = this [i] + lineLength [i];

            if (i < LineCount - 1)
            {
                ptr--;
            }
            buffer.Insert(ptr, newContent);
            lineLength [i] += newContent.Length;
            editMutex.ExitWriteLock();
            LineUpadateEvent.Raise(this, new TextBufferEventArgs(i));
        }
예제 #5
0
 public CodeLine this[int i]
 {
     get { return(lines[i]); }
     set {
         if (lines [i] == value)
         {
             return;
         }
         lock (EditMutex) {
             lines [i] = value;
             LineUpadateEvent.Raise(this, new CodeBufferEventArgs(i));
         }
     }
 }
예제 #6
0
 public CodeLine this[int i]
 {
     get { return(i < LineCount ? lines[i] : null); }
     set {
         if (lines [i] == value)
         {
             return;
         }
         editMutex.EnterWriteLock();
         lines [i] = value;
         editMutex.ExitWriteLock();
         LineUpadateEvent.Raise(this, new CodeBufferEventArgs(i));
     }
 }
예제 #7
0
파일: TextBuffer.cs 프로젝트: masums/Crow
        /// <summary>
        /// Insert new string at caret position, should be sure no line break is inside.
        /// </summary>
        /// <param name="str">String.</param>
        public void InsertAt(string str)
        {
            if (!SelectionIsEmpty)
            {
                this.Delete();
            }

            editMutex.EnterWriteLock();

            string tmp     = reghexLineBrk.Replace(str, "\n");         //use single char line break in buffer
            int    buffPtr = this [CurrentLine] + CurrentColumn;

            buffer.Insert(buffPtr, tmp);

            int lPtr = CurrentLine, strPtr = 0;
            int remainingLength = lineLength [lPtr] - CurrentColumn;

            lineLength [lPtr] = CurrentColumn;
            foreach (Match match in slb.Matches(tmp))
            {
                lineLength [lPtr] += match.Index + 1 - strPtr;
                lPtr++;
                lineLength.Insert(lPtr, 0);
                strPtr = match.Index + 1;
                //CurrentLine++;
            }
            remainingLength   += tmp.Length - strPtr;
            lineLength [lPtr] += remainingLength;

            CurrentLine = lPtr;
            if (strPtr == 0)
            {
                CurrentColumn += tmp.Length;
            }
            else
            {
                CurrentColumn = tmp.Length - strPtr;
            }

            editMutex.ExitWriteLock();
            if (strPtr > 0)
            {
                LineAdditionEvent.Raise(this, null);
            }
            else
            {
                LineUpadateEvent.Raise(this, null);
            }
        }
예제 #8
0
파일: TextBuffer.cs 프로젝트: masums/Crow
        public void Delete()
        {
            editMutex.EnterWriteLock();
            if (SelectionIsEmpty)
            {
                if (CurrentColumn == 0)
                {
                    if (CurrentLine == 0)
                    {
                        editMutex.ExitWriteLock();
                        return;
                    }

                    buffer.Remove(this [CurrentLine] - 1, 1);

                    int col = lineLength [CurrentLine - 1] - 1;
                    lineLength [CurrentLine - 1] += lineLength [CurrentLine] - 1;
                    lineLength.RemoveAt(CurrentLine);

                    CurrentLine--;
                    CurrentColumn = col;

                    editMutex.ExitWriteLock();
                    LineRemoveEvent.Raise(this, null);
                    return;
                }
                CurrentColumn--;
                buffer.Remove(this [CurrentLine] + CurrentColumn, 1);
                lineLength [CurrentLine]--;
            }
            else
            {
                int linesToRemove = SelectionEnd.Y - SelectionStart.Y;
                int ptr           = this [SelectionStart.Y] + SelectionStart.X;
                int length        = lineLength [SelectionStart.Y] - SelectionStart.X;
                int l             = 1;
                while (l <= linesToRemove)
                {
                    length += lineLength [SelectionStart.Y + l];
                    l++;
                }
                length -= lineLength [SelectionEnd.Y] - SelectionEnd.X;
                buffer.Remove(ptr, length);
                lineLength [SelectionStart.Y] = SelectionStart.X + lineLength [SelectionEnd.Y] - SelectionEnd.X;
                lineLength.RemoveRange(SelectionStart.Y + 1, linesToRemove);

                CurrentLine   = SelectionStart.Y;
                CurrentColumn = SelectionStart.X;
                ResetSelection();

                if (linesToRemove > 0)
                {
                    LineRemoveEvent.Raise(this, null);
                }
                else
                {
                    LineUpadateEvent.Raise(this, null);
                }
            }
            editMutex.ExitWriteLock();
        }