示例#1
0
        internal bool IsReadOnly(ITextBuffer textBuffer)
        {
            var editorOptions = _editorOptionsFactoryService.GetOptions(textBuffer);

            if (editorOptions != null &&
                EditorOptionsUtil.GetOptionValueOrDefault(editorOptions, DefaultTextViewOptions.ViewProhibitUserInputId, false))
            {
                return(true);
            }

            var textLines = _editorAdaptersFactoryService.GetBufferAdapter(textBuffer);

            if (textLines == null)
            {
                return(false);
            }

            uint flags;

            if (ErrorHandler.Succeeded(textLines.GetStateFlags(out flags)) &&
                0 != (flags & (uint)BUFFERSTATEFLAGS.BSF_USER_READONLY))
            {
                return(true);
            }

            return(false);
        }
示例#2
0
文件: VsAdapter.cs 项目: pckben/VsVim
        internal bool IsReadOnly(ITextView textView)
        {
            var editorOptions = textView.Options;

            if (editorOptions != null &&
                EditorOptionsUtil.GetOptionValueOrDefault(editorOptions, DefaultTextViewOptions.ViewProhibitUserInputId, false))
            {
                return(true);
            }

            return(IsReadOnly(textView.TextBuffer));
        }