Added alternatescreen functionalilty, and added options to terminate the current process. also added write option to the terminal module

This commit is contained in:
TimonPost 2018-07-01 22:40:07 +02:00
parent 621d698ac6
commit 4a943c124e
38 changed files with 952 additions and 569 deletions

View File

@ -2,10 +2,41 @@
<project version="4"> <project version="4">
<component name="ChangeListManager"> <component name="ChangeListManager">
<list default="true" id="310aeab2-4737-4e8e-b7eb-0aac10d104a3" name="Default" comment=""> <list default="true" id="310aeab2-4737-4e8e-b7eb-0aac10d104a3" name="Default" comment="">
<change afterPath="$PROJECT_DIR$/examples/Crossterm 0.2.2 - New Version (Not finished)/program_examples/first_depth_search/map.rs" afterDir="false" />
<change afterPath="$PROJECT_DIR$/examples/Crossterm 0.2.2 - New Version (Not finished)/program_examples/first_depth_search/mod.rs" afterDir="false" />
<change afterPath="$PROJECT_DIR$/examples/Crossterm 0.2.2 - New Version (Not finished)/program_examples/first_depth_search/variables.rs" afterDir="false" />
<change afterPath="$PROJECT_DIR$/examples/Crossterm 0.2.2 - New Version (Not finished)/program_examples/mod.rs" afterDir="false" />
<change afterPath="$PROJECT_DIR$/src/shared/environment.rs" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" /> <change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/examples/Crossterm 0.2.2 - New Version (Not finished)/bin.rs" beforeDir="false" afterPath="$PROJECT_DIR$/examples/Crossterm 0.2.2 - New Version (Not finished)/bin.rs" afterDir="false" />
<change beforePath="$PROJECT_DIR$/examples/Crossterm 0.2.2 - New Version (Not finished)/color/mod.rs" beforeDir="false" afterPath="$PROJECT_DIR$/examples/Crossterm 0.2.2 - New Version (Not finished)/color/mod.rs" afterDir="false" />
<change beforePath="$PROJECT_DIR$/examples/Crossterm 0.2.2 - New Version (Not finished)/cursor/mod.rs" beforeDir="false" afterPath="$PROJECT_DIR$/examples/Crossterm 0.2.2 - New Version (Not finished)/cursor/mod.rs" afterDir="false" />
<change beforePath="$PROJECT_DIR$/examples/Crossterm 0.2.2 - New Version (Not finished)/terminal/alternate_screen.rs" beforeDir="false" afterPath="$PROJECT_DIR$/examples/Crossterm 0.2.2 - New Version (Not finished)/terminal/alternate_screen.rs" afterDir="false" />
<change beforePath="$PROJECT_DIR$/examples/Crossterm 0.2.2 - New Version (Not finished)/terminal/mod.rs" beforeDir="false" afterPath="$PROJECT_DIR$/examples/Crossterm 0.2.2 - New Version (Not finished)/terminal/mod.rs" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/cursor/cursor.rs" beforeDir="false" afterPath="$PROJECT_DIR$/src/cursor/cursor.rs" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/cursor/winapi_cursor.rs" beforeDir="false" afterPath="$PROJECT_DIR$/src/cursor/winapi_cursor.rs" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/kernel/windows_kernel/ansi_support.rs" beforeDir="false" afterPath="$PROJECT_DIR$/src/kernel/windows_kernel/ansi_support.rs" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/kernel/windows_kernel/cursor.rs" beforeDir="false" afterPath="$PROJECT_DIR$/src/kernel/windows_kernel/cursor.rs" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/kernel/windows_kernel/kernel.rs" beforeDir="false" afterPath="$PROJECT_DIR$/src/kernel/windows_kernel/kernel.rs" afterDir="false" /> <change beforePath="$PROJECT_DIR$/src/kernel/windows_kernel/kernel.rs" beforeDir="false" afterPath="$PROJECT_DIR$/src/kernel/windows_kernel/kernel.rs" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/kernel/windows_kernel/terminal.rs" beforeDir="false" afterPath="$PROJECT_DIR$/src/kernel/windows_kernel/terminal.rs" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/lib.rs" beforeDir="false" afterPath="$PROJECT_DIR$/src/lib.rs" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/manager/manager.rs" beforeDir="false" afterPath="$PROJECT_DIR$/src/manager/manager.rs" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/manager/mod.rs" beforeDir="false" afterPath="$PROJECT_DIR$/src/manager/mod.rs" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/manager/win_manager.rs" beforeDir="false" afterPath="$PROJECT_DIR$/src/manager/win_manager.rs" afterDir="false" /> <change beforePath="$PROJECT_DIR$/src/manager/win_manager.rs" beforeDir="false" afterPath="$PROJECT_DIR$/src/manager/win_manager.rs" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/shared/functions.rs" beforeDir="false" afterPath="$PROJECT_DIR$/src/shared/functions.rs" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/shared/mod.rs" beforeDir="false" afterPath="$PROJECT_DIR$/src/shared/mod.rs" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/shared/raw.rs" beforeDir="false" afterPath="$PROJECT_DIR$/src/shared/raw.rs" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/shared/screen.rs" beforeDir="false" afterPath="$PROJECT_DIR$/src/shared/screen.rs" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/state/commands/shared_commands.rs" beforeDir="false" afterPath="$PROJECT_DIR$/src/state/commands/shared_commands.rs" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/state/commands/win_commands.rs" beforeDir="false" afterPath="$PROJECT_DIR$/src/state/commands/win_commands.rs" afterDir="false" /> <change beforePath="$PROJECT_DIR$/src/state/commands/win_commands.rs" beforeDir="false" afterPath="$PROJECT_DIR$/src/state/commands/win_commands.rs" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/state/context.rs" beforeDir="false" afterPath="$PROJECT_DIR$/src/state/context.rs" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/state/state_manager.rs" beforeDir="false" afterPath="$PROJECT_DIR$/src/state/state_manager.rs" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/style/color/color.rs" beforeDir="false" afterPath="$PROJECT_DIR$/src/style/color/color.rs" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/style/color/winapi_color.rs" beforeDir="false" afterPath="$PROJECT_DIR$/src/style/color/winapi_color.rs" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/style/styles/objectstyle.rs" beforeDir="false" afterPath="$PROJECT_DIR$/src/style/styles/objectstyle.rs" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/terminal/ansi_terminal.rs" beforeDir="false" afterPath="$PROJECT_DIR$/src/terminal/ansi_terminal.rs" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/terminal/terminal.rs" beforeDir="false" afterPath="$PROJECT_DIR$/src/terminal/terminal.rs" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/terminal/winapi_terminal.rs" beforeDir="false" afterPath="$PROJECT_DIR$/src/terminal/winapi_terminal.rs" afterDir="false" />
</list> </list>
<option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" /> <option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" />
<option name="TRACKING_ENABLED" value="true" /> <option name="TRACKING_ENABLED" value="true" />
@ -16,15 +47,38 @@
</component> </component>
<component name="FileEditorManager"> <component name="FileEditorManager">
<leaf SIDE_TABS_SIZE_LIMIT_KEY="300"> <leaf SIDE_TABS_SIZE_LIMIT_KEY="300">
<file leaf-file-name="win_manager.rs" pinned="false" current-in-tab="false"> <file leaf-file-name="cursor.rs" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/src/manager/win_manager.rs"> <entry file="file://$PROJECT_DIR$/src/cursor/cursor.rs">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="672"> <state relative-caret-position="408">
<caret line="63" column="21" selection-start-line="63" selection-start-column="11" selection-end-line="63" selection-end-column="21" /> <caret line="313" column="11" selection-start-line="313" selection-start-column="11" selection-end-line="313" selection-end-column="11" />
<folding> </state>
<element signature="e#1321#1322#0" expanded="true" /> </provider>
<element signature="e#1377#1378#0" expanded="true" /> </entry>
</folding> </file>
<file leaf-file-name="bin.rs" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/examples/Crossterm 0.2.2 - New Version (Not finished)/bin.rs">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="459">
<caret line="27" column="61" selection-start-line="27" selection-start-column="61" selection-end-line="27" selection-end-column="61" />
</state>
</provider>
</entry>
</file>
<file leaf-file-name="winapi_cursor.rs" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/src/cursor/winapi_cursor.rs">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="498">
<caret line="66" column="25" selection-start-line="66" selection-start-column="25" selection-end-line="66" selection-end-column="25" />
</state>
</provider>
</entry>
</file>
<file leaf-file-name="alternate_screen.rs" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/examples/Crossterm 0.2.2 - New Version (Not finished)/terminal/alternate_screen.rs">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="204">
<caret line="18" column="13" selection-start-line="18" selection-start-column="13" selection-end-line="18" selection-end-column="13" />
</state> </state>
</provider> </provider>
</entry> </entry>
@ -32,8 +86,17 @@
<file leaf-file-name="screen.rs" pinned="false" current-in-tab="false"> <file leaf-file-name="screen.rs" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/src/shared/screen.rs"> <entry file="file://$PROJECT_DIR$/src/shared/screen.rs">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="604"> <state relative-caret-position="340">
<caret line="93" selection-start-line="93" selection-end-line="93" /> <caret line="26" column="11" selection-start-line="26" selection-start-column="11" selection-end-line="26" selection-end-column="11" />
</state>
</provider>
</entry>
</file>
<file leaf-file-name="terminal.rs" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/src/terminal/terminal.rs">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="742">
<caret line="197" column="11" selection-start-line="197" selection-start-column="11" selection-end-line="197" selection-end-column="11" />
</state> </state>
</provider> </provider>
</entry> </entry>
@ -41,8 +104,8 @@
<file leaf-file-name="kernel.rs" pinned="false" current-in-tab="true"> <file leaf-file-name="kernel.rs" pinned="false" current-in-tab="true">
<entry file="file://$PROJECT_DIR$/src/kernel/windows_kernel/kernel.rs"> <entry file="file://$PROJECT_DIR$/src/kernel/windows_kernel/kernel.rs">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="612"> <state relative-caret-position="540">
<caret line="36" column="32" lean-forward="true" selection-start-line="36" selection-start-column="32" selection-end-line="36" selection-end-column="32" /> <caret line="203" column="5" selection-start-line="203" selection-start-column="5" selection-end-line="203" selection-end-column="5" />
</state> </state>
</provider> </provider>
</entry> </entry>
@ -52,56 +115,20 @@
<provider selected="true" editor-type-id="text-editor" /> <provider selected="true" editor-type-id="text-editor" />
</entry> </entry>
</file> </file>
<file leaf-file-name="styledobject.rs" pinned="false" current-in-tab="false"> <file leaf-file-name="winapi_color.rs" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/src/style/styles/styledobject.rs"> <entry file="file://$PROJECT_DIR$/src/style/color/winapi_color.rs">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="641"> <state relative-caret-position="158">
<caret line="149" column="17" selection-start-line="149" selection-start-column="17" selection-end-line="149" selection-end-column="17" /> <caret line="64" column="69" selection-start-line="64" selection-start-column="69" selection-end-line="64" selection-end-column="69" />
</state> </state>
</provider> </provider>
</entry> </entry>
</file> </file>
<file leaf-file-name="cursor.rs" pinned="false" current-in-tab="false"> <file leaf-file-name="ansi_terminal.rs" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/src/kernel/windows_kernel/cursor.rs"> <entry file="file://$PROJECT_DIR$/src/terminal/ansi_terminal.rs">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="34"> <state relative-caret-position="391">
<caret line="2" column="18" selection-start-line="2" selection-start-column="18" selection-end-line="2" selection-end-column="18" /> <caret line="45" column="66" selection-start-line="45" selection-start-column="66" selection-end-line="45" selection-end-column="66" />
</state>
</provider>
</entry>
</file>
<file leaf-file-name="alternate_screen.rs" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/examples/Crossterm 0.2.2 - New Version (Not finished)/terminal/alternate_screen.rs">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="638">
<caret line="74" column="52" selection-start-line="74" selection-start-column="52" selection-end-line="74" selection-end-column="52" />
</state>
</provider>
</entry>
</file>
<file leaf-file-name="unix_command.rs" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/src/state/commands/unix_command.rs">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="600">
<caret line="40" column="9" selection-start-line="40" selection-start-column="9" selection-end-line="40" selection-end-column="9" />
</state>
</provider>
</entry>
</file>
<file leaf-file-name="win_commands.rs" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/src/state/commands/win_commands.rs">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="424">
<caret line="193" column="10" selection-start-line="187" selection-start-column="7" selection-end-line="193" selection-end-column="10" />
</state>
</provider>
</entry>
</file>
<file leaf-file-name="bin.rs" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/examples/Crossterm 0.2.2 - New Version (Not finished)/bin.rs">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="629">
<caret line="37" column="1" selection-start-line="37" selection-start-column="1" selection-end-line="37" selection-end-column="1" />
</state> </state>
</provider> </provider>
</entry> </entry>
@ -117,11 +144,6 @@
</component> </component>
<component name="FindInProjectRecents"> <component name="FindInProjectRecents">
<findStrings> <findStrings>
<find>cursor(</find>
<find>IStateCommand</find>
<find>execute</find>
<find>functions</find>
<find>set</find>
<find>cursor_vis</find> <find>cursor_vis</find>
<find>write</find> <find>write</find>
<find>ToAlternateScreenBufferCommand</find> <find>ToAlternateScreenBufferCommand</find>
@ -141,12 +163,17 @@
<find>fmt</find> <find>fmt</find>
<find>STD_OUTPUT_HANDLE</find> <find>STD_OUTPUT_HANDLE</find>
<find>data</find> <find>data</find>
<find>context</find>
<find>WinApiScreenManager</find> <find>WinApiScreenManager</find>
<find>color(</find> <find>color(</find>
<find>d</find> <find>d</find>
<find>srct_read_rect</find> <find>srct_read_rect</find>
<find>get_output_handle();</find> <find>get_output_handle();</find>
<find>color</find>
<find>super::</find>
<find>get_current_ha</find>
<find>csbi</find>
<find>context</find>
<find>terminal_size</find>
</findStrings> </findStrings>
<replaceStrings> <replaceStrings>
<replace>crossterm_cursor</replace> <replace>crossterm_cursor</replace>
@ -170,56 +197,56 @@
<component name="IdeDocumentHistory"> <component name="IdeDocumentHistory">
<option name="CHANGED_PATHS"> <option name="CHANGED_PATHS">
<list> <list>
<option value="$PROJECT_DIR$/src/terminal/screen.rs" />
<option value="$PROJECT_DIR$/src/shared/terminal.rs" />
<option value="$PROJECT_DIR$/src/terminal/raw.rs" />
<option value="$PROJECT_DIR$/examples/Crossterm 0.2.2 - New Version (Not finished)/terminal/mod.rs" />
<option value="$PROJECT_DIR$/src/state/mod.rs" />
<option value="$PROJECT_DIR$/src/shared/mod.rs" />
<option value="$PROJECT_DIR$/src/style/styles/mod.rs" />
<option value="$PROJECT_DIR$/src/style/color/mod.rs" />
<option value="$PROJECT_DIR$/src/kernel/windows_kernel/handle.rs" />
<option value="$PROJECT_DIR$/src/kernel/windows_kernel/mod.rs" />
<option value="$PROJECT_DIR$/src/shared/traits.rs" />
<option value="$PROJECT_DIR$/src/style/color/ansi_color.rs" />
<option value="$PROJECT_DIR$/src/style/mod.rs" /> <option value="$PROJECT_DIR$/src/style/mod.rs" />
<option value="$PROJECT_DIR$/src/style/color/winapi_color.rs" />
<option value="$PROJECT_DIR$/src/lib.rs" />
<option value="$PROJECT_DIR$/src/style/color/color.rs" />
<option value="$PROJECT_DIR$/src/shared/raw.rs" />
<option value="$PROJECT_DIR$/src/state/command_manager.rs" /> <option value="$PROJECT_DIR$/src/state/command_manager.rs" />
<option value="$PROJECT_DIR$/examples/Crossterm 0.2.2 - New Version (Not finished)/terminal/raw_mode.rs" /> <option value="$PROJECT_DIR$/examples/Crossterm 0.2.2 - New Version (Not finished)/terminal/raw_mode.rs" />
<option value="$PROJECT_DIR$/src/manager/mod.rs" />
<option value="$PROJECT_DIR$/src/kernel/windows_kernel/cursor.rs" />
<option value="$PROJECT_DIR$/src/kernel/windows_kernel/ansi_support.rs" />
<option value="$PROJECT_DIR$/src/state/commands/mod.rs" /> <option value="$PROJECT_DIR$/src/state/commands/mod.rs" />
<option value="$PROJECT_DIR$/src/state/context.rs" />
<option value="$PROJECT_DIR$/src/style/styles/objectstyle.rs" />
<option value="$PROJECT_DIR$/src/state/state_manager.rs" />
<option value="$PROJECT_DIR$/src/manager/ansi_manager.rs" /> <option value="$PROJECT_DIR$/src/manager/ansi_manager.rs" />
<option value="$PROJECT_DIR$/src/cursor/mod.rs" /> <option value="$PROJECT_DIR$/src/cursor/mod.rs" />
<option value="$PROJECT_DIR$/src/cursor/winapi_cursor.rs" />
<option value="$PROJECT_DIR$/src/state/commands/shared_commands.rs" />
<option value="$PROJECT_DIR$/src/state/commands/unix_command.rs" /> <option value="$PROJECT_DIR$/src/state/commands/unix_command.rs" />
<option value="$PROJECT_DIR$/examples/Crossterm 0.2.2 - New Version (Not finished)/color/mod.rs" />
<option value="$PROJECT_DIR$/src/shared/functions.rs" />
<option value="$PROJECT_DIR$/src/kernel/windows_kernel/terminal.rs" />
<option value="$PROJECT_DIR$/src/cursor/ansi_cursor.rs" /> <option value="$PROJECT_DIR$/src/cursor/ansi_cursor.rs" />
<option value="$PROJECT_DIR$/src/cursor/cursor.rs" />
<option value="$PROJECT_DIR$/src/kernel/unix_kernel/terminal.rs" /> <option value="$PROJECT_DIR$/src/kernel/unix_kernel/terminal.rs" />
<option value="$PROJECT_DIR$/src/terminal/terminal.rs" />
<option value="$PROJECT_DIR$/src/terminal/ansi_terminal.rs" />
<option value="$PROJECT_DIR$/src/terminal/winapi_terminal.rs" />
<option value="$PROJECT_DIR$/src/terminal/mod.rs" /> <option value="$PROJECT_DIR$/src/terminal/mod.rs" />
<option value="$PROJECT_DIR$/examples/Crossterm 0.2.2 - New Version (Not finished)/terminal/alternate_screen.rs" />
<option value="$PROJECT_DIR$/examples/Crossterm 0.2.2 - New Version (Not finished)/terminal/terminal.rs" /> <option value="$PROJECT_DIR$/examples/Crossterm 0.2.2 - New Version (Not finished)/terminal/terminal.rs" />
<option value="$PROJECT_DIR$/examples/Crossterm 0.2.2 - New Version (Not finished)/cursor/mod.rs" />
<option value="$PROJECT_DIR$/src/manager/manager.rs" />
<option value="$PROJECT_DIR$/src/shared/screen.rs" />
<option value="$PROJECT_DIR$/src/style/styles/styledobject.rs" /> <option value="$PROJECT_DIR$/src/style/styles/styledobject.rs" />
<option value="$PROJECT_DIR$/src/shared/raw.rs" />
<option value="$PROJECT_DIR$/examples/Crossterm 0.2.2 - New Version (Not finished)/terminal/mod.rs" />
<option value="$PROJECT_DIR$/examples/Crossterm 0.2.2 - New Version (Not finished)/color/mod.rs" />
<option value="$PROJECT_DIR$/examples/Crossterm 0.2.2 - New Version (Not finished)/cursor/mod.rs" />
<option value="$PROJECT_DIR$/examples/Crossterm 0.2.2 - New Version (Not finished)/games/README.md" />
<option value="$PROJECT_DIR$/src/kernel/windows_kernel/ansi_support.rs" />
<option value="$PROJECT_DIR$/src/state/commands/shared_commands.rs" />
<option value="$PROJECT_DIR$/src/manager/mod.rs" />
<option value="$PROJECT_DIR$/src/state/state_manager.rs" />
<option value="$PROJECT_DIR$/src/state/context.rs" />
<option value="$PROJECT_DIR$/examples/Crossterm 0.2.2 - New Version (Not finished)/games/FirstDepthSearch/main.rs" />
<option value="$PROJECT_DIR$/examples/Crossterm 0.2.2 - New Version (Not finished)/program_examples/first_depth_search/Cargo.toml" />
<option value="$PROJECT_DIR$/examples/Crossterm 0.2.2 - New Version (Not finished)/program_examples/first_depth_search/src/main.rs" />
<option value="$PROJECT_DIR$/src/shared/screen.rs" />
<option value="$PROJECT_DIR$/examples/Crossterm 0.2.2 - New Version (Not finished)/bin.rs" /> <option value="$PROJECT_DIR$/examples/Crossterm 0.2.2 - New Version (Not finished)/bin.rs" />
<option value="$PROJECT_DIR$/src/state/commands/win_commands.rs" /> <option value="$PROJECT_DIR$/src/shared/mod.rs" />
<option value="$PROJECT_DIR$/src/shared/envoirment.rs" />
<option value="$PROJECT_DIR$/src/lib.rs" />
<option value="$PROJECT_DIR$/src/style/styles/objectstyle.rs" />
<option value="$PROJECT_DIR$/examples/Crossterm 0.2.2 - New Version (Not finished)/program_examples/first_depth_search/mod.rs" />
<option value="$PROJECT_DIR$/src/shared/environment.rs" />
<option value="$PROJECT_DIR$/examples/Crossterm 0.2.2 - New Version (Not finished)/program_examples/first_depth_search/variables.rs" />
<option value="$PROJECT_DIR$/examples/Crossterm 0.2.2 - New Version (Not finished)/program_examples/first_depth_search/map.rs" />
<option value="$PROJECT_DIR$/examples/Crossterm 0.2.2 - New Version (Not finished)/program_examples/mod.rs" />
<option value="$PROJECT_DIR$/src/manager/manager.rs" />
<option value="$PROJECT_DIR$/src/terminal/terminal.rs" />
<option value="$PROJECT_DIR$/src/cursor/cursor.rs" />
<option value="$PROJECT_DIR$/src/kernel/windows_kernel/cursor.rs" />
<option value="$PROJECT_DIR$/src/cursor/winapi_cursor.rs" />
<option value="$PROJECT_DIR$/src/manager/win_manager.rs" /> <option value="$PROJECT_DIR$/src/manager/win_manager.rs" />
<option value="$PROJECT_DIR$/src/terminal/winapi_terminal.rs" />
<option value="$PROJECT_DIR$/src/style/color/color.rs" />
<option value="$PROJECT_DIR$/src/state/commands/win_commands.rs" />
<option value="$PROJECT_DIR$/src/kernel/windows_kernel/terminal.rs" />
<option value="$PROJECT_DIR$/src/shared/functions.rs" />
<option value="$PROJECT_DIR$/src/style/color/winapi_color.rs" />
<option value="$PROJECT_DIR$/src/terminal/ansi_terminal.rs" />
<option value="$PROJECT_DIR$/examples/Crossterm 0.2.2 - New Version (Not finished)/terminal/alternate_screen.rs" />
<option value="$PROJECT_DIR$/src/kernel/windows_kernel/kernel.rs" /> <option value="$PROJECT_DIR$/src/kernel/windows_kernel/kernel.rs" />
</list> </list>
</option> </option>
@ -234,8 +261,8 @@
<packageJsonPaths /> <packageJsonPaths />
</component> </component>
<component name="ProjectFrameBounds" extendedState="6"> <component name="ProjectFrameBounds" extendedState="6">
<option name="x" value="-8" /> <option name="x" value="-529" />
<option name="y" value="-8" /> <option name="y" value="-20" />
<option name="width" value="2576" /> <option name="width" value="2576" />
<option name="height" value="1056" /> <option name="height" value="1056" />
</component> </component>
@ -278,6 +305,13 @@
<item name="examples" type="462c0819:PsiDirectoryNode" /> <item name="examples" type="462c0819:PsiDirectoryNode" />
<item name="Crossterm 0.2.2 - New Version (Not finished)" type="462c0819:PsiDirectoryNode" /> <item name="Crossterm 0.2.2 - New Version (Not finished)" type="462c0819:PsiDirectoryNode" />
</path> </path>
<path>
<item name="crossterm" type="b2602c69:ProjectViewProjectNode" />
<item name="crossterm" type="462c0819:PsiDirectoryNode" />
<item name="examples" type="462c0819:PsiDirectoryNode" />
<item name="Crossterm 0.2.2 - New Version (Not finished)" type="462c0819:PsiDirectoryNode" />
<item name="color" type="462c0819:PsiDirectoryNode" />
</path>
<path> <path>
<item name="crossterm" type="b2602c69:ProjectViewProjectNode" /> <item name="crossterm" type="b2602c69:ProjectViewProjectNode" />
<item name="crossterm" type="462c0819:PsiDirectoryNode" /> <item name="crossterm" type="462c0819:PsiDirectoryNode" />
@ -285,6 +319,21 @@
<item name="Crossterm 0.2.2 - New Version (Not finished)" type="462c0819:PsiDirectoryNode" /> <item name="Crossterm 0.2.2 - New Version (Not finished)" type="462c0819:PsiDirectoryNode" />
<item name="cursor" type="462c0819:PsiDirectoryNode" /> <item name="cursor" type="462c0819:PsiDirectoryNode" />
</path> </path>
<path>
<item name="crossterm" type="b2602c69:ProjectViewProjectNode" />
<item name="crossterm" type="462c0819:PsiDirectoryNode" />
<item name="examples" type="462c0819:PsiDirectoryNode" />
<item name="Crossterm 0.2.2 - New Version (Not finished)" type="462c0819:PsiDirectoryNode" />
<item name="program_examples" type="462c0819:PsiDirectoryNode" />
</path>
<path>
<item name="crossterm" type="b2602c69:ProjectViewProjectNode" />
<item name="crossterm" type="462c0819:PsiDirectoryNode" />
<item name="examples" type="462c0819:PsiDirectoryNode" />
<item name="Crossterm 0.2.2 - New Version (Not finished)" type="462c0819:PsiDirectoryNode" />
<item name="program_examples" type="462c0819:PsiDirectoryNode" />
<item name="first_depth_search" type="462c0819:PsiDirectoryNode" />
</path>
<path> <path>
<item name="crossterm" type="b2602c69:ProjectViewProjectNode" /> <item name="crossterm" type="b2602c69:ProjectViewProjectNode" />
<item name="crossterm" type="462c0819:PsiDirectoryNode" /> <item name="crossterm" type="462c0819:PsiDirectoryNode" />
@ -354,6 +403,13 @@
<item name="src" type="462c0819:PsiDirectoryNode" /> <item name="src" type="462c0819:PsiDirectoryNode" />
<item name="style" type="462c0819:PsiDirectoryNode" /> <item name="style" type="462c0819:PsiDirectoryNode" />
</path> </path>
<path>
<item name="crossterm" type="b2602c69:ProjectViewProjectNode" />
<item name="crossterm" type="462c0819:PsiDirectoryNode" />
<item name="src" type="462c0819:PsiDirectoryNode" />
<item name="style" type="462c0819:PsiDirectoryNode" />
<item name="color" type="462c0819:PsiDirectoryNode" />
</path>
<path> <path>
<item name="crossterm" type="b2602c69:ProjectViewProjectNode" /> <item name="crossterm" type="b2602c69:ProjectViewProjectNode" />
<item name="crossterm" type="462c0819:PsiDirectoryNode" /> <item name="crossterm" type="462c0819:PsiDirectoryNode" />
@ -371,26 +427,26 @@
<select /> <select />
</subPane> </subPane>
</pane> </pane>
<pane id="Scope" />
<pane id="PackagesPane" /> <pane id="PackagesPane" />
<pane id="AndroidView" /> <pane id="AndroidView" />
<pane id="Scope" />
</panes> </panes>
</component> </component>
<component name="PropertiesComponent"> <component name="PropertiesComponent">
<property name="SearchEverywhereHistoryKey" value="&#9;FILE&#9;file://D:/Windows/GIT/crossterm/src/crossterm_state/commands/win_commands.rs" /> <property name="SearchEverywhereHistoryKey" value="&#9;FILE&#9;file://D:/Windows/GIT/crossterm/src/crossterm_state/commands/win_commands.rs" />
<property name="WebServerToolWindowFactoryState" value="false" /> <property name="WebServerToolWindowFactoryState" value="false" />
<property name="aspect.path.notification.shown" value="true" /> <property name="aspect.path.notification.shown" value="true" />
<property name="last_opened_file_path" value="$PROJECT_DIR$/../async_test" /> <property name="last_opened_file_path" value="$PROJECT_DIR$" />
<property name="org.rust.cargo.project.model.PROJECT_DISCOVERY" value="true" /> <property name="org.rust.cargo.project.model.PROJECT_DISCOVERY" value="true" />
<property name="settings.editor.selected.configurable" value="preferences.sourceCode.Rust" /> <property name="settings.editor.selected.configurable" value="preferences.sourceCode.Rust" />
</component> </component>
<component name="RecentsManager"> <component name="RecentsManager">
<key name="MoveFile.RECENT_KEYS"> <key name="MoveFile.RECENT_KEYS">
<recent name="C:\Users\Timon\Documents\Programming\rust\crossterm\examples\Crossterm 0.2.2 - New Version (Not finished)\program_examples\first_depth_search" />
<recent name="$PROJECT_DIR$/examples" /> <recent name="$PROJECT_DIR$/examples" />
<recent name="$PROJECT_DIR$/src/state" /> <recent name="$PROJECT_DIR$/src/state" />
<recent name="$PROJECT_DIR$/src/shared" /> <recent name="$PROJECT_DIR$/src/shared" />
<recent name="$PROJECT_DIR$/src/manager" /> <recent name="$PROJECT_DIR$/src/manager" />
<recent name="D:\Windows\GIT\crossterm\src\crossterm_terminal" />
</key> </key>
</component> </component>
<component name="RunDashboard"> <component name="RunDashboard">
@ -560,12 +616,18 @@
<workItem from="1529689699529" duration="6745000" /> <workItem from="1529689699529" duration="6745000" />
<workItem from="1529741655974" duration="14906000" /> <workItem from="1529741655974" duration="14906000" />
<workItem from="1530030893916" duration="6941000" /> <workItem from="1530030893916" duration="6941000" />
<workItem from="1530039628703" duration="4296000" /> <workItem from="1530039628703" duration="4384000" />
<workItem from="1530118776793" duration="7324000" />
<workItem from="1530203797893" duration="10260000" />
<workItem from="1530289442537" duration="10502000" />
<workItem from="1530344478032" duration="18289000" />
<workItem from="1530446561530" duration="7222000" />
<workItem from="1530473645162" duration="3874000" />
</task> </task>
<servers /> <servers />
</component> </component>
<component name="TimeTrackingManager"> <component name="TimeTrackingManager">
<option name="totallyTimeSpent" value="624139000" /> <option name="totallyTimeSpent" value="681698000" />
</component> </component>
<component name="ToolWindowManager"> <component name="ToolWindowManager">
<frame x="-8" y="-8" width="2576" height="1056" extended-state="6" /> <frame x="-8" y="-8" width="2576" height="1056" extended-state="6" />
@ -587,7 +649,7 @@
<window_info id="Designer" order="3" /> <window_info id="Designer" order="3" />
<window_info active="true" content_ui="combo" id="Project" order="0" visible="true" weight="0.1625" /> <window_info active="true" content_ui="combo" id="Project" order="0" visible="true" weight="0.1625" />
<window_info anchor="right" id="Database" order="6" /> <window_info anchor="right" id="Database" order="6" />
<window_info anchor="bottom" id="Find" order="1" sideWeight="0.496875" weight="0.20828906" /> <window_info anchor="bottom" id="Find" order="1" sideWeight="0.496875" visible="true" weight="0.1487779" />
<window_info id="Structure" order="1" side_tool="true" weight="0.25" /> <window_info id="Structure" order="1" side_tool="true" weight="0.25" />
<window_info anchor="right" id="Ant Build" order="1" weight="0.25" /> <window_info anchor="right" id="Ant Build" order="1" weight="0.25" />
<window_info id="UI Designer" order="4" /> <window_info id="UI Designer" order="4" />
@ -637,291 +699,289 @@
<option name="myLimit" value="2678400000" /> <option name="myLimit" value="2678400000" />
</component> </component>
<component name="editorHistoryManager"> <component name="editorHistoryManager">
<entry file="file://$USER_HOME$/.cargo/registry/src/github.com-1ecc6299db9ec823/winapi-0.3.5/src/um/wincon.rs" /> <entry file="file://$PROJECT_DIR$/examples/Crossterm 0.2.2 - New Version (Not finished)/terminal/mod.rs">
<entry file="file://$USER_HOME$/.rustup/toolchains/nightly-x86_64-pc-windows-msvc/lib/rustlib/src/rust/src/libcore/result.rs" />
<entry file="file://$USER_HOME$/.rustup/toolchains/nightly-x86_64-pc-windows-msvc/lib/rustlib/src/rust/src/libstd/ffi/c_str.rs" />
<entry file="file://$PROJECT_DIR$/src/lib.rs">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="306"> <state relative-caret-position="17">
<caret line="18" column="35" selection-start-line="18" selection-start-column="35" selection-end-line="18" selection-end-column="35" /> <caret line="1" column="114" selection-start-line="1" selection-start-column="114" selection-end-line="1" selection-end-column="114" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/examples/Crossterm 0.2.2 - New Version (Not finished)/terminal/raw_mode.rs">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="466">
<caret line="48" column="41" selection-start-line="48" selection-start-column="41" selection-end-line="48" selection-end-column="41" />
</state>
</provider>
</entry>
<entry file="file://$USER_HOME$/.rustup/toolchains/nightly-x86_64-pc-windows-msvc/lib/rustlib/src/rust/src/liballoc/boxed.rs" />
<entry file="file://$USER_HOME$/.cargo/registry/src/github.com-1ecc6299db9ec823/winapi-0.3.5/src/um/winnt.rs" />
<entry file="file://$PROJECT_DIR$/src/state/commands/mod.rs">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="493">
<caret line="29" column="108" selection-start-line="29" selection-start-column="108" selection-end-line="29" selection-end-column="108" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/style/styles/objectstyle.rs">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="85">
<caret line="5" column="22" selection-start-line="5" selection-start-column="22" selection-end-line="5" selection-end-column="22" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/shared/mod.rs">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="68">
<caret line="4" column="15" lean-forward="true" selection-start-line="4" selection-start-column="15" selection-end-line="4" selection-end-column="15" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/Cargo.toml">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="435">
<caret line="29" selection-start-line="29" selection-end-line="29" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/state/context.rs">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="119">
<caret line="7" column="18" selection-start-line="7" selection-start-column="11" selection-end-line="7" selection-end-column="18" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/kernel/windows_kernel/mod.rs">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="442">
<caret line="28" column="7" selection-start-line="28" selection-start-column="7" selection-end-line="28" selection-end-column="7" />
</state>
</provider>
</entry>
<entry file="file://$USER_HOME$/.rustup/toolchains/nightly-x86_64-pc-windows-msvc/lib/rustlib/src/rust/src/libcore/time.rs" />
<entry file="file://$PROJECT_DIR$/src/cursor/mod.rs">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="774">
<caret line="54" column="33" selection-start-line="54" selection-start-column="33" selection-end-line="54" selection-end-column="33" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/kernel/windows_kernel/ansi_support.rs">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="34">
<caret line="2" column="17" selection-start-line="2" selection-start-column="17" selection-end-line="2" selection-end-column="17" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/cursor/winapi_cursor.rs">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="740">
<caret line="64" selection-start-line="64" selection-end-line="64" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/shared/traits.rs">
<provider selected="true" editor-type-id="text-editor">
<state>
<caret selection-end-line="4" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/shared/macros.rs">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="34">
<caret line="2" column="13" selection-start-line="2" selection-start-column="13" selection-end-line="2" selection-end-column="13" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/state/command_manager.rs">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="360">
<caret line="24" selection-start-line="24" selection-end-line="24" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/manager/ansi_manager.rs">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="135">
<caret line="9" column="28" selection-start-line="9" selection-start-column="11" selection-end-line="9" selection-end-column="28" />
</state> </state>
</provider> </provider>
</entry> </entry>
<entry file="file://$PROJECT_DIR$/src/manager/mod.rs"> <entry file="file://$PROJECT_DIR$/src/manager/mod.rs">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="135"> <state relative-caret-position="408">
<caret line="9" column="29" selection-start-line="9" selection-start-column="29" selection-end-line="9" selection-end-column="29" /> <caret line="24" column="47" selection-start-line="24" selection-start-column="47" selection-end-line="24" selection-end-column="47" />
</state> </state>
</provider> </provider>
</entry> </entry>
<entry file="file://$PROJECT_DIR$/src/shared/raw.rs"> <entry file="file://$USER_HOME$/.rustup/toolchains/stable-x86_64-pc-windows-msvc/lib/rustlib/src/rust/src/libcore/ops/drop.rs">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="795"> <state relative-caret-position="204">
<caret line="53" column="61" selection-start-line="53" selection-start-column="61" selection-end-line="53" selection-end-column="61" /> <caret line="94" column="10" selection-start-line="94" selection-start-column="10" selection-end-line="94" selection-end-column="10" />
</state> </state>
</provider> </provider>
</entry> </entry>
<entry file="file://$PROJECT_DIR$/src/state/state_manager.rs"> <entry file="file://$PROJECT_DIR$/src/state/state_manager.rs">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="735"> <state relative-caret-position="442">
<caret line="52" column="28" selection-start-line="52" selection-start-column="11" selection-end-line="52" selection-end-column="28" /> <caret line="26" column="26" selection-start-line="26" selection-start-column="11" selection-end-line="26" selection-end-column="26" />
</state> </state>
</provider> </provider>
</entry> </entry>
<entry file="file://$PROJECT_DIR$/src/state/commands/shared_commands.rs"> <entry file="file://$PROJECT_DIR$/src/state/commands/shared_commands.rs">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="510"> <state relative-caret-position="476">
<caret line="40" column="1" selection-start-line="40" selection-start-column="1" selection-end-line="40" selection-end-column="1" /> <caret line="34" column="48" selection-start-line="34" selection-start-column="48" selection-end-line="34" selection-end-column="48" />
</state> </state>
</provider> </provider>
</entry> </entry>
<entry file="file://$PROJECT_DIR$/src/style/color/color.rs"> <entry file="file://$PROJECT_DIR$/examples/Crossterm 0.2.2 - New Version (Not finished)/games/FirstDepthSearch/main.rs" />
<provider selected="true" editor-type-id="text-editor"> <entry file="file://$PROJECT_DIR$/examples/Crossterm 0.2.2 - New Version (Not finished)/program_examples/first_depth_search/Cargo.toml" />
<state relative-caret-position="788"> <entry file="file://$PROJECT_DIR$/examples/Crossterm 0.2.2 - New Version (Not finished)/program_examples/README.md">
<caret line="129" column="7" selection-start-line="129" selection-start-column="7" selection-end-line="129" selection-end-column="7" /> <provider selected="true" editor-type-id="split-provider[text-editor;markdown-preview-editor]">
<folding> <state split_layout="SPLIT">
<element signature="e#3841#3842#0" expanded="true" /> <first_editor />
<element signature="e#3886#3887#0" expanded="true" /> <second_editor />
</folding>
</state> </state>
</provider> </provider>
</entry> </entry>
<entry file="file://$PROJECT_DIR$/examples/Crossterm 0.2.2 - New Version (Not finished)/color/mod.rs"> <entry file="file://$PROJECT_DIR$/src/shared/mod.rs">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="635"> <state relative-caret-position="119">
<caret line="144" column="1" selection-start-line="144" selection-start-column="1" selection-end-line="144" selection-end-column="1" /> <caret line="7" column="16" selection-start-line="7" selection-start-column="16" selection-end-line="7" selection-end-column="16" />
</state> </state>
</provider> </provider>
</entry> </entry>
<entry file="file://$PROJECT_DIR$/src/style/color/ansi_color.rs"> <entry file="file://$PROJECT_DIR$/src/cursor/mod.rs">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="450"> <state relative-caret-position="544">
<caret line="32" column="102" selection-start-line="32" selection-start-column="11" selection-end-line="32" selection-end-column="102" /> <caret line="32" column="10" selection-start-line="32" selection-start-column="10" selection-end-line="32" selection-end-column="10" />
</state> </state>
</provider> </provider>
</entry> </entry>
<entry file="file://$PROJECT_DIR$/examples/Crossterm 0.2.2 - New Version (Not finished)/terminal/mod.rs"> <entry file="file://$PROJECT_DIR$/src/lib.rs">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="30"> <state relative-caret-position="272">
<caret line="2" column="12" selection-start-line="2" selection-start-column="12" selection-end-line="2" selection-end-column="12" /> <caret line="16" column="37" selection-start-line="16" selection-start-column="37" selection-end-line="16" selection-end-column="37" />
</state> </state>
</provider> </provider>
</entry> </entry>
<entry file="file://$PROJECT_DIR$/src/shared/functions.rs"> <entry file="file://$PROJECT_DIR$/examples/Crossterm 0.2.2 - New Version (Not finished)/program_examples/first_depth_search/main.rs" />
<entry file="file://$PROJECT_DIR$/src/kernel/windows_kernel/mod.rs">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="886"> <state relative-caret-position="612">
<caret line="62" column="31" selection-start-line="62" selection-start-column="31" selection-end-line="62" selection-end-column="31" /> <caret line="38" column="1" selection-start-line="38" selection-start-column="1" selection-end-line="38" selection-end-column="1" />
<folding>
<element signature="e#500#501#0" expanded="true" />
<element signature="e#522#523#0" expanded="true" />
</folding>
</state> </state>
</provider> </provider>
</entry> </entry>
<entry file="file://$PROJECT_DIR$/src/cursor/ansi_cursor.rs"> <entry file="file://$PROJECT_DIR$/src/manager/ansi_manager.rs">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="871"> <state relative-caret-position="272">
<caret line="102" column="48" selection-start-line="102" selection-start-column="48" selection-end-line="102" selection-end-column="48" /> <caret line="16" column="1" selection-start-line="16" selection-start-column="1" selection-end-line="16" selection-end-column="1" />
</state> </state>
</provider> </provider>
</entry> </entry>
<entry file="file://$PROJECT_DIR$/src/cursor/cursor.rs"> <entry file="file://$USER_HOME$/.rustup/toolchains/stable-x86_64-pc-windows-msvc/lib/rustlib/src/rust/src/libcore/default.rs">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="316"> <state relative-caret-position="305">
<caret line="361" column="5" selection-start-line="361" selection-start-column="5" selection-end-line="361" selection-end-column="5" /> <caret line="93" column="10" selection-start-line="93" selection-start-column="10" selection-end-line="93" selection-end-column="10" />
</state> </state>
</provider> </provider>
</entry> </entry>
<entry file="file://$PROJECT_DIR$/src/kernel/unix_kernel/terminal.rs"> <entry file="file://$PROJECT_DIR$/src/style/mod.rs">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="541"> <state relative-caret-position="195">
<caret line="129" column="45" selection-start-line="129" selection-start-column="45" selection-end-line="129" selection-end-column="45" /> <caret line="28" column="9" selection-start-line="28" selection-start-column="9" selection-end-line="28" selection-end-column="9" />
<folding>
<element signature="e#3437#3438#0" expanded="true" />
<element signature="e#3468#3469#0" expanded="true" />
</folding>
</state> </state>
</provider> </provider>
</entry> </entry>
<entry file="file://$PROJECT_DIR$/src/kernel/windows_kernel/terminal.rs"> <entry file="file://$PROJECT_DIR$/examples/Crossterm 0.2.2 - New Version (Not finished)/program_examples/first_depth_search/mod.rs">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="180"> <state relative-caret-position="221">
<caret line="12" column="1" selection-start-line="12" selection-start-column="1" selection-end-line="12" selection-end-column="1" /> <caret line="13" column="23" selection-start-line="13" selection-start-column="23" selection-end-line="13" selection-end-column="23" />
<folding>
<element signature="e#276#277#0" expanded="true" />
<element signature="e#307#308#0" expanded="true" />
</folding>
</state> </state>
</provider> </provider>
</entry> </entry>
<entry file="file://$PROJECT_DIR$/src/terminal/terminal.rs"> <entry file="file://$PROJECT_DIR$/src/shared/environment.rs">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="353"> <state relative-caret-position="187">
<caret line="187" column="5" selection-start-line="187" selection-start-column="5" selection-end-line="187" selection-end-column="5" /> <caret line="11" column="11" selection-start-line="11" selection-start-column="11" selection-end-line="11" selection-end-column="11" />
</state> </state>
</provider> </provider>
</entry> </entry>
<entry file="file://$PROJECT_DIR$/src/terminal/ansi_terminal.rs"> <entry file="file://$PROJECT_DIR$/examples/Crossterm 0.2.2 - New Version (Not finished)/program_examples/first_depth_search/variables.rs">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="1105"> <state relative-caret-position="740">
<caret line="67" column="5" selection-start-line="67" selection-start-column="5" selection-end-line="67" selection-end-column="5" /> <caret line="59" column="5" lean-forward="true" selection-start-line="59" selection-start-column="5" selection-end-line="59" selection-end-column="5" />
</state> </state>
</provider> </provider>
</entry> </entry>
<entry file="file://$PROJECT_DIR$/src/terminal/winapi_terminal.rs"> <entry file="file://$PROJECT_DIR$/examples/Crossterm 0.2.2 - New Version (Not finished)/program_examples/first_depth_search/map.rs">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="2465"> <state relative-caret-position="281">
<caret line="148" column="28" selection-start-line="148" selection-start-column="28" selection-end-line="148" selection-end-column="28" /> <caret line="18" column="5" selection-start-line="18" selection-start-column="5" selection-end-line="18" selection-end-column="5" />
</state> </state>
</provider> </provider>
</entry> </entry>
<entry file="file://$PROJECT_DIR$/src/terminal/mod.rs"> <entry file="file://$PROJECT_DIR$/examples/Crossterm 0.2.2 - New Version (Not finished)/program_examples/mod.rs">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="697"> <state relative-caret-position="17">
<caret line="41" column="43" selection-start-line="41" selection-start-column="43" selection-end-line="41" selection-end-column="43" /> <caret line="1" selection-start-line="1" selection-end-line="1" />
</state>
</provider>
</entry>
<entry file="file://$USER_HOME$/.cargo/registry/src/github.com-1ecc6299db9ec823/winapi-0.3.5/src/um/wincon.rs">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="4233">
<caret line="249" column="11" selection-start-line="249" selection-start-column="11" selection-end-line="249" selection-end-column="11" />
</state>
</provider>
</entry>
<entry file="file://$USER_HOME$/.cargo/registry/src/github.com-1ecc6299db9ec823/winapi-0.3.5/src/lib.rs">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="578">
<caret line="34" column="13" selection-start-line="34" selection-start-column="13" selection-end-line="34" selection-end-column="13" />
</state>
</provider>
</entry>
<entry file="file://$USER_HOME$/.cargo/registry/src/github.com-1ecc6299db9ec823/winapi-0.3.5/src/um/winnt.rs">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="527">
<caret line="31" column="18" selection-start-line="31" selection-start-column="18" selection-end-line="31" selection-end-column="18" />
</state>
</provider>
</entry>
<entry file="file://$USER_HOME$/.cargo/registry/src/github.com-1ecc6299db9ec823/winapi-0.3.5/src/um/consoleapi.rs">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="1207">
<caret line="71" column="26" selection-start-line="71" selection-start-column="26" selection-end-line="71" selection-end-column="26" />
</state> </state>
</provider> </provider>
</entry> </entry>
<entry file="file://$PROJECT_DIR$/examples/Crossterm 0.2.2 - New Version (Not finished)/terminal/terminal.rs"> <entry file="file://$PROJECT_DIR$/examples/Crossterm 0.2.2 - New Version (Not finished)/terminal/terminal.rs">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="1326"> <state relative-caret-position="-255" />
<caret line="78" column="32" selection-start-line="78" selection-start-column="32" selection-end-line="78" selection-end-column="32" /> </provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/kernel/windows_kernel/ansi_support.rs">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="187">
<caret line="11" column="31" selection-start-line="11" selection-start-column="31" selection-end-line="11" selection-end-column="31" />
</state> </state>
</provider> </provider>
</entry> </entry>
<entry file="file://$PROJECT_DIR$/examples/Crossterm 0.2.2 - New Version (Not finished)/cursor/mod.rs"> <entry file="file://$USER_HOME$/.rustup/toolchains/stable-x86_64-pc-windows-msvc/lib/rustlib/src/rust/src/liballoc/rc.rs">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="2397"> <state relative-caret-position="275">
<caret line="141" selection-start-line="141" selection-end-line="141" /> <caret line="450" column="24" selection-start-line="450" selection-start-column="24" selection-end-line="450" selection-end-column="24" />
</state> </state>
</provider> </provider>
</entry> </entry>
<entry file="file://$PROJECT_DIR$/src/manager/manager.rs"> <entry file="file://$PROJECT_DIR$/src/state/context.rs">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="434"> <state relative-caret-position="170">
<caret line="30" column="64" selection-start-line="30" selection-start-column="64" selection-end-line="30" selection-end-column="64" /> <caret line="10" column="8" selection-start-line="10" selection-start-column="8" selection-end-line="10" selection-end-column="8" />
</state> </state>
</provider> </provider>
</entry> </entry>
<entry file="file://$PROJECT_DIR$/src/shared/screen.rs"> <entry file="file://$PROJECT_DIR$/examples/Crossterm 0.2.2 - New Version (Not finished)/terminal/raw_mode.rs">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="604"> <state relative-caret-position="357">
<caret line="93" selection-start-line="93" selection-end-line="93" /> <caret line="21" column="24" selection-start-line="21" selection-start-column="24" selection-end-line="21" selection-end-column="24" />
</state> </state>
</provider> </provider>
</entry> </entry>
<entry file="file://$PROJECT_DIR$/src/kernel/windows_kernel/cursor.rs"> <entry file="file://$PROJECT_DIR$/src/style/color/color.rs">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="34"> <state relative-caret-position="-1062">
<caret line="2" column="18" selection-start-line="2" selection-start-column="18" selection-end-line="2" selection-end-column="18" /> <caret line="21" column="82" selection-start-line="21" selection-start-column="82" selection-end-line="21" selection-end-column="82" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/style/styles/objectstyle.rs">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="578">
<caret line="34" column="11" selection-start-line="34" selection-start-column="11" selection-end-line="34" selection-end-column="11" />
</state> </state>
</provider> </provider>
</entry> </entry>
<entry file="file://$PROJECT_DIR$/src/style/styles/styledobject.rs"> <entry file="file://$PROJECT_DIR$/src/style/styles/styledobject.rs">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="641"> <state relative-caret-position="-1649">
<caret line="149" column="17" selection-start-line="149" selection-start-column="17" selection-end-line="149" selection-end-column="17" /> <caret line="14" column="11" selection-start-line="14" selection-start-column="11" selection-end-line="14" selection-end-column="11" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/state/commands/win_commands.rs">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="-1309">
<caret line="40" column="54" selection-start-line="40" selection-start-column="54" selection-end-line="40" selection-end-column="54" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/kernel/windows_kernel/terminal.rs">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="17">
<caret line="1" column="7" selection-start-line="1" selection-start-column="7" selection-end-line="1" selection-end-column="7" />
<folding>
<element signature="e#346#347#0" expanded="true" />
<element signature="e#379#380#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/terminal/winapi_terminal.rs">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="424">
<caret line="42" column="25" selection-start-line="42" selection-start-column="25" selection-end-line="42" selection-end-column="25" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/kernel/unix_kernel/terminal.rs">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="297">
<caret line="43" column="7" selection-start-line="43" selection-start-column="7" selection-end-line="43" selection-end-column="7" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/shared/functions.rs">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="228">
<caret line="30" column="14" selection-start-line="30" selection-start-column="14" selection-end-line="30" selection-end-column="14" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/kernel/windows_kernel/cursor.rs">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="544">
<caret line="32" column="23" selection-start-line="32" selection-start-column="23" selection-end-line="32" selection-end-column="23" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/manager/manager.rs">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="408">
<caret line="24" column="21" selection-start-line="24" selection-start-column="21" selection-end-line="24" selection-end-column="21" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/manager/win_manager.rs">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="493">
<caret line="32" column="36" selection-start-line="32" selection-start-column="36" selection-end-line="32" selection-end-column="36" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/style/color/winapi_color.rs">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="158">
<caret line="64" column="69" selection-start-line="64" selection-start-column="69" selection-end-line="64" selection-end-column="69" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/terminal/ansi_terminal.rs">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="391">
<caret line="45" column="66" selection-start-line="45" selection-start-column="66" selection-end-line="45" selection-end-column="66" />
</state> </state>
</provider> </provider>
</entry> </entry>
@ -930,47 +990,50 @@
</entry> </entry>
<entry file="file://$PROJECT_DIR$/examples/Crossterm 0.2.2 - New Version (Not finished)/bin.rs"> <entry file="file://$PROJECT_DIR$/examples/Crossterm 0.2.2 - New Version (Not finished)/bin.rs">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="629"> <state relative-caret-position="459">
<caret line="37" column="1" selection-start-line="37" selection-start-column="1" selection-end-line="37" selection-end-column="1" /> <caret line="27" column="61" selection-start-line="27" selection-start-column="61" selection-end-line="27" selection-end-column="61" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/shared/screen.rs">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="340">
<caret line="26" column="11" selection-start-line="26" selection-start-column="11" selection-end-line="26" selection-end-column="11" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/terminal/terminal.rs">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="742">
<caret line="197" column="11" selection-start-line="197" selection-start-column="11" selection-end-line="197" selection-end-column="11" />
</state> </state>
</provider> </provider>
</entry> </entry>
<entry file="file://$PROJECT_DIR$/examples/Crossterm 0.2.2 - New Version (Not finished)/terminal/alternate_screen.rs"> <entry file="file://$PROJECT_DIR$/examples/Crossterm 0.2.2 - New Version (Not finished)/terminal/alternate_screen.rs">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="638"> <state relative-caret-position="204">
<caret line="74" column="52" selection-start-line="74" selection-start-column="52" selection-end-line="74" selection-end-column="52" /> <caret line="18" column="13" selection-start-line="18" selection-start-column="13" selection-end-line="18" selection-end-column="13" />
</state> </state>
</provider> </provider>
</entry> </entry>
<entry file="file://$PROJECT_DIR$/src/state/commands/unix_command.rs"> <entry file="file://$PROJECT_DIR$/src/cursor/cursor.rs">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="600"> <state relative-caret-position="408">
<caret line="40" column="9" selection-start-line="40" selection-start-column="9" selection-end-line="40" selection-end-column="9" /> <caret line="313" column="11" selection-start-line="313" selection-start-column="11" selection-end-line="313" selection-end-column="11" />
</state> </state>
</provider> </provider>
</entry> </entry>
<entry file="file://$PROJECT_DIR$/src/state/commands/win_commands.rs"> <entry file="file://$PROJECT_DIR$/src/cursor/winapi_cursor.rs">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="424"> <state relative-caret-position="498">
<caret line="193" column="10" selection-start-line="187" selection-start-column="7" selection-end-line="193" selection-end-column="10" /> <caret line="66" column="25" selection-start-line="66" selection-start-column="25" selection-end-line="66" selection-end-column="25" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/manager/win_manager.rs">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="672">
<caret line="63" column="21" selection-start-line="63" selection-start-column="11" selection-end-line="63" selection-end-column="21" />
<folding>
<element signature="e#1321#1322#0" expanded="true" />
<element signature="e#1377#1378#0" expanded="true" />
</folding>
</state> </state>
</provider> </provider>
</entry> </entry>
<entry file="file://$PROJECT_DIR$/src/kernel/windows_kernel/kernel.rs"> <entry file="file://$PROJECT_DIR$/src/kernel/windows_kernel/kernel.rs">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="612"> <state relative-caret-position="540">
<caret line="36" column="32" lean-forward="true" selection-start-line="36" selection-start-column="32" selection-end-line="36" selection-end-column="32" /> <caret line="203" column="5" selection-start-line="203" selection-start-column="5" selection-end-line="203" selection-end-column="5" />
</state> </state>
</provider> </provider>
</entry> </entry>

0
123 Normal file
View File

View File

@ -16,23 +16,17 @@ extern crate crossterm;
mod terminal; mod terminal;
mod cursor; mod cursor;
mod color; mod color;
mod program_examples;
use terminal::alternate_screen;
use terminal::raw_mode;
use terminal::terminal as term;
use self::crossterm::Context;
use self::crossterm::terminal::ClearType;
use crossterm::raw;
use crossterm::screen;
use crossterm::raw::IntoRawMode;
use std::io::Write;
use std::{time, thread};
use std::process::exit;
fn main() { fn main() {
let context = Context::new();
alternate_screen::print_wait_screen_on_alternate_window();
use crossterm::Context;
{
let mut context = Context::new();
terminal::alternate_screen::print_wait_screen_on_alternate_window(context.clone());
println!("count: {}", std::rc::Rc::strong_count(&context));
}
} }

View File

@ -1,5 +1,5 @@
//! //!
//! Color Examples //! Examples of coloring the terminal.
//! //!
extern crate crossterm; extern crate crossterm;

View File

@ -1,5 +1,5 @@
//! //!
//! Cursor Examples //! Examples of actions that could be performed with te cursor.
//! //!
extern crate crossterm; extern crate crossterm;
@ -140,7 +140,7 @@ pub fn show_cursor()
cursor.show(); cursor.show();
} }
/// Show cursor display | demonstration. /// Show cursor display, only works on certain terminals.| demonstration
pub fn blink_cursor() pub fn blink_cursor()
{ {
let context = Context::new(); let context = Context::new();

View File

@ -0,0 +1,3 @@
This folder will contain some examples of how to use this crate.
If you have created a game or something feel free to upload it, would be a great help for other people and me.

View File

@ -0,0 +1,49 @@
use super::variables::{Cell, Position, Size };
use crossterm::terminal::terminal;
use crossterm::Environment;
use crossterm::style::{ObjectStyle, StyledObject};
use crossterm::Context;
use std::rc::Rc;
use std::fmt::Display;
pub struct Map<D: Display>
{
map: Vec<Vec<Cell<D>>>,
wall_style: StyledObject<D>,
map_style: StyledObject<D>,
}
impl<D: Display> Map<D>
{
pub fn new(context: Rc<Context>) -> Map<D>
{
Map { map: Vec::new(), wall_style: ObjectStyle::apply_ to("", context.clone() )}
}
pub fn init(&self, environment: &mut Environment, map_size: Size) -> Map<D>
{
let mut map: Vec<Vec<Cell<D>>> = Vec::new();
for y in 0..map[0].len()
{
for x in 0..map[1].len()
{
if (y == 0 || y == map.len() - 1) || (x == 0 || x == map[0].len())
{
map[y][x] = Cell::new(Position::new(x,y), wall_style.apply_to(environment.context(), ""));
}
else{
map[y][x] = Cell::new(Position::new(x,y), map_style);
}
}
}
Map { map }
}
fn render_map()
{
}
}

View File

@ -0,0 +1,17 @@
mod map;
mod variables;
use crossterm;
use crossterm::style::Color;
use self::variables::Size;
fn run()
{
let mut env = crossterm::Environment::new();
let map_size = Size::new(20,20);
let wall_style = env.paint("").with(Color::Blue).on(Color::Black);
let map_style = env.paint(" ").with(Color::White).on(Color::White);
map::Map::init(&mut env, map_size, wall_style, map_style);
}

View File

@ -0,0 +1,63 @@
extern crate crossterm;
use self::crossterm::terminal::{terminal, ClearType};
use self::crossterm::Context;
use self::crossterm::style::{Color, StyledObject, ObjectStyle };
#[derive(Copy, Clone)]
pub enum Direction
{
Up,
Down,
Left,
Right
}
#[derive(Copy, Clone)]
pub struct Position
{
pub x: usize,
pub y: usize
}
impl Position
{
pub fn new(x: usize, y: usize) -> Position
{
Position { x, y }
}
}
#[derive(Copy, Clone)]
pub struct Size
{
pub width: u16,
pub height: u16
}
impl Size
{
pub fn new(width: u16, height: u16) -> Size
{
Size {width,height}
}
}
use std::fmt::Display;
pub struct Cell<'a, D: Display>
{
position: Position,
style: &'a StyledObject<D>,
visited: bool
}
use std::rc::Rc;
impl<'a, D: Display> Cell<'a, D>
{
pub fn new(position: Position, style: &'a StyledObject<D>) -> Cell<D>
{
Cell { position: position, style: style, visited: false }
}
}

View File

@ -0,0 +1 @@
//pub mod first_depth_search;

View File

@ -8,23 +8,19 @@ use crossterm::terminal::{self, ClearType};
use std::io::{Write, stdout}; use std::io::{Write, stdout};
use std::{time, thread}; use std::{time, thread};
use std::rc::Rc; use std::rc::Rc;
fn print_wait_screen(context: Rc<Context>) fn print_wait_screen(context: Rc<Context>)
{ {
terminal::terminal(context.clone()).clear(ClearType::All); let mut terminal = terminal::terminal(context.clone());
terminal.clear(ClearType::All);
let mut cursor = cursor(context.clone()); let mut cursor = cursor(context.clone());
cursor.goto(0,0); cursor.goto(0,0);
cursor.hide();
{ terminal.write("Welcome to the wait screen.\n\
let mut screen_manager = context.screen_manager.lock().unwrap();
{
write!(screen_manager,
"Welcome to the wait screen.\n\
Please wait a few seconds until we arrive back at the main screen.\n\ Please wait a few seconds until we arrive back at the main screen.\n\
Progress: " Progress: ");
);
}
}
// print some progress example. // print some progress example.
for i in 1..5 for i in 1..5
@ -35,13 +31,12 @@ fn print_wait_screen(context: Rc<Context>)
// 1 second delay // 1 second delay
thread::sleep(time::Duration::from_secs(1)); thread::sleep(time::Duration::from_secs(1));
} }
} }
/// print wait screen on alternate screen, then swich back. /// print wait screen on alternate screen, then swich back.
pub fn print_wait_screen_on_alternate_window() pub fn print_wait_screen_on_alternate_window(context: Rc<Context>)
{ {
let context = Context::new();
// create scope. If this scope ends the screen will be switched back to mainscreen. // create scope. If this scope ends the screen will be switched back to mainscreen.
// because `AlternateScreen` switches back to main screen when switching back. // because `AlternateScreen` switches back to main screen when switching back.
{ {
@ -51,8 +46,6 @@ pub fn print_wait_screen_on_alternate_window()
// Print the wait screen. // Print the wait screen.
print_wait_screen(context.clone()); print_wait_screen(context.clone());
} }
println!("Whe are back at the main screen");
} }
/// some stress test switch from and to alternate screen. /// some stress test switch from and to alternate screen.

View File

@ -1,3 +1,10 @@
/// Examples of actions that could be performed on the alternatescreen.
/// !! Note that alternate screen only works on Unix and windows 10 systems. I am working on windows 7 support. !!
pub mod alternate_screen; pub mod alternate_screen;
pub mod raw_mode;
/// Examples of actions that could be performed on the terminal.
pub mod terminal; pub mod terminal;
/// Alternate screen is only supported for unix systems. Windows support will come later :).
#[cfg(target_os = "unix")]
pub mod raw_mode;

View File

@ -6,6 +6,7 @@
use super::*; use super::*;
use Context; use Context;
use super::super::shared::functions; use super::super::shared::functions;
use std::io::Write;
use std::fmt::Display; use std::fmt::Display;
use std::rc::Rc; use std::rc::Rc;
@ -21,7 +22,7 @@ impl TerminalCursor
/// Create new cursor instance whereon cursor related actions can be performed. /// Create new cursor instance whereon cursor related actions can be performed.
pub fn new(context: Rc<Context>) -> TerminalCursor { pub fn new(context: Rc<Context>) -> TerminalCursor {
#[cfg(target_os = "windows")] #[cfg(target_os = "windows")]
let cursor = functions::get_module::<Box<ITerminalCursor>>(WinApiCursor::new(), AnsiCursor::new(context.clone())); let cursor = functions::get_module::<Box<ITerminalCursor>>(WinApiCursor::new(context.screen_manager.clone()), AnsiCursor::new(context.clone()));
#[cfg(not(target_os = "windows"))] #[cfg(not(target_os = "windows"))]
let cursor = Some(AnsiCursor::new(context.clone()) as Box<ITerminalCursor>); let cursor = Some(AnsiCursor::new(context.clone()) as Box<ITerminalCursor>);
@ -242,7 +243,9 @@ impl TerminalCursor
let mut string = String::new(); let mut string = String::new();
write!(string, "{}", value).unwrap(); write!(string, "{}", value).unwrap();
screen_manager.write_ansi(string); screen_manager.write_val(string);
screen_manager.flush();
} }
} }
self self

View File

@ -2,25 +2,34 @@
//! This module is used for windows terminals that do not support ANSI escape codes. //! This module is used for windows terminals that do not support ANSI escape codes.
//! Note that the cursor position is 0 based. This means that we start counting at 0 when setting the cursor position ect. //! Note that the cursor position is 0 based. This means that we start counting at 0 when setting the cursor position ect.
use super::ITerminalCursor; use super::ITerminalCursor;
use super::super::manager::{IScreenManager, ScreenManager, WinApiScreenManager };
use kernel::windows_kernel::{kernel, cursor}; use kernel::windows_kernel::{kernel, cursor};
use std::rc::Rc;
use std::sync::Mutex;
/// This struct is an windows implementation for cursor related actions. /// This struct is an windows implementation for cursor related actions.
pub struct WinApiCursor; pub struct WinApiCursor
{
screen_manager: Rc<Mutex<ScreenManager>>
}
impl WinApiCursor { impl WinApiCursor {
pub fn new() -> Box<WinApiCursor> { pub fn new(screen_manager: Rc<Mutex<ScreenManager>>) -> Box<WinApiCursor> {
Box::from(WinApiCursor { }) Box::from(WinApiCursor { screen_manager })
} }
} }
impl ITerminalCursor for WinApiCursor { impl ITerminalCursor for WinApiCursor
{
fn goto(&self, x: u16, y: u16) { fn goto(&self, x: u16, y: u16) {
kernel::set_console_cursor_position(x as i16, y as i16);
kernel::set_console_cursor_position(x as i16, y as i16, &self.screen_manager);
} }
fn pos(&self) -> (u16, u16) { fn pos(&self) -> (u16, u16) {
cursor::pos() cursor::pos(&self.screen_manager)
} }
fn move_up(&self, count: u16) { fn move_up(&self, count: u16) {
@ -45,22 +54,22 @@ impl ITerminalCursor for WinApiCursor {
fn save_position(&mut self) fn save_position(&mut self)
{ {
cursor::save_cursor_pos(); cursor::save_cursor_pos(&self.screen_manager);
} }
fn reset_position(&self) fn reset_position(&self)
{ {
cursor::reset_to_saved_position(); cursor::reset_to_saved_position(&self.screen_manager);
} }
fn hide(&self) fn hide(&self)
{ {
kernel::cursor_visibility(false); kernel::cursor_visibility(false, &self.screen_manager);
} }
fn show(&self) fn show(&self)
{ {
kernel::cursor_visibility(true); kernel::cursor_visibility(true, &self.screen_manager);
} }
fn blink(&self, blink: bool) fn blink(&self, blink: bool)

View File

@ -7,6 +7,7 @@ static mut HAS_BEEN_TRYED_TO_ENABLE: bool = false;
static mut IS_ANSI_ON_WINDOWS_ENABLED: Option<bool> = None; static mut IS_ANSI_ON_WINDOWS_ENABLED: Option<bool> = None;
static mut DOES_WINDOWS_SUPPORT_ANSI: Option<bool> = None; static mut DOES_WINDOWS_SUPPORT_ANSI: Option<bool> = None;
static START: Once = ONCE_INIT; static START: Once = ONCE_INIT;
/// Try enable `ANSI escape codes` and return the result. /// Try enable `ANSI escape codes` and return the result.
pub fn try_enable_ansi_support() -> bool pub fn try_enable_ansi_support() -> bool
{ {
@ -18,7 +19,6 @@ pub fn try_enable_ansi_support() -> bool
set_is_windows_ansi_supportable(success); set_is_windows_ansi_supportable(success);
set_ansi_enabled(success); set_ansi_enabled(success);
has_been_tried_to_enable(true); has_been_tried_to_enable(true);
}); });
windows_supportable() windows_supportable()

View File

@ -1,22 +1,26 @@
//! This module handles some logic for cursor interaction in the windows console. //! This module handles some logic for cursor interaction in the windows console.
use super::kernel; use super::kernel;
use super::super::super::manager::{ScreenManager, WinApiScreenManager};
use std::rc::Rc;
use std::sync::Mutex;
/// This stores the cursor pos, at program level. So it can be recalled later. /// This stores the cursor pos, at program level. So it can be recalled later.
static mut SAVED_CURSOR_POS:(u16,u16) = (0,0); static mut SAVED_CURSOR_POS:(u16,u16) = (0,0);
/// Reset to saved cursor position /// Reset to saved cursor position
pub fn reset_to_saved_position() pub fn reset_to_saved_position(screen_manager: &Rc<Mutex<ScreenManager>>)
{ {
unsafe { unsafe {
kernel::set_console_cursor_position(SAVED_CURSOR_POS.0 as i16, SAVED_CURSOR_POS.1 as i16); kernel::set_console_cursor_position(SAVED_CURSOR_POS.0 as i16, SAVED_CURSOR_POS.1 as i16, screen_manager);
} }
} }
/// Save current cursor position to recall later. /// Save current cursor position to recall later.
pub fn save_cursor_pos() pub fn save_cursor_pos(screen_manager: &Rc<Mutex<ScreenManager>>)
{ {
let position = pos(); let position = pos(screen_manager);
unsafe { unsafe {
SAVED_CURSOR_POS = (position.0, position.1); SAVED_CURSOR_POS = (position.0, position.1);
@ -24,8 +28,8 @@ pub fn save_cursor_pos()
} }
/// get the current cursor position. /// get the current cursor position.
pub fn pos() -> (u16,u16) pub fn pos(screen_manager: &Rc<Mutex<ScreenManager>>) -> (u16,u16)
{ {
let csbi = kernel::get_console_screen_buffer_info(); let csbi = kernel::get_console_screen_buffer_info(screen_manager);
( csbi.dwCursorPosition.X as u16, csbi.dwCursorPosition.Y as u16 ) ( csbi.dwCursorPosition.X as u16, csbi.dwCursorPosition.Y as u16 )
} }

View File

@ -2,7 +2,6 @@
use Context; use Context;
use std::rc::Rc; use std::rc::Rc;
use winapi::um::winnt::HANDLE; use winapi::um::winnt::HANDLE;
use winapi::um::winbase::{STD_OUTPUT_HANDLE, STD_INPUT_HANDLE }; use winapi::um::winbase::{STD_OUTPUT_HANDLE, STD_INPUT_HANDLE };
use winapi::um::handleapi::INVALID_HANDLE_VALUE; use winapi::um::handleapi::INVALID_HANDLE_VALUE;
@ -11,9 +10,13 @@ use winapi::um::consoleapi::{SetConsoleMode,GetConsoleMode, };
use winapi::shared::ntdef::{NULL}; use winapi::shared::ntdef::{NULL};
use winapi::shared::minwindef::{TRUE, FALSE}; use winapi::shared::minwindef::{TRUE, FALSE};
use winapi::um::wincon; use winapi::um::wincon;
use winapi::um::consoleapi::WriteConsoleW;
use winapi::um::wincon:: use winapi::um::wincon::
{ {
ENABLE_PROCESSED_INPUT,
WriteConsoleOutputW,
WriteConsoleOutputCharacterA, WriteConsoleOutputCharacterA,
WriteConsoleOutputCharacterW,
SetConsoleWindowInfo, SetConsoleCursorPosition, SetConsoleTextAttribute, SetConsoleScreenBufferSize, CreateConsoleScreenBuffer,SetConsoleActiveScreenBuffer, SetConsoleCursorInfo, SetConsoleWindowInfo, SetConsoleCursorPosition, SetConsoleTextAttribute, SetConsoleScreenBufferSize, CreateConsoleScreenBuffer,SetConsoleActiveScreenBuffer, SetConsoleCursorInfo,
GetLargestConsoleWindowSize, GetConsoleScreenBufferInfo, GetLargestConsoleWindowSize, GetConsoleScreenBufferInfo,
FillConsoleOutputCharacterA, FillConsoleOutputAttribute,WriteConsoleOutputAttribute, FillConsoleOutputCharacterA, FillConsoleOutputAttribute,WriteConsoleOutputAttribute,
@ -24,19 +27,13 @@ use super::{Empty};
static mut CONSOLE_OUTPUT_HANDLE: Option<HANDLE> = None; static mut CONSOLE_OUTPUT_HANDLE: Option<HANDLE> = None;
static mut CONSOLE_INPUT_HANDLE: Option<HANDLE> = None; static mut CONSOLE_INPUT_HANDLE: Option<HANDLE> = None;
use super::super::super::manager::{ScreenManager, WinApiScreenManager};
use std::sync::Mutex;
pub fn get_current_handle(context: Rc<Context>) -> Rc<HANDLE> /// Get the global stored handle.
pub fn get_current_handle(screen_manager: &mut WinApiScreenManager) -> &HANDLE
{ {
let mut screen_manager = context.screen_manager.lock().unwrap(); return screen_manager.get_handle();
use super::super::super::manager::WinApiScreenManager;
let b: &mut WinApiScreenManager = match screen_manager.as_any().downcast_mut::<WinApiScreenManager>() {
Some(b) => { b },
None => panic!("")
};
let handle = b.get_handle();
return handle.clone()
} }
/// Get the std_output_handle of the console /// Get the std_output_handle of the console
@ -85,13 +82,20 @@ fn is_valid_handle(handle: &HANDLE) -> bool {
true true
} }
} }
/// Create a new console screen buffer info struct.
pub fn get_console_screen_buffer_info(screen_manager: &Rc<Mutex<ScreenManager>>) -> CONSOLE_SCREEN_BUFFER_INFO {
pub fn get_console_screen_buffer_info() -> CONSOLE_SCREEN_BUFFER_INFO { let mut screen_manager = screen_manager.lock().unwrap();
let output_handle = get_output_handle(); let winapi_screen_manager: &mut WinApiScreenManager = match screen_manager.as_any().downcast_mut::<WinApiScreenManager>() {
Some(win_api) => { win_api },
None => panic!("")
};
let output_handle = get_current_handle(winapi_screen_manager);
let mut csbi = CONSOLE_SCREEN_BUFFER_INFO::empty(); let mut csbi = CONSOLE_SCREEN_BUFFER_INFO::empty();
let success; let success;
unsafe { success = GetConsoleScreenBufferInfo(output_handle, &mut csbi) } unsafe { success = GetConsoleScreenBufferInfo(*output_handle, &mut csbi) }
if success == 0 { if success == 0 {
panic!("Cannot get console screen buffer info"); panic!("Cannot get console screen buffer info");
@ -100,6 +104,22 @@ pub fn get_console_screen_buffer_info() -> CONSOLE_SCREEN_BUFFER_INFO {
csbi csbi
} }
/// Create a new console screen buffer info struct.
pub fn get_console_screen_buffer_info_from_handle(handle: &HANDLE) -> CONSOLE_SCREEN_BUFFER_INFO {
let mut csbi = CONSOLE_SCREEN_BUFFER_INFO::empty();
let success;
unsafe { success = GetConsoleScreenBufferInfo(*handle, &mut csbi) }
if success == 0 {
panic!("Cannot get console screen buffer info");
}
csbi
}
/// Get the larged console window size posible.
pub fn get_largest_console_window_size() -> COORD pub fn get_largest_console_window_size() -> COORD
{ {
let output_handle = get_output_handle(); let output_handle = get_output_handle();
@ -109,11 +129,13 @@ pub fn get_largest_console_window_size() -> COORD
} }
} }
pub fn get_original_console_color() -> u16 { /// Get the original color of the terminal.
let console_buffer_info = get_console_screen_buffer_info(); pub fn get_original_console_color(screen_manager: &Rc<Mutex<ScreenManager>>) -> u16 {
let console_buffer_info = get_console_screen_buffer_info(screen_manager);
console_buffer_info.wAttributes as u16 console_buffer_info.wAttributes as u16
} }
/// Set the console mode to the given console mode.
pub fn set_console_mode(handle: &HANDLE, console_mode: u32) -> bool pub fn set_console_mode(handle: &HANDLE, console_mode: u32) -> bool
{ {
unsafe { unsafe {
@ -122,6 +144,7 @@ pub fn set_console_mode(handle: &HANDLE, console_mode: u32) -> bool
} }
} }
/// Get the console mode.
pub fn get_console_mode(handle: &HANDLE, current_mode: &mut u32) -> bool pub fn get_console_mode(handle: &HANDLE, current_mode: &mut u32) -> bool
{ {
unsafe { unsafe {
@ -130,7 +153,8 @@ pub fn get_console_mode(handle: &HANDLE, current_mode: &mut u32) -> bool
} }
} }
pub fn set_console_cursor_position(x: i16, y: i16) /// Set the cursor position to the given x and y. Note that this is 0 based.
pub fn set_console_cursor_position(x: i16, y: i16, screen_manager: &Rc<Mutex<ScreenManager>>)
{ {
if x < 0 || x >= <i16>::max_value() { if x < 0 || x >= <i16>::max_value() {
panic!("X: {}, Argument Out of Range Exception", x); panic!("X: {}, Argument Out of Range Exception", x);
@ -140,11 +164,18 @@ pub fn set_console_cursor_position(x: i16, y: i16)
panic!("Y: {}, Argument Out of Range Exception", y); panic!("Y: {}, Argument Out of Range Exception", y);
} }
let output_handle = get_output_handle(); let mut screen_manager = screen_manager.lock().unwrap();
let winapi_screen_manager: &mut WinApiScreenManager = match screen_manager.as_any().downcast_mut::<WinApiScreenManager>() {
Some(win_api) => { win_api },
None => panic!("")
};
let handle = get_current_handle(winapi_screen_manager);
let position = COORD { X: x, Y: y }; let position = COORD { X: x, Y: y };
unsafe { unsafe {
let success = SetConsoleCursorPosition(output_handle, position); let success = SetConsoleCursorPosition(*handle, position);
if success == 0 { if success == 0 {
panic!("Argument out of range."); panic!("Argument out of range.");
@ -152,23 +183,31 @@ pub fn set_console_cursor_position(x: i16, y: i16)
} }
} }
pub fn cursor_visibility(visable: bool) /// change the cursor visibility.
pub fn cursor_visibility(visable: bool, screen_manager: &Rc<Mutex<ScreenManager>>)
{ {
let handle = get_output_handle(); let mut screen_manager = screen_manager.lock().unwrap();
let winapi_screen_manager: &mut WinApiScreenManager = match screen_manager.as_any().downcast_mut::<WinApiScreenManager>() {
Some(win_api) => { win_api },
None => panic!("")
};
let handle = get_current_handle(winapi_screen_manager);
let cursor_info = CONSOLE_CURSOR_INFO let cursor_info = CONSOLE_CURSOR_INFO
{ {
dwSize: 100,
dwSize: 1,
bVisible: if visable { TRUE } else {FALSE} bVisible: if visable { TRUE } else {FALSE}
}; };
unsafe unsafe
{ {
SetConsoleCursorInfo(handle, &cursor_info); SetConsoleCursorInfo(*handle, &cursor_info);
} }
} }
pub fn set_console_text_attribute(value: u16) /// Change the console text attribute.
pub fn set_console_text_attribute(value: u16, screen_manager: &Rc<Mutex<ScreenManager>>)
{ {
let output_handle = get_output_handle(); let output_handle = get_output_handle();
@ -177,38 +216,58 @@ pub fn set_console_text_attribute(value: u16)
} }
} }
pub fn set_console_info(absolute: bool, rect: &SMALL_RECT) -> bool /// Change console info.
pub fn set_console_info(absolute: bool, rect: &SMALL_RECT, screen_manager: &Rc<Mutex<ScreenManager>>) -> bool
{ {
let mut screen_manager = screen_manager.lock().unwrap();
let winapi_screen_manager: &mut WinApiScreenManager = match screen_manager.as_any().downcast_mut::<WinApiScreenManager>() {
Some(win_api) => { win_api },
None => panic!("")
};
let output_handle = get_output_handle(); let handle = get_current_handle(winapi_screen_manager);
let absolute = match absolute { true => 1, false => 0, }; let absolute = match absolute { true => 1, false => 0, };
unsafe unsafe
{ {
let success = SetConsoleWindowInfo(output_handle,absolute ,rect); let success = SetConsoleWindowInfo(*handle,absolute ,rect);
is_true(success) is_true(success)
} }
} }
pub fn set_console_screen_buffer_size( size: COORD) -> bool /// Set the console screen buffer size
pub fn set_console_screen_buffer_size( size: COORD, screen_manager: &Rc<Mutex<ScreenManager>>) -> bool
{ {
let output_handle = get_output_handle(); let mut screen_manager = screen_manager.lock().unwrap();
let winapi_screen_manager: &mut WinApiScreenManager = match screen_manager.as_any().downcast_mut::<WinApiScreenManager>() {
Some(win_api) => { win_api },
None => panic!("")
};
let handle = get_current_handle(winapi_screen_manager);
unsafe unsafe
{ {
let success = SetConsoleScreenBufferSize(output_handle, size); let success = SetConsoleScreenBufferSize(*handle, size);
is_true(success) is_true(success)
} }
} }
pub fn fill_console_output_character(cells_written: &mut u32, start_location: COORD, cells_to_write: u32) -> bool /// Fill a certain block with characters.
pub fn fill_console_output_character(cells_written: &mut u32, start_location: COORD, cells_to_write: u32, screen_manager: &Rc<Mutex<ScreenManager>>) -> bool
{ {
let output_handle = get_output_handle(); let mut screen_manager = screen_manager.lock().unwrap();
let winapi_screen_manager: &mut WinApiScreenManager = match screen_manager.as_any().downcast_mut::<WinApiScreenManager>() {
Some(win_api) => { win_api },
None => panic!("")
};
let handle = get_current_handle(winapi_screen_manager);
unsafe { unsafe {
// fill the cells in console with blanks // fill the cells in console with blanks
let success = FillConsoleOutputCharacterA ( let success = FillConsoleOutputCharacterA (
output_handle, *handle,
' ' as i8, ' ' as i8,
cells_to_write, cells_to_write,
start_location, start_location,
@ -218,17 +277,26 @@ pub fn fill_console_output_character(cells_written: &mut u32, start_location: CO
} }
} }
pub fn fill_console_output_attribute(cells_written: &mut u32, start_location: COORD, cells_to_write: u32) -> bool /// Set console ouput attribute for certain block.
pub fn fill_console_output_attribute(cells_written: &mut u32, start_location: COORD, cells_to_write: u32,screen_manager: &Rc<Mutex<ScreenManager>>) -> bool
{ {
// Get the position of the current console window // Get the position of the current console window
let csbi = get_console_screen_buffer_info(); let csbi = get_console_screen_buffer_info(screen_manager);
let output_handle = get_output_handle();
let mut screen_manager = screen_manager.lock().unwrap();
let winapi_screen_manager: &mut WinApiScreenManager = match screen_manager.as_any().downcast_mut::<WinApiScreenManager>() {
Some(win_api) => { win_api },
None => panic!("")
};
let handle = get_current_handle(winapi_screen_manager);
let success; let success;
unsafe { unsafe {
success = FillConsoleOutputAttribute ( success = FillConsoleOutputAttribute (
output_handle, *handle,
csbi.wAttributes, csbi.wAttributes,
cells_to_write, cells_to_write,
start_location, start_location,
@ -239,6 +307,7 @@ pub fn fill_console_output_attribute(cells_written: &mut u32, start_location: CO
is_true(success) is_true(success)
} }
/// Create new console screen buffer. This can be used for alternate screen.
pub fn create_console_screen_buffer() -> HANDLE pub fn create_console_screen_buffer() -> HANDLE
{ {
use winapi::shared::ntdef::NULL; use winapi::shared::ntdef::NULL;
@ -269,6 +338,7 @@ pub fn create_console_screen_buffer() -> HANDLE
} }
} }
/// Set the active screen buffer to the given handle. This can be used for alternate screen.
pub fn set_active_screen_buffer(new_buffer: HANDLE) pub fn set_active_screen_buffer(new_buffer: HANDLE)
{ {
unsafe unsafe
@ -280,6 +350,7 @@ pub fn set_active_screen_buffer(new_buffer: HANDLE)
} }
} }
/// Read the console outptut.
pub fn read_console_output(read_buffer: &HANDLE, copy_buffer: &mut [CHAR_INFO;160], buffer_size: COORD, buffer_coord: COORD, source_buffer: PSMALL_RECT) pub fn read_console_output(read_buffer: &HANDLE, copy_buffer: &mut [CHAR_INFO;160], buffer_size: COORD, buffer_coord: COORD, source_buffer: PSMALL_RECT)
{ {
use self::wincon::ReadConsoleOutputA; use self::wincon::ReadConsoleOutputA;
@ -299,6 +370,7 @@ pub fn read_console_output(read_buffer: &HANDLE, copy_buffer: &mut [CHAR_INFO;16
} }
} }
/// Write console output.
pub fn write_console_output(write_buffer: &HANDLE, copy_buffer: &mut [CHAR_INFO;160], buffer_size: COORD, buffer_coord: COORD, source_buffer: PSMALL_RECT) pub fn write_console_output(write_buffer: &HANDLE, copy_buffer: &mut [CHAR_INFO;160], buffer_size: COORD, buffer_coord: COORD, source_buffer: PSMALL_RECT)
{ {
use self::wincon::WriteConsoleOutputA; use self::wincon::WriteConsoleOutputA;
@ -318,38 +390,34 @@ pub fn write_console_output(write_buffer: &HANDLE, copy_buffer: &mut [CHAR_INFO;
} }
} }
use std::ffi::OsStr;
use std::os::windows::ffi::OsStrExt;
use std::iter::once;
fn win32_string( value : &str ) -> Vec<u16> {
OsStr::new( value ).encode_wide().chain( once( 0 ) ).collect()
}
//use std::os::raw::c_void;
use winapi::ctypes::c_void;
use std::mem::transmute;
use std::str;
/// Write utf8 buffer to console.
pub fn write_char_buffer(handle: HANDLE, buf: &[u8]) pub fn write_char_buffer(handle: HANDLE, buf: &[u8])
{ {
use std::ffi::{ NulError, CString };
use std::str;
// get string from u8[] and parse it to an c_str // get string from u8[] and parse it to an c_str
let mut utf8 = match str::from_utf8(buf) let mut utf8 = match str::from_utf8(buf)
{ {
Ok(string) => string, Ok(string) => string,
Err(_) => "", Err(_) => "123",
}; };
let utf16_bytes: Vec<u16> = utf8.encode_utf16().collect(); let utf16: Vec<u16> = utf8.encode_utf16().collect();
let utf16_ptr: *const c_void = utf16.as_ptr() as *const _ as *const c_void;
let mut utf16 = match String::from_utf16(&utf16_bytes)
{
Ok(string) => string,
Err(_) => String::new()
};
let str_length = utf16.len() as u32;
let c_str = match CString::new(utf16)
{
Ok(c) => c,
Err(_) => CString::new("").unwrap()
};
let ptr: *const i8 = c_str.as_ptr() as *const i8;
// get buffer info // get buffer info
let csbi = get_console_screen_buffer_info(); let csbi = get_console_screen_buffer_info_from_handle(&handle);
// get current position // get current position
let current_pos = COORD {X: csbi.dwCursorPosition.X, Y: csbi.dwCursorPosition.Y}; let current_pos = COORD {X: csbi.dwCursorPosition.X, Y: csbi.dwCursorPosition.Y};
@ -359,18 +427,8 @@ pub fn write_char_buffer(handle: HANDLE, buf: &[u8])
// write to console // write to console
unsafe unsafe
{ {
// WriteConsoleOutputCharacterA() WriteConsoleW(handle, utf16_ptr, utf16.len() as u32, &mut cells_written, NULL);
// ::winapi::um::consoleapi::WriteConsoleW(handle, utf16.as_ptr(), utf16.len() as u32, &mut cells_written, NULL);
WriteConsoleOutputCharacterA(handle, ptr, str_length, current_pos, &mut cells_written);
} }
// get buffer info
let csbi = get_console_screen_buffer_info();
// get current position
let new_pos = COORD {X: csbi.dwCursorPosition.X, Y: csbi.dwCursorPosition.Y};
set_console_cursor_position(new_pos.X, new_pos.Y + 1);
} }
/// Parse integer to an bool /// Parse integer to an bool

View File

@ -1,12 +1,18 @@
use ScreenManager;
use std::sync::Mutex;
use std::rc::Rc;
/// Get the terminal size /// Get the terminal size
pub fn terminal_size() -> (u16, u16) { pub fn terminal_size(screen_manager: &Rc<Mutex<ScreenManager>>) -> (u16, u16) {
let csbi = super::kernel::get_console_screen_buffer_info(); let csbi = super::kernel::get_console_screen_buffer_info(screen_manager);
( (
(csbi.srWindow.Right - csbi.srWindow.Left) as u16, (csbi.srWindow.Right - csbi.srWindow.Left) as u16,
(csbi.srWindow.Bottom - csbi.srWindow.Top) as u16, (csbi.srWindow.Bottom - csbi.srWindow.Top) as u16,
) )
} }
/// Exit the current process.
pub fn exit() pub fn exit()
{ {
::std::process::exit(256); ::std::process::exit(256);

View File

@ -13,7 +13,8 @@ pub mod style;
pub mod terminal; pub mod terminal;
pub mod manager; pub mod manager;
pub use shared::{screen, raw}; pub use shared::{screen};
pub use shared::environment::Environment;
pub use state::context::Context; pub use state::context::Context;
use state::commands::IStateCommand; use state::commands::IStateCommand;

View File

@ -1,5 +1,6 @@
//! This module provides an interface for working with the sceen. With that I mean that you can get or wirte to the handle of the current screen. stdout. //! This module provides an interface for working with the screen. With that I mean that you can get or wirte to the handle of the current screen. stdout.
//! Because crossterm can work with alternate screen, we need a place that holds the handle to the current screen. And this module provides this place. //! Because crossterm can work with alternate screen, we need a place that holds the handle to the current screen so we can write to that screen.
use super::*; use super::*;
use super::super::shared::functions; use super::super::shared::functions;
use std::any::Any; use std::any::Any;
@ -20,15 +21,15 @@ impl ScreenManager
{ {
/// Create new screen manager instance whereon screen related actions can be performed. /// Create new screen manager instance whereon screen related actions can be performed.
pub fn new() -> ScreenManager { pub fn new() -> ScreenManager {
// #[cfg(target_os = "windows")] #[cfg(target_os = "windows")]
// let screen_manager = functions::get_module::<Box<IScreenManager>>(Box::from(WinApiScreenManager::new()), Box::from(AnsiScreenManager::new())).unwrap(); let screen_manager = functions::get_module::<Box<IScreenManager>>(Box::from(WinApiScreenManager::new()), Box::from(AnsiScreenManager::new())).unwrap();
//
// #[cfg(not(target_os = "windows"))] #[cfg(not(target_os = "windows"))]
// let screen_manager = Box::from(AnsiScreenManager::new()) as Box<IScreenManager>; let screen_manager = Box::from(AnsiScreenManager::new()) as Box<IScreenManager>;
ScreenManager ScreenManager
{ {
screen_manager: Box::new(WinApiScreenManager::new()) screen_manager: screen_manager
} }
} }
@ -49,13 +50,19 @@ impl ScreenManager
self.screen_manager.write_ansi_str(string); self.screen_manager.write_ansi_str(string);
} }
/// Can be used to get an specific implementation used for the current platform.
pub fn as_any(&mut self) -> &mut Any { self.screen_manager.as_any() } pub fn as_any(&mut self) -> &mut Any { self.screen_manager.as_any() }
pub fn write_val(&mut self, value: String)
{
self.screen_manager.write(value.as_bytes());
}
} }
impl Write for ScreenManager impl Write for ScreenManager
{ {
fn write(&mut self, buf: &[u8]) -> io::Result<usize> { fn write(&mut self, buf: &[u8]) -> io::Result<usize> {
self.screen_manager.write(buf) self.write(buf)
} }
fn flush(&mut self) -> io::Result<()> { fn flush(&mut self) -> io::Result<()> {

View File

@ -17,17 +17,16 @@ use std::any::Any;
pub trait IScreenManager pub trait IScreenManager
{ {
/// get the stdout of the screen. This can be used to write to the /// Toggle the value if alternatescreen is on.
// fn stdout(&mut self) -> &mut Self::Output;
fn toggle_is_alternate_screen(&mut self, is_alternate_screen: bool); fn toggle_is_alternate_screen(&mut self, is_alternate_screen: bool);
/// Write ansi code as String to the current stdout. /// Write ansi code as String to the current stdout.
fn write_ansi(&mut self, string: String); fn write_ansi(&mut self, string: String);
/// Write a &str to the current stdout. /// Write a &str to the current stdout.
fn write_ansi_str(&mut self, string: &str); fn write_ansi_str(&mut self, string: &str);
/// Write buffer to console.
fn write(&mut self, buf: &[u8]) -> io::Result<usize>; fn write(&mut self, buf: &[u8]) -> io::Result<usize>;
/// Flush the current output.
fn flush(&mut self) -> io::Result<()>; fn flush(&mut self) -> io::Result<()>;
/// Can be used to convert to an specific IScreenManager implementation.
fn as_any(&mut self) -> &mut Any; fn as_any(&mut self) -> &mut Any;
} }

View File

@ -1,6 +1,7 @@
use super::IScreenManager; use super::IScreenManager;
use kernel::windows_kernel::kernel; use kernel::windows_kernel::kernel;
use winapi::um::winnt::HANDLE; use winapi::um::winnt::HANDLE;
use winapi::um::wincon::ENABLE_PROCESSED_OUTPUT;
use std::io::{self,Write}; use std::io::{self,Write};
use std::any::Any; use std::any::Any;
@ -59,16 +60,19 @@ impl WinApiScreenManager {
pub fn set_alternate_handle(&mut self, alternate_handle: HANDLE) pub fn set_alternate_handle(&mut self, alternate_handle: HANDLE)
{ {
self.alternate_handle = alternate_handle; self.alternate_handle = alternate_handle;
// needs to be turned on so that escape characters like \n and \t will be processed.
kernel::set_console_mode(&self.alternate_handle, ENABLE_PROCESSED_OUTPUT as u32);
} }
pub fn get_handle(&mut self) -> Rc<HANDLE> pub fn get_handle(&mut self) -> &HANDLE
{ {
if self.is_alternate_screen if self.is_alternate_screen
{ {
return Rc::from(self.alternate_handle); return &self.alternate_handle;
} }
else { else {
return Rc::from(self.output); return &self.output;
} }
} }
} }

66
src/shared/environment.rs Normal file
View File

@ -0,0 +1,66 @@
use Context;
use super::super::cursor;
use super::super::terminal::terminal;
use super::super::style;
use std::mem;
use std::rc::Rc;
use std::fmt::Display;
use std::sync::{ONCE_INIT, Once};
static START: Once = ONCE_INIT;
pub struct Environment
{
context: Rc<Context>,
terminal: Box<terminal::Terminal>,
cursor: Box<cursor::TerminalCursor>,
color: Box<style::TerminalColor>
}
impl Environment
{
pub fn new() -> Environment
{
return Environment { context: Context::new(), terminal: unsafe{ mem::zeroed()}, cursor: unsafe{ mem::zeroed()}, color: unsafe{ mem::zeroed() }}
}
pub fn terminal(&mut self) -> &Box<terminal::Terminal>
{
START.call_once(|| {
self.terminal = terminal::terminal(self.context.clone());
});
&self.terminal
}
pub fn cursor(&mut self) -> &Box<cursor::TerminalCursor>
{
START.call_once(|| {
self.cursor = cursor::cursor(self.context.clone());
});
&self.cursor
}
pub fn color(&mut self) -> &Box<style::TerminalColor>
{
START.call_once(|| {
self.color = style::color(self.context.clone());
});
&self.color
}
pub fn paint<D: Display>(&mut self, value: D) -> style::StyledObject<D>
{
self.terminal().paint(value)
}
pub fn context(&self) -> Rc<Context>
{
return self.context.clone()
}
}

View File

@ -1,7 +1,9 @@
//! Some actions need to preformed platform independently since they can not be solved `ANSI escape codes`. //! Some actions need to preformed platform independently since they can not be solved `ANSI escape codes`.
use Context; use Context;
use ScreenManager;
use std::rc::Rc; use std::rc::Rc;
use std::sync::Mutex;
#[cfg(windows)] #[cfg(windows)]
use kernel::windows_kernel::terminal::{exit, terminal_size}; use kernel::windows_kernel::terminal::{exit, terminal_size};
@ -13,9 +15,13 @@ use kernel::windows_kernel::cursor::pos;
use kernel::unix_kernel::terminal::{pos, exit,terminal_size }; use kernel::unix_kernel::terminal::{pos, exit,terminal_size };
/// Get the terminal size based on the current platform. /// Get the terminal size based on the current platform.
pub fn get_terminal_size() -> (u16, u16) pub fn get_terminal_size(screen_manager: &Rc<Mutex<ScreenManager>>) -> (u16, u16)
{ {
terminal_size() #[cfg(unix)]
return terminal_size(screen_manager);
#[cfg(windows)]
return terminal_size(screen_manager);
} }
/// Get the cursor position based on the current platform. /// Get the cursor position based on the current platform.
@ -25,7 +31,7 @@ pub fn get_cursor_position(context: Rc<Context>) -> (u16, u16)
return pos(context.clone()); return pos(context.clone());
#[cfg(windows)] #[cfg(windows)]
return pos(); return pos(&context.screen_manager);
} }
/// exit the current terminal. /// exit the current terminal.
@ -46,12 +52,13 @@ pub fn get_module<T>(winapi_impl: T, unix_impl: T) -> Option<T>
let mut does_support = true; let mut does_support = true;
if cfg!(target_os = "windows") { if cfg!(target_os = "windows") {
#[cfg(windows)] // #[cfg(windows)]
use kernel::windows_kernel::ansi_support::try_enable_ansi_support; // use kernel::windows_kernel::ansi_support::try_enable_ansi_support;
// Try to enable ansi on windows if not than use WINAPI. // Try to enable ansi on windows if not than use WINAPI.
does_support = try_enable_ansi_support(); // does_support = try_enable_ansi_support();
does_support = false;
if !does_support if !does_support
{ {
term = Some(winapi_impl); term = Some(winapi_impl);
@ -60,6 +67,7 @@ pub fn get_module<T>(winapi_impl: T, unix_impl: T) -> Option<T>
if does_support if does_support
{ {
println!("Does support");
term = Some(unix_impl); term = Some(unix_impl);
} }

View File

@ -5,4 +5,7 @@ pub mod macros;
pub mod traits; pub mod traits;
pub mod functions; pub mod functions;
pub mod screen; pub mod screen;
pub mod environment;
#[cfg(target_os = "unix")]
pub mod raw; pub mod raw;

View File

@ -12,6 +12,8 @@
//! //!
//! With these modes you can easier design the terminal screen. //! With these modes you can easier design the terminal screen.
//! //!
//! !! Note that this module is only working for unix currently. !!
//!
//! # Example //! # Example
//! //!
//! ```rust //! ```rust

View File

@ -4,9 +4,13 @@
//! The alternate buffer is exactly the dimensions of the window, without any scrollback region. //! The alternate buffer is exactly the dimensions of the window, without any scrollback region.
//! For an example of this behavior, consider when vim is launched from bash. //! For an example of this behavior, consider when vim is launched from bash.
//! Vim uses the entirety of the screen to edit the file, then returning to bash leaves the original buffer unchanged. //! Vim uses the entirety of the screen to edit the file, then returning to bash leaves the original buffer unchanged.
//!
//! !! Note: this module is only working for unix and windows 10 terminals only. If you are using windows 10 or lower do not implement this functionality. Work in progress...
//!
use Context; use Context;
use state::commands::*; use state::commands::*;
use shared::functions;
use std::io::{self, Write}; use std::io::{self, Write};
use std::rc::Rc; use std::rc::Rc;
@ -79,27 +83,20 @@ impl Drop for AlternateScreen
{ {
fn drop(&mut self) fn drop(&mut self)
{ {
let mut mutex = &self.context.state_manager; use CommandManager;
{
let mut state_manager = mutex.lock().unwrap();
let mut mx = &state_manager.get(self.command_id); CommandManager::undo(self.context.clone(), self.command_id);
{
let mut command = mx.lock().unwrap();
command.undo();
}
}
} }
} }
// Get the alternate screen command to enable and disable alternate screen based on the current platform // Get the alternate screen command to enable and disable alternate screen based on the current platform
fn get_to_alternate_screen_command(context: Rc<Context>) -> u16 fn get_to_alternate_screen_command(context: Rc<Context>) -> u16
{ {
// #[cfg(target_os = "windows")] #[cfg(target_os = "windows")]
// let command = functions::get_module::<Box<ICommand>>(win_commands::ToAlternateScreenBufferCommand::new(), shared_commands::ToAlternateScreenBufferCommand::new(), context).unwrap(); let command_id = functions::get_module::<u16>(win_commands::ToAlternateScreenBufferCommand::new(context.clone()), shared_commands::ToAlternateScreenBufferCommand::new(context.clone())).unwrap();
//
// #[cfg(not(target_os = "windows"))]
// shared_commands::ToAlternateScreenBufferCommand::new(context.clone())
win_commands::ToAlternateScreenBufferCommand::new(context.clone()) #[cfg(not(target_os = "windows"))]
let command_id = shared_commands::ToAlternateScreenBufferCommand::new(context.clone());
return command_id;
} }

View File

@ -44,9 +44,10 @@ impl IStateCommand for ToAlternateScreenBufferCommand
{ {
fn execute(&mut self) -> bool fn execute(&mut self) -> bool
{ {
println!("asdfasdf");
let mut screen = self.context.screen_manager.lock().unwrap(); let mut screen = self.context.screen_manager.lock().unwrap();
{ {
screen.write_ansi_str(csi!("?1049h"));
screen.toggle_is_alternate_screen(true); screen.toggle_is_alternate_screen(true);
return true; return true;
} }

View File

@ -1,12 +1,12 @@
//! This module contains the commands that can be used for windows systems. //! This module contains the commands that can be used for windows systems.
use super::IStateCommand; use super::IStateCommand;
use { StateManager, Context }; use {StateManager, Context};
use kernel::windows_kernel::{kernel, ansi_support}; use kernel::windows_kernel::{kernel, ansi_support};
use winapi::shared::minwindef::DWORD; use winapi::shared::minwindef::DWORD;
use winapi::um::wincon; use winapi::um::wincon;
use winapi::um::wincon::{ENABLE_VIRTUAL_TERMINAL_PROCESSING ,SMALL_RECT, COORD, CHAR_INFO}; use winapi::um::wincon::{ENABLE_VIRTUAL_TERMINAL_PROCESSING, SMALL_RECT, COORD, CHAR_INFO};
use std::mem; use std::mem;
use std::rc::Rc; use std::rc::Rc;
@ -31,7 +31,7 @@ impl EnableAnsiCommand
impl IStateCommand for EnableAnsiCommand impl IStateCommand for EnableAnsiCommand
{ {
fn execute(&mut self,) -> bool fn execute(&mut self) -> bool
{ {
// we need to check whether we tried to enable ansi before. If we have we can just return if that had succeeded. // we need to check whether we tried to enable ansi before. If we have we can just return if that had succeeded.
if ansi_support::has_been_tried_to_enable_ansi() && ansi_support::ansi_enabled() if ansi_support::has_been_tried_to_enable_ansi() && ansi_support::ansi_enabled()
@ -86,13 +86,13 @@ impl IStateCommand for EnableAnsiCommand
pub struct EnableRawModeCommand pub struct EnableRawModeCommand
{ {
mask: DWORD, mask: DWORD,
key: u16 key: u16,
} }
impl EnableRawModeCommand impl EnableRawModeCommand
{ {
pub fn new(state_manager: &Mutex<StateManager>) -> u16 { pub fn new(state_manager: &Mutex<StateManager>) -> u16 {
use self::wincon::{ENABLE_LINE_INPUT,ENABLE_PROCESSED_INPUT, ENABLE_ECHO_INPUT}; use self::wincon::{ENABLE_LINE_INPUT, ENABLE_PROCESSED_INPUT, ENABLE_ECHO_INPUT};
let mut state = state_manager.lock().unwrap(); let mut state = state_manager.lock().unwrap();
{ {
@ -161,7 +161,7 @@ impl ToAlternateScreenBufferCommand
let mut state = context.state_manager.lock().unwrap(); let mut state = context.state_manager.lock().unwrap();
{ {
let key = state.get_changes_count(); let key = state.get_changes_count();
let command = ToAlternateScreenBufferCommand {context: context.clone()}; let command = ToAlternateScreenBufferCommand { context: context.clone() };
state.register_change(Box::from(command), key); state.register_change(Box::from(command), key);
key key
@ -175,7 +175,7 @@ impl IStateCommand for ToAlternateScreenBufferCommand
{ {
use super::super::super::manager::WinApiScreenManager; use super::super::super::manager::WinApiScreenManager;
let mut chi_buffer: [CHAR_INFO;160] = unsafe {mem::zeroed() }; let mut chi_buffer: [CHAR_INFO; 160] = unsafe { mem::zeroed() };
let handle = kernel::get_output_handle(); let handle = kernel::get_output_handle();
@ -189,7 +189,7 @@ impl IStateCommand for ToAlternateScreenBufferCommand
screen_manager.toggle_is_alternate_screen(true); screen_manager.toggle_is_alternate_screen(true);
let b: &mut WinApiScreenManager = match screen_manager.as_any().downcast_mut::<WinApiScreenManager>() { let b: &mut WinApiScreenManager = match screen_manager.as_any().downcast_mut::<WinApiScreenManager>() {
Some(b) => { b }, Some(b) => { b }
None => panic!("") None => panic!("")
}; };

View File

@ -45,10 +45,13 @@ impl Context
} }
} }
use std::io::Write;
impl Drop for Context impl Drop for Context
{ {
fn drop(&mut self) fn drop(&mut self)
{ {
panic!();
let mut changes = self.state_manager.lock().unwrap(); let mut changes = self.state_manager.lock().unwrap();
changes.restore_changes(); changes.restore_changes();
} }

View File

@ -30,6 +30,8 @@ impl StateManager
{ {
let mut item = item.lock().unwrap(); let mut item = item.lock().unwrap();
item.undo(); item.undo();
println!("undo!");
} }
} }

View File

@ -19,7 +19,7 @@ impl TerminalColor {
/// Create new instance whereon color related actions can be performed. /// Create new instance whereon color related actions can be performed.
pub fn new(context: Rc<Context>) -> TerminalColor { pub fn new(context: Rc<Context>) -> TerminalColor {
#[cfg(target_os = "windows")] #[cfg(target_os = "windows")]
let color = functions::get_module::<Box<ITerminalColor>>(WinApiColor::new(), AnsiColor::new()); let color = functions::get_module::<Box<ITerminalColor>>(WinApiColor::new(context.screen_manager.clone()), AnsiColor::new());
#[cfg(not(target_os = "windows"))] #[cfg(not(target_os = "windows"))]
let color = Some(AnsiColor::new() as Box<ITerminalColor>); let color = Some(AnsiColor::new() as Box<ITerminalColor>);

View File

@ -8,15 +8,16 @@ use std::sync::Mutex;
use std::rc::Rc; use std::rc::Rc;
/// This struct is an windows implementation for color related actions. /// This struct is an windows implementation for color related actions.
#[derive(Debug)]
pub struct WinApiColor { pub struct WinApiColor {
original_console_color: u16, original_console_color: u16,
screen_manager: Rc<Mutex<ScreenManager>>
} }
impl WinApiColor { impl WinApiColor {
pub fn new() -> Box<WinApiColor> { pub fn new(screen_manager: Rc<Mutex<ScreenManager>>) -> Box<WinApiColor> {
Box::from(WinApiColor { Box::from(WinApiColor {
original_console_color: kernel::get_original_console_color(), original_console_color: kernel::get_original_console_color(&screen_manager),
screen_manager: screen_manager
}) })
} }
} }
@ -26,7 +27,7 @@ impl ITerminalColor for WinApiColor {
fn set_fg(&self, fg_color: Color, screen_manager: Rc<Mutex<ScreenManager>>) { fn set_fg(&self, fg_color: Color, screen_manager: Rc<Mutex<ScreenManager>>) {
let color_value = &self.color_value(fg_color, ColorType::Foreground); let color_value = &self.color_value(fg_color, ColorType::Foreground);
let csbi = kernel::get_console_screen_buffer_info(); let csbi = kernel::get_console_screen_buffer_info(&self.screen_manager);
// Notice that the color values are stored in wAttribute. // Notice that the color values are stored in wAttribute.
// So we need to use bitwise operators to check if the values exists or to get current console colors. // So we need to use bitwise operators to check if the values exists or to get current console colors.
@ -41,13 +42,13 @@ impl ITerminalColor for WinApiColor {
color = color | wincon::BACKGROUND_INTENSITY as u16; color = color | wincon::BACKGROUND_INTENSITY as u16;
} }
kernel::set_console_text_attribute(color); kernel::set_console_text_attribute(color,&self.screen_manager);
} }
fn set_bg(&self, bg_color: Color, screen_manager: Rc<Mutex<ScreenManager>>) { fn set_bg(&self, bg_color: Color, screen_manager: Rc<Mutex<ScreenManager>>) {
let color_value = &self.color_value(bg_color, ColorType::Background); let color_value = &self.color_value(bg_color, ColorType::Background);
let csbi = kernel::get_console_screen_buffer_info(); let csbi = kernel::get_console_screen_buffer_info(&self.screen_manager);
// Notice that the color values are stored in wAttribute. // Notice that the color values are stored in wAttribute.
// So wee need to use bitwise operators to check if the values exists or to get current console colors. // So wee need to use bitwise operators to check if the values exists or to get current console colors.
let mut color: u16; let mut color: u16;
@ -61,11 +62,11 @@ impl ITerminalColor for WinApiColor {
color = color | wincon::FOREGROUND_INTENSITY as u16; color = color | wincon::FOREGROUND_INTENSITY as u16;
} }
kernel::set_console_text_attribute(color); kernel::set_console_text_attribute(color,&self.screen_manager);
} }
fn reset(&self, screen_manager: Rc<Mutex<ScreenManager>>) { fn reset(&self, screen_manager: Rc<Mutex<ScreenManager>>) {
kernel::set_console_text_attribute(self.original_console_color); kernel::set_console_text_attribute(self.original_console_color,&self.screen_manager);
} }
/// This will get the winapi color value from the Color and ColorType struct /// This will get the winapi color value from the Color and ColorType struct

View File

@ -10,7 +10,7 @@ use std::rc::Rc;
use super::super::Attribute; use super::super::Attribute;
/// Struct that contains the style properties that can be applied to an displayable object. /// Struct that contains the style properties that can be applied to an displayable object.
#[derive(Clone)] #[derive(Copy, Clone)]
pub struct ObjectStyle { pub struct ObjectStyle {
pub fg_color: Option<Color>, pub fg_color: Option<Color>,
pub bg_color: Option<Color>, pub bg_color: Option<Color>,

View File

@ -43,7 +43,7 @@ impl ITerminal for AnsiTerminal {
} }
fn terminal_size(&self) -> (u16, u16) { fn terminal_size(&self) -> (u16, u16) {
functions::get_terminal_size() functions::get_terminal_size(&self.context.screen_manager)
} }
fn scroll_up(&self, count: i16) { fn scroll_up(&self, count: i16) {

View File

@ -6,6 +6,7 @@ use Context;
use super::super::style; use super::super::style;
use super::super::shared::functions; use super::super::shared::functions;
use std::fmt::Write;
use std::fmt; use std::fmt;
use std::rc::Rc; use std::rc::Rc;
@ -193,6 +194,20 @@ impl Terminal {
terminal.exit(); terminal.exit();
} }
} }
pub fn write<D: fmt::Display>(&mut self, value: D)
{
let mut mutex = &self.context.screen_manager;
{
let mut screen_manager = mutex.lock().unwrap();
use std::fmt::Write;
let mut string = String::new();
write!(string, "{}", value).unwrap();
screen_manager.write_val(string);
}
}
} }
/// Get an Terminal implementation whereon terminal related actions can be performed. /// Get an Terminal implementation whereon terminal related actions can be performed.

View File

@ -7,6 +7,9 @@ use super::{ClearType, ITerminal, Rc};
use winapi::um::wincon::{SMALL_RECT, COORD, CONSOLE_SCREEN_BUFFER_INFO,}; use winapi::um::wincon::{SMALL_RECT, COORD, CONSOLE_SCREEN_BUFFER_INFO,};
use kernel::windows_kernel::{kernel, terminal}; use kernel::windows_kernel::{kernel, terminal};
use super::super::shared::functions; use super::super::shared::functions;
use super::super::ScreenManager;
use std::sync::Mutex;
/// This struct is an windows implementation for terminal related actions. /// This struct is an windows implementation for terminal related actions.
pub struct WinApiTerminal pub struct WinApiTerminal
@ -23,29 +26,29 @@ impl WinApiTerminal {
impl ITerminal for WinApiTerminal { impl ITerminal for WinApiTerminal {
fn clear(&self, clear_type: ClearType) { fn clear(&self, clear_type: ClearType) {
let csbi = kernel::get_console_screen_buffer_info(); let csbi = kernel::get_console_screen_buffer_info(&self.context.screen_manager);
let pos = cursor(self.context.clone()).pos(); let pos = cursor(self.context.clone()).pos();
match clear_type match clear_type
{ {
ClearType::All => clear_entire_screen(csbi, self.context.clone()), ClearType::All => clear_entire_screen(csbi, &self.context),
ClearType::FromCursorDown => clear_after_cursor(pos,csbi, self.context.clone()), ClearType::FromCursorDown => clear_after_cursor(pos,csbi, &self.context),
ClearType::FromCursorUp => clear_before_cursor(pos, csbi, self.context.clone()), ClearType::FromCursorUp => clear_before_cursor(pos, csbi, &self.context),
ClearType::CurrentLine => clear_current_line(pos, csbi, self.context.clone()), ClearType::CurrentLine => clear_current_line(pos, csbi, &self.context),
ClearType::UntilNewLine => clear_until_line(pos, csbi,self.context.clone()), ClearType::UntilNewLine => clear_until_line(pos, csbi, &self.context),
}; };
} }
fn terminal_size(&self) -> (u16, u16) { fn terminal_size(&self) -> (u16, u16) {
terminal::terminal_size() terminal::terminal_size(&self.context.screen_manager)
} }
fn scroll_up(&self, count: i16) { fn scroll_up(&self, count: i16) {
// yet to be inplemented // yet to be implemented
} }
fn scroll_down(&self, count: i16) { fn scroll_down(&self, count: i16) {
let csbi = kernel::get_console_screen_buffer_info(); let csbi = kernel::get_console_screen_buffer_info(&self.context.screen_manager);
let mut srct_window; let mut srct_window;
// Set srctWindow to the current window size and location. // Set srctWindow to the current window size and location.
@ -56,7 +59,7 @@ impl ITerminal for WinApiTerminal {
srct_window.Top += count; // move top down srct_window.Top += count; // move top down
srct_window.Bottom += count; // move bottom down srct_window.Bottom += count; // move bottom down
let success = kernel::set_console_info(true, &mut srct_window); let success = kernel::set_console_info(true, &mut srct_window, &self.context.screen_manager);
if success { if success {
panic!("Something went wrong when scrolling down"); panic!("Something went wrong when scrolling down");
} }
@ -76,7 +79,7 @@ impl ITerminal for WinApiTerminal {
} }
// Get the position of the current console window // Get the position of the current console window
let csbi = kernel::get_console_screen_buffer_info(); let csbi = kernel::get_console_screen_buffer_info(&self.context.screen_manager);
let mut success = false; let mut success = false;
// If the buffer is smaller than this new window size, resize the // If the buffer is smaller than this new window size, resize the
@ -105,7 +108,7 @@ impl ITerminal for WinApiTerminal {
} }
if resize_buffer { if resize_buffer {
success = kernel::set_console_screen_buffer_size(size); success = kernel::set_console_screen_buffer_size(size, &self.context.screen_manager);
if !success if !success
{ {
@ -118,12 +121,12 @@ impl ITerminal for WinApiTerminal {
fsr_window.Bottom = fsr_window.Top + height; fsr_window.Bottom = fsr_window.Top + height;
fsr_window.Right = fsr_window.Left + width; fsr_window.Right = fsr_window.Left + width;
let success = kernel::set_console_info(true, &fsr_window); let success = kernel::set_console_info(true, &fsr_window, &self.context.screen_manager);
if success { if success {
// If we resized the buffer, un-resize it. // If we resized the buffer, un-resize it.
if resize_buffer { if resize_buffer {
kernel::set_console_screen_buffer_size(csbi.dwSize); kernel::set_console_screen_buffer_size(csbi.dwSize, &self.context.screen_manager);
} }
let bounds = kernel::get_largest_console_window_size(); let bounds = kernel::get_largest_console_window_size();
@ -145,7 +148,7 @@ impl ITerminal for WinApiTerminal {
} }
} }
pub fn clear_after_cursor(pos: (u16,u16), csbi: CONSOLE_SCREEN_BUFFER_INFO, context: Rc<Context>) { pub fn clear_after_cursor(pos: (u16,u16), csbi: CONSOLE_SCREEN_BUFFER_INFO, context: &Rc<Context>) {
let (mut x,mut y) = pos; let (mut x,mut y) = pos;
// if cursor position is at the outer right position // if cursor position is at the outer right position
@ -160,10 +163,10 @@ pub fn clear_after_cursor(pos: (u16,u16), csbi: CONSOLE_SCREEN_BUFFER_INFO, cont
// get sum cells before cursor // get sum cells before cursor
let cells_to_write = csbi.dwSize.X as u32 * csbi.dwSize.Y as u32; let cells_to_write = csbi.dwSize.X as u32 * csbi.dwSize.Y as u32;
clear(start_location,cells_to_write); clear(start_location,cells_to_write, &context.screen_manager);
} }
pub fn clear_before_cursor(pos: (u16,u16), csbi: CONSOLE_SCREEN_BUFFER_INFO, context: Rc<Context>) { pub fn clear_before_cursor(pos: (u16,u16), csbi: CONSOLE_SCREEN_BUFFER_INFO, context: &Rc<Context>) {
let (xpos,ypos) = pos; let (xpos,ypos) = pos;
// one cell after cursor position // one cell after cursor position
@ -176,10 +179,10 @@ pub fn clear_before_cursor(pos: (u16,u16), csbi: CONSOLE_SCREEN_BUFFER_INFO, con
// get sum cells before cursor // get sum cells before cursor
let cells_to_write = (csbi.dwSize.X as u32 * ypos as u32) + (xpos as u32 + 1); let cells_to_write = (csbi.dwSize.X as u32 * ypos as u32) + (xpos as u32 + 1);
clear(start_location, cells_to_write); clear(start_location, cells_to_write, &context.screen_manager);
} }
pub fn clear_entire_screen(csbi: CONSOLE_SCREEN_BUFFER_INFO, context: Rc<Context>) { pub fn clear_entire_screen(csbi: CONSOLE_SCREEN_BUFFER_INFO, context: &Rc<Context>) {
// position x at start // position x at start
let x = 0; let x = 0;
// position y at start // position y at start
@ -191,13 +194,13 @@ pub fn clear_entire_screen(csbi: CONSOLE_SCREEN_BUFFER_INFO, context: Rc<Context
let cells_to_write = csbi.dwSize.X as u32 * csbi.dwSize.Y as u32; let cells_to_write = csbi.dwSize.X as u32 * csbi.dwSize.Y as u32;
clear( start_location, cells_to_write); clear( start_location, cells_to_write, &context.screen_manager);
// put the cursor back at (0, 0) // put the cursor back at (0, 0)
cursor(context.clone()).goto(0, 0); cursor(context.clone()).goto(0, 0);
} }
pub fn clear_current_line(pos: (u16,u16), csbi: CONSOLE_SCREEN_BUFFER_INFO, context: Rc<Context>) pub fn clear_current_line(pos: (u16,u16), csbi: CONSOLE_SCREEN_BUFFER_INFO, context: &Rc<Context>)
{ {
// position x at start // position x at start
let x = 0; let x = 0;
@ -210,13 +213,13 @@ pub fn clear_current_line(pos: (u16,u16), csbi: CONSOLE_SCREEN_BUFFER_INFO, cont
let cells_to_write = csbi.dwSize.X as u32; let cells_to_write = csbi.dwSize.X as u32;
clear(start_location, cells_to_write); clear(start_location, cells_to_write, &context.screen_manager);
// put the cursor back at 1 cell on current row // put the cursor back at 1 cell on current row
cursor(context.clone()).goto(0, y); cursor(context.clone()).goto(0, y);
} }
pub fn clear_until_line(pos: (u16,u16), csbi: CONSOLE_SCREEN_BUFFER_INFO, context: Rc<Context>) pub fn clear_until_line(pos: (u16,u16), csbi: CONSOLE_SCREEN_BUFFER_INFO, context: &Rc<Context>)
{ {
let (x,y) = pos; let (x,y) = pos;
@ -225,7 +228,7 @@ pub fn clear_until_line(pos: (u16,u16), csbi: CONSOLE_SCREEN_BUFFER_INFO, contex
// get sum cells before cursor // get sum cells before cursor
let cells_to_write = (csbi.dwSize.X - x as i16) as u32; let cells_to_write = (csbi.dwSize.X - x as i16) as u32;
clear(start_location, cells_to_write); clear(start_location, cells_to_write, &context.screen_manager);
// put the cursor back at original cursor position // put the cursor back at original cursor position
cursor(context.clone()).goto(x,y); cursor(context.clone()).goto(x,y);
@ -233,12 +236,13 @@ pub fn clear_until_line(pos: (u16,u16), csbi: CONSOLE_SCREEN_BUFFER_INFO, contex
fn clear( fn clear(
start_loaction: COORD, start_loaction: COORD,
cells_to_write: u32 cells_to_write: u32,
screen_manager: &Rc<Mutex<ScreenManager>>
) { ) {
let mut cells_written = 0; let mut cells_written = 0;
let mut success = false; let mut success = false;
success = kernel::fill_console_output_character(&mut cells_written, start_loaction, cells_to_write); success = kernel::fill_console_output_character(&mut cells_written, start_loaction, cells_to_write, screen_manager);
if !success if !success
{ {
@ -247,7 +251,7 @@ fn clear(
cells_written = 0; cells_written = 0;
success = kernel::fill_console_output_attribute(&mut cells_written, start_loaction, cells_to_write); success = kernel::fill_console_output_attribute(&mut cells_written, start_loaction, cells_to_write, screen_manager);
if !success { if !success {
panic!("Couldnot reset attributes after cursor"); panic!("Couldnot reset attributes after cursor");

0
string Normal file
View File