示例#1
0
        protected virtual void ProcessKey(string key)
        {
            CheckDisposed();
            string focus = StflApi.stfl_get_focus(f_Handle);

            OnKeyPressed(new KeyPressedEventArgs(key, focus));
        }
示例#2
0
 protected virtual void Dispose(bool disposing)
 {
     if (f_Handle != IntPtr.Zero)
     {
         StflApi.stfl_free(f_Handle);
     }
 }
示例#3
0
        void Resize()
        {
            var width = Width;

            if (!AutoLineWrap || width <= 0)
            {
                // nothing to do
                return;
            }

            // re-wrap all lines and re-apply offset
            WrappedLineCount = 0;
            var offset = Offset;
            var items  = new StringBuilder("{list", Lines.Count + 2);

            foreach (var line in Lines)
            {
                foreach (var wrappedLine in WrapLine(line, width))
                {
                    WrappedLineCount++;
                    items.AppendFormat("{{listitem text:{0}}}",
                                       StflApi.stfl_quote(wrappedLine));
                }
            }
            items.Append("}");
            Form.Modify(WidgetName, "replace_inner", items.ToString());
            Offset = offset;
        }
示例#4
0
 public string this[string name] {
     get {
         return(StflApi.stfl_get(f_Handle, name));
     }
     set {
         StflApi.stfl_set(f_Handle, name, value);
     }
 }
示例#5
0
        public Form(string text)
        {
            f_Handle = StflApi.stfl_create(text);

            // initialize ncurses
            StflApi.stfl_run(f_Handle, -3);
            //StflApi.raw();
            NcursesApi.nocbreak();
        }
示例#6
0
 public string this[string name] {
     get {
         CheckDisposed();
         return(StflApi.stfl_get(f_Handle, name));
     }
     set {
         CheckDisposed();
         StflApi.stfl_set(f_Handle, name, value);
     }
 }
示例#7
0
 public void AppendWrappedLine(string line)
 {
     WrappedLineCount++;
     Form.Modify(
         WidgetName,
         "append",
         String.Format("{{listitem text:{0}}}",
                       StflApi.stfl_quote(line))
         );
 }
示例#8
0
        static void Main()
        {
            //IntPtr handle = StflApi.stfl_create("<MainWindow.stfl>");
            IntPtr handle = StflApi.stfl_create("vbox[vbox_1]");

            StflApi.stfl_modify(handle, "vbox_1", "append", "textview[tv_0]");
            StflApi.stfl_modify(handle, "vbox_1", "append", "textview[tv_2]");
            StflApi.stfl_modify(handle, "vbox_1", "append", "textview[tv_3]");
            StflApi.stfl_run(handle, 0);
        }
示例#9
0
        public virtual void Run(int timeout)
        {
            CheckDisposed();
            string @event = StflApi.stfl_run(f_Handle, timeout);

            if (timeout == -3)
            {
                // HACK: timeout of -3 should never return an event but
                // sometimes does which causes event duplication
                return;
            }
            ProcessEvent(@event);
        }
示例#10
0
        protected virtual void Dispose(bool disposing)
        {
            var disposed = Disposed;

            if (disposed)
            {
                return;
            }

            if (f_Handle != IntPtr.Zero)
            {
                StflApi.stfl_free(f_Handle);
            }
        }
示例#11
0
        public Form(Assembly assembly, string resourceName)
        {
            if (assembly == null)
            {
                assembly = Assembly.GetCallingAssembly();
            }

            using (Stream stream = assembly.GetManifestResourceStream(resourceName))
                using (StreamReader reader = new StreamReader(stream)) {
                    if (stream == null)
                    {
                        throw new ArgumentException(resourceName + " could not be found in assembly", "resourceName");
                    }
                    string text = reader.ReadToEnd();
                    if (String.IsNullOrEmpty(text))
                    {
                        throw new ArgumentException(resourceName + " in assembly is missing or empty.", "resourceName");
                    }
                    f_Handle = StflApi.stfl_create(text);
                }
        }
示例#12
0
文件: TextView.cs 项目: shubhtr/smuxi
        void Resize()
        {
            var width = Width;

            if (!AutoLineWrap || width <= 0)
            {
                // nothing to do
                return;
            }

            var estimatedLines = Math.Max(WrappedLineCount, Lines.Count);
            // see items.AppendFormat() below
            var lineStyleOverhead = 18;
            var listStyleOverhead = 6;
            var estimatedLength   = listStyleOverhead +
                                    (estimatedLines * (width + lineStyleOverhead));

            estimatedLength = (int)(estimatedLength * 1.2);

            // re-wrap all lines and re-apply offset
            WrappedLineCount = 0;
            var offset = Offset;
            var items  = new StringBuilder("{list", estimatedLength);

            foreach (var line in Lines)
            {
                foreach (var wrappedLine in WrapLine(line, width))
                {
                    WrappedLineCount++;
                    items.AppendFormat("{{listitem text:{0}}}",
                                       StflApi.stfl_quote(wrappedLine));
                }
            }
            items.Append("}");
            Form.Modify(WidgetName, "replace_inner", items.ToString());
            Offset = offset;
        }
示例#13
0
 public string Dump(string name, string prefix, int focus)
 {
     CheckDisposed();
     return(StflApi.stfl_dump(f_Handle, name, prefix, focus));
 }
示例#14
0
 public void Reset()
 {
     CheckDisposed();
     Dispose();
     StflApi.stfl_reset();
 }
示例#15
0
 public string Dump(string name, string prefix, int focus)
 {
     return(StflApi.stfl_dump(f_Handle, name, prefix, focus));
 }
示例#16
0
 public void Modify(string name, string mode, string text)
 {
     StflApi.stfl_modify(f_Handle, name, mode, text);
 }
示例#17
0
        public virtual void Run(int timeout)
        {
            string @event = StflApi.stfl_run(f_Handle, timeout);

            ProcessEvent(@event);
        }
示例#18
0
 public void Modify(string name, string mode, string text)
 {
     CheckDisposed();
     StflApi.stfl_modify(f_Handle, name, mode, text);
 }