Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect cursor placement/drawing when highlighting with mouse #328

Open
rgoring opened this issue Mar 19, 2016 · 5 comments
Open

Incorrect cursor placement/drawing when highlighting with mouse #328

rgoring opened this issue Mar 19, 2016 · 5 comments

Comments

@rgoring
Copy link

rgoring commented Mar 19, 2016

Expected Behavior

When highlighting text in a console using the mouse, the cursor should remain at the last cursor location and draw at the last cursor location if keys are pressed (either input from the alpha-numeric keys, or history if using the up/down arrow keys).

Windows console (cmd.exe) handles this by first un-selecting text that was highlighted with the mouse, then printing output at the last known cursor location.

Actual Behavior

When using the mouse to highlight text in a console (using cmd.exe in this case) the cursor placement moves to the top of the window and drawing happens at the top of the console window, or not at all.

Steps to reproduce

  1. Run a console using the standard windows cmd.exe in ConsoleZ
  2. Run the "dir" command to get a page-full of text output
  3. highlight some text using click and drag anywhere in the console window (the middle works well)
  4. With the highlighted text still selected, begin typing or use the arrow keys to browse history. The new input will be at the top of the screen instead of at the last cursor location.

Diagnostic Report

ConsoleZ aero amd64 1.16.1.16068
is elevated? no
UAC prefix "Administrator: "
Tab (active): Console
  View (active): 1. Console
  is elevated? no
  Windows console font
font index: 0
face name: Lucida Console
font familly: 54 MODERN vector true type
font weight: 400
font size: width=3 height=5
max window size: cols=140 rows=203
  ConsoleZ font
GetFontLanguageInfo returns 262144.
The font contains extra glyphs not normally accessible using the code page.

Monitors 2
+ Flags 1  primary
  DeviceID \\?\DISPLAY#ACI2493#5&b1fcaa&0&UID3146000#{e6f07b5f-ee97-4a90-b076-33f57bf4eaa7}
  DeviceKey \Registry\Machine\System\CurrentControlSet\Control\Class\{4d36e96e-e325-11ce-bfc1-08002be10318}\0002
  DeviceName \\.\DISPLAY1\Monitor0
  DeviceString Generic PnP Monitor
  StateFlags 3
  Rect (0,0)x(1920,1080)
  Work (0,0)x(1920,1040)
  DPI (per monitor: no)
+ Flags 0
  DeviceID \\?\DISPLAY#ACI2493#5&b1fcaa&0&UID3146003#{e6f07b5f-ee97-4a90-b076-33f57bf4eaa7}
  DeviceKey \Registry\Machine\System\CurrentControlSet\Control\Class\{4d36e96e-e325-11ce-bfc1-08002be10318}\0001
  DeviceName \\.\DISPLAY2\Monitor0
  DeviceString Generic PnP Monitor
  StateFlags 3
  Rect (1920,0)x(3840,1080)
  Work (1920,0)x(3840,1080)
  DPI (per monitor: no)
System dpi 96
System metrics
  SM_CXSMICON        16
  SM_CYSMICON        16
  SM_CXICON          32
  SM_CYICON          32
  SM_CXVIRTUALSCREEN 3840
  SM_CYVIRTUALSCREEN 1080
  SM_CYVIRTUALSCREEN 1080
