Windows alternate screen working. color implementation for alternate screen fixed. And all functionalities for the main screen should also work

This commit is contained in:
TimonPost 2018-07-03 22:48:04 +02:00
parent 223b353101
commit 26a1960159
13 changed files with 473 additions and 406 deletions

View File

@ -2,58 +2,19 @@
<project version="4">
<component name="ChangeListManager">
<list default="true" id="310aeab2-4737-4e8e-b7eb-0aac10d104a3" name="Default" comment="">
<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)/program_examples/mod.rs" beforeDir="false" afterPath="$PROJECT_DIR$/examples/Crossterm 0.2.2 - New Version (Not finished)/program_examples/mod.rs" 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)/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$/examples/Crossterm 0.2.2 - New Version (Not finished)/terminal/raw_mode.rs" beforeDir="false" afterPath="$PROJECT_DIR$/examples/Crossterm 0.2.2 - New Version (Not finished)/terminal/raw_mode.rs" afterDir="false" />
<change beforePath="$PROJECT_DIR$/examples/Crossterm 0.2.2 - New Version (Not finished)/terminal/terminal.rs" beforeDir="false" afterPath="$PROJECT_DIR$/examples/Crossterm 0.2.2 - New Version (Not finished)/terminal/terminal.rs" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/cursor/ansi_cursor.rs" beforeDir="false" afterPath="$PROJECT_DIR$/src/cursor/ansi_cursor.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/mod.rs" beforeDir="false" afterPath="$PROJECT_DIR$/src/cursor/mod.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/mod.rs" beforeDir="false" afterPath="$PROJECT_DIR$/src/kernel/mod.rs" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/kernel/unix_kernel/mod.rs" beforeDir="false" afterPath="$PROJECT_DIR$/src/kernel/unix_kernel/mod.rs" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/kernel/unix_kernel/terminal.rs" beforeDir="false" afterPath="$PROJECT_DIR$/src/kernel/unix_kernel/terminal.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/mod.rs" beforeDir="false" afterPath="$PROJECT_DIR$/src/kernel/windows_kernel/mod.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/ansi_manager.rs" beforeDir="false" afterPath="$PROJECT_DIR$/src/manager/ansi_manager.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/shared/environment.rs" beforeDir="false" afterPath="$PROJECT_DIR$/src/shared/environment.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/macros.rs" beforeDir="false" afterPath="$PROJECT_DIR$/src/shared/macros.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/shared/traits.rs" beforeDir="false" afterPath="$PROJECT_DIR$/src/shared/traits.rs" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/state/command_manager.rs" beforeDir="false" afterPath="$PROJECT_DIR$/src/state/command_manager.rs" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/state/commands/mod.rs" beforeDir="false" afterPath="$PROJECT_DIR$/src/state/commands/mod.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/unix_command.rs" beforeDir="false" afterPath="$PROJECT_DIR$/src/state/commands/unix_command.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/mod.rs" beforeDir="false" afterPath="$PROJECT_DIR$/src/state/mod.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/ansi_color.rs" beforeDir="false" afterPath="$PROJECT_DIR$/src/style/color/ansi_color.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/mod.rs" beforeDir="false" afterPath="$PROJECT_DIR$/src/style/color/mod.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/mod.rs" beforeDir="false" afterPath="$PROJECT_DIR$/src/style/mod.rs" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/style/styles/mod.rs" beforeDir="false" afterPath="$PROJECT_DIR$/src/style/styles/mod.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/style/styles/styledobject.rs" beforeDir="false" afterPath="$PROJECT_DIR$/src/style/styles/styledobject.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/mod.rs" beforeDir="false" afterPath="$PROJECT_DIR$/src/terminal/mod.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>
<option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" />
<option name="TRACKING_ENABLED" value="true" />
@ -64,11 +25,96 @@
</component>
<component name="FileEditorManager">
<leaf SIDE_TABS_SIZE_LIMIT_KEY="300">
<file leaf-file-name="raw.rs" pinned="false" current-in-tab="true">
<entry file="file://$PROJECT_DIR$/src/shared/raw.rs">
<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="357">
<caret line="53" lean-forward="true" selection-start-line="53" selection-end-line="53" />
<state relative-caret-position="243">
<caret line="46" column="44" selection-start-line="46" selection-start-column="44" selection-end-line="46" selection-end-column="44" />
</state>
</provider>
</entry>
</file>
<file leaf-file-name="screen.rs" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/src/shared/screen.rs">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="438">
<caret line="70" column="22" selection-start-line="70" selection-start-column="22" selection-end-line="70" selection-end-column="22" />
</state>
</provider>
</entry>
</file>
<file leaf-file-name="manager.rs" pinned="false" current-in-tab="true">
<entry file="file://$PROJECT_DIR$/src/manager/manager.rs">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="549">
<caret line="61" column="58" selection-start-line="61" selection-start-column="58" selection-end-line="61" selection-end-column="58" />
</state>
</provider>
</entry>
</file>
<file leaf-file-name="terminal.rs" pinned="false" current-in-tab="false">
<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" />
</entry>
</file>
<file leaf-file-name="impls.rs" pinned="false" current-in-tab="false">
<entry file="file://$USER_HOME$/.rustup/toolchains/stable-x86_64-pc-windows-msvc/lib/rustlib/src/rust/src/libstd/io/impls.rs">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="251">
<caret line="48" column="7" selection-start-line="48" selection-start-column="7" selection-end-line="48" selection-end-column="7" />
</state>
</provider>
</entry>
</file>
<file leaf-file-name="ansi_manager.rs" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/src/manager/ansi_manager.rs">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="413">
<caret line="30" column="30" selection-start-line="30" selection-start-column="30" selection-end-line="30" selection-end-column="30" />
<folding>
<element signature="e#852#853#0" expanded="true" />
<element signature="e#889#890#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
</file>
<file leaf-file-name="raw_mode.rs" pinned="false" current-in-tab="false">
<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="221">
<caret line="19" column="10" selection-start-line="19" selection-start-column="10" selection-end-line="19" selection-end-column="10" />
</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="532">
<caret line="227" column="33" selection-start-line="227" selection-start-column="33" selection-end-line="227" selection-end-column="33" />
<folding>
<element signature="e#5601#5602#0" expanded="true" />
<element signature="e#5677#5678#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
</file>
<file leaf-file-name="kernel.rs" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/src/kernel/windows_kernel/kernel.rs">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="89">
<caret line="391" column="7" selection-start-line="391" selection-start-column="7" selection-end-line="391" selection-end-column="7" />
</state>
</provider>
</entry>
</file>
<file leaf-file-name="win_manager.rs" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/src/manager/win_manager.rs">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="362">
<caret line="32" column="5" selection-start-line="24" selection-start-column="3" selection-end-line="32" selection-end-column="5" />
</state>
</provider>
</entry>
@ -84,11 +130,6 @@
</component>
<component name="FindInProjectRecents">
<findStrings>
<find>cursor_vis</find>
<find>write</find>
<find>ToAlternateScreenBufferCommand</find>
<find>new</find>
<find>terminal</find>
<find>ICommand</find>
<find>Write</find>
<find>StyledObject</find>
@ -114,6 +155,11 @@
<find>csbi</find>
<find>context</find>
<find>terminal_size</find>
<find>colored_terminal</find>
<find>get_output</find>
<find>get</find>
<find>haha</find>
<find>handle</find>
</findStrings>
<replaceStrings>
<replace>crossterm_cursor</replace>
@ -137,8 +183,6 @@
<component name="IdeDocumentHistory">
<option name="CHANGED_PATHS">
<list>
<option value="$PROJECT_DIR$/src/style/mod.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$/src/state/commands/mod.rs" />
<option value="$PROJECT_DIR$/src/manager/ansi_manager.rs" />
@ -148,7 +192,6 @@
<option value="$PROJECT_DIR$/src/kernel/unix_kernel/terminal.rs" />
<option value="$PROJECT_DIR$/src/terminal/mod.rs" />
<option value="$PROJECT_DIR$/examples/Crossterm 0.2.2 - New Version (Not finished)/terminal/terminal.rs" />
<option value="$PROJECT_DIR$/src/style/styles/styledobject.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" />
@ -161,7 +204,6 @@
<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$/src/shared/mod.rs" />
<option value="$PROJECT_DIR$/src/shared/envoirment.rs" />
@ -172,22 +214,26 @@
<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/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/shared/raw.rs" />
<option value="$PROJECT_DIR$/src/cursor/cursor.rs" />
<option value="$PROJECT_DIR$/src/state/commands/win_commands.rs" />
<option value="$PROJECT_DIR$/src/style/color/mod.rs" />
<option value="$PROJECT_DIR$/src/style/color/winapi_color.rs" />
<option value="$PROJECT_DIR$/src/style/color/color.rs" />
<option value="$PROJECT_DIR$/src/style/color/ansi_color.rs" />
<option value="$PROJECT_DIR$/src/style/styles/styledobject.rs" />
<option value="$PROJECT_DIR$/src/terminal/terminal.rs" />
<option value="$PROJECT_DIR$/src/shared/screen.rs" />
<option value="$PROJECT_DIR$/src/kernel/windows_kernel/kernel.rs" />
<option value="$PROJECT_DIR$/src/manager/win_manager.rs" />
<option value="$PROJECT_DIR$/examples/Crossterm 0.2.2 - New Version (Not finished)/terminal/alternate_screen.rs" />
<option value="$PROJECT_DIR$/src/manager/manager.rs" />
</list>
</option>
</component>
@ -227,6 +273,7 @@
<foldersAlwaysOnTop value="true" />
</navigator>
<panes>
<pane id="Scope" />
<pane id="ProjectPane">
<subPane>
<expand>
@ -367,7 +414,6 @@
<select />
</subPane>
</pane>
<pane id="Scope" />
<pane id="PackagesPane" />
<pane id="AndroidView" />
</panes>
@ -562,12 +608,14 @@
<workItem from="1530289442537" duration="10502000" />
<workItem from="1530344478032" duration="18289000" />
<workItem from="1530446561530" duration="7222000" />
<workItem from="1530473645162" duration="4134000" />
<workItem from="1530473645162" duration="4319000" />
<workItem from="1530555023055" duration="7338000" />
<workItem from="1530634062082" duration="10908000" />
</task>
<servers />
</component>
<component name="TimeTrackingManager">
<option name="totallyTimeSpent" value="681958000" />
<option name="totallyTimeSpent" value="700389000" />
</component>
<component name="ToolWindowManager">
<frame x="-8" y="-8" width="2576" height="1056" extended-state="6" />
@ -606,14 +654,14 @@
<window_info anchor="right" id="Palette" order="3" />
<window_info anchor="right" content_ui="combo" id="Hierarchy" order="2" weight="0.25" />
<window_info anchor="right" id="Capture Analysis" order="8" />
<window_info anchor="bottom" id="Version Control" order="8" />
<window_info anchor="bottom" id="Run" order="2" />
<window_info anchor="right" id="Cargo" order="4" />
<window_info content_ui="combo" id="Project" order="0" visible="true" weight="0.1140625" />
<window_info id="Structure" order="1" weight="0.25" />
<window_info anchor="right" id="Commander" order="0" weight="0.4" />
<window_info anchor="right" id="Ant Build" order="1" weight="0.25" />
<window_info anchor="bottom" id="TODO" order="6" />
<window_info anchor="bottom" id="Run" order="2" />
<window_info anchor="bottom" id="Version Control" order="8" />
<window_info id="Image Layers" order="5" />
<window_info id="Designer" order="3" />
<window_info id="UI Designer" order="4" />
@ -639,30 +687,6 @@
<option name="myLimit" value="2678400000" />
</component>
<component name="editorHistoryManager">
<entry file="file://$PROJECT_DIR$/src/state/state_manager.rs">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="442">
<caret line="26" column="26" selection-start-line="26" selection-start-column="11" selection-end-line="26" selection-end-column="26" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/state/commands/shared_commands.rs">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="476">
<caret line="34" column="48" selection-start-line="34" selection-start-column="48" selection-end-line="34" selection-end-column="48" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/examples/Crossterm 0.2.2 - New Version (Not finished)/games/FirstDepthSearch/main.rs" />
<entry file="file://$PROJECT_DIR$/examples/Crossterm 0.2.2 - New Version (Not finished)/program_examples/first_depth_search/Cargo.toml" />
<entry file="file://$PROJECT_DIR$/examples/Crossterm 0.2.2 - New Version (Not finished)/program_examples/README.md">
<provider selected="true" editor-type-id="split-provider[text-editor;markdown-preview-editor]">
<state split_layout="SPLIT">
<first_editor />
<second_editor />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/shared/mod.rs">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="119">
@ -692,13 +716,6 @@
</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="272">
<caret line="16" column="1" selection-start-line="16" selection-start-column="1" selection-end-line="16" selection-end-column="1" />
</state>
</provider>
</entry>
<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">
<state relative-caret-position="305">
@ -706,13 +723,6 @@
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/style/mod.rs">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="195">
<caret line="28" column="9" selection-start-line="28" selection-start-column="9" selection-end-line="28" selection-end-column="9" />
</state>
</provider>
</entry>
<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">
<state relative-caret-position="221">
@ -776,11 +786,6 @@
</state>
</provider>
</entry>
<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">
<state relative-caret-position="-255" />
</provider>
</entry>
<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">
<state relative-caret-position="275">
@ -788,55 +793,6 @@
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/state/context.rs">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="170">
<caret line="10" column="8" selection-start-line="10" selection-start-column="8" selection-end-line="10" selection-end-column="8" />
</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="357">
<caret line="21" column="24" selection-start-line="21" selection-start-column="24" selection-end-line="21" selection-end-column="24" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/style/color/color.rs">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="-1062">
<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>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/style/styles/styledobject.rs">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="-1649">
<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/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/shared/functions.rs">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="228">
@ -844,27 +800,6 @@
</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="141">
<caret line="63" column="69" selection-start-line="63" selection-start-column="69" selection-end-line="63" 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="357">
@ -879,34 +814,6 @@
</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="844">
<caret line="200" column="11" selection-start-line="200" selection-start-column="11" selection-end-line="200" selection-end-column="11" />
</state>
</provider>
</entry>
<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="187">
<caret line="17" column="13" selection-start-line="17" selection-start-column="13" selection-end-line="17" selection-end-column="13" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/cursor/cursor.rs">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="459">
<caret line="316" column="11" selection-start-line="316" selection-start-column="11" selection-end-line="316" selection-end-column="11" />
</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="566">
@ -914,16 +821,6 @@
</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="246">
<caret line="79" column="13" lean-forward="true" selection-start-line="79" selection-start-column="13" selection-end-line="79" selection-end-column="13" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/kernel/mod.rs">
<provider selected="true" editor-type-id="text-editor" />
</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">
@ -931,13 +828,6 @@
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/kernel/windows_kernel/kernel.rs">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="98">
<caret line="204" column="18" selection-start-line="204" selection-start-column="18" selection-end-line="204" selection-end-column="18" />
</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">
@ -952,16 +842,209 @@
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/examples/Crossterm 0.2.2 - New Version (Not finished)/cursor/mod.rs">
<provider selected="true" editor-type-id="text-editor" />
</entry>
<entry file="file://$PROJECT_DIR$/src/shared/macros.rs">
<provider selected="true" editor-type-id="text-editor" />
</entry>
<entry file="file://$PROJECT_DIR$/src/shared/raw.rs">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="357">
<caret line="53" lean-forward="true" selection-start-line="53" selection-end-line="53" />
<state relative-caret-position="434">
<caret line="66" column="58" selection-start-line="66" selection-start-column="58" selection-end-line="66" selection-end-column="58" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/terminal/mod.rs">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="-110" />
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/cursor/cursor.rs">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="4148">
<caret line="244" column="49" selection-start-line="244" selection-start-column="49" selection-end-line="244" selection-end-column="49" />
</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="544">
<caret line="32" column="17" selection-start-line="32" selection-start-column="17" selection-end-line="32" selection-end-column="17" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/style/color/mod.rs">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="476">
<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/stable-x86_64-pc-windows-msvc/lib/rustlib/src/rust/src/libcore/str/mod.rs">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="305">
<caret line="2542" column="7" selection-start-line="2542" selection-start-column="7" selection-end-line="2542" selection-end-column="7" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/style/color/ansi_color.rs">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="297">
<caret line="50" column="7" selection-start-line="50" selection-start-column="7" selection-end-line="50" selection-end-column="7" />
</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="1215">
<caret line="79" column="13" selection-start-line="79" selection-start-column="13" selection-end-line="79" selection-end-column="13" />
</state>
</provider>
</entry>
<entry file="file://$USER_HOME$/.rustup/toolchains/stable-x86_64-pc-windows-msvc/lib/rustlib/src/rust/src/libcore/clone.rs">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="746">
<caret line="209" column="11" selection-start-line="209" selection-start-column="11" selection-end-line="209" selection-end-column="11" />
<folding>
<element signature="e#7227#7228#0" expanded="true" />
<element signature="e#7255#7256#0" expanded="true" />
</folding>
</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="314">
<caret line="38" column="17" selection-start-line="38" selection-start-column="17" selection-end-line="38" selection-end-column="17" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/state/context.rs">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="136">
<caret line="8" column="11" selection-start-line="8" selection-start-column="11" selection-end-line="8" selection-end-column="11" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/style/mod.rs">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="195">
<caret line="28" column="9" selection-start-line="28" selection-start-column="9" selection-end-line="28" selection-end-column="9" />
</state>
</provider>
</entry>
<entry file="file://$USER_HOME$/.rustup/toolchains/stable-x86_64-pc-windows-msvc/lib/rustlib/src/rust/src/libcore/fmt/mod.rs">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="305">
<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://$PROJECT_DIR$/src/terminal/winapi_terminal.rs">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="-35">
<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/style/color/winapi_color.rs">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="859">
<caret line="51" column="41" selection-start-line="51" selection-start-column="41" selection-end-line="51" selection-end-column="41" />
</state>
</provider>
</entry>
<entry file="file://$USER_HOME$/.rustup/toolchains/stable-x86_64-pc-windows-msvc/lib/rustlib/src/rust/src/liballoc/string.rs">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="305">
<caret line="382" column="11" selection-start-line="382" selection-start-column="11" selection-end-line="382" selection-end-column="11" />
<folding>
<element signature="e#11610#11611#0" expanded="true" />
<element signature="e#11651#11652#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/style/color/color.rs">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="315">
<caret line="107" column="11" selection-start-line="107" selection-start-column="11" selection-end-line="107" selection-end-column="11" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/style/styles/styledobject.rs">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="757">
<caret line="197" column="32" selection-start-line="197" selection-start-column="32" selection-end-line="197" selection-end-column="32" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/terminal/terminal.rs">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="532">
<caret line="227" column="33" selection-start-line="227" selection-start-column="33" selection-end-line="227" selection-end-column="33" />
<folding>
<element signature="e#5601#5602#0" expanded="true" />
<element signature="e#5677#5678#0" expanded="true" />
</folding>
</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="221">
<caret line="19" column="10" selection-start-line="19" selection-start-column="10" selection-end-line="19" selection-end-column="10" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/kernel/windows_kernel/kernel.rs">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="89">
<caret line="391" column="7" selection-start-line="391" selection-start-column="7" selection-end-line="391" selection-end-column="7" />
</state>
</provider>
</entry>
<entry file="file://$USER_HOME$/.rustup/toolchains/stable-x86_64-pc-windows-msvc/lib/rustlib/src/rust/src/libstd/io/impls.rs">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="251">
<caret line="48" column="7" selection-start-line="48" selection-start-column="7" selection-end-line="48" selection-end-column="7" />
</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="362">
<caret line="32" column="5" selection-start-line="24" selection-start-column="3" selection-end-line="32" selection-end-column="5" />
</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="413">
<caret line="30" column="30" selection-start-line="30" selection-start-column="30" selection-end-line="30" selection-end-column="30" />
<folding>
<element signature="e#852#853#0" expanded="true" />
<element signature="e#889#890#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
<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" />
</entry>
<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="243">
<caret line="46" column="44" selection-start-line="46" selection-start-column="44" selection-end-line="46" selection-end-column="44" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/shared/screen.rs">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="438">
<caret line="70" column="22" selection-start-line="70" selection-start-column="22" selection-end-line="70" selection-end-column="22" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/manager/manager.rs">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="549">
<caret line="61" column="58" selection-start-line="61" selection-start-column="58" selection-end-line="61" selection-end-column="58" />
</state>
</provider>
</entry>

