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

            OnKeyPressed(new KeyPressedEventArgs(key, focus));
        }
Exemple #2
0
 protected virtual void Dispose(bool disposing)
 {
     if (f_Handle != IntPtr.Zero)
     {
         StflApi.stfl_free(f_Handle);
     }
 }
Exemple #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;
        }
Exemple #4
0
 public string this[string name] {
     get {
         return(StflApi.stfl_get(f_Handle, name));
     }
     set {
         StflApi.stfl_set(f_Handle, name, value);
     }
 }
Exemple #5
0
        public Form(string text)
        {
            f_Handle = StflApi.stfl_create(text);

            // initialize ncurses
            StflApi.stfl_run(f_Handle, -3);
            //StflApi.raw();
            NcursesApi.nocbreak();
        }
Exemple #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);
     }
 }
Exemple #7
0
 public void AppendWrappedLine(string line)
 {
     WrappedLineCount++;
     Form.Modify(
         WidgetName,
         "append",
         String.Format("{{listitem text:{0}}}",
                       StflApi.stfl_quote(line))
         );
 }
Exemple #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);
        }
Exemple #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);
        }
Exemple #10
0
        protected virtual void Dispose(bool disposing)
        {
            var disposed = Disposed;

            if (disposed)
            {
                return;
            }

            if (f_Handle != IntPtr.Zero)
            {
                StflApi.stfl_free(f_Handle);
            }
        }
Exemple #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);
                }
        }
Exemple #12
0
        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;
        }
Exemple #13
0
 public string Dump(string name, string prefix, int focus)
 {
     CheckDisposed();
     return(StflApi.stfl_dump(f_Handle, name, prefix, focus));
 }
Exemple #14
0
 public void Reset()
 {
     CheckDisposed();
     Dispose();
     StflApi.stfl_reset();
 }
Exemple #15
0
 public string Dump(string name, string prefix, int focus)
 {
     return(StflApi.stfl_dump(f_Handle, name, prefix, focus));
 }
Exemple #16
0
 public void Modify(string name, string mode, string text)
 {
     StflApi.stfl_modify(f_Handle, name, mode, text);
 }
Exemple #17
0
        public virtual void Run(int timeout)
        {
            string @event = StflApi.stfl_run(f_Handle, timeout);

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