Settings file C:\console\console.xml
<?xml version="1.0"?>
<settings>
    <console change_refresh="10" refresh="100" rows="45" columns="140" buffer_rows="32766" buffer_columns="0" shell="" init_dir="c:\" start_hidden="0" save_size="0" background_text_opacity="255">
        <colors background_text_opacity="255">
            <color id="0" r="0" g="0" b="0"/>
            <color id="1" r="0" g="0" b="128"/>
            <color id="2" r="0" g="150" b="0"/>
            <color id="3" r="0" g="150" b="150"/>
            <color id="4" r="170" g="25" b="25"/>
            <color id="5" r="128" g="0" b="128"/>
            <color id="6" r="128" g="128" b="0"/>
            <color id="7" r="192" g="192" b="192"/>
            <color id="8" r="128" g="128" b="128"/>
            <color id="9" r="0" g="100" b="255"/>
            <color id="10" r="0" g="255" b="0"/>
            <color id="11" r="0" g="255" b="255"/>
            <color id="12" r="255" g="50" b="50"/>
            <color id="13" r="255" g="0" b="255"/>
            <color id="14" r="255" g="255" b="0"/>
            <color id="15" r="255" g="255" b="255"/>
        </colors>
        <cursor style="14" r="255" g="255" b="255"/>
        <background type="0" r="0" g="0" b="0">
            <image file="" relative="0" extend="0" position="0">
                <tint opacity="0" r="0" g="0" b="0"/>
            </image>
        </background>
    </console>
    <appearance>
        <font name="Lucida Console" size="10" bold="0" italic="0" smoothing="0" bold_intensified="0" italic_intensified="0" extra_width="0" ligature="0">
            <color use="0" r="0" g="0" b="0"/>
        </font>
        <window title="ConsoleZ" icon="" use_tab_icon="1" use_console_title="0" show_cmd="1" show_cmd_tabs="1" use_tab_title="1" trim_tab_titles="20" trim_tab_titles_right="0" main_title_format="?U([%u] )?N({%u} )%m?s( - %s)" tab_title_format="%n. ?U([%u] )?N({%u} )%t?s( - %s)"/>
        <controls show_menu="1" show_toolbar="0" show_statusbar="1" show_tabs="1" hide_single_tab="1" show_scrollbars="1" flat_scrollbars="0" tabs_on_bottom="0" hide_tab_icons="0" show_searchbar="1"/>
        <styles caption="1" resizable="1" taskbar_button="1" border="1" inside_border="2" tray_icon="1" quake_like="0" jumplist="0" integrated_ime="0" quake_animation_time="300" hide_when_inactive="0">
            <selection_color r="255" g="255" b="255"/>
        </styles>
        <position x="-1" y="-1" dock="-1" snap="-1" z_order="0" save_position="0" w="-1" h="-1" save_size="0"/>
        <transparency type="0" active_alpha="240" inactive_alpha="255" r="192" g="192" b="192"/>
        <fullscreen start_in_fullscreen="0" fullscreen_monitor="0"/>
    </appearance>
    <behavior>
        <copy_paste copy_on_select="0" clear_on_copy="1" no_wrap="1" trim_spaces="1" copy_newline_char="0" sensitive_copy="1" include_left_delimiter="0" include_right_delimiter="0" left_delimiters=" ([" right_delimiters=" )]" eol_spaces="1" rtf="1"/>
        <scroll page_scroll_rows="0"/>
        <tab_highlight flashes="3" stay_highligted="1"/>
        <close allow_closing_last_view="0" confirm_closing_multiple_views="1"/>
        <focus follow_mouse="0"/>
        <instance allow_multi="1"/>
        <clone use_current_dir="0"/>
        <search match_case="0" match_whole_word="0"/>
        <runas use_credprov="1"/>
    </behavior>
    <hotkeys use_scroll_lock="1">
        <hotkey ctrl="1" shift="0" alt="0" extended="0" code="83" command="settings"/>
        <hotkey ctrl="0" shift="0" alt="0" extended="0" code="112" command="help"/>
        <hotkey ctrl="0" shift="0" alt="1" extended="0" code="115" command="exit"/>
        <hotkey ctrl="1" shift="0" alt="0" extended="0" code="112" command="newtab1"/>
        <hotkey ctrl="1" shift="0" alt="0" extended="0" code="113" command="newtab2"/>
        <hotkey ctrl="1" shift="0" alt="0" extended="0" code="114" command="newtab3"/>
        <hotkey ctrl="1" shift="0" alt="0" extended="0" code="115" command="newtab4"/>
        <hotkey ctrl="1" shift="0" alt="0" extended="0" code="116" command="newtab5"/>
        <hotkey ctrl="1" shift="0" alt="0" extended="0" code="117" command="newtab6"/>
        <hotkey ctrl="1" shift="0" alt="0" extended="0" code="118" command="newtab7"/>
        <hotkey ctrl="1" shift="0" alt="0" extended="0" code="119" command="newtab8"/>
        <hotkey ctrl="1" shift="0" alt="0" extended="0" code="120" command="newtab9"/>
        <hotkey ctrl="1" shift="0" alt="0" extended="0" code="121" command="newtab10"/>
        <hotkey ctrl="1" shift="0" alt="0" extended="0" code="122" command="newtab11"/>
        <hotkey ctrl="1" shift="0" alt="0" extended="0" code="123" command="newtab12"/>
        <hotkey ctrl="1" shift="0" alt="0" extended="0" code="49" command="switchtab1"/>
        <hotkey ctrl="1" shift="0" alt="0" extended="0" code="50" command="switchtab2"/>
        <hotkey ctrl="1" shift="0" alt="0" extended="0" code="51" command="switchtab3"/>
        <hotkey ctrl="1" shift="0" alt="0" extended="0" code="52" command="switchtab4"/>
        <hotkey ctrl="1" shift="0" alt="0" extended="0" code="53" command="switchtab5"/>
        <hotkey ctrl="1" shift="0" alt="0" extended="0" code="54" command="switchtab6"/>
        <hotkey ctrl="1" shift="0" alt="0" extended="0" code="55" command="switchtab7"/>
        <hotkey ctrl="1" shift="0" alt="0" extended="0" code="56" command="switchtab8"/>
        <hotkey ctrl="1" shift="0" alt="0" extended="0" code="57" command="switchtab9"/>
        <hotkey ctrl="1" shift="0" alt="0" extended="0" code="48" command="switchtab10"/>
        <hotkey ctrl="0" shift="0" alt="0" extended="0" code="0" command="switchtab11"/>
        <hotkey ctrl="0" shift="0" alt="0" extended="0" code="0" command="switchtab12"/>
        <hotkey ctrl="1" shift="0" alt="0" extended="0" code="9" command="nexttab"/>
        <hotkey ctrl="1" shift="1" alt="0" extended="0" code="9" command="prevtab"/>
        <hotkey ctrl="1" shift="0" alt="0" extended="0" code="87" command="closetab"/>
        <hotkey ctrl="1" shift="0" alt="0" extended="0" code="82" command="renametab"/>
        <hotkey ctrl="1" shift="0" alt="0" extended="1" code="34" command="nextview"/>
        <hotkey ctrl="1" shift="0" alt="0" extended="1" code="33" command="prevview"/>
        <hotkey ctrl="0" shift="0" alt="1" extended="1" code="37" command="leftview"/>
        <hotkey ctrl="0" shift="0" alt="1" extended="1" code="39" command="rightview"/>
        <hotkey ctrl="0" shift="0" alt="1" extended="1" code="38" command="topview"/>
        <hotkey ctrl="0" shift="0" alt="1" extended="1" code="40" command="bottomview"/>
        <hotkey ctrl="0" shift="0" alt="0" extended="0" code="0" command="dechsize"/>
        <hotkey ctrl="0" shift="0" alt="0" extended="0" code="0" command="inchsize"/>
        <hotkey ctrl="0" shift="0" alt="0" extended="0" code="0" command="decvsize"/>
        <hotkey ctrl="0" shift="0" alt="0" extended="0" code="0" command="incvsize"/>
        <hotkey ctrl="1" shift="1" alt="0" extended="0" code="87" command="closeview"/>
        <hotkey ctrl="0" shift="0" alt="0" extended="0" code="0" command="detachview"/>
        <hotkey ctrl="0" shift="0" alt="0" extended="0" code="0" command="attach"/>
        <hotkey ctrl="1" shift="1" alt="0" extended="0" code="79" command="splithoriz"/>
        <hotkey ctrl="1" shift="1" alt="0" extended="0" code="69" command="splitvert"/>
        <hotkey ctrl="0" shift="0" alt="0" extended="0" code="0" command="clone"/>
        <hotkey ctrl="0" shift="0" alt="0" extended="0" code="122" command="fullscreen"/>
        <hotkey ctrl="1" shift="0" alt="0" extended="0" code="96" command="zoom100"/>
        <hotkey ctrl="1" shift="0" alt="0" extended="0" code="107" command="zoominc"/>
        <hotkey ctrl="1" shift="0" alt="0" extended="0" code="109" command="zoomdec"/>
        <hotkey ctrl="1" shift="0" alt="0" extended="0" code="71" command="groupall"/>
        <hotkey ctrl="1" shift="1" alt="0" extended="0" code="71" command="ungroupall"/>
        <hotkey ctrl="1" shift="0" alt="0" extended="0" code="84" command="grouptab"/>
        <hotkey ctrl="1" shift="1" alt="0" extended="0" code="84" command="ungrouptab"/>
        <hotkey ctrl="0" shift="0" alt="0" extended="0" code="0" command="clear"/>
        <hotkey ctrl="1" shift="1" alt="0" extended="0" code="67" command="copy"/>
        <hotkey ctrl="1" shift="0" alt="0" extended="0" code="65" command="selectall"/>
        <hotkey ctrl="1" shift="0" alt="0" extended="1" code="46" command="clear_selection"/>
        <hotkey ctrl="1" shift="1" alt="0" extended="0" code="86" command="paste"/>
        <hotkey ctrl="0" shift="0" alt="0" extended="0" code="0" command="paste_selection"/>
        <hotkey ctrl="0" shift="0" alt="0" extended="0" code="0" command="stopscroll"/>
        <hotkey ctrl="0" shift="0" alt="0" extended="0" code="0" command="scrollrowup"/>
        <hotkey ctrl="0" shift="0" alt="0" extended="0" code="0" command="scrollrowdown"/>
        <hotkey ctrl="0" shift="1" alt="0" extended="1" code="33" command="scrollpageup"/>
        <hotkey ctrl="0" shift="1" alt="0" extended="1" code="34" command="scrollpagedown"/>
        <hotkey ctrl="0" shift="0" alt="0" extended="0" code="0" command="scrollcolleft"/>
        <hotkey ctrl="0" shift="0" alt="0" extended="0" code="0" command="scrollcolright"/>
        <hotkey ctrl="0" shift="0" alt="0" extended="0" code="0" command="scrollpageleft"/>
        <hotkey ctrl="0" shift="0" alt="0" extended="0" code="0" command="scrollpageright"/>
        <hotkey ctrl="1" shift="0" alt="0" extended="0" code="70" command="find"/>
        <hotkey ctrl="0" shift="0" alt="0" extended="0" code="114" command="findnext"/>
        <hotkey ctrl="0" shift="1" alt="0" extended="0" code="114" command="findprev"/>
        <hotkey ctrl="0" shift="0" alt="0" extended="0" code="0" command="switchtransparency"/>
        <hotkey ctrl="1" shift="1" alt="0" extended="0" code="112" command="dumpbuffer"/>
        <hotkey ctrl="0" shift="0" alt="0" extended="0" code="0" command="cmdMenu1"/>
        <hotkey ctrl="0" shift="0" alt="0" extended="0" code="0" command="cmdMenu2"/>
        <hotkey ctrl="0" shift="0" alt="0" extended="0" code="0" command="cmdMenu3"/>
        <hotkey ctrl="0" shift="0" alt="0" extended="0" code="0" command="ctrlC"/>
        <hotkey ctrl="0" shift="0" alt="0" extended="0" code="0" command="externalcmd1"/>
        <hotkey ctrl="0" shift="0" alt="0" extended="0" code="0" command="externalcmd2"/>
        <hotkey ctrl="0" shift="0" alt="0" extended="0" code="0" command="externalcmd3"/>
        <hotkey ctrl="0" shift="0" alt="0" extended="0" code="0" command="externalcmd4"/>
        <hotkey ctrl="0" shift="0" alt="0" extended="0" code="0" command="externalcmd5"/>
        <hotkey ctrl="0" shift="0" alt="0" extended="0" code="0" command="externalcmd6"/>
        <hotkey ctrl="0" shift="0" alt="0" extended="0" code="0" command="externalcmd7"/>
        <hotkey ctrl="0" shift="0" alt="0" extended="0" code="0" command="externalcmd8"/>
        <hotkey ctrl="0" shift="0" alt="0" extended="0" code="0" command="externalcmd9"/>
        <hotkey ctrl="0" shift="0" alt="0" extended="0" code="0" command="externalcmd10"/>
        <hotkey ctrl="0" shift="0" alt="0" extended="0" code="0" command="activate" win="0"/>
    </hotkeys>
    <mouse>
        <actions>
            <action ctrl="0" shift="1" alt="0" button="1" name="copy"/>
            <action ctrl="0" shift="0" alt="0" button="1" name="select"/>
            <action ctrl="0" shift="0" alt="0" button="0" name="select_column"/>
            <action ctrl="0" shift="0" alt="0" button="3" name="paste"/>
            <action ctrl="1" shift="0" alt="0" button="1" name="drag"/>
            <action ctrl="0" shift="0" alt="0" button="4" name="link"/>
            <action ctrl="0" shift="0" alt="0" button="2" name="menu"/>
            <action ctrl="0" shift="0" alt="0" button="0" name="menu2"/>
            <action ctrl="0" shift="0" alt="0" button="0" name="menu3"/>
        </actions>
    </mouse>
    <tabs>
        <tab title="Console" use_default_icon="0">
            <console shell="%windir%\system32\cmd.exe /k c:\console\cmds\env.cmd" init_dir="c:\" priority="2" run_as_user="0" user="" net_only="0" run_as_admin="0"/>
        </tab>
        <tab title="Admin Console" icon="C:\Windows\System32\imageres.dll,73" use_default_icon="0">
            <console shell="%windir%\system32\cmd.exe /k c:\console\cmds\env.cmd" init_dir="c:\" priority="2" run_as_user="0" user="" net_only="0" run_as_admin="1"/>
        </tab>
        <tab title="Python 2.7" icon="C:\Python27\python.exe" use_default_icon="0">
            <console shell="C:\Python27\python.exe" init_dir="c:\" priority="2" run_as_user="0" user="" net_only="0" run_as_admin="0"/>
        </tab>
        <tab title="Powershell" icon="%SystemRoot%\system32\WindowsPowerShell\v1.0\powershell.exe" use_default_icon="0">
            <console shell="%SystemRoot%\system32\WindowsPowerShell\v1.0\powershell.exe" init_dir="c:\" priority="2" run_as_user="0" user="" net_only="0" run_as_admin="0"/>
        </tab>
        <tab title="Admin Powershell" icon="%SystemRoot%\system32\WindowsPowerShell\v1.0\powershell.exe,1" use_default_icon="0">
            <console shell="%SystemRoot%\system32\WindowsPowerShell\v1.0\powershell.exe" init_dir="c:\" priority="2" run_as_user="0" user="" net_only="0" run_as_admin="1"/>
        </tab>
    </tabs>
    <external_commands>
