Esempio n. 1
0
        /// <summary>
        ///
        /// </summary>
        private void OnMarkerChanged(ScintillaControl sci, Int32 line)
        {
            if (sci != this.editor && sci != this.editor2)
            {
                return;
            }
            if (line == -1) // all markers cleared
            {
                this.bookmarks.Clear();
                ButtonManager.UpdateFlaggedButtons();
                return;
            }
            Boolean hadBookmark = this.bookmarks.Contains(line);
            Boolean hasBookmark = MarkerManager.HasMarker(sci, 0, line);

            if (hadBookmark != hasBookmark) // any change?
            {
                if (!hadBookmark && hasBookmark)
                {
                    this.bookmarks.Add(line);
                }
                else if (hadBookmark && !hasBookmark)
                {
                    this.bookmarks.Remove(line);
                }
                ButtonManager.UpdateFlaggedButtons();
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Reloads an editable document
        /// </summary>
        public void Reload(Boolean showQuestion)
        {
            if (!this.IsEditable)
            {
                return;
            }
            if (showQuestion)
            {
                String dlgTitle = TextHelper.GetString("Title.ConfirmDialog");
                String message  = TextHelper.GetString("Info.AreYouSureToReload");
                if (MessageBox.Show(Globals.MainForm, message, " " + dlgTitle, MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
                {
                    return;
                }
            }
            Globals.MainForm.ReloadingDocument = true;
            Int32     position = this.SciControl.CurrentPos;
            TextEvent te       = new TextEvent(EventType.FileReload, this.FileName);

            EventManager.DispatchEvent(Globals.MainForm, te);
            if (!te.Handled)
            {
                EncodingFileInfo info = FileHelper.GetEncodingFileInfo(this.FileName);
                if (info.CodePage == -1)
                {
                    Globals.MainForm.ReloadingDocument = false;
                    return; // If the files is locked, stop.
                }
                Encoding encoding = Encoding.GetEncoding(info.CodePage);
                this.SciControl.IsReadOnly = false;
                this.SciControl.Encoding   = encoding;
                this.SciControl.Text       = info.Contents;
                this.SciControl.IsReadOnly = FileHelper.FileIsReadOnly(this.FileName);
                this.SciControl.SetSel(position, position);
                this.SciControl.EmptyUndoBuffer();
                int lineCount = SciControl.LineCount;
                foreach (var lineNum in this.bookmarks)
                {
                    if (lineNum < 0)
                    {
                        continue;
                    }
                    if (lineNum >= lineCount)
                    {
                        if (!MarkerManager.HasMarker(SciControl, 0, lineCount - 1))
                        {
                            MarkerManager.ToggleMarker(SciControl, 0, lineCount - 1);
                        }
                    }
                    else
                    {
                        MarkerManager.ToggleMarker(SciControl, 0, lineNum);
                    }
                }
                this.InitBookmarks();
                this.fileInfo = new FileInfo(this.FileName);
            }
            Globals.MainForm.OnDocumentReload(this);
        }
Esempio n. 3
0
 /// <summary>
 /// Checks the bookmarks when document is active.
 /// </summary>
 public void InitBookmarks()
 {
     this.bookmarks.Clear();
     for (Int32 i = 0; i < editor.LineCount; i++)
     {
         if (MarkerManager.HasMarker(SciControl, 0, i))
         {
             this.bookmarks.Add(i);
         }
     }
 }