View File

@ -1,5 +1,6 @@
extern crate crossterm;
use crossterm::style::Color;
use crossterm::cursor::cursor;
use crossterm::screen::AlternateScreen;
use crossterm::terminal::{self, ClearType};
@ -28,11 +29,13 @@ fn print_wait_screen(context: Rc<Context>) {
// print the current counter at the line of `Seconds to Go: {counter}`
cursor
.goto(10, 2)
.print(format!("{} of the 5 items processed", i));
.print(terminal.paint(format!("{} of the 5 items processed", i)).with(Color::Red).on(Color::Blue));
// 1 second delay
thread::sleep(time::Duration::from_secs(1));
}
stdout().flush();
}
/// print wait screen on alternate screen, then swich back.
@ -43,6 +46,8 @@ pub fn print_wait_screen_on_alternate_window(context: Rc<Context>) {
// create new alternate screen instance and switch to the alternate screen.
let mut screen = AlternateScreen::from(context.clone());
write!(screen, "test");
println!();
// Print the wait screen.
print_wait_screen(context.clone());
}

View File

@ -240,14 +240,13 @@ impl TerminalCursor {
/// ```
pub fn print<D: Display>(&mut self, value: D) -> &mut TerminalCursor {
{
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();
let mut mutex = &self.context.screen_manager;
{
let mut screen_manager = mutex.lock().unwrap();
screen_manager.write_val(string);
screen_manager.flush();

View File

@ -29,8 +29,25 @@ use super::super::super::manager::{ScreenManager, WinApiScreenManager};
use std::sync::Mutex;
/// Get the global stored handle.
pub fn get_current_handle(screen_manager: &mut WinApiScreenManager) -> &HANDLE {
return screen_manager.get_handle();
pub fn get_current_handle(screen_manager: &Rc<Mutex<ScreenManager>>) -> HANDLE {
let mut mx_guard = screen_manager;
let handle: HANDLE;
let mut screen_manager = mx_guard.lock().unwrap();
{
let winapi_screen_manager: &mut WinApiScreenManager = match screen_manager
.as_any()
.downcast_mut::<WinApiScreenManager>()
{
Some(win_api) => win_api,
None => panic!(""),
};
handle = *winapi_screen_manager.get_handle();
}
return handle;
}
/// Get the std_output_handle of the console
@ -81,20 +98,11 @@ fn is_valid_handle(handle: &HANDLE) -> bool {
pub fn get_console_screen_buffer_info(
screen_manager: &Rc<Mutex<ScreenManager>>,
) -> CONSOLE_SCREEN_BUFFER_INFO {
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_current_handle(winapi_screen_manager);
let mut csbi = CONSOLE_SCREEN_BUFFER_INFO::empty();
let success;
unsafe { success = GetConsoleScreenBufferInfo(*output_handle, &mut csbi) }
unsafe { success = GetConsoleScreenBufferInfo(get_current_handle(screen_manager), &mut csbi) }
if success == 0 {
panic!("Cannot get console screen buffer info");
@ -103,6 +111,14 @@ pub fn get_console_screen_buffer_info(
csbi
}
pub fn get_buffer_info_and_hande(screen_manager: &Rc<Mutex<ScreenManager>>) -> (CONSOLE_SCREEN_BUFFER_INFO, HANDLE)
{
let handle = get_current_handle(screen_manager);
let csbi = get_console_screen_buffer_info_from_handle(&handle);
return (csbi, handle)
}
/// 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();
@ -156,21 +172,12 @@ pub fn set_console_cursor_position(x: i16, y: i16, screen_manager: &Rc<Mutex<Scr
panic!("Y: {}, Argument Out of Range Exception", y);
}
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 handle = get_current_handle(screen_manager);
let position = COORD { X: x, Y: y };
unsafe {
let success = SetConsoleCursorPosition(*handle, position);
let success = SetConsoleCursorPosition(handle, position);
if success == 0 {
panic!("Argument out of range.");
@ -180,16 +187,7 @@ pub fn set_console_cursor_position(x: i16, y: i16, screen_manager: &Rc<Mutex<Scr
/// change the cursor visibility.
pub fn cursor_visibility(visable: bool, screen_manager: &Rc<Mutex<ScreenManager>>) {
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 handle = get_current_handle(screen_manager);
let cursor_info = CONSOLE_CURSOR_INFO {
dwSize: 100,
@ -197,16 +195,16 @@ pub fn cursor_visibility(visable: bool, screen_manager: &Rc<Mutex<ScreenManager>
};
unsafe {
SetConsoleCursorInfo(*handle, &cursor_info);
SetConsoleCursorInfo(handle, &cursor_info);
}
}
/// 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 handle = get_current_handle(screen_manager);
unsafe {
SetConsoleTextAttribute(output_handle, value);
SetConsoleTextAttribute(handle, value);
}
}
@ -216,23 +214,14 @@ pub fn set_console_info(
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 handle = get_current_handle(winapi_screen_manager);
let handle = get_current_handle(screen_manager);
let absolute = match absolute {
true => 1,
false => 0,
};
unsafe {
let success = SetConsoleWindowInfo(*handle, absolute, rect);
let success = SetConsoleWindowInfo(handle, absolute, rect);
is_true(success)
}
}
@ -242,19 +231,11 @@ pub fn set_console_screen_buffer_size(
size: COORD,
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 handle = get_current_handle(winapi_screen_manager);
let handle = get_current_handle(screen_manager);
unsafe {
let success = SetConsoleScreenBufferSize(*handle, size);
let success = SetConsoleScreenBufferSize(handle, size);
is_true(success)
}
}
@ -266,21 +247,13 @@ pub fn fill_console_output_character(
cells_to_write: u32,
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 handle = get_current_handle(winapi_screen_manager);
let handle = get_current_handle(screen_manager);
unsafe {
// fill the cells in console with blanks
let success = FillConsoleOutputCharacterA(
*handle,
handle,
' ' as i8,
cells_to_write,
start_location,
@ -298,24 +271,14 @@ pub fn fill_console_output_attribute(
screen_manager: &Rc<Mutex<ScreenManager>>,
) -> bool {
// Get the position of the current console window
let csbi = get_console_screen_buffer_info(screen_manager);
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 (csbi, mut handle) = get_buffer_info_and_hande(screen_manager);
let success;
unsafe {
success = FillConsoleOutputAttribute(
*handle,
handle,
csbi.wAttributes,
cells_to_write,
start_location,
@ -426,18 +389,17 @@ use std::str;
use winapi::ctypes::c_void;
/// Write utf8 buffer to console.
pub fn write_char_buffer(handle: HANDLE, buf: &[u8]) {
pub fn write_char_buffer(handle: &HANDLE, buf: &[u8]) {
// get string from u8[] and parse it to an c_str
let mut utf8 = match str::from_utf8(buf) {
Ok(string) => string,
Err(_) => "123",
};
let utf16: Vec<u16> = utf8.encode_utf16().collect();
let utf16_ptr: *const c_void = utf16.as_ptr() as *const _ as *const c_void;
// get buffer info
let csbi = get_console_screen_buffer_info_from_handle(&handle);
let csbi = get_console_screen_buffer_info_from_handle(handle);
// get current position
let current_pos = COORD {
@ -450,7 +412,7 @@ pub fn write_char_buffer(handle: HANDLE, buf: &[u8]) {
// write to console
unsafe {
WriteConsoleW(
handle,
*handle,
utf16_ptr,
utf16.len() as u32,
&mut cells_written,

View File

@ -60,7 +60,7 @@ impl ScreenManager {
impl Write for ScreenManager {
fn write(&mut self, buf: &[u8]) -> io::Result<usize> {
self.write(buf)
self.screen_manager.write(buf)
}
fn flush(&mut self) -> io::Result<()> {

View File

@ -24,9 +24,10 @@ impl IScreenManager for WinApiScreenManager {
fn write(&mut self, buf: &[u8]) -> io::Result<usize> {
if self.is_alternate_screen {
kernel::write_char_buffer(self.alternate_handle, buf);
kernel::write_char_buffer(&self.alternate_handle, buf);
} else {
kernel::write_char_buffer(self.output, buf);
kernel::write_char_buffer(&self.output, buf);
}
Ok(0)
}
@ -59,6 +60,7 @@ impl WinApiScreenManager {
pub fn get_handle(&mut self) -> &HANDLE {
if self.is_alternate_screen {
return &self.alternate_handle;
} else {
return &self.output;
}

View File

@ -30,6 +30,7 @@ impl EnableAnsiCommand {
impl IStateCommand for EnableAnsiCommand {
fn execute(&mut self) -> bool {
panic!();
// 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() {
return ansi_support::windows_supportable();

View File

@ -9,38 +9,40 @@ use std::rc::Rc;
use std::sync::Mutex;
/// This struct is an ansi implementation for color related actions.
#[derive(Debug)]
pub struct AnsiColor;
pub struct AnsiColor
{
screen_manager: Rc<Mutex<ScreenManager>>
}
impl AnsiColor {
pub fn new() -> Box<AnsiColor> {
Box::from(AnsiColor {})
pub fn new(screen_manager: Rc<Mutex<ScreenManager>>) -> Box<AnsiColor> {
Box::from(AnsiColor { screen_manager })
}
}
impl ITerminalColor for AnsiColor {
fn set_fg(&self, fg_color: Color, screen_manager: Rc<Mutex<ScreenManager>>) {
let mut screen = screen_manager.lock().unwrap();
{
fn set_fg(&mut self, fg_color: Color ) {
let mx_guard = &self.screen_manager;
let mut screen = mx_guard.lock().unwrap();
screen.write_ansi(format!(
csi!("{}m"),
self.color_value(fg_color, ColorType::Foreground)
));
}
}
fn set_bg(&self, bg_color: Color, screen_manager: Rc<Mutex<ScreenManager>>) {
let mut screen = screen_manager.lock().unwrap();
{
fn set_bg(&mut self, bg_color: Color) {
let mx_guard = &self.screen_manager;
let mut screen = mx_guard.lock().unwrap();
screen.write_ansi(format!(
csi!("{}m"),
self.color_value(bg_color, ColorType::Background)
));
}
}
fn reset(&self, screen_manager: Rc<Mutex<ScreenManager>>) {
let mut screen = screen_manager.lock().unwrap();
fn reset(&mut self) {
let mut screen = self.screen_manager.lock().unwrap();
{
screen.write_ansi_str(csi!("0m"));
}

View File

@ -21,11 +21,11 @@ impl TerminalColor {
#[cfg(target_os = "windows")]
let color = functions::get_module::<Box<ITerminalColor>>(
WinApiColor::new(context.screen_manager.clone()),
AnsiColor::new(),
AnsiColor::new(context.screen_manager.clone()),
);
#[cfg(not(target_os = "windows"))]
let color = Some(AnsiColor::new() as Box<ITerminalColor>);
let color = Some(AnsiColor::new(context.screen_manager.clone()) as Box<ITerminalColor>);
TerminalColor {
color: color,
@ -55,8 +55,8 @@ impl TerminalColor {
///
/// ```
pub fn set_fg(&mut self, color: Color) {
if let Some(ref terminal_color) = self.color {
terminal_color.set_fg(color, self.screen_manager.clone());
if let Some(ref mut terminal_color) = self.color {
terminal_color.set_fg(color);
}
}
@ -83,8 +83,8 @@ impl TerminalColor {
///
/// ```
pub fn set_bg(&mut self, color: Color) {
if let Some(ref terminal_color) = self.color {
terminal_color.set_bg(color, self.screen_manager.clone());
if let Some(ref mut terminal_color) = self.color {
terminal_color.set_bg(color);
}
}
@ -106,8 +106,8 @@ impl TerminalColor {
///
/// ```
pub fn reset(&mut self) {
if let Some(ref terminal_color) = self.color {
terminal_color.reset(self.screen_manager.clone());
if let Some(ref mut terminal_color) = self.color {
terminal_color.reset();
}
}

View File

@ -24,11 +24,11 @@ use std::sync::Mutex;
///! so that color related actions can be preformed on both unix and windows systems.
pub trait ITerminalColor {
/// Set the foreground color to the given color.
fn set_fg(&self, fg_color: Color, screen_manager: Rc<Mutex<ScreenManager>>);
fn set_fg(&mut self, fg_color: Color);
/// Set the background color to the given color.
fn set_bg(&self, fg_color: Color, screen_manager: Rc<Mutex<ScreenManager>>);
fn set_bg(&mut self, fg_color: Color);
/// Reset the terminal color to default.
fn reset(&self, screen_manager: Rc<Mutex<ScreenManager>>);
fn reset(&mut self);
/// Gets an value that represents an color from the given `Color` and `ColorType`.
fn color_value(&self, color: Color, color_type: ColorType) -> String;
}

View File

@ -3,12 +3,14 @@ use super::ITerminalColor;
use kernel::windows_kernel::kernel;
use winapi::um::wincon;
use ScreenManager;
use super::super::super::manager::WinApiScreenManager;
use std::rc::Rc;
use std::sync::Mutex;
/// This struct is an windows implementation for color related actions.
pub struct WinApiColor {
original_console_color: u16,
screen_manager: Rc<Mutex<ScreenManager>>,
}
@ -23,7 +25,7 @@ impl WinApiColor {
}
impl ITerminalColor for WinApiColor {
fn set_fg(&self, fg_color: Color, screen_manager: Rc<Mutex<ScreenManager>>) {
fn set_fg(&mut self, fg_color: Color) {
let color_value = &self.color_value(fg_color, ColorType::Foreground);
let csbi = kernel::get_console_screen_buffer_info(&self.screen_manager);
@ -44,10 +46,11 @@ impl ITerminalColor for WinApiColor {
kernel::set_console_text_attribute(color, &self.screen_manager);
}
fn set_bg(&self, bg_color: Color, screen_manager: Rc<Mutex<ScreenManager>>) {
fn set_bg(&mut self, bg_color: Color) {
let color_value = &self.color_value(bg_color, ColorType::Background);
let csbi = kernel::get_console_screen_buffer_info(&self.screen_manager);
let (csbi,handle) = kernel::get_buffer_info_and_hande(&self.screen_manager);
// 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.
let mut color: u16;
@ -64,7 +67,7 @@ impl ITerminalColor for WinApiColor {
kernel::set_console_text_attribute(color, &self.screen_manager);
}
fn reset(&self, screen_manager: Rc<Mutex<ScreenManager>>) {
fn reset(&mut self) {
kernel::set_console_text_attribute(self.original_console_color, &self.screen_manager);
}

View File

@ -2,13 +2,16 @@
use Context;
use std::fmt;
use std::fmt::{self,Display};
use std::io::Write;
use std::rc::Rc;
#[cfg(unix)]
use super::super::Attribute;
#[cfg(windows)]
use super::super::super::manager::WinApiScreenManager;
use style::{Color, ObjectStyle};
/// Struct that contains both the style and the content wits can be styled.
@ -18,7 +21,7 @@ pub struct StyledObject<D> {
pub context: Rc<Context>,
}
impl<D> StyledObject<D> {
impl<D> StyledObject<D> where D: Display {
/// Set the foreground of the styled object to the passed `Color`
///
/// #Example
@ -143,12 +146,10 @@ impl<D> StyledObject<D> {
}
}
/// This is used to make StyledObject able to be displayed.
/// This macro will set the styles stored in Styled Object
macro_rules! impl_fmt {
($name:ident) => {
impl<D: fmt::$name> fmt::$name for StyledObject<D> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
impl <D:Display> Display for StyledObject<D>
{
fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> {
let mut colored_terminal = super::super::color(self.context.clone());
let mut reset = true;
@ -172,7 +173,20 @@ macro_rules! impl_fmt {
reset = true;
}
fmt::$name::fmt(&self.content, f)?;
if cfg!(target_os = "linux") {
fmt::Display::fmt(&self.content, f)?;
} else {
let mutex = &self.context.screen_manager;
{
let mut screen_manager = mutex.lock().unwrap();
use std::fmt::Write;
let mut string = String::new();
write!(string, "{}", self.content).unwrap();
screen_manager.write_val(string)
}
}
let mutex = &self.context.screen_manager;
{
@ -187,8 +201,3 @@ macro_rules! impl_fmt {
Ok(())
}
}
};
}
impl_fmt!(Debug);
impl_fmt!(Display);

View File

@ -184,20 +184,21 @@ impl Terminal {
/// // Or all in one line
/// println!("{}", paint("Colored font").with(Color::Red).on(Color::Blue));
/// }
///
/// ```
pub fn paint<D>(&self, val: D) -> style::StyledObject<D>
where
D: fmt::Display,
pub fn paint<D>(&self, val: D) -> style::StyledObject<D> where D: fmt::Display
{
style::ObjectStyle::new().apply_to(val, self.context.clone())
}
/// Exit the current process.fy
pub fn exit(&self) {
if let Some(ref terminal) = self.terminal {
terminal.exit();
}
}
/// Write any displayable content to the current terminal screen.
pub fn write<D: fmt::Display>(&mut self, value: D) {
let mut mutex = &self.context.screen_manager;
{