Permalink
Browse files

Add idle handlers and stop method

  • Loading branch information...
1 parent 9b7ae35 commit 17331dc22db9db59f4d2df55813132a3764a1f93 @migueldeicaza migueldeicaza committed Jan 28, 2011
View
2 Makefile
@@ -62,7 +62,7 @@ t-bugosx:
#cute hack to avoid depending on ncurses-devel on Linux
detect:
echo "main () {initscr();}" > tmp.c
- gcc tmp.c -lncurses -o tmp
+ gcc tmp.c -lncursesw -o tmp
make binding CURSES=`ldd ./tmp | grep ncurses | awk '{print $$3}' | sed 's#.*libncurses#ncurses#'`
binding:
View
2 README
@@ -40,6 +40,8 @@ Features
TODO
====
+ * Rename x,y,w,h into something better, expose rects?
+ * Merge Widget and Container?
* Add scrollbar and thumb to listviews
* Add text view widget
* Add scrollable control
View
19 binding.cs.in
@@ -207,8 +207,9 @@ namespace Mono.Terminal {
[DllImport ("@CURSES@")]
extern public static int move (int line, int col);
- [DllImport ("@CURSES@")]
- extern public static int addch (int ch);
+ [DllImport ("@CURSES@", EntryPoint="addch")]
+ extern internal static int _addch (int ch);
+
[DllImport ("@CURSES@")]
extern public static int addstr (string s);
@@ -217,6 +218,14 @@ namespace Mono.Terminal {
var s = string.Format (format, args);
return addstr (s);
}
+
+ static char [] r = new char [1];
+
+ public static int addch (int ch)
+ {
+ char c = (char) ch;
@txdv
txdv Feb 24, 2011

This breaks support for ACS_ characters, because they are bigger than a simple character.
public const int ACS_VLINE = unchecked((int)0x400078);
It's an 'x' | 0x0400000

Is there a particular reasion why you are doing this? The commit message doesn't give much away.

+ return addstr (new String (c, 1));
+ }
[DllImport ("@CURSES@")]
extern internal static int wmove (IntPtr win, int line, int col);
@@ -236,13 +245,13 @@ namespace Mono.Terminal {
#region Input
[DllImport ("@CURSES@")]
- extern internal static int getch ();
+ extern public static int getch ();
[DllImport ("@CURSES@")]
- extern internal static int ungetch (int ch);
+ extern public static int ungetch (int ch);
[DllImport ("@CURSES@")]
- extern internal static int mvgetch (int y, int x);
+ extern public static int mvgetch (int y, int x);
#endregion
#region Colors
View
115 docs/Mono.Terminal/Application.xml
@@ -37,6 +37,35 @@
<remarks>To be added.</remarks>
</Docs>
</Member>
+ <Member MemberName="Begin">
+ <MemberSignature Language="C#" Value="public static Mono.Terminal.RunState Begin (Mono.Terminal.Container container);" />
+ <MemberType>Method</MemberType>
+ <AssemblyInfo>
+ <AssemblyVersion>1.0.0.0</AssemblyVersion>
+ </AssemblyInfo>
+ <ReturnValue>
+ <ReturnType>Mono.Terminal.RunState</ReturnType>
+ </ReturnValue>
+ <Parameters>
+ <Parameter Name="container" Type="Mono.Terminal.Container" />
+ </Parameters>
+ <Docs>
+ <param name="container">To be added.</param>
+ <summary>
+ Starts running a new container or dialog box.
+ </summary>
+ <returns>To be added.</returns>
+ <remarks>
+ Use this method if you want to start the dialog, but
+ you want to control the main loop execution manually
+ by calling the RunLoop method (for example, to start
+ the dialog, but continuing to process events).
+ Use the returned value as the argument to RunLoop
+ and later to the End method to remove the container
+ from the screen.
+ </remarks>
+ </Docs>
+ </Member>
<Member MemberName="ColorBasic">
<MemberSignature Language="C#" Value="public static int ColorBasic;" />
<MemberSignature Language="ILAsm" Value=".field public static int32 ColorBasic" />
@@ -410,6 +439,26 @@
<remarks>To be added.</remarks>
</Docs>
</Member>
+ <Member MemberName="End">
+ <MemberSignature Language="C#" Value="public static void End (Mono.Terminal.RunState state);" />
+ <MemberType>Method</MemberType>
+ <AssemblyInfo>
+ <AssemblyVersion>1.0.0.0</AssemblyVersion>
+ </AssemblyInfo>
+ <ReturnValue>
+ <ReturnType>System.Void</ReturnType>
+ </ReturnValue>
+ <Parameters>
+ <Parameter Name="state" Type="Mono.Terminal.RunState" />
+ </Parameters>
+ <Docs>
+ <param name="state">To be added.</param>
+ <summary>
+ Use this method to complete an execution started with Begin
+ </summary>
+ <remarks>To be added.</remarks>
+ </Docs>
+ </Member>
<Member MemberName="Error">
<MemberSignature Language="C#" Value="public static void Error (string caption, string text);" />
<MemberSignature Language="ILAsm" Value=".method public static hidebysig void Error(string caption, string text) cil managed" />
@@ -566,7 +615,7 @@
main loop.
</summary>
<remarks>
- See also <see cref="F:Mono.Terminal.Application.Timeout" /></remarks>
+ See also <see cref="!:Timeout" /></remarks>
</Docs>
</Member>
<Member MemberName="Lines">
@@ -720,13 +769,75 @@
</remarks>
</Docs>
</Member>
+ <Member MemberName="RunLoop">
+ <MemberSignature Language="C#" Value="public static void RunLoop (Mono.Terminal.RunState state);" />
+ <MemberType>Method</MemberType>
+ <AssemblyInfo>
+ <AssemblyVersion>1.0.0.0</AssemblyVersion>
+ </AssemblyInfo>
+ <ReturnValue>
+ <ReturnType>System.Void</ReturnType>
+ </ReturnValue>
+ <Parameters>
+ <Parameter Name="state" Type="Mono.Terminal.RunState" />
+ </Parameters>
+ <Docs>
+ <param name="state">To be added.</param>
+ <summary>
+ Runs the main loop for the created dialog
+ </summary>
+ <remarks>
+ Calling this method will block until the
+ dialog has completed execution.
+ </remarks>
+ </Docs>
+ </Member>
+ <Member MemberName="RunLoop">
+ <MemberSignature Language="C#" Value="public static void RunLoop (Mono.Terminal.RunState state, bool wait);" />
+ <MemberType>Method</MemberType>
+ <AssemblyInfo>
+ <AssemblyVersion>1.0.0.0</AssemblyVersion>
+ </AssemblyInfo>
+ <ReturnValue>
+ <ReturnType>System.Void</ReturnType>
+ </ReturnValue>
+ <Parameters>
+ <Parameter Name="state" Type="Mono.Terminal.RunState" />
+ <Parameter Name="wait" Type="System.Boolean" />
+ </Parameters>
+ <Docs>
+ <param name="state">To be added.</param>
+ <param name="wait">To be added.</param>
+ <summary>
+ Runs the main loop for the created dialog
+ </summary>
+ <remarks>
+ Use the wait parameter to control whether this is a
+ blocking or non-blocking call.
+ </remarks>
+ </Docs>
+ </Member>
+ <Member MemberName="Stop">
+ <MemberSignature Language="C#" Value="public static void Stop ();" />
+ <MemberType>Method</MemberType>
+ <AssemblyInfo>
+ <AssemblyVersion>1.0.0.0</AssemblyVersion>
+ </AssemblyInfo>
+ <ReturnValue>
+ <ReturnType>System.Void</ReturnType>
+ </ReturnValue>
+ <Parameters />
+ <Docs>
+ <summary>To be added.</summary>
+ <remarks>To be added.</remarks>
+ </Docs>
+ </Member>
<Member MemberName="Timeout">
<MemberSignature Language="C#" Value="public static int Timeout;" />
<MemberSignature Language="ILAsm" Value=".field public static int32 Timeout" />
<MemberType>Field</MemberType>
<AssemblyInfo>
<AssemblyVersion>0.0.0.0</AssemblyVersion>
- <AssemblyVersion>1.0.0.0</AssemblyVersion>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.Int32</ReturnType>
View
2 docs/Mono.Terminal/Button.xml
@@ -261,7 +261,7 @@
</Docs>
</Member>
<Member MemberName="Text">
- <MemberSignature Language="C#" Value="public string Text { get; set; }" />
+ <MemberSignature Language="C#" Value="public string Text { set; get; }" />
<MemberSignature Language="ILAsm" Value=".property instance string Text" />
<MemberType>Property</MemberType>
<AssemblyInfo>
View
4 docs/Mono.Terminal/CheckBox.xml
@@ -69,7 +69,7 @@
</Docs>
</Member>
<Member MemberName="Checked">
- <MemberSignature Language="C#" Value="public bool Checked { get; set; }" />
+ <MemberSignature Language="C#" Value="public bool Checked { set; get; }" />
<MemberSignature Language="ILAsm" Value=".property instance bool Checked" />
<MemberType>Property</MemberType>
<AssemblyInfo>
@@ -158,7 +158,7 @@
</Docs>
</Member>
<Member MemberName="Text">
- <MemberSignature Language="C#" Value="public string Text { get; set; }" />
+ <MemberSignature Language="C#" Value="public string Text { set; get; }" />
<MemberSignature Language="ILAsm" Value=".property instance string Text" />
<MemberType>Property</MemberType>
<AssemblyInfo>
View
111 docs/Mono.Terminal/Curses.xml
@@ -286,7 +286,7 @@
</Member>
<Member MemberName="addch">
<MemberSignature Language="C#" Value="public static int addch (int ch);" />
- <MemberSignature Language="ILAsm" Value=".method public static hidebysig pinvokeimpl (&quot;ncurses.so.5&quot; as &quot;addch&quot; winapi)int32 addch(int32 ch) cil managed" />
+ <MemberSignature Language="ILAsm" Value=".method public static hidebysig pinvokeimpl (&quot;ncursesw.so.5&quot; as &quot;addch&quot; winapi)int32 addch(int32 ch) cil managed" />
<MemberType>Method</MemberType>
<AssemblyInfo>
<AssemblyVersion>0.0.0.0</AssemblyVersion>
@@ -307,7 +307,7 @@
</Member>
<Member MemberName="addstr">
<MemberSignature Language="C#" Value="public static int addstr (string s);" />
- <MemberSignature Language="ILAsm" Value=".method public static hidebysig pinvokeimpl (&quot;ncurses.so.5&quot; as &quot;addstr&quot; winapi)int32 addstr(string s) cil managed" />
+ <MemberSignature Language="ILAsm" Value=".method public static hidebysig pinvokeimpl (&quot;ncursesw.so.5&quot; as &quot;addstr&quot; winapi)int32 addstr(string s) cil managed" />
<MemberType>Method</MemberType>
<AssemblyInfo>
<AssemblyVersion>0.0.0.0</AssemblyVersion>
@@ -356,7 +356,7 @@
</Member>
<Member MemberName="attroff">
<MemberSignature Language="C#" Value="public static int attroff (int attrs);" />
- <MemberSignature Language="ILAsm" Value=".method public static hidebysig pinvokeimpl (&quot;ncurses.so.5&quot; as &quot;attroff&quot; winapi)int32 attroff(int32 attrs) cil managed" />
+ <MemberSignature Language="ILAsm" Value=".method public static hidebysig pinvokeimpl (&quot;ncursesw.so.5&quot; as &quot;attroff&quot; winapi)int32 attroff(int32 attrs) cil managed" />
<MemberType>Method</MemberType>
<AssemblyInfo>
<AssemblyVersion>0.0.0.0</AssemblyVersion>
@@ -377,7 +377,7 @@
</Member>
<Member MemberName="attron">
<MemberSignature Language="C#" Value="public static int attron (int attrs);" />
- <MemberSignature Language="ILAsm" Value=".method public static hidebysig pinvokeimpl (&quot;ncurses.so.5&quot; as &quot;attron&quot; winapi)int32 attron(int32 attrs) cil managed" />
+ <MemberSignature Language="ILAsm" Value=".method public static hidebysig pinvokeimpl (&quot;ncursesw.so.5&quot; as &quot;attron&quot; winapi)int32 attron(int32 attrs) cil managed" />
<MemberType>Method</MemberType>
<AssemblyInfo>
<AssemblyVersion>0.0.0.0</AssemblyVersion>
@@ -398,7 +398,7 @@
</Member>
<Member MemberName="attrset">
<MemberSignature Language="C#" Value="public static int attrset (int attrs);" />
- <MemberSignature Language="ILAsm" Value=".method public static hidebysig pinvokeimpl (&quot;ncurses.so.5&quot; as &quot;attrset&quot; winapi)int32 attrset(int32 attrs) cil managed" />
+ <MemberSignature Language="ILAsm" Value=".method public static hidebysig pinvokeimpl (&quot;ncursesw.so.5&quot; as &quot;attrset&quot; winapi)int32 attrset(int32 attrs) cil managed" />
<MemberType>Method</MemberType>
<AssemblyInfo>
<AssemblyVersion>0.0.0.0</AssemblyVersion>
@@ -419,7 +419,7 @@
</Member>
<Member MemberName="cbreak">
<MemberSignature Language="C#" Value="public static int cbreak ();" />
- <MemberSignature Language="ILAsm" Value=".method public static hidebysig pinvokeimpl (&quot;ncurses.so.5&quot; as &quot;cbreak&quot; winapi)int32 cbreak() cil managed" />
+ <MemberSignature Language="ILAsm" Value=".method public static hidebysig pinvokeimpl (&quot;ncursesw.so.5&quot; as &quot;cbreak&quot; winapi)int32 cbreak() cil managed" />
<MemberType>Method</MemberType>
<AssemblyInfo>
<AssemblyVersion>0.0.0.0</AssemblyVersion>
@@ -611,7 +611,7 @@
</Member>
<Member MemberName="doupdate">
<MemberSignature Language="C#" Value="public static int doupdate ();" />
- <MemberSignature Language="ILAsm" Value=".method public static hidebysig pinvokeimpl (&quot;ncurses.so.5&quot; as &quot;doupdate&quot; winapi)int32 doupdate() cil managed" />
+ <MemberSignature Language="ILAsm" Value=".method public static hidebysig pinvokeimpl (&quot;ncursesw.so.5&quot; as &quot;doupdate&quot; winapi)int32 doupdate() cil managed" />
<MemberType>Method</MemberType>
<AssemblyInfo>
<AssemblyVersion>0.0.0.0</AssemblyVersion>
@@ -629,7 +629,7 @@
</Member>
<Member MemberName="echo">
<MemberSignature Language="C#" Value="public static int echo ();" />
- <MemberSignature Language="ILAsm" Value=".method public static hidebysig pinvokeimpl (&quot;ncurses.so.5&quot; as &quot;echo&quot; winapi)int32 echo() cil managed" />
+ <MemberSignature Language="ILAsm" Value=".method public static hidebysig pinvokeimpl (&quot;ncursesw.so.5&quot; as &quot;echo&quot; winapi)int32 echo() cil managed" />
<MemberType>Method</MemberType>
<AssemblyInfo>
<AssemblyVersion>0.0.0.0</AssemblyVersion>
@@ -647,7 +647,7 @@
</Member>
<Member MemberName="endwin">
<MemberSignature Language="C#" Value="public static int endwin ();" />
- <MemberSignature Language="ILAsm" Value=".method public static hidebysig pinvokeimpl (&quot;ncurses.so.5&quot; as &quot;endwin&quot; winapi)int32 endwin() cil managed" />
+ <MemberSignature Language="ILAsm" Value=".method public static hidebysig pinvokeimpl (&quot;ncursesw.so.5&quot; as &quot;endwin&quot; winapi)int32 endwin() cil managed" />
<MemberType>Method</MemberType>
<AssemblyInfo>
<AssemblyVersion>0.0.0.0</AssemblyVersion>
@@ -680,9 +680,26 @@
<remarks>To be added.</remarks>
</Docs>
</Member>
+ <Member MemberName="getch">
+ <MemberSignature Language="C#" Value="public static int getch ();" />
+ <MemberSignature Language="ILAsm" Value=".method public static hidebysig pinvokeimpl (&quot;ncursesw.so.5&quot; as &quot;getch&quot; winapi)int32 getch() cil managed" />
+ <MemberType>Method</MemberType>
+ <AssemblyInfo>
+ <AssemblyVersion>1.0.0.0</AssemblyVersion>
+ </AssemblyInfo>
+ <ReturnValue>
+ <ReturnType>System.Int32</ReturnType>
+ </ReturnValue>
+ <Parameters />
+ <Docs>
+ <summary>To be added.</summary>
+ <returns>To be added.</returns>
+ <remarks>To be added.</remarks>
+ </Docs>
+ </Member>
<Member MemberName="halfdelay">
<MemberSignature Language="C#" Value="public static int halfdelay (int t);" />
- <MemberSignature Language="ILAsm" Value=".method public static hidebysig pinvokeimpl (&quot;ncurses.so.5&quot; as &quot;halfdelay&quot; winapi)int32 halfdelay(int32 t) cil managed" />
+ <MemberSignature Language="ILAsm" Value=".method public static hidebysig pinvokeimpl (&quot;ncursesw.so.5&quot; as &quot;halfdelay&quot; winapi)int32 halfdelay(int32 t) cil managed" />
<MemberType>Method</MemberType>
<AssemblyInfo>
<AssemblyVersion>0.0.0.0</AssemblyVersion>
@@ -721,7 +738,7 @@
</Member>
<Member MemberName="internal_newterm">
<MemberSignature Language="C#" Value="public static IntPtr internal_newterm (string type, IntPtr file_outfd, IntPtr file_infd);" />
- <MemberSignature Language="ILAsm" Value=".method public static hidebysig pinvokeimpl (&quot;ncurses.so.5&quot; as &quot;internal_newterm&quot; winapi)native int internal_newterm(string type, native int file_outfd, native int file_infd) cil managed" />
+ <MemberSignature Language="ILAsm" Value=".method public static hidebysig pinvokeimpl (&quot;ncursesw.so.5&quot; as &quot;internal_newterm&quot; winapi)native int internal_newterm(string type, native int file_outfd, native int file_infd) cil managed" />
<MemberType>Method</MemberType>
<AssemblyInfo>
<AssemblyVersion>0.0.0.0</AssemblyVersion>
@@ -746,7 +763,7 @@
</Member>
<Member MemberName="internal_set_term">
<MemberSignature Language="C#" Value="public static IntPtr internal_set_term (IntPtr newscreen);" />
- <MemberSignature Language="ILAsm" Value=".method public static hidebysig pinvokeimpl (&quot;ncurses.so.5&quot; as &quot;internal_set_term&quot; winapi)native int internal_set_term(native int newscreen) cil managed" />
+ <MemberSignature Language="ILAsm" Value=".method public static hidebysig pinvokeimpl (&quot;ncursesw.so.5&quot; as &quot;internal_set_term&quot; winapi)native int internal_set_term(native int newscreen) cil managed" />
<MemberType>Method</MemberType>
<AssemblyInfo>
<AssemblyVersion>0.0.0.0</AssemblyVersion>
@@ -788,7 +805,7 @@
</Member>
<Member MemberName="isendwin">
<MemberSignature Language="C#" Value="public static bool isendwin ();" />
- <MemberSignature Language="ILAsm" Value=".method public static hidebysig pinvokeimpl (&quot;ncurses.so.5&quot; as &quot;isendwin&quot; winapi)bool isendwin() cil managed" />
+ <MemberSignature Language="ILAsm" Value=".method public static hidebysig pinvokeimpl (&quot;ncursesw.so.5&quot; as &quot;isendwin&quot; winapi)bool isendwin() cil managed" />
<MemberType>Method</MemberType>
<AssemblyInfo>
<AssemblyVersion>0.0.0.0</AssemblyVersion>
@@ -1202,7 +1219,7 @@
</Member>
<Member MemberName="move">
<MemberSignature Language="C#" Value="public static int move (int line, int col);" />
- <MemberSignature Language="ILAsm" Value=".method public static hidebysig pinvokeimpl (&quot;ncurses.so.5&quot; as &quot;move&quot; winapi)int32 move(int32 line, int32 col) cil managed" />
+ <MemberSignature Language="ILAsm" Value=".method public static hidebysig pinvokeimpl (&quot;ncursesw.so.5&quot; as &quot;move&quot; winapi)int32 move(int32 line, int32 col) cil managed" />
<MemberType>Method</MemberType>
<AssemblyInfo>
<AssemblyVersion>0.0.0.0</AssemblyVersion>
@@ -1223,9 +1240,31 @@
<remarks>To be added.</remarks>
</Docs>
</Member>
+ <Member MemberName="mvgetch">
+ <MemberSignature Language="C#" Value="public static int mvgetch (int y, int x);" />
+ <MemberSignature Language="ILAsm" Value=".method public static hidebysig pinvokeimpl (&quot;ncursesw.so.5&quot; as &quot;mvgetch&quot; winapi)int32 mvgetch(int32 y, int32 x) cil managed" />
+ <MemberType>Method</MemberType>
+ <AssemblyInfo>
+ <AssemblyVersion>1.0.0.0</AssemblyVersion>
+ </AssemblyInfo>
+ <ReturnValue>
+ <ReturnType>System.Int32</ReturnType>
+ </ReturnValue>
+ <Parameters>
+ <Parameter Name="y" Type="System.Int32" />
+ <Parameter Name="x" Type="System.Int32" />
+ </Parameters>
+ <Docs>
+ <param name="y">To be added.</param>
+ <param name="x">To be added.</param>
+ <summary>To be added.</summary>
+ <returns>To be added.</returns>
+ <remarks>To be added.</remarks>
+ </Docs>
+ </Member>
<Member MemberName="nl">
<MemberSignature Language="C#" Value="public static int nl ();" />
- <MemberSignature Language="ILAsm" Value=".method public static hidebysig pinvokeimpl (&quot;ncurses.so.5&quot; as &quot;nl&quot; winapi)int32 nl() cil managed" />
+ <MemberSignature Language="ILAsm" Value=".method public static hidebysig pinvokeimpl (&quot;ncursesw.so.5&quot; as &quot;nl&quot; winapi)int32 nl() cil managed" />
<MemberType>Method</MemberType>
<AssemblyInfo>
<AssemblyVersion>0.0.0.0</AssemblyVersion>
@@ -1243,7 +1282,7 @@
</Member>
<Member MemberName="nocbreak">
<MemberSignature Language="C#" Value="public static int nocbreak ();" />
- <MemberSignature Language="ILAsm" Value=".method public static hidebysig pinvokeimpl (&quot;ncurses.so.5&quot; as &quot;nocbreak&quot; winapi)int32 nocbreak() cil managed" />
+ <MemberSignature Language="ILAsm" Value=".method public static hidebysig pinvokeimpl (&quot;ncursesw.so.5&quot; as &quot;nocbreak&quot; winapi)int32 nocbreak() cil managed" />
<MemberType>Method</MemberType>
<AssemblyInfo>
<AssemblyVersion>0.0.0.0</AssemblyVersion>
@@ -1261,7 +1300,7 @@
</Member>
<Member MemberName="noecho">
<MemberSignature Language="C#" Value="public static int noecho ();" />
- <MemberSignature Language="ILAsm" Value=".method public static hidebysig pinvokeimpl (&quot;ncurses.so.5&quot; as &quot;noecho&quot; winapi)int32 noecho() cil managed" />
+ <MemberSignature Language="ILAsm" Value=".method public static hidebysig pinvokeimpl (&quot;ncursesw.so.5&quot; as &quot;noecho&quot; winapi)int32 noecho() cil managed" />
<MemberType>Method</MemberType>
<AssemblyInfo>
<AssemblyVersion>0.0.0.0</AssemblyVersion>
@@ -1279,7 +1318,7 @@
</Member>
<Member MemberName="nonl">
<MemberSignature Language="C#" Value="public static int nonl ();" />
- <MemberSignature Language="ILAsm" Value=".method public static hidebysig pinvokeimpl (&quot;ncurses.so.5&quot; as &quot;nonl&quot; winapi)int32 nonl() cil managed" />
+ <MemberSignature Language="ILAsm" Value=".method public static hidebysig pinvokeimpl (&quot;ncursesw.so.5&quot; as &quot;nonl&quot; winapi)int32 nonl() cil managed" />
<MemberType>Method</MemberType>
<AssemblyInfo>
<AssemblyVersion>0.0.0.0</AssemblyVersion>
@@ -1297,7 +1336,7 @@
</Member>
<Member MemberName="noqiflush">
<MemberSignature Language="C#" Value="public static void noqiflush ();" />
- <MemberSignature Language="ILAsm" Value=".method public static hidebysig pinvokeimpl (&quot;ncurses.so.5&quot; as &quot;noqiflush&quot; winapi)void noqiflush() cil managed" />
+ <MemberSignature Language="ILAsm" Value=".method public static hidebysig pinvokeimpl (&quot;ncursesw.so.5&quot; as &quot;noqiflush&quot; winapi)void noqiflush() cil managed" />
<MemberType>Method</MemberType>
<AssemblyInfo>
<AssemblyVersion>0.0.0.0</AssemblyVersion>
@@ -1314,7 +1353,7 @@
</Member>
<Member MemberName="noraw">
<MemberSignature Language="C#" Value="public static int noraw ();" />
- <MemberSignature Language="ILAsm" Value=".method public static hidebysig pinvokeimpl (&quot;ncurses.so.5&quot; as &quot;noraw&quot; winapi)int32 noraw() cil managed" />
+ <MemberSignature Language="ILAsm" Value=".method public static hidebysig pinvokeimpl (&quot;ncursesw.so.5&quot; as &quot;noraw&quot; winapi)int32 noraw() cil managed" />
<MemberType>Method</MemberType>
<AssemblyInfo>
<AssemblyVersion>0.0.0.0</AssemblyVersion>
@@ -1332,7 +1371,7 @@
</Member>
<Member MemberName="qiflush">
<MemberSignature Language="C#" Value="public static void qiflush ();" />
- <MemberSignature Language="ILAsm" Value=".method public static hidebysig pinvokeimpl (&quot;ncurses.so.5&quot; as &quot;qiflush&quot; winapi)void qiflush() cil managed" />
+ <MemberSignature Language="ILAsm" Value=".method public static hidebysig pinvokeimpl (&quot;ncursesw.so.5&quot; as &quot;qiflush&quot; winapi)void qiflush() cil managed" />
<MemberType>Method</MemberType>
<AssemblyInfo>
<AssemblyVersion>0.0.0.0</AssemblyVersion>
@@ -1349,7 +1388,7 @@
</Member>
<Member MemberName="raw">
<MemberSignature Language="C#" Value="public static int raw ();" />
- <MemberSignature Language="ILAsm" Value=".method public static hidebysig pinvokeimpl (&quot;ncurses.so.5&quot; as &quot;raw&quot; winapi)int32 raw() cil managed" />
+ <MemberSignature Language="ILAsm" Value=".method public static hidebysig pinvokeimpl (&quot;ncursesw.so.5&quot; as &quot;raw&quot; winapi)int32 raw() cil managed" />
<MemberType>Method</MemberType>
<AssemblyInfo>
<AssemblyVersion>0.0.0.0</AssemblyVersion>
@@ -1367,7 +1406,7 @@
</Member>
<Member MemberName="refresh">
<MemberSignature Language="C#" Value="public static int refresh ();" />
- <MemberSignature Language="ILAsm" Value=".method public static hidebysig pinvokeimpl (&quot;ncurses.so.5&quot; as &quot;refresh&quot; winapi)int32 refresh() cil managed" />
+ <MemberSignature Language="ILAsm" Value=".method public static hidebysig pinvokeimpl (&quot;ncursesw.so.5&quot; as &quot;refresh&quot; winapi)int32 refresh() cil managed" />
<MemberType>Method</MemberType>
<AssemblyInfo>
<AssemblyVersion>0.0.0.0</AssemblyVersion>
@@ -1385,7 +1424,7 @@
</Member>
<Member MemberName="setscrreg">
<MemberSignature Language="C#" Value="public static int setscrreg (int top, int bot);" />
- <MemberSignature Language="ILAsm" Value=".method public static hidebysig pinvokeimpl (&quot;ncurses.so.5&quot; as &quot;setscrreg&quot; winapi)int32 setscrreg(int32 top, int32 bot) cil managed" />
+ <MemberSignature Language="ILAsm" Value=".method public static hidebysig pinvokeimpl (&quot;ncursesw.so.5&quot; as &quot;setscrreg&quot; winapi)int32 setscrreg(int32 top, int32 bot) cil managed" />
<MemberType>Method</MemberType>
<AssemblyInfo>
<AssemblyVersion>0.0.0.0</AssemblyVersion>
@@ -1408,7 +1447,7 @@
</Member>
<Member MemberName="timeout">
<MemberSignature Language="C#" Value="public static int timeout (int delay);" />
- <MemberSignature Language="ILAsm" Value=".method public static hidebysig pinvokeimpl (&quot;ncurses.so.5&quot; as &quot;timeout&quot; winapi)int32 timeout(int32 delay) cil managed" />
+ <MemberSignature Language="ILAsm" Value=".method public static hidebysig pinvokeimpl (&quot;ncursesw.so.5&quot; as &quot;timeout&quot; winapi)int32 timeout(int32 delay) cil managed" />
<MemberType>Method</MemberType>
<AssemblyInfo>
<AssemblyVersion>0.0.0.0</AssemblyVersion>
@@ -1429,7 +1468,7 @@
</Member>
<Member MemberName="typeahead">
<MemberSignature Language="C#" Value="public static int typeahead (IntPtr fd);" />
- <MemberSignature Language="ILAsm" Value=".method public static hidebysig pinvokeimpl (&quot;ncurses.so.5&quot; as &quot;typeahead&quot; winapi)int32 typeahead(native int fd) cil managed" />
+ <MemberSignature Language="ILAsm" Value=".method public static hidebysig pinvokeimpl (&quot;ncursesw.so.5&quot; as &quot;typeahead&quot; winapi)int32 typeahead(native int fd) cil managed" />
<MemberType>Method</MemberType>
<AssemblyInfo>
<AssemblyVersion>0.0.0.0</AssemblyVersion>
@@ -1448,5 +1487,25 @@
<remarks>To be added.</remarks>
</Docs>
</Member>
+ <Member MemberName="ungetch">
+ <MemberSignature Language="C#" Value="public static int ungetch (int ch);" />
+ <MemberSignature Language="ILAsm" Value=".method public static hidebysig pinvokeimpl (&quot;ncursesw.so.5&quot; as &quot;ungetch&quot; winapi)int32 ungetch(int32 ch) cil managed" />
+ <MemberType>Method</MemberType>
+ <AssemblyInfo>
+ <AssemblyVersion>1.0.0.0</AssemblyVersion>
+ </AssemblyInfo>
+ <ReturnValue>
+ <ReturnType>System.Int32</ReturnType>
+ </ReturnValue>
+ <Parameters>
+ <Parameter Name="ch" Type="System.Int32" />
+ </Parameters>
+ <Docs>
+ <param name="ch">To be added.</param>
+ <summary>To be added.</summary>
+ <returns>To be added.</returns>
+ <remarks>To be added.</remarks>
+ </Docs>
+ </Member>
</Members>
</Type>
View
6 docs/Mono.Terminal/Entry.xml
@@ -66,7 +66,7 @@
</Docs>
</Member>
<Member MemberName="Color">
- <MemberSignature Language="C#" Value="public int Color { get; set; }" />
+ <MemberSignature Language="C#" Value="public int Color { set; get; }" />
<MemberSignature Language="ILAsm" Value=".property instance int32 Color" />
<MemberType>Property</MemberType>
<AssemblyInfo>
@@ -175,7 +175,7 @@
</Docs>
</Member>
<Member MemberName="Secret">
- <MemberSignature Language="C#" Value="public bool Secret { get; set; }" />
+ <MemberSignature Language="C#" Value="public bool Secret { set; get; }" />
<MemberSignature Language="ILAsm" Value=".property instance bool Secret" />
<MemberType>Property</MemberType>
<AssemblyInfo>
@@ -195,7 +195,7 @@
</Docs>
</Member>
<Member MemberName="Text">
- <MemberSignature Language="C#" Value="public string Text { get; set; }" />
+ <MemberSignature Language="C#" Value="public string Text { set; get; }" />
<MemberSignature Language="ILAsm" Value=".property instance string Text" />
<MemberType>Property</MemberType>
<AssemblyInfo>
View
2 docs/Mono.Terminal/Label.xml
@@ -118,7 +118,7 @@
</Docs>
</Member>
<Member MemberName="Text">
- <MemberSignature Language="C#" Value="public virtual string Text { get; set; }" />
+ <MemberSignature Language="C#" Value="public virtual string Text { set; get; }" />
<MemberSignature Language="ILAsm" Value=".property instance string Text" />
<MemberType>Property</MemberType>
<AssemblyInfo>
View
2 docs/Mono.Terminal/ListView.xml
@@ -145,7 +145,7 @@
</Docs>
</Member>
<Member MemberName="Selected">
- <MemberSignature Language="C#" Value="public int Selected { get; set; }" />
+ <MemberSignature Language="C#" Value="public int Selected { set; get; }" />
<MemberSignature Language="ILAsm" Value=".property instance int32 Selected" />
<MemberType>Property</MemberType>
<AssemblyInfo>
View
61 docs/Mono.Terminal/MainLoop.xml
@@ -32,6 +32,27 @@
<remarks>To be added.</remarks>
</Docs>
</Member>
+ <Member MemberName="AddIdle">
+ <MemberSignature Language="C#" Value="public Func&lt;bool&gt; AddIdle (Func&lt;bool&gt; idleHandler);" />
+ <MemberType>Method</MemberType>
+ <AssemblyInfo>
+ <AssemblyVersion>1.0.0.0</AssemblyVersion>
+ </AssemblyInfo>
+ <ReturnValue>
+ <ReturnType>System.Func&lt;System.Boolean&gt;</ReturnType>
+ </ReturnValue>
+ <Parameters>
+ <Parameter Name="idleHandler" Type="System.Func&lt;System.Boolean&gt;" />
+ </Parameters>
+ <Docs>
+ <param name="idleHandler">To be added.</param>
+ <summary>
+ Executes the specified @idleHandler on the idle loop. The return value is a token to remove it.
+ </summary>
+ <returns>To be added.</returns>
+ <remarks>To be added.</remarks>
+ </Docs>
+ </Member>
<Member MemberName="AddTimeout">
<MemberSignature Language="C#" Value="public object AddTimeout (TimeSpan time, Func&lt;Mono.Terminal.MainLoop,bool&gt; callback);" />
<MemberSignature Language="ILAsm" Value=".method public hidebysig instance object AddTimeout(valuetype System.TimeSpan time, class System.Func`2&lt;class Mono.Terminal.MainLoop, bool&gt; callback) cil managed" />
@@ -120,6 +141,26 @@
</remarks>
</Docs>
</Member>
+ <Member MemberName="Invoke">
+ <MemberSignature Language="C#" Value="public void Invoke (Mono.Terminal.Action action);" />
+ <MemberType>Method</MemberType>
+ <AssemblyInfo>
+ <AssemblyVersion>1.0.0.0</AssemblyVersion>
+ </AssemblyInfo>
+ <ReturnValue>
+ <ReturnType>System.Void</ReturnType>
+ </ReturnValue>
+ <Parameters>
+ <Parameter Name="action" Type="Mono.Terminal.Action" />
+ </Parameters>
+ <Docs>
+ <param name="action">To be added.</param>
+ <summary>
+ Runs @action on the thread that is processing events
+ </summary>
+ <remarks>To be added.</remarks>
+ </Docs>
+ </Member>
<Member MemberName="MainIteration">
<MemberSignature Language="C#" Value="public void MainIteration ();" />
<MemberSignature Language="ILAsm" Value=".method public hidebysig instance void MainIteration() cil managed" />
@@ -165,6 +206,26 @@
</remarks>
</Docs>
</Member>
+ <Member MemberName="RemoveIdle">
+ <MemberSignature Language="C#" Value="public void RemoveIdle (Func&lt;bool&gt; idleHandler);" />
+ <MemberType>Method</MemberType>
+ <AssemblyInfo>
+ <AssemblyVersion>1.0.0.0</AssemblyVersion>
+ </AssemblyInfo>
+ <ReturnValue>
+ <ReturnType>System.Void</ReturnType>
+ </ReturnValue>
+ <Parameters>
+ <Parameter Name="idleHandler" Type="System.Func&lt;System.Boolean&gt;" />
+ </Parameters>
+ <Docs>
+ <param name="idleHandler">To be added.</param>
+ <summary>
+ Removes the specified idleHandler from processing.
+ </summary>
+ <remarks>To be added.</remarks>
+ </Docs>
+ </Member>
<Member MemberName="RemoveTimeout">
<MemberSignature Language="C#" Value="public void RemoveTimeout (object token);" />
<MemberSignature Language="ILAsm" Value=".method public hidebysig instance void RemoveTimeout(object token) cil managed" />
View
2 docs/Mono.Terminal/MenuBar.xml
@@ -52,7 +52,7 @@
</Docs>
</Member>
<Member MemberName="Menus">
- <MemberSignature Language="C#" Value="public Mono.Terminal.MenuBarItem[] Menus { get; set; }" />
+ <MemberSignature Language="C#" Value="public Mono.Terminal.MenuBarItem[] Menus { set; get; }" />
<MemberSignature Language="ILAsm" Value=".property instance class Mono.Terminal.MenuBarItem[] Menus" />
<MemberType>Property</MemberType>
<AssemblyInfo>
View
6 docs/Mono.Terminal/MenuBarItem.xml
@@ -33,7 +33,7 @@
</Docs>
</Member>
<Member MemberName="Children">
- <MemberSignature Language="C#" Value="public Mono.Terminal.MenuItem[] Children { get; set; }" />
+ <MemberSignature Language="C#" Value="public Mono.Terminal.MenuItem[] Children { set; get; }" />
<MemberSignature Language="ILAsm" Value=".property instance class Mono.Terminal.MenuItem[] Children" />
<MemberType>Property</MemberType>
<AssemblyInfo>
@@ -49,7 +49,7 @@
</Docs>
</Member>
<Member MemberName="Current">
- <MemberSignature Language="C#" Value="public int Current { get; set; }" />
+ <MemberSignature Language="C#" Value="public int Current { set; get; }" />
<MemberSignature Language="ILAsm" Value=".property instance int32 Current" />
<MemberType>Property</MemberType>
<AssemblyInfo>
@@ -65,7 +65,7 @@
</Docs>
</Member>
<Member MemberName="Title">
- <MemberSignature Language="C#" Value="public string Title { get; set; }" />
+ <MemberSignature Language="C#" Value="public string Title { set; get; }" />
<MemberSignature Language="ILAsm" Value=".property instance string Title" />
<MemberType>Property</MemberType>
<AssemblyInfo>
View
8 docs/Mono.Terminal/MenuItem.xml
@@ -35,7 +35,7 @@
</Docs>
</Member>
<Member MemberName="Action">
- <MemberSignature Language="C#" Value="public Mono.Terminal.Action Action { get; set; }" />
+ <MemberSignature Language="C#" Value="public Mono.Terminal.Action Action { set; get; }" />
<MemberSignature Language="ILAsm" Value=".property instance class Mono.Terminal.Action Action" />
<MemberType>Property</MemberType>
<AssemblyInfo>
@@ -51,7 +51,7 @@
</Docs>
</Member>
<Member MemberName="Help">
- <MemberSignature Language="C#" Value="public string Help { get; set; }" />
+ <MemberSignature Language="C#" Value="public string Help { set; get; }" />
<MemberSignature Language="ILAsm" Value=".property instance string Help" />
<MemberType>Property</MemberType>
<AssemblyInfo>
@@ -67,7 +67,7 @@
</Docs>
</Member>
<Member MemberName="Title">
- <MemberSignature Language="C#" Value="public string Title { get; set; }" />
+ <MemberSignature Language="C#" Value="public string Title { set; get; }" />
<MemberSignature Language="ILAsm" Value=".property instance string Title" />
<MemberType>Property</MemberType>
<AssemblyInfo>
@@ -83,7 +83,7 @@
</Docs>
</Member>
<Member MemberName="Width">
- <MemberSignature Language="C#" Value="public int Width { get; set; }" />
+ <MemberSignature Language="C#" Value="public int Width { set; get; }" />
<MemberSignature Language="ILAsm" Value=".property instance int32 Width" />
<MemberType>Property</MemberType>
<AssemblyInfo>
View
2 docs/Mono.Terminal/TrimLabel.xml
@@ -63,7 +63,7 @@
</Docs>
</Member>
<Member MemberName="Text">
- <MemberSignature Language="C#" Value="public override string Text { get; set; }" />
+ <MemberSignature Language="C#" Value="public override string Text { set; get; }" />
<MemberSignature Language="ILAsm" Value=".property instance string Text" />
<MemberType>Property</MemberType>
<AssemblyInfo>
View
4 docs/Mono.Terminal/Widget.xml
@@ -87,7 +87,7 @@
</Docs>
</Member>
<Member MemberName="CanFocus">
- <MemberSignature Language="C#" Value="public bool CanFocus { get; set; }" />
+ <MemberSignature Language="C#" Value="public bool CanFocus { set; get; }" />
<MemberSignature Language="ILAsm" Value=".property instance bool CanFocus" />
<MemberType>Property</MemberType>
<AssemblyInfo>
@@ -381,7 +381,7 @@
</Docs>
</Member>
<Member MemberName="HasFocus">
- <MemberSignature Language="C#" Value="public virtual bool HasFocus { get; set; }" />
+ <MemberSignature Language="C#" Value="public virtual bool HasFocus { set; get; }" />
<MemberSignature Language="ILAsm" Value=".property instance bool HasFocus" />
<MemberType>Property</MemberType>
<AssemblyInfo>
View
1 docs/index.xml
@@ -49,6 +49,7 @@
<Type Name="MenuBarItem" Kind="Class" />
<Type Name="MenuItem" Kind="Class" />
<Type Name="MessageBox" Kind="Class" />
+ <Type Name="RunState" Kind="Class" />
<Type Name="Screen" Kind="Class" />
<Type Name="TrimLabel" Kind="Class" />
<Type Name="Widget" Kind="Class" />
View
149 gui.cs
@@ -4,7 +4,7 @@
// Authors:
// Miguel de Icaza (miguel.de.icaza@gmail.com)
//
-// Copyright (C) 2007 Novell (http://www.novell.com)
+// Copyright (C) 2007-2011 Novell (http://www.novell.com)
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
@@ -2424,22 +2424,6 @@ public class Application {
public static int ColorMenuHot;
/// <summary>
- /// The time before we timeout on a curses call.
- /// </summary>
- /// <remarks>
- /// This is needed for applications that need to
- /// poll or update other bits of information at
- /// specified intervals.
- /// <para>The default value -1, means to wait until
- /// an event is ready. If the value is zero, then
- /// events are only processed if they are available,
- /// otherwise it is timeout in milliseconds to wait
- /// for an event to arrive before running an
- /// iteration on the main loop. See <see cref="Iteration"/>.</para>
- /// </remarks>
- static public int Timeout = -1;
-
- /// <summary>
/// This event is raised on each iteration of the
/// main loop.
/// </summary>
@@ -2493,6 +2477,10 @@ public static int MakeColor (short f, short b)
/// </summary>
public static void Init (bool disable_color)
{
+ if (inited)
+ return;
+ inited = true;
+
empty_container = new Container (0, 0, Application.Cols, Application.Lines);
try {
@@ -2501,10 +2489,10 @@ public static void Init (bool disable_color)
Console.WriteLine ("Curses failed to initialize, the exception is: " + e);
throw new Exception ("Application.Init failed");
}
-
- if (inited)
- return;
- inited = true;
+ Curses.raw ();
+ Curses.noecho ();
+ //Curses.nonl ();
+ Window.Standard.keypad (true);
#if BREAK_UTF8_RENDERING
Curses.Event old = 0;
@@ -2591,14 +2579,6 @@ public static void Init (bool disable_color)
}
}
- static void InitApp ()
- {
- Curses.raw ();
- Curses.noecho ();
- //Curses.nonl ();
- Window.Standard.keypad (true);
- }
-
/// <summary>
/// Displays a message on a modal dialog box.
/// </summary>
@@ -2717,20 +2697,27 @@ public static void Refresh ()
}
/// <summary>
- /// Runs the main loop on the given container.
+ /// Starts running a new container or dialog box.
/// </summary>
/// <remarks>
- /// This method is used to start processing events
- /// for the main application, but it is also used to
- /// run modal dialog boxes.
+ /// Use this method if you want to start the dialog, but
+ /// you want to control the main loop execution manually
+ /// by calling the RunLoop method (for example, to start
+ /// the dialog, but continuing to process events).
+ ///
+ /// Use the returned value as the argument to RunLoop
+ /// and later to the End method to remove the container
+ /// from the screen.
/// </remarks>
- static public void Run (Container container)
+ static public RunState Begin (Container container)
{
+ if (container == null)
+ throw new ArgumentNullException ("container");
+ var rs = new RunState (container);
+
Init (false);
Curses.timeout (-1);
- if (toplevels.Count == 0)
- InitApp ();
toplevels.Add (container);
@@ -2739,20 +2726,83 @@ static public void Run (Container container)
container.FocusFirst ();
Redraw (container);
container.PositionCursor ();
+ Curses.refresh ();
- Curses.timeout (Timeout);
+ return rs;
+ }
- container.Running = true;
- for (container.Running = true; container.Running && mainloop.EventsPending (true); ){
- mainloop.MainIteration ();
- if (Iteration != null)
- Iteration (null, EventArgs.Empty);
+ /// <summary>
+ /// Runs the main loop for the created dialog
+ /// </summary>
+ /// <remarks>
+ /// Calling this method will block until the
+ /// dialog has completed execution.
+ /// </remarks>
+ public static void RunLoop (RunState state)
+ {
+ RunLoop (state, true);
+ }
+
+ /// <summary>
+ /// Runs the main loop for the created dialog
+ /// </summary>
+ /// <remarks>
+ /// Use the wait parameter to control whether this is a
+ /// blocking or non-blocking call.
+ /// </remarks>
+ public static void RunLoop (RunState state, bool wait)
+ {
+ if (state == null)
+ throw new ArgumentNullException ("state");
+ if (state.Container == null)
+ throw new ObjectDisposedException ("state");
+
+ for (state.Container.Running = true; state.Container.Running; ){
+ if (mainloop.EventsPending (wait)){
+ mainloop.MainIteration ();
+ if (Iteration != null)
+ Iteration (null, EventArgs.Empty);
+ } else if (wait == false)
+ return;
}
- toplevels.Remove (container);
+ }
+
+ public static void Stop ()
+ {
+ if (toplevels.Count == 0)
+ return;
+ toplevels [toplevels.Count-1].Running = false;
+ MainLoop.Stop ();
+ }
+
+ /// <summary>
+ /// Runs the main loop on the given container.
+ /// </summary>
+ /// <remarks>
+ /// This method is used to start processing events
+ /// for the main application, but it is also used to
+ /// run modal dialog boxes.
+ /// </remarks>
+ static public void Run (Container container)
+ {
+ var runToken = Begin (container);
+ RunLoop (runToken);
+ End (runToken);
+ }
+
+ /// <summary>
+ /// Use this method to complete an execution started with Begin
+ /// </summary>
+ static public void End (RunState state)
+ {
+ if (state == null)
+ throw new ArgumentNullException ("state");
+ toplevels.Remove (state.Container);
if (toplevels.Count == 0)
Shutdown ();
else
Refresh ();
+ state.Container = null;
}
static void ProcessChar (Container container)
@@ -2782,7 +2832,7 @@ static void ProcessChar (Container container)
int k = Curses.getch ();
if (k != Curses.ERR && k != 27)
ch = Curses.KeyAlt | k;
- Curses.timeout (Timeout);
+ Curses.timeout (-1);
}
if (container.ProcessHotKey (ch))
@@ -2813,11 +2863,20 @@ static void ProcessChar (Container container)
if (ch == 9 || ch == Curses.KeyDown || ch == Curses.KeyRight){
if (!container.FocusNext ())
container.FocusNext ();
+ Curses.refresh ();
} else if (ch == Curses.KeyUp || ch == Curses.KeyLeft){
if (!container.FocusPrev ())
container.FocusPrev ();
+ Curses.refresh ();
}
}
-
+ }
+
+ public class RunState {
+ internal RunState (Container container)
+ {
+ Container = container;
+ }
+ internal Container Container;
}
}
View
72 mainloop.cs
@@ -28,6 +28,7 @@
using Mono.Unix.Native;
using System.Collections.Generic;
using System;
+using System.Runtime.InteropServices;
namespace Mono.Terminal {
@@ -77,21 +78,65 @@ class Timeout {
public TimeSpan Span;
public Func<MainLoop,bool> Callback;
}
-
+
Dictionary <int, Watch> descriptorWatchers = new Dictionary<int,Watch>();
SortedList <double, Timeout> timeouts = new SortedList<double,Timeout> ();
+ List<Func<bool>> idleHandlers = new List<Func<bool>> ();
Pollfd [] pollmap;
bool poll_dirty = true;
+ int [] wakeupPipes = new int [2];
+ static IntPtr ignore = Marshal.AllocHGlobal (1);
/// <summary>
/// Default constructor
/// </summary>
public MainLoop ()
{
+ Syscall.pipe (wakeupPipes);
@txdv
txdv Mar 12, 2011

getch doesn't return only characters from stdin, but special characters like KEY_RESIZE as well, which indicate that the terminal for example has been resized.

+ AddWatch (wakeupPipes [0], Condition.PollIn, ml => {
+ Syscall.read (wakeupPipes [0], ignore, 1);
+ return true;
+ });
+ }
+
+ void Wakeup ()
+ {
+ Syscall.write (wakeupPipes [1], ignore, 1);
+ }
+
+ /// <summary>
+ /// Runs @action on the thread that is processing events
+ /// </summary>
+ public void Invoke (Action action)
+ {
+ AddIdle (()=> {
+ action ();
+ return false;
+ });
+ Wakeup ();
+ }
+
+ /// <summary>
+ /// Executes the specified @idleHandler on the idle loop. The return value is a token to remove it.
+ /// </summary>
+ public Func<bool> AddIdle (Func<bool> idleHandler)
+ {
+ lock (idleHandlers)
+ idleHandlers.Add (idleHandler);
+ return idleHandler;
}
/// <summary>
+ /// Removes the specified idleHandler from processing.
+ /// </summary>
+ public void RemoveIdle (Func<bool> idleHandler)
+ {
+ lock (idleHandler)
+ idleHandlers.Remove (idleHandler);
+ }
+
+ /// <summary>
/// Watches a file descriptor for activity.
/// </summary>
/// <remarks>
@@ -225,6 +270,21 @@ void RunTimers ()
AddTimeout (timeout.Span, timeout);
}
+ void RunIdle ()
+ {
+ List<Func<bool>> iterate;
+ lock (idleHandlers){
+ iterate = idleHandlers;
+ idleHandlers = new List<Func<bool>> ();
+ }
+
+ foreach (var idle in iterate){
+ if (idle ())
+ lock (idleHandlers)
+ idleHandlers.Add (idle);
+ }
+ }
+
bool running;
/// <summary>
@@ -233,6 +293,7 @@ void RunTimers ()
public void Stop ()
{
running = false;
+ Wakeup ();
}
/// <summary>
@@ -258,9 +319,12 @@ public bool EventsPending (bool wait = false)
UpdatePollMap ();
n = Syscall.poll (pollmap, (uint) pollmap.Length, pollTimeout);
- return n > 0 || timeouts.Count > 0 && ((timeouts.Keys [0] - DateTime.UtcNow.Ticks) < 0);
+ int ic;
+ lock (idleHandlers)
+ ic = idleHandlers.Count;
+ return n > 0 || timeouts.Count > 0 && ((timeouts.Keys [0] - DateTime.UtcNow.Ticks) < 0) || ic > 0;
}
-
+
/// <summary>
/// Runs one iteration of timers and file watches
/// </summary>
@@ -286,6 +350,8 @@ public void MainIteration ()
if (!watch.Callback (this))
descriptorWatchers.Remove (p.fd);
}
+ if (idleHandlers.Count > 0)
+ RunIdle ();
}
/// <summary>
View
11 test.cs
@@ -13,6 +13,17 @@ static void Main ()
// Recommended
Curses.nonl ();
+ Curses.addch ('ó');
+ Curses.addch ('ó');
+ Curses.addch ('ó');
+ Curses.addch ('ó');
+ Curses.addch ('ó');
+ Curses.addch ('ó');
+ Curses.addch ('ó');
+ Curses.addstr ("acción");
+ Curses.refresh ();
+ Curses.getch ();
+
Window.Standard.intrflush (false);
Window.Standard.keypad (true);

0 comments on commit 17331dc

Please sign in to comment.