</external_commands>
</settings>

Crash Report

Not applicable.

@cbucher
Copy link
Owner

cbucher commented Mar 22, 2016

void ConsoleHandler::StopScrolling()
{
    // emulate 'Mark' sysmenu item click in Windows console window (will stop scrolling until the user presses ESC)
    // or a selection is cleared (copied or not)
    SendMessage(WM_SYSCOMMAND, SC_CONSOLE_MARK, 0);
}

We need to stop scrolling during selection. And to stop scrolling we call the mark command.
mark
So this behavior is the Windows console behavior.
On Windows 10 the mark command does no longer position the cursor in top left corner.

@rgoring
Copy link
Author

rgoring commented Mar 23, 2016

Using the windows console directly, I see the behavior of the cursor temporarily moving to the top when marking using the mouse. However, in windows console, as soon as I begin typing, the highlighted selection disappears and the text goes back to the original location at the prompt.

When using ConsoleZ, and typing while a section of text is marked, the cursor does not return to the last position as it does in windows console, and the highlighted section remains - this causes the output to appear at the top, rather than at the prompt as it does in windows console.

@rgoring
Copy link
Author

rgoring commented Mar 23, 2016

It's almost as if ConsoleZ initializes the Mark command on the underlying console, but then does not properly de-initialize Mark when the console does to continue input from the user.

@cbucher
Copy link
Owner

cbucher commented Mar 24, 2016

but then does not properly de-initialize Mark when the console does to continue input from the user.

If that were the case , then the console will remain locked after end of selection.
Escape key is simulated to unlock scrolling when selection is done.

Mark state does no longer exist under Windows 10.
In other versions, during Mark state, Windows console should not process inputs.

What is your OS version?

@rgoring
Copy link
Author

rgoring commented Apr 5, 2016

I'm using Windows 7 x64 enterprise. I have not yet tried it on Windows 10.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants