mirror of
https://github.com/microsoft/terminal.git
synced 2026-04-11 00:31:11 +00:00
Compare commits
3 Commits
dev/migrie
...
dev/lhecke
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
20a4d739d4 | ||
|
|
ab7b58eeb9 | ||
|
|
4e46c855e9 |
15
.github/actions/spelling/README.md
vendored
Normal file
15
.github/actions/spelling/README.md
vendored
Normal file
@@ -0,0 +1,15 @@
|
||||
# check-spelling/check-spelling configuration
|
||||
|
||||
File | Purpose | Format | Info
|
||||
-|-|-|-
|
||||
[allow/*.txt](allow/) | Add words to the dictionary | one word per line (only letters and `'`s allowed) | [allow](https://github.com/check-spelling/check-spelling/wiki/Configuration#allow)
|
||||
[reject.txt](reject.txt) | Remove words from the dictionary (after allow) | grep pattern matching whole dictionary words | [reject](https://github.com/check-spelling/check-spelling/wiki/Configuration-Examples%3A-reject)
|
||||
[excludes.txt](excludes.txt) | Files to ignore entirely | perl regular expression | [excludes](https://github.com/check-spelling/check-spelling/wiki/Configuration-Examples%3A-excludes)
|
||||
[patterns/*.txt](patterns/) | Patterns to ignore from checked lines | perl regular expression (order matters, first match wins) | [patterns](https://github.com/check-spelling/check-spelling/wiki/Configuration-Examples%3A-patterns)
|
||||
[candidate.patterns](candidate.patterns) | Patterns that might be worth adding to [patterns.txt](patterns.txt) | perl regular expression with optional comment block introductions (all matches will be suggested) | [candidates](https://github.com/check-spelling/check-spelling/wiki/Feature:-Suggest-patterns)
|
||||
[line_forbidden.patterns](line_forbidden.patterns) | Patterns to flag in checked lines | perl regular expression (order matters, first match wins) | [patterns](https://github.com/check-spelling/check-spelling/wiki/Configuration-Examples%3A-patterns)
|
||||
[expect/*.txt](expect.txt) | Expected words that aren't in the dictionary | one word per line (sorted, alphabetically) | [expect](https://github.com/check-spelling/check-spelling/wiki/Configuration#expect)
|
||||
[advice.md](advice.md) | Supplement for GitHub comment when unrecognized words are found | GitHub Markdown | [advice](https://github.com/check-spelling/check-spelling/wiki/Configuration-Examples%3A-advice)
|
||||
|
||||
Note: you can replace any of these files with a directory by the same name (minus the suffix)
|
||||
and then include multiple files inside that directory (with that suffix) to merge multiple files together.
|
||||
38
.github/actions/spelling/advice.md
vendored
38
.github/actions/spelling/advice.md
vendored
@@ -1,4 +1,4 @@
|
||||
<!-- markdownlint-disable MD033 MD041 -->
|
||||
<!-- See https://github.com/check-spelling/check-spelling/wiki/Configuration-Examples%3A-advice --> <!-- markdownlint-disable MD033 MD041 -->
|
||||
<details>
|
||||
<summary>
|
||||
:pencil2: Contributor please read this
|
||||
@@ -6,7 +6,7 @@
|
||||
|
||||
By default the command suggestion will generate a file named based on your commit. That's generally ok as long as you add the file to your commit. Someone can reorganize it later.
|
||||
|
||||
:warning: The command is written for posix shells. You can copy the contents of each `perl` command excluding the outer `'` marks and dropping any `'"`/`"'` quotation mark pairs into a file and then run `perl file.pl` from the root of the repository to run the code. Alternatively, you can manually insert the items...
|
||||
:warning: The command is written for posix shells. If it doesn't work for you, you can manually _add_ (one word per line) / _remove_ items to `expect.txt` and the `excludes.txt` files.
|
||||
|
||||
If the listed items are:
|
||||
|
||||
@@ -20,31 +20,29 @@ See the `README.md` in each directory for more information.
|
||||
|
||||
:microscope: You can test your commits **without** *appending* to a PR by creating a new branch with that extra change and pushing it to your fork. The [check-spelling](https://github.com/marketplace/actions/check-spelling) action will run in response to your **push** -- it doesn't require an open pull request. By using such a branch, you can limit the number of typos your peers see you make. :wink:
|
||||
|
||||
<details><summary>:clamp: If you see a bunch of garbage</summary>
|
||||
|
||||
If it relates to a ...
|
||||
<details><summary>well-formed pattern</summary>
|
||||
<details><summary>If the flagged items are :exploding_head: false positives</summary>
|
||||
|
||||
See if there's a [pattern](https://github.com/check-spelling/check-spelling/wiki/Configuration-Examples:-patterns) that would match it.
|
||||
If items relate to a ...
|
||||
* binary file (or some other file you wouldn't want to check at all).
|
||||
|
||||
If not, try writing one and adding it to a `patterns/{file}.txt`.
|
||||
Please add a file path to the `excludes.txt` file matching the containing file.
|
||||
|
||||
Patterns are Perl 5 Regular Expressions - you can [test](
|
||||
https://www.regexplanet.com/advanced/perl/) yours before committing to verify it will match your lines.
|
||||
|
||||
Note that patterns can't match multiline strings.
|
||||
</details>
|
||||
<details><summary>binary-ish string</summary>
|
||||
|
||||
Please add a file path to the `excludes.txt` file instead of just accepting the garbage.
|
||||
|
||||
File paths are Perl 5 Regular Expressions - you can [test](
|
||||
File paths are Perl 5 Regular Expressions - you can [test](
|
||||
https://www.regexplanet.com/advanced/perl/) yours before committing to verify it will match your files.
|
||||
|
||||
`^` refers to the file's path from the root of the repository, so `^README\.md$` would exclude [README.md](
|
||||
`^` refers to the file's path from the root of the repository, so `^README\.md$` would exclude [README.md](
|
||||
../tree/HEAD/README.md) (on whichever branch you're using).
|
||||
</details>
|
||||
|
||||
|
||||
* well-formed pattern.
|
||||
|
||||
If you can write a [pattern](https://github.com/check-spelling/check-spelling/wiki/Configuration-Examples:-patterns) that would match it,
|
||||
try adding it to the `patterns.txt` file.
|
||||
|
||||
Patterns are Perl 5 Regular Expressions - you can [test](
|
||||
https://www.regexplanet.com/advanced/perl/) yours before committing to verify it will match your lines.
|
||||
|
||||
Note that patterns can't match multiline strings.
|
||||
</details>
|
||||
|
||||
</details>
|
||||
|
||||
29
.github/actions/spelling/allow/allow.txt
vendored
29
.github/actions/spelling/allow/allow.txt
vendored
@@ -1,50 +1,66 @@
|
||||
admins
|
||||
apc
|
||||
allcolors
|
||||
Apc
|
||||
apc
|
||||
breadcrumb
|
||||
breadcrumbs
|
||||
bsd
|
||||
calt
|
||||
ccmp
|
||||
changelog
|
||||
clickable
|
||||
clig
|
||||
CMMI
|
||||
copyable
|
||||
cybersecurity
|
||||
dalet
|
||||
dcs
|
||||
Dcs
|
||||
dcs
|
||||
dialytika
|
||||
dje
|
||||
downside
|
||||
downsides
|
||||
dze
|
||||
dzhe
|
||||
EDDB
|
||||
EDDC
|
||||
Enum'd
|
||||
Fitt
|
||||
formattings
|
||||
FTCS
|
||||
ftp
|
||||
fvar
|
||||
gantt
|
||||
gcc
|
||||
geeksforgeeks
|
||||
ghe
|
||||
github
|
||||
gje
|
||||
godbolt
|
||||
hostname
|
||||
hostnames
|
||||
https
|
||||
hyperlink
|
||||
hyperlinking
|
||||
hyperlinks
|
||||
iconify
|
||||
img
|
||||
inlined
|
||||
It'd
|
||||
kje
|
||||
libfuzzer
|
||||
libuv
|
||||
liga
|
||||
lje
|
||||
Llast
|
||||
llvm
|
||||
Lmid
|
||||
locl
|
||||
lol
|
||||
lorem
|
||||
Lorigin
|
||||
maxed
|
||||
minimalistic
|
||||
mkmk
|
||||
mnt
|
||||
mru
|
||||
@@ -53,6 +69,7 @@ noreply
|
||||
ogonek
|
||||
ok'd
|
||||
overlined
|
||||
pipeline
|
||||
postmodern
|
||||
ptys
|
||||
qof
|
||||
@@ -67,11 +84,16 @@ runtimes
|
||||
shcha
|
||||
slnt
|
||||
Sos
|
||||
ssh
|
||||
timeline
|
||||
timelines
|
||||
timestamped
|
||||
TLDR
|
||||
tokenizes
|
||||
tonos
|
||||
toolset
|
||||
tshe
|
||||
ubuntu
|
||||
uiatextrange
|
||||
UIs
|
||||
und
|
||||
@@ -80,6 +102,7 @@ versioned
|
||||
vsdevcmd
|
||||
We'd
|
||||
wildcards
|
||||
XBox
|
||||
YBox
|
||||
yeru
|
||||
zhe
|
||||
allcolors
|
||||
|
||||
45
.github/actions/spelling/allow/apis.txt
vendored
45
.github/actions/spelling/allow/apis.txt
vendored
@@ -5,21 +5,23 @@ aclapi
|
||||
alignas
|
||||
alignof
|
||||
APPLYTOSUBMENUS
|
||||
appxrecipe
|
||||
bitfield
|
||||
bitfields
|
||||
BUILDBRANCH
|
||||
BUILDMSG
|
||||
BUILDNUMBER
|
||||
BYPOSITION
|
||||
BYCOMMAND
|
||||
BYPOSITION
|
||||
charconv
|
||||
CLASSNOTAVAILABLE
|
||||
CLOSEAPP
|
||||
cmdletbinding
|
||||
COLORPROPERTY
|
||||
colspan
|
||||
COMDLG
|
||||
comparand
|
||||
commandlinetoargv
|
||||
comparand
|
||||
cstdint
|
||||
CXICON
|
||||
CYICON
|
||||
@@ -28,8 +30,14 @@ dataobject
|
||||
dcomp
|
||||
DERR
|
||||
dlldata
|
||||
DNE
|
||||
DONTADDTORECENT
|
||||
DWMSBT
|
||||
DWMWA
|
||||
DWMWA
|
||||
DWORDLONG
|
||||
endfor
|
||||
ENDSESSION
|
||||
enumset
|
||||
environstrings
|
||||
EXPCMDFLAGS
|
||||
@@ -51,6 +59,8 @@ hotkeys
|
||||
href
|
||||
hrgn
|
||||
HTCLOSE
|
||||
hwinsta
|
||||
HWINSTA
|
||||
IActivation
|
||||
IApp
|
||||
IAppearance
|
||||
@@ -67,19 +77,22 @@ IDirect
|
||||
IExplorer
|
||||
IFACEMETHOD
|
||||
IFile
|
||||
IGraphics
|
||||
IInheritable
|
||||
IMap
|
||||
IMonarch
|
||||
IObject
|
||||
iosfwd
|
||||
IPackage
|
||||
IPeasant
|
||||
isspace
|
||||
ISetup
|
||||
isspace
|
||||
IStorage
|
||||
istream
|
||||
IStringable
|
||||
ITab
|
||||
ITaskbar
|
||||
itow
|
||||
IUri
|
||||
IVirtual
|
||||
KEYSELECT
|
||||
@@ -88,15 +101,21 @@ llabs
|
||||
llu
|
||||
localtime
|
||||
lround
|
||||
Lsa
|
||||
lsass
|
||||
LSHIFT
|
||||
LTGRAY
|
||||
MAINWINDOW
|
||||
memchr
|
||||
memicmp
|
||||
MENUCOMMAND
|
||||
MENUDATA
|
||||
MENUINFO
|
||||
MENUITEMINFOW
|
||||
memicmp
|
||||
mptt
|
||||
mmeapi
|
||||
MOUSELEAVE
|
||||
mov
|
||||
mptt
|
||||
msappx
|
||||
MULTIPLEUSE
|
||||
NCHITTEST
|
||||
@@ -120,6 +139,8 @@ oaidl
|
||||
ocidl
|
||||
ODR
|
||||
offsetof
|
||||
ofstream
|
||||
onefuzz
|
||||
osver
|
||||
OSVERSIONINFOEXW
|
||||
otms
|
||||
@@ -127,14 +148,17 @@ OUTLINETEXTMETRICW
|
||||
overridable
|
||||
PACL
|
||||
PAGESCROLL
|
||||
PATINVERT
|
||||
PEXPLICIT
|
||||
PICKFOLDERS
|
||||
pmr
|
||||
ptstr
|
||||
QUERYENDSESSION
|
||||
rcx
|
||||
REGCLS
|
||||
RETURNCMD
|
||||
rfind
|
||||
ROOTOWNER
|
||||
roundf
|
||||
RSHIFT
|
||||
SACL
|
||||
@@ -144,6 +168,7 @@ serializer
|
||||
SETVERSION
|
||||
SHELLEXECUTEINFOW
|
||||
shobjidl
|
||||
SHOWHIDE
|
||||
SHOWMINIMIZED
|
||||
SHOWTIP
|
||||
SINGLEUSE
|
||||
@@ -164,12 +189,15 @@ Stubless
|
||||
Subheader
|
||||
Subpage
|
||||
syscall
|
||||
SYSTEMBACKDROP
|
||||
TABROW
|
||||
TASKBARCREATED
|
||||
TBPF
|
||||
THEMECHANGED
|
||||
tlg
|
||||
TME
|
||||
tmp
|
||||
tmpdir
|
||||
tolower
|
||||
toupper
|
||||
TRACKMOUSEEVENT
|
||||
@@ -178,13 +206,20 @@ TVal
|
||||
UChar
|
||||
UFIELD
|
||||
ULARGE
|
||||
UOI
|
||||
UPDATEINIFILE
|
||||
userenv
|
||||
USEROBJECTFLAGS
|
||||
Viewbox
|
||||
virtualalloc
|
||||
wcsstr
|
||||
wcstoui
|
||||
winmain
|
||||
winsta
|
||||
winstamin
|
||||
wmemcmp
|
||||
wpc
|
||||
WSF
|
||||
wsregex
|
||||
wwinmain
|
||||
xchg
|
||||
|
||||
7
.github/actions/spelling/allow/microsoft.txt
vendored
7
.github/actions/spelling/allow/microsoft.txt
vendored
@@ -19,6 +19,7 @@ CPRs
|
||||
cryptbase
|
||||
DACL
|
||||
DACLs
|
||||
defaultlib
|
||||
diffs
|
||||
disposables
|
||||
dotnetfeed
|
||||
@@ -27,6 +28,8 @@ DWINRT
|
||||
enablewttlogging
|
||||
Intelli
|
||||
IVisual
|
||||
libucrt
|
||||
libucrtd
|
||||
LKG
|
||||
LOCKFILE
|
||||
Lxss
|
||||
@@ -36,8 +39,10 @@ microsoftonline
|
||||
MSAA
|
||||
msixbundle
|
||||
MSVC
|
||||
MSVCP
|
||||
muxc
|
||||
netcore
|
||||
Onefuzz
|
||||
osgvsowi
|
||||
PFILETIME
|
||||
pgc
|
||||
@@ -62,6 +67,8 @@ systemroot
|
||||
taskkill
|
||||
tasklist
|
||||
tdbuildteamid
|
||||
ucrt
|
||||
ucrtd
|
||||
unvirtualized
|
||||
VCRT
|
||||
vcruntime
|
||||
|
||||
10
.github/actions/spelling/allow/names.txt
vendored
10
.github/actions/spelling/allow/names.txt
vendored
@@ -1,13 +1,16 @@
|
||||
Anup
|
||||
austdi
|
||||
arkthur
|
||||
Ballmer
|
||||
bhoj
|
||||
Bhojwani
|
||||
Bluloco
|
||||
carlos
|
||||
dhowett
|
||||
Diviness
|
||||
dsafa
|
||||
duhowett
|
||||
DXP
|
||||
ekg
|
||||
eryksun
|
||||
ethanschoonover
|
||||
@@ -21,6 +24,7 @@ Hernan
|
||||
Howett
|
||||
Illhardt
|
||||
iquilezles
|
||||
italo
|
||||
jantari
|
||||
jerrysh
|
||||
Kaiyu
|
||||
@@ -34,7 +38,9 @@ leonmsft
|
||||
Lepilleur
|
||||
lhecker
|
||||
lukesampson
|
||||
Macbook
|
||||
Manandhar
|
||||
masserano
|
||||
mbadolato
|
||||
Mehrain
|
||||
menger
|
||||
@@ -63,12 +69,16 @@ Rincewind
|
||||
rprichard
|
||||
Schoonover
|
||||
shadertoy
|
||||
Shomnipotence
|
||||
simioni
|
||||
Somuah
|
||||
sonph
|
||||
sonpham
|
||||
stakx
|
||||
talo
|
||||
thereses
|
||||
Walisch
|
||||
WDX
|
||||
Wellons
|
||||
Wirt
|
||||
Wojciech
|
||||
|
||||
523
.github/actions/spelling/candidate.patterns
vendored
Normal file
523
.github/actions/spelling/candidate.patterns
vendored
Normal file
@@ -0,0 +1,523 @@
|
||||
# marker to ignore all code on line
|
||||
^.*/\* #no-spell-check-line \*/.*$
|
||||
# marker for ignoring a comment to the end of the line
|
||||
// #no-spell-check.*$
|
||||
|
||||
# patch hunk comments
|
||||
^\@\@ -\d+(?:,\d+|) \+\d+(?:,\d+|) \@\@ .*
|
||||
# git index header
|
||||
index [0-9a-z]{7,40}\.\.[0-9a-z]{7,40}
|
||||
|
||||
# cid urls
|
||||
(['"])cid:.*?\g{-1}
|
||||
|
||||
# data url in parens
|
||||
\(data:[^)]*?(?:[A-Z]{3,}|[A-Z][a-z]{2,}|[a-z]{3,})[^)]*\)
|
||||
# data url in quotes
|
||||
([`'"])data:.*?(?:[A-Z]{3,}|[A-Z][a-z]{2,}|[a-z]{3,}).*\g{-1}
|
||||
# data url
|
||||
data:[-a-zA-Z=;:/0-9+]*,\S*
|
||||
|
||||
# mailto urls
|
||||
mailto:[-a-zA-Z=;:/?%&0-9+@.]{3,}
|
||||
|
||||
# magnet urls
|
||||
magnet:[?=:\w]+
|
||||
|
||||
# magnet urls
|
||||
"magnet:[^"]+"
|
||||
|
||||
# obs:
|
||||
"obs:[^"]*"
|
||||
|
||||
# The `\b` here means a break, it's the fancy way to handle urls, but it makes things harder to read
|
||||
# In this examples content, I'm using a number of different ways to match things to show various approaches
|
||||
# asciinema
|
||||
\basciinema\.org/a/[0-9a-zA-Z]+
|
||||
|
||||
# apple
|
||||
\bdeveloper\.apple\.com/[-\w?=/]+
|
||||
# Apple music
|
||||
\bembed\.music\.apple\.com/fr/playlist/usr-share/[-\w.]+
|
||||
|
||||
# appveyor api
|
||||
\bci\.appveyor\.com/api/projects/status/[0-9a-z]+
|
||||
# appveyor project
|
||||
\bci\.appveyor\.com/project/(?:[^/\s"]*/){2}builds?/\d+/job/[0-9a-z]+
|
||||
|
||||
# Amazon
|
||||
|
||||
# Amazon
|
||||
\bamazon\.com/[-\w]+/(?:dp/[0-9A-Z]+|)
|
||||
# AWS S3
|
||||
\b\w*\.s3[^.]*\.amazonaws\.com/[-\w/&#%_?:=]*
|
||||
# AWS execute-api
|
||||
\b[0-9a-z]{10}\.execute-api\.[-0-9a-z]+\.amazonaws\.com\b
|
||||
# AWS ELB
|
||||
\b\w+\.[-0-9a-z]+\.elb\.amazonaws\.com\b
|
||||
# AWS SNS
|
||||
\bsns\.[-0-9a-z]+.amazonaws\.com/[-\w/&#%_?:=]*
|
||||
# AWS VPC
|
||||
vpc-\w+
|
||||
|
||||
# While you could try to match `http://` and `https://` by using `s?` in `https?://`, sometimes there
|
||||
# YouTube url
|
||||
\b(?:(?:www\.|)youtube\.com|youtu.be)/(?:channel/|embed/|user/|playlist\?list=|watch\?v=|v/|)[-a-zA-Z0-9?&=_%]*
|
||||
# YouTube music
|
||||
\bmusic\.youtube\.com/youtubei/v1/browse(?:[?&]\w+=[-a-zA-Z0-9?&=_]*)
|
||||
# YouTube tag
|
||||
<\s*youtube\s+id=['"][-a-zA-Z0-9?_]*['"]
|
||||
# YouTube image
|
||||
\bimg\.youtube\.com/vi/[-a-zA-Z0-9?&=_]*
|
||||
# Google Accounts
|
||||
\baccounts.google.com/[-_/?=.:;+%&0-9a-zA-Z]*
|
||||
# Google Analytics
|
||||
\bgoogle-analytics\.com/collect.[-0-9a-zA-Z?%=&_.~]*
|
||||
# Google APIs
|
||||
\bgoogleapis\.(?:com|dev)/[a-z]+/(?:v\d+/|)[a-z]+/[-@:./?=\w+|&]+
|
||||
# Google Storage
|
||||
\b[-a-zA-Z0-9.]*\bstorage\d*\.googleapis\.com(?:/\S*|)
|
||||
# Google Calendar
|
||||
\bcalendar\.google\.com/calendar(?:/u/\d+|)/embed\?src=[@./?=\w&%]+
|
||||
\w+\@group\.calendar\.google\.com\b
|
||||
# Google DataStudio
|
||||
\bdatastudio\.google\.com/(?:(?:c/|)u/\d+/|)(?:embed/|)(?:open|reporting|datasources|s)/[-0-9a-zA-Z]+(?:/page/[-0-9a-zA-Z]+|)
|
||||
# The leading `/` here is as opposed to the `\b` above
|
||||
# ... a short way to match `https://` or `http://` since most urls have one of those prefixes
|
||||
# Google Docs
|
||||
/docs\.google\.com/[a-z]+/(?:ccc\?key=\w+|(?:u/\d+|d/(?:e/|)[0-9a-zA-Z_-]+/)?(?:edit\?[-\w=#.]*|/\?[\w=&]*|))
|
||||
# Google Drive
|
||||
\bdrive\.google\.com/(?:file/d/|open)[-0-9a-zA-Z_?=]*
|
||||
# Google Groups
|
||||
\bgroups\.google\.com/(?:(?:forum/#!|d/)(?:msg|topics?|searchin)|a)/[^/\s"]+/[-a-zA-Z0-9$]+(?:/[-a-zA-Z0-9]+)*
|
||||
# Google Maps
|
||||
\bmaps\.google\.com/maps\?[\w&;=]*
|
||||
# Google themes
|
||||
themes\.googleusercontent\.com/static/fonts/[^/\s"]+/v\d+/[^.]+.
|
||||
# Google CDN
|
||||
\bclients2\.google(?:usercontent|)\.com[-0-9a-zA-Z/.]*
|
||||
# Goo.gl
|
||||
/goo\.gl/[a-zA-Z0-9]+
|
||||
# Google Chrome Store
|
||||
\bchrome\.google\.com/webstore/detail/[-\w]*(?:/\w*|)
|
||||
# Google Books
|
||||
\bgoogle\.(?:\w{2,4})/books(?:/\w+)*\?[-\w\d=&#.]*
|
||||
# Google Fonts
|
||||
\bfonts\.(?:googleapis|gstatic)\.com/[-/?=:;+&0-9a-zA-Z]*
|
||||
# Google Forms
|
||||
\bforms\.gle/\w+
|
||||
# Google Scholar
|
||||
\bscholar\.google\.com/citations\?user=[A-Za-z0-9_]+
|
||||
# Google Colab Research Drive
|
||||
\bcolab\.research\.google\.com/drive/[-0-9a-zA-Z_?=]*
|
||||
|
||||
# GitHub SHAs (api)
|
||||
\bapi.github\.com/repos(?:/[^/\s"]+){3}/[0-9a-f]+\b
|
||||
# GitHub SHAs (markdown)
|
||||
(?:\[`?[0-9a-f]+`?\]\(https:/|)/(?:www\.|)github\.com(?:/[^/\s"]+){2,}(?:/[^/\s")]+)(?:[0-9a-f]+(?:[-0-9a-zA-Z/#.]*|)\b|)
|
||||
# GitHub SHAs
|
||||
\bgithub\.com(?:/[^/\s"]+){2}[@#][0-9a-f]+\b
|
||||
# GitHub wiki
|
||||
\bgithub\.com/(?:[^/]+/){2}wiki/(?:(?:[^/]+/|)_history|[^/]+(?:/_compare|)/[0-9a-f.]{40,})\b
|
||||
# githubusercontent
|
||||
/[-a-z0-9]+\.githubusercontent\.com/[-a-zA-Z0-9?&=_\/.]*
|
||||
# githubassets
|
||||
\bgithubassets.com/[0-9a-f]+(?:[-/\w.]+)
|
||||
# gist github
|
||||
\bgist\.github\.com/[^/\s"]+/[0-9a-f]+
|
||||
# git.io
|
||||
\bgit\.io/[0-9a-zA-Z]+
|
||||
# GitHub JSON
|
||||
"node_id": "[-a-zA-Z=;:/0-9+]*"
|
||||
# Contributor
|
||||
\[[^\]]+\]\(https://github\.com/[^/\s"]+\)
|
||||
# GHSA
|
||||
GHSA(?:-[0-9a-z]{4}){3}
|
||||
|
||||
# GitLab commit
|
||||
\bgitlab\.[^/\s"]*/\S+/\S+/commit/[0-9a-f]{7,16}#[0-9a-f]{40}\b
|
||||
# GitLab merge requests
|
||||
\bgitlab\.[^/\s"]*/\S+/\S+/-/merge_requests/\d+/diffs#[0-9a-f]{40}\b
|
||||
# GitLab uploads
|
||||
\bgitlab\.[^/\s"]*/uploads/[-a-zA-Z=;:/0-9+]*
|
||||
# GitLab commits
|
||||
\bgitlab\.[^/\s"]*/(?:[^/\s"]+/){2}commits?/[0-9a-f]+\b
|
||||
|
||||
# binanace
|
||||
accounts.binance.com/[a-z/]*oauth/authorize\?[-0-9a-zA-Z&%]*
|
||||
|
||||
# bitbucket diff
|
||||
\bapi\.bitbucket\.org/\d+\.\d+/repositories/(?:[^/\s"]+/){2}diff(?:stat|)(?:/[^/\s"]+){2}:[0-9a-f]+
|
||||
# bitbucket repositories commits
|
||||
\bapi\.bitbucket\.org/\d+\.\d+/repositories/(?:[^/\s"]+/){2}commits?/[0-9a-f]+
|
||||
# bitbucket commits
|
||||
\bbitbucket\.org/(?:[^/\s"]+/){2}commits?/[0-9a-f]+
|
||||
|
||||
# bit.ly
|
||||
\bbit\.ly/\w+
|
||||
|
||||
# bitrise
|
||||
\bapp\.bitrise\.io/app/[0-9a-f]*/[\w.?=&]*
|
||||
|
||||
# bootstrapcdn.com
|
||||
\bbootstrapcdn\.com/[-./\w]+
|
||||
|
||||
# cdn.cloudflare.com
|
||||
\bcdnjs\.cloudflare\.com/[./\w]+
|
||||
|
||||
# circleci
|
||||
\bcircleci\.com/gh(?:/[^/\s"]+){1,5}.[a-z]+\?[-0-9a-zA-Z=&]+
|
||||
|
||||
# gitter
|
||||
\bgitter\.im(?:/[^/\s"]+){2}\?at=[0-9a-f]+
|
||||
|
||||
# gravatar
|
||||
\bgravatar\.com/avatar/[0-9a-f]+
|
||||
|
||||
# ibm
|
||||
[a-z.]*ibm\.com/[-_#=:%!?~.\\/\d\w]*
|
||||
|
||||
# imgur
|
||||
\bimgur\.com/[^.]+
|
||||
|
||||
# Internet Archive
|
||||
\barchive\.org/web/\d+/(?:[-\w.?,'/\\+&%$#_:]*)
|
||||
|
||||
# discord
|
||||
/discord(?:app\.com|\.gg)/(?:invite/)?[a-zA-Z0-9]{7,}
|
||||
|
||||
# Disqus
|
||||
\bdisqus\.com/[-\w/%.()!?&=_]*
|
||||
|
||||
# medium link
|
||||
\blink\.medium\.com/[a-zA-Z0-9]+
|
||||
# medium
|
||||
\bmedium\.com/\@?[^/\s"]+/[-\w]+
|
||||
|
||||
# microsoft
|
||||
\b(?:https?://|)(?:(?:download\.visualstudio|docs|msdn2?|research)\.microsoft|blogs\.msdn)\.com/[-_a-zA-Z0-9()=./%]*
|
||||
# powerbi
|
||||
\bapp\.powerbi\.com/reportEmbed/[^"' ]*
|
||||
# vs devops
|
||||
\bvisualstudio.com(?::443|)/[-\w/?=%&.]*
|
||||
# microsoft store
|
||||
\bmicrosoft\.com/store/apps/\w+
|
||||
|
||||
# mvnrepository.com
|
||||
\bmvnrepository\.com/[-0-9a-z./]+
|
||||
|
||||
# now.sh
|
||||
/[0-9a-z-.]+\.now\.sh\b
|
||||
|
||||
# oracle
|
||||
\bdocs\.oracle\.com/[-0-9a-zA-Z./_?#&=]*
|
||||
|
||||
# chromatic.com
|
||||
/\S+.chromatic.com\S*[")]
|
||||
|
||||
# codacy
|
||||
\bapi\.codacy\.com/project/badge/Grade/[0-9a-f]+
|
||||
|
||||
# compai
|
||||
\bcompai\.pub/v1/png/[0-9a-f]+
|
||||
|
||||
# mailgun api
|
||||
\.api\.mailgun\.net/v3/domains/[0-9a-z]+\.mailgun.org/messages/[0-9a-zA-Z=@]*
|
||||
# mailgun
|
||||
\b[0-9a-z]+.mailgun.org
|
||||
|
||||
# /message-id/
|
||||
/message-id/[-\w@./%]+
|
||||
|
||||
# Reddit
|
||||
\breddit\.com/r/[/\w_]*
|
||||
|
||||
# requestb.in
|
||||
\brequestb\.in/[0-9a-z]+
|
||||
|
||||
# sched
|
||||
\b[a-z0-9]+\.sched\.com\b
|
||||
|
||||
# Slack url
|
||||
slack://[a-zA-Z0-9?&=]+
|
||||
# Slack
|
||||
\bslack\.com/[-0-9a-zA-Z/_~?&=.]*
|
||||
# Slack edge
|
||||
\bslack-edge\.com/[-a-zA-Z0-9?&=%./]+
|
||||
# Slack images
|
||||
\bslack-imgs\.com/[-a-zA-Z0-9?&=%.]+
|
||||
|
||||
# shields.io
|
||||
\bshields\.io/[-\w/%?=&.:+;,]*
|
||||
|
||||
# stackexchange -- https://stackexchange.com/feeds/sites
|
||||
\b(?:askubuntu|serverfault|stack(?:exchange|overflow)|superuser).com/(?:questions/\w+/[-\w]+|a/)
|
||||
|
||||
# Sentry
|
||||
[0-9a-f]{32}\@o\d+\.ingest\.sentry\.io\b
|
||||
|
||||
# Twitter markdown
|
||||
\[\@[^[/\]:]*?\]\(https://twitter.com/[^/\s"')]*(?:/status/\d+(?:\?[-_0-9a-zA-Z&=]*|)|)\)
|
||||
# Twitter hashtag
|
||||
\btwitter\.com/hashtag/[\w?_=&]*
|
||||
# Twitter status
|
||||
\btwitter\.com/[^/\s"')]*(?:/status/\d+(?:\?[-_0-9a-zA-Z&=]*|)|)
|
||||
# Twitter profile images
|
||||
\btwimg\.com/profile_images/[_\w./]*
|
||||
# Twitter media
|
||||
\btwimg\.com/media/[-_\w./?=]*
|
||||
# Twitter link shortened
|
||||
\bt\.co/\w+
|
||||
|
||||
# facebook
|
||||
\bfburl\.com/[0-9a-z_]+
|
||||
# facebook CDN
|
||||
\bfbcdn\.net/[\w/.,]*
|
||||
# facebook watch
|
||||
\bfb\.watch/[0-9A-Za-z]+
|
||||
|
||||
# dropbox
|
||||
\bdropbox\.com/sh?/[^/\s"]+/[-0-9A-Za-z_.%?=&;]+
|
||||
|
||||
# ipfs protocol
|
||||
ipfs://[0-9a-z]*
|
||||
# ipfs url
|
||||
/ipfs/[0-9a-z]*
|
||||
|
||||
# w3
|
||||
\bw3\.org/[-0-9a-zA-Z/#.]+
|
||||
|
||||
# loom
|
||||
\bloom\.com/embed/[0-9a-f]+
|
||||
|
||||
# regex101
|
||||
\bregex101\.com/r/[^/\s"]+/\d+
|
||||
|
||||
# figma
|
||||
\bfigma\.com/file(?:/[0-9a-zA-Z]+/)+
|
||||
|
||||
# freecodecamp.org
|
||||
\bfreecodecamp\.org/[-\w/.]+
|
||||
|
||||
# image.tmdb.org
|
||||
\bimage\.tmdb\.org/[/\w.]+
|
||||
|
||||
# mermaid
|
||||
\bmermaid\.ink/img/[-\w]+|\bmermaid-js\.github\.io/mermaid-live-editor/#/edit/[-\w]+
|
||||
|
||||
# Wikipedia
|
||||
\ben\.wikipedia\.org/wiki/[-\w%.#]+
|
||||
|
||||
# gitweb
|
||||
[^"\s]+/gitweb/\S+;h=[0-9a-f]+
|
||||
|
||||
# HyperKitty lists
|
||||
/archives/list/[^@/]+\@[^/\s"]*/message/[^/\s"]*/
|
||||
|
||||
# lists
|
||||
/thread\.html/[^"\s]+
|
||||
|
||||
# list-management
|
||||
\blist-manage\.com/subscribe(?:[?&](?:u|id)=[0-9a-f]+)+
|
||||
|
||||
# kubectl.kubernetes.io/last-applied-configuration
|
||||
"kubectl.kubernetes.io/last-applied-configuration": ".*"
|
||||
|
||||
# pgp
|
||||
\bgnupg\.net/pks/lookup[?&=0-9a-zA-Z]*
|
||||
|
||||
# Spotify
|
||||
\bopen\.spotify\.com/embed/playlist/\w+
|
||||
|
||||
# Mastodon
|
||||
\bmastodon\.[-a-z.]*/(?:media/|\@)[?&=0-9a-zA-Z_]*
|
||||
|
||||
# scastie
|
||||
\bscastie\.scala-lang\.org/[^/]+/\w+
|
||||
|
||||
# images.unsplash.com
|
||||
\bimages\.unsplash\.com/(?:(?:flagged|reserve)/|)[-\w./%?=%&.;]+
|
||||
|
||||
# pastebin
|
||||
\bpastebin\.com/[\w/]+
|
||||
|
||||
# heroku
|
||||
\b\w+\.heroku\.com/source/archive/\w+
|
||||
|
||||
# quip
|
||||
\b\w+\.quip\.com/\w+(?:(?:#|/issues/)\w+)?
|
||||
|
||||
# badgen.net
|
||||
\bbadgen\.net/badge/[^")\]'\s]+
|
||||
|
||||
# statuspage.io
|
||||
\w+\.statuspage\.io\b
|
||||
|
||||
# media.giphy.com
|
||||
\bmedia\.giphy\.com/media/[^/]+/[\w.?&=]+
|
||||
|
||||
# tinyurl
|
||||
\btinyurl\.com/\w+
|
||||
|
||||
# getopts
|
||||
\bgetopts\s+(?:"[^"]+"|'[^']+')
|
||||
|
||||
# ANSI color codes
|
||||
(?:\\(?:u00|x)1b|\x1b)\[\d+(?:;\d+|)m
|
||||
|
||||
# URL escaped characters
|
||||
\%[0-9A-F][A-F]
|
||||
# IPv6
|
||||
\b(?:[0-9a-fA-F]{0,4}:){3,7}[0-9a-fA-F]{0,4}\b
|
||||
# c99 hex digits (not the full format, just one I've seen)
|
||||
0x[0-9a-fA-F](?:\.[0-9a-fA-F]*|)[pP]
|
||||
# Punycode
|
||||
\bxn--[-0-9a-z]+
|
||||
# sha
|
||||
sha\d+:[0-9]*[a-f]{3,}[0-9a-f]*
|
||||
# sha-... -- uses a fancy capture
|
||||
(['"]|")[0-9a-f]{40,}\g{-1}
|
||||
# hex runs
|
||||
\b[0-9a-fA-F]{16,}\b
|
||||
# hex in url queries
|
||||
=[0-9a-fA-F]*?(?:[A-F]{3,}|[a-f]{3,})[0-9a-fA-F]*?&
|
||||
# ssh
|
||||
(?:ssh-\S+|-nistp256) [-a-zA-Z=;:/0-9+]{12,}
|
||||
|
||||
# PGP
|
||||
\b(?:[0-9A-F]{4} ){9}[0-9A-F]{4}\b
|
||||
# GPG keys
|
||||
\b(?:[0-9A-F]{4} ){5}(?: [0-9A-F]{4}){5}\b
|
||||
# Well known gpg keys
|
||||
.well-known/openpgpkey/[\w./]+
|
||||
|
||||
# uuid:
|
||||
\b[0-9a-fA-F]{8}-(?:[0-9a-fA-F]{4}-){3}[0-9a-fA-F]{12}\b
|
||||
# hex digits including css/html color classes:
|
||||
(?:[\\0][xX]|\\u|[uU]\+|#x?|\%23)[0-9_a-fA-FgGrR]*?[a-fA-FgGrR]{2,}[0-9_a-fA-FgGrR]*(?:[uUlL]{0,3}|u\d+)\b
|
||||
# integrity
|
||||
integrity="sha\d+-[-a-zA-Z=;:/0-9+]{40,}"
|
||||
|
||||
# https://www.gnu.org/software/groff/manual/groff.html
|
||||
# man troff content
|
||||
\\f[BCIPR]
|
||||
# '
|
||||
\\\(aq
|
||||
|
||||
# .desktop mime types
|
||||
^MimeTypes?=.*$
|
||||
# .desktop localized entries
|
||||
^[A-Z][a-z]+\[[a-z]+\]=.*$
|
||||
# Localized .desktop content
|
||||
Name\[[^\]]+\]=.*
|
||||
|
||||
# IServiceProvider
|
||||
\bI(?=(?:[A-Z][a-z]{2,})+\b)
|
||||
|
||||
# crypt
|
||||
"\$2[ayb]\$.{56}"
|
||||
|
||||
# scrypt / argon
|
||||
\$(?:scrypt|argon\d+[di]*)\$\S+
|
||||
|
||||
# Input to GitHub JSON
|
||||
content: "[-a-zA-Z=;:/0-9+]*="
|
||||
|
||||
# Python stringprefix / binaryprefix
|
||||
# Note that there's a high false positive rate, remove the `?=` and search for the regex to see if the matches seem like reasonable strings
|
||||
(?<!')\b(?:B|BR|Br|F|FR|Fr|R|RB|RF|Rb|Rf|U|UR|Ur|b|bR|br|f|fR|fr|r|rB|rF|rb|rf|u|uR|ur)'(?:[A-Z]{3,}|[A-Z][a-z]{2,}|[a-z]{3,})
|
||||
|
||||
# Regular expressions for (P|p)assword
|
||||
\([A-Z]\|[a-z]\)[a-z]+
|
||||
|
||||
# JavaScript regular expressions
|
||||
# javascript test regex
|
||||
/.*/[gim]*\.test\(
|
||||
# javascript match regex
|
||||
\.match\(/[^/\s"]*/[gim]*\s*
|
||||
# javascript match regex
|
||||
\.match\(/\\[b].*?/[gim]*\s*\)(?:;|$)
|
||||
# javascript regex
|
||||
^\s*/\\[b].*/[gim]*\s*(?:\)(?:;|$)|,$)
|
||||
# javascript replace regex
|
||||
\.replace\(/[^/\s"]*/[gim]*\s*,
|
||||
|
||||
# Go regular expressions
|
||||
regexp?\.MustCompile\(`[^`]*`\)
|
||||
|
||||
# sed regular expressions
|
||||
sed 's/(?:[^/]*?[a-zA-Z]{3,}[^/]*?/){2}
|
||||
|
||||
# go install
|
||||
go install(?:\s+[a-z]+\.[-@\w/.]+)+
|
||||
|
||||
# kubernetes pod status lists
|
||||
# https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle/#pod-phase
|
||||
\w+(?:-\w+)+\s+\d+/\d+\s+(?:Running|Pending|Succeeded|Failed|Unknown)\s+
|
||||
|
||||
# kubectl - pods in CrashLoopBackOff
|
||||
\w+-[0-9a-f]+-\w+\s+\d+/\d+\s+CrashLoopBackOff\s+
|
||||
|
||||
# kubernetes object suffix
|
||||
-[0-9a-f]{10}-\w{5}\s
|
||||
|
||||
# posthog secrets
|
||||
posthog\.init\((['"])phc_[^"',]+\g{-1},
|
||||
|
||||
# xcode
|
||||
|
||||
# xcodeproject scenes
|
||||
(?:Controller|ID|id)="\w{3}-\w{2}-\w{3}"
|
||||
|
||||
# xcode api botches
|
||||
customObjectInstantitationMethod
|
||||
|
||||
# font awesome classes
|
||||
\.fa-[-a-z0-9]+
|
||||
|
||||
# Update Lorem based on your content (requires `ge` and `w` from https://github.com/jsoref/spelling; and `review` from https://github.com/check-spelling/check-spelling/wiki/Looking-for-items-locally )
|
||||
# grep '^[^#].*lorem' .github/actions/spelling/patterns.txt|perl -pne 's/.*i..\?://;s/\).*//' |tr '|' "\n"|sort -f |xargs -n1 ge|perl -pne 's/^[^:]*://'|sort -u|w|sed -e 's/ .*//'|w|review -
|
||||
# Warning, while `(?i)` is very neat and fancy, if you have some binary files that aren't proper unicode, you might run into:
|
||||
## Operation "substitution (s///)" returns its argument for non-Unicode code point 0x1C19AE (the code point will vary).
|
||||
## You could manually change `(?i)X...` to use `[Xx]...`
|
||||
## or you could add the files to your `excludes` file (a version after 0.0.19 should identify the file path)
|
||||
# Lorem
|
||||
(?:\w|\s|[,.])*\b(?i)(?:amet|consectetur|cursus|dolor|eros|ipsum|lacus|libero|ligula|lorem|magna|neque|nulla|suscipit|tempus)\b(?:\w|\s|[,.])*
|
||||
|
||||
# Non-English
|
||||
[a-zA-Z]*[ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝßàáâãäåæçèéêëìíîïðñòóôõöøùúûüýÿĀāŁłŃńŅņŒœŚśŠšŜŝŸŽžź][a-zA-Z]{3}[a-zA-ZÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝßàáâãäåæçèéêëìíîïðñòóôõöøùúûüýÿĀāŁłŃńŅņŒœŚśŠšŜŝŸŽžź]*
|
||||
|
||||
# French
|
||||
# This corpus only had capital letters, but you probably want lowercase ones as well.
|
||||
\b[LN]'+[a-z]{2,}\b
|
||||
|
||||
# latex
|
||||
\\(?:n(?:ew|ormal|osub)|r(?:enew)|t(?:able(?:of|)|he|itle))(?=[a-z]+)
|
||||
|
||||
# the negative lookahead here is to allow catching 'templatesz' as a misspelling
|
||||
# but to otherwise recognize a Windows path with \templates\foo.template or similar:
|
||||
\\(?:necessary|r(?:eport|esolve[dr]?|esult)|t(?:arget|emplates?))(?![a-z])
|
||||
# ignore long runs of a single character:
|
||||
\b([A-Za-z])\g{-1}{3,}\b
|
||||
# Note that the next example is no longer necessary if you are using
|
||||
# to match a string starting with a `#`, use a character-class:
|
||||
[#]backwards
|
||||
# version suffix <word>v#
|
||||
(?:(?<=[A-Z]{2})V|(?<=[a-z]{2}|[A-Z]{2})v)\d+(?:\b|(?=[a-zA-Z_]))
|
||||
# Compiler flags (Scala)
|
||||
(?:^|[\t ,>"'`=(])-J-[DPWXY](?=[A-Z]{2,}|[A-Z][a-z]|[a-z]{2,})
|
||||
# Compiler flags
|
||||
#(?:^|[\t ,"'`=(])-[DPWXYLlf](?=[A-Z]{2,}|[A-Z][a-z]|[a-z]{2,})
|
||||
|
||||
# Compiler flags (linker)
|
||||
,-B
|
||||
# curl arguments
|
||||
\b(?:\\n|)curl(?:\s+-[a-zA-Z]{1,2}\b)*(?:\s+-[a-zA-Z]{3,})(?:\s+-[a-zA-Z]+)*
|
||||
# set arguments
|
||||
\bset(?:\s+-[abefimouxE]{1,2})*\s+-[abefimouxE]{3,}(?:\s+-[abefimouxE]+)*
|
||||
# tar arguments
|
||||
\b(?:\\n|)g?tar(?:\.exe|)(?:(?:\s+--[-a-zA-Z]+|\s+-[a-zA-Z]+|\s[ABGJMOPRSUWZacdfh-pr-xz]+\b)(?:=[^ ]*|))+
|
||||
# tput arguments -- https://man7.org/linux/man-pages/man5/terminfo.5.html -- technically they can be more than 5 chars long...
|
||||
\btput\s+(?:(?:-[SV]|-T\s*\w+)\s+)*\w{3,5}\b
|
||||
# macOS temp folders
|
||||
/var/folders/\w\w/[+\w]+/(?:T|-Caches-)/
|
||||
46
.github/actions/spelling/excludes.txt
vendored
46
.github/actions/spelling/excludes.txt
vendored
@@ -1,28 +1,39 @@
|
||||
# See https://github.com/check-spelling/check-spelling/wiki/Configuration-Examples:-excludes
|
||||
(?:(?i)\.png$)
|
||||
(?:^|/)(?i)COPYRIGHT
|
||||
(?:^|/)(?i)LICEN[CS]E
|
||||
(?:^|/)3rdparty/
|
||||
(?:^|/)dirs$
|
||||
(?:^|/)go\.mod$
|
||||
(?:^|/)go\.sum$
|
||||
(?:^|/)package-lock\.json$
|
||||
(?:^|/)package(?:-lock|)\.json$
|
||||
(?:^|/)sources(?:|\.dep)$
|
||||
SUMS$
|
||||
(?:^|/)vendor/
|
||||
\.a$
|
||||
\.ai$
|
||||
\.avi$
|
||||
\.bmp$
|
||||
\.bz2$
|
||||
\.cer$
|
||||
\.class$
|
||||
\.crl$
|
||||
\.crt$
|
||||
\.csr$
|
||||
\.dll$
|
||||
\.docx?$
|
||||
\.drawio$
|
||||
\.DS_Store$
|
||||
\.eot$
|
||||
\.eps$
|
||||
\.exe$
|
||||
\.gif$
|
||||
\.gitattributes$
|
||||
\.graffle$
|
||||
\.gz$
|
||||
\.icns$
|
||||
\.ico$
|
||||
\.jar$
|
||||
\.jks$
|
||||
\.jpeg$
|
||||
\.jpg$
|
||||
\.key$
|
||||
@@ -30,28 +41,53 @@ SUMS$
|
||||
\.lock$
|
||||
\.map$
|
||||
\.min\..
|
||||
\.mod$
|
||||
\.mp3$
|
||||
\.mp4$
|
||||
\.o$
|
||||
\.ocf$
|
||||
\.otf$
|
||||
\.pbxproj$
|
||||
\.pdf$
|
||||
\.pem$
|
||||
\.png$
|
||||
\.psd$
|
||||
\.pyc$
|
||||
\.runsettings$
|
||||
\.s$
|
||||
\.sig$
|
||||
\.so$
|
||||
\.svg$
|
||||
\.svgz$
|
||||
\.svgz?$
|
||||
\.tar$
|
||||
\.tgz$
|
||||
\.tiff?$
|
||||
\.ttf$
|
||||
\.vsdx$
|
||||
\.wav$
|
||||
\.webm$
|
||||
\.webp$
|
||||
\.woff
|
||||
\.woff2?$
|
||||
\.xcf$
|
||||
\.xls
|
||||
\.xlsx?$
|
||||
\.xpm$
|
||||
\.yml$
|
||||
\.zip$
|
||||
^\.github/actions/spelling/
|
||||
^\.github/fabricbot.json$
|
||||
^\.gitignore$
|
||||
^\Q.git-blame-ignore-revs\E$
|
||||
^\Q.github/workflows/spelling.yml\E$
|
||||
^\Qdoc/reference/windows-terminal-logo.ans\E$
|
||||
^\Qsamples/ConPTY/EchoCon/EchoCon/EchoCon.vcxproj.filters\E$
|
||||
^\Qsrc/host/exe/Host.EXE.vcxproj.filters\E$
|
||||
^\Qsrc/host/ft_host/chafa.txt\E$
|
||||
^\Qsrc/tools/closetest/CloseTest.vcxproj.filters\E$
|
||||
^\XamlStyler.json$
|
||||
^build/config/
|
||||
^consolegit2gitfilters\.json$
|
||||
^dep/
|
||||
^doc/reference/master-sequence-list.csv$
|
||||
@@ -76,6 +112,6 @@ SUMS$
|
||||
^src/tools/texttests/fira\.txt$
|
||||
^src/tools/U8U16Test/(?:fr|ru|zh)\.txt$
|
||||
^src/types/ut_types/UtilsTests.cpp$
|
||||
^\.github/actions/spelling/
|
||||
^\.gitignore$
|
||||
^\XamlStyler.json$
|
||||
^tools/ReleaseEngineering/ServicingPipeline.ps1$
|
||||
ignore$
|
||||
SUMS$
|
||||
|
||||
8
.github/actions/spelling/expect/alphabet.txt
vendored
8
.github/actions/spelling/expect/alphabet.txt
vendored
@@ -5,26 +5,19 @@ AAAAAABBBBBBCCC
|
||||
AAAAABBBBBBCCC
|
||||
abcd
|
||||
abcd
|
||||
abcde
|
||||
abcdef
|
||||
ABCDEFG
|
||||
ABCDEFGH
|
||||
ABCDEFGHIJ
|
||||
abcdefghijk
|
||||
ABCDEFGHIJKLMNO
|
||||
abcdefghijklmnop
|
||||
ABCDEFGHIJKLMNOPQRST
|
||||
abcdefghijklmnopqrstuvwxyz
|
||||
ABCG
|
||||
ABE
|
||||
abf
|
||||
BBBBB
|
||||
BBBBBBBB
|
||||
BBBBBBBBBBBBBBDDDD
|
||||
BBBBBCCC
|
||||
BBBBCCCCC
|
||||
BBGGRR
|
||||
CCE
|
||||
EFG
|
||||
EFGh
|
||||
QQQQQQQQQQABCDEFGHIJ
|
||||
@@ -33,7 +26,6 @@ QQQQQQQQQQABCDEFGHIJKLMNOPQRSTQQQQQQQQQQ
|
||||
QQQQQQQQQQABCDEFGHIJPQRSTQQQQQQQQQQ
|
||||
qrstuvwxyz
|
||||
qwerty
|
||||
QWERTYUIOP
|
||||
qwertyuiopasdfg
|
||||
YYYYYYYDDDDDDDDDDD
|
||||
ZAAZZ
|
||||
|
||||
887
.github/actions/spelling/expect/expect.txt
vendored
887
.github/actions/spelling/expect/expect.txt
vendored
File diff suppressed because it is too large
Load Diff
22
.github/actions/spelling/expect/web.txt
vendored
22
.github/actions/spelling/expect/web.txt
vendored
@@ -1,28 +1,6 @@
|
||||
http
|
||||
www
|
||||
easyrgb
|
||||
php
|
||||
ecma
|
||||
rapidtables
|
||||
WCAG
|
||||
freedesktop
|
||||
ycombinator
|
||||
robertelder
|
||||
kovidgoyal
|
||||
leonerd
|
||||
fixterms
|
||||
winui
|
||||
appshellintegration
|
||||
mdtauk
|
||||
cppreference
|
||||
gfycat
|
||||
Guake
|
||||
askubuntu
|
||||
dostips
|
||||
viewtopic
|
||||
rosettacode
|
||||
Rexx
|
||||
tldp
|
||||
HOWTO
|
||||
uwspace
|
||||
uwaterloo
|
||||
|
||||
62
.github/actions/spelling/line_forbidden.patterns
vendored
Normal file
62
.github/actions/spelling/line_forbidden.patterns
vendored
Normal file
@@ -0,0 +1,62 @@
|
||||
# reject `m_data` as there's a certain OS which has evil defines that break things if it's used elsewhere
|
||||
# \bm_data\b
|
||||
|
||||
# If you have a framework that uses `it()` for testing and `fit()` for debugging a specific test,
|
||||
# you might not want to check in code where you were debugging w/ `fit()`, in which case, you might want
|
||||
# to use this:
|
||||
#\bfit\(
|
||||
|
||||
# s.b. GitHub
|
||||
\bGithub\b
|
||||
|
||||
# s.b. GitLab
|
||||
\bGitlab\b
|
||||
|
||||
# s.b. JavaScript
|
||||
\bJavascript\b
|
||||
|
||||
# s.b. Microsoft
|
||||
\bMicroSoft\b
|
||||
|
||||
# s.b. another
|
||||
\ban[- ]other\b
|
||||
|
||||
# s.b. greater than
|
||||
\bgreater then\b
|
||||
|
||||
# s.b. into
|
||||
#\sin to\s
|
||||
|
||||
# s.b. opt-in
|
||||
\sopt in\s
|
||||
|
||||
# s.b. less than
|
||||
\bless then\b
|
||||
|
||||
# s.b. otherwise
|
||||
\bother[- ]wise\b
|
||||
|
||||
# s.b. nonexistent
|
||||
\bnon existing\b
|
||||
\b[Nn]o[nt][- ]existent\b
|
||||
|
||||
# s.b. preexisting
|
||||
[Pp]re[- ]existing
|
||||
|
||||
# s.b. preempt
|
||||
[Pp]re[- ]empt\b
|
||||
|
||||
# s.b. preemptively
|
||||
[Pp]re[- ]emptively
|
||||
|
||||
# s.b. reentrancy
|
||||
[Rr]e[- ]entrancy
|
||||
|
||||
# s.b. reentrant
|
||||
[Rr]e[- ]entrant
|
||||
|
||||
# s.b. workaround(s)
|
||||
#\bwork[- ]arounds?\b
|
||||
|
||||
# Reject duplicate words
|
||||
\s([A-Z]{3,}|[A-Z][a-z]{2,}|[a-z]{3,})\s\g{-1}\s
|
||||
82
.github/actions/spelling/patterns/patterns.txt
vendored
82
.github/actions/spelling/patterns/patterns.txt
vendored
@@ -1,11 +1,6 @@
|
||||
https://(?:(?:[-a-zA-Z0-9?&=]*\.|)microsoft\.com)/[-a-zA-Z0-9?&=_#\/.]*
|
||||
https://aka\.ms/[-a-zA-Z0-9?&=\/_]*
|
||||
https://www\.itscj\.ipsj\.or\.jp/iso-ir/[-0-9]+\.pdf
|
||||
https://www\.vt100\.net/docs/[-a-zA-Z0-9#_\/.]*
|
||||
https://www.w3.org/[-a-zA-Z0-9?&=\/_#]*
|
||||
https://(?:(?:www\.|)youtube\.com|youtu.be)/[-a-zA-Z0-9?&=]*
|
||||
https://(?:[a-z-]+\.|)github(?:usercontent|)\.com/[-a-zA-Z0-9?%&=_\/.+]*
|
||||
https://www.xfree86.org/[-a-zA-Z0-9?&=\/_#]*
|
||||
# See https://github.com/check-spelling/check-spelling/wiki/Configuration-Examples:-patterns
|
||||
|
||||
https?://\S+
|
||||
[Pp]ublicKeyToken="?[0-9a-fA-F]{16}"?
|
||||
(?:[{"]|UniqueIdentifier>)[0-9a-fA-F]{8}-(?:[0-9a-fA-F]{4}-){3}[0-9a-fA-F]{12}(?:[}"]|</UniqueIdentifier)
|
||||
(?:0[Xx]|\\x|U\+|#)[a-f0-9A-FGgRr]{2,}[Uu]?[Ll]{0,2}\b
|
||||
@@ -28,3 +23,74 @@ vcvars\w*
|
||||
ROY\sG\.\sBIV
|
||||
!(?:(?i)ESC)!\[
|
||||
!(?:(?i)CSI)!(?:\d+(?:;\d+|)m|[ABCDF])
|
||||
|
||||
# Python stringprefix / binaryprefix
|
||||
\b(?:B|BR|Br|F|FR|Fr|R|RB|RF|Rb|Rf|U|UR|Ur|b|bR|br|f|fR|fr|r|rB|rF|rb|rf|u|uR|ur)'
|
||||
|
||||
# Automatically suggested patterns
|
||||
# hit-count: 3831 file-count: 582
|
||||
# IServiceProvider
|
||||
\bI(?=(?:[A-Z][a-z]{2,})+\b)
|
||||
|
||||
# hit-count: 71 file-count: 35
|
||||
# Compiler flags
|
||||
(?:^|[\t ,"'`=(])-[D](?=[A-Z]{2,}|[A-Z][a-z])
|
||||
(?:^|[\t ,"'`=(])-[X](?=[A-Z]{2,}|[A-Z][a-z]|[a-z]{2,})
|
||||
|
||||
# hit-count: 41 file-count: 28
|
||||
# version suffix <word>v#
|
||||
(?:(?<=[A-Z]{2})V|(?<=[a-z]{2}|[A-Z]{2})v)\d+(?:\b|(?=[a-zA-Z_]))
|
||||
|
||||
# hit-count: 20 file-count: 9
|
||||
# hex runs
|
||||
\b[0-9a-fA-F]{16,}\b
|
||||
|
||||
# hit-count: 10 file-count: 7
|
||||
# uuid:
|
||||
\b[0-9a-fA-F]{8}-(?:[0-9a-fA-F]{4}-){3}[0-9a-fA-F]{12}\b
|
||||
|
||||
# hit-count: 4 file-count: 4
|
||||
# mailto urls
|
||||
mailto:[-a-zA-Z=;:/?%&0-9+@.]{3,}
|
||||
|
||||
# hit-count: 4 file-count: 1
|
||||
# ANSI color codes
|
||||
(?:\\(?:u00|x)1b|\x1b)\[\d+(?:;\d+|)m
|
||||
|
||||
# hit-count: 2 file-count: 1
|
||||
# latex
|
||||
\\(?:n(?:ew|ormal|osub)|r(?:enew)|t(?:able(?:of|)|he|itle))(?=[a-z]+)
|
||||
|
||||
# hit-count: 1 file-count: 1
|
||||
# hex digits including css/html color classes:
|
||||
(?:[\\0][xX]|\\u|[uU]\+|#x?|\%23)[0-9_a-fA-FgGrR]*?[a-fA-FgGrR]{2,}[0-9_a-fA-FgGrR]*(?:[uUlL]{0,3}|u\d+)\b
|
||||
|
||||
# hit-count: 1 file-count: 1
|
||||
# Non-English
|
||||
[a-zA-Z]*[ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝßàáâãäåæçèéêëìíîïðñòóôõöøùúûüýÿĀāŁłŃńŅņŒœŚśŠšŜŝŸŽžź][a-zA-Z]{3}[a-zA-ZÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝßàáâãäåæçèéêëìíîïðñòóôõöøùúûüýÿĀāŁłŃńŅņŒœŚśŠšŜŝŸŽžź]*
|
||||
|
||||
# hit-count: 1 file-count: 1
|
||||
# French
|
||||
# This corpus only had capital letters, but you probably want lowercase ones as well.
|
||||
\b[LN]'+[a-z]{2,}\b
|
||||
|
||||
# acceptable duplicates
|
||||
# ls directory listings
|
||||
[-bcdlpsw](?:[-r][-w][-sx]){3}\s+\d+\s+(\S+)\s+\g{-1}\s+\d+\s+
|
||||
# C/idl types + English ...
|
||||
\s(Guid|long|LONG|that) \g{-1}\s
|
||||
|
||||
# javadoc / .net
|
||||
(?:[\\@](?:groupname|param)|(?:public|private)(?:\s+static|\s+readonly)*)\s+(\w+)\s+\g{-1}\s
|
||||
|
||||
# Commit message -- Signed-off-by and friends
|
||||
^\s*(?:(?:Based-on-patch|Co-authored|Helped|Mentored|Reported|Reviewed|Signed-off)-by|Thanks-to): (?:[^<]*<[^>]*>|[^<]*)\s*$
|
||||
|
||||
# Autogenerated revert commit message
|
||||
^This reverts commit [0-9a-f]{40}\.$
|
||||
|
||||
# vtmode
|
||||
--vtmode\s+(\w+)\s+\g{-1}\s
|
||||
|
||||
# ignore long runs of a single character:
|
||||
\b([A-Za-z])\g{-1}{3,}\b
|
||||
|
||||
28
.github/actions/spelling/reject.txt
vendored
28
.github/actions/spelling/reject.txt
vendored
@@ -1,22 +1,12 @@
|
||||
^attache$
|
||||
^attacher$
|
||||
^attachers$
|
||||
^spae$
|
||||
^spaebook$
|
||||
^spaecraft$
|
||||
^spaed$
|
||||
^spaedom$
|
||||
^spaeing$
|
||||
^spaeings$
|
||||
^spae-man$
|
||||
^spaeman$
|
||||
^spaer$
|
||||
^Spaerobee$
|
||||
^spaes$
|
||||
^spaewife$
|
||||
^spaewoman$
|
||||
^spaework$
|
||||
^spaewright$
|
||||
^wether$
|
||||
^wethers$
|
||||
^wetherteg$
|
||||
benefitting
|
||||
occurences?
|
||||
^dependan.*
|
||||
^oer$
|
||||
Sorce
|
||||
^[Ss]pae.*
|
||||
^untill$
|
||||
^untilling$
|
||||
^wether.*
|
||||
|
||||
132
.github/workflows/spelling2.yml
vendored
132
.github/workflows/spelling2.yml
vendored
@@ -1,20 +1,134 @@
|
||||
# spelling.yml is blocked per https://github.com/check-spelling/check-spelling/security/advisories/GHSA-g86g-chm8-7r2p
|
||||
name: Spell checking
|
||||
|
||||
# Comment management is handled through a secondary job, for details see:
|
||||
# https://github.com/check-spelling/check-spelling/wiki/Feature%3A-Restricted-Permissions
|
||||
#
|
||||
# `jobs.comment-push` runs when a push is made to a repository and the `jobs.spelling` job needs to make a comment
|
||||
# (in odd cases, it might actually run just to collapse a commment, but that's fairly rare)
|
||||
# it needs `contents: write` in order to add a comment.
|
||||
#
|
||||
# `jobs.comment-pr` runs when a pull_request is made to a repository and the `jobs.spelling` job needs to make a comment
|
||||
# or collapse a comment (in the case where it had previously made a comment and now no longer needs to show a comment)
|
||||
# it needs `pull-requests: write` in order to manipulate those comments.
|
||||
|
||||
# Updating pull request branches is managed via comment handling.
|
||||
# For details, see: https://github.com/check-spelling/check-spelling/wiki/Feature:-Update-expect-list
|
||||
#
|
||||
# These elements work together to make it happen:
|
||||
#
|
||||
# `on.issue_comment`
|
||||
# This event listens to comments by users asking to update the metadata.
|
||||
#
|
||||
# `jobs.update`
|
||||
# This job runs in response to an issue_comment and will push a new commit
|
||||
# to update the spelling metadata.
|
||||
#
|
||||
# `with.experimental_apply_changes_via_bot`
|
||||
# Tells the action to support and generate messages that enable it
|
||||
# to make a commit to update the spelling metadata.
|
||||
#
|
||||
# `with.ssh_key`
|
||||
# In order to trigger workflows when the commit is made, you can provide a
|
||||
# secret (typically, a write-enabled github deploy key).
|
||||
#
|
||||
# For background, see: https://github.com/check-spelling/check-spelling/wiki/Feature:-Update-with-deploy-key
|
||||
|
||||
on:
|
||||
pull_request_target:
|
||||
push:
|
||||
branches:
|
||||
- "**"
|
||||
tags-ignore:
|
||||
- "**"
|
||||
pull_request_target:
|
||||
branches:
|
||||
- "**"
|
||||
tags-ignore:
|
||||
- "**"
|
||||
types:
|
||||
- 'opened'
|
||||
- 'reopened'
|
||||
- 'synchronize'
|
||||
issue_comment:
|
||||
types:
|
||||
- 'created'
|
||||
|
||||
jobs:
|
||||
spelling:
|
||||
name: Spell checking
|
||||
permissions:
|
||||
contents: read
|
||||
pull-requests: read
|
||||
actions: read
|
||||
outputs:
|
||||
followup: ${{ steps.spelling.outputs.followup }}
|
||||
runs-on: ubuntu-latest
|
||||
if: "contains(github.event_name, 'pull_request') || github.event_name == 'push'"
|
||||
concurrency:
|
||||
group: spelling-${{ github.event.pull_request.number || github.ref }}
|
||||
# note: If you use only_check_changed_files, you do not want cancel-in-progress
|
||||
cancel-in-progress: true
|
||||
steps:
|
||||
- name: checkout-merge
|
||||
if: "contains(github.event_name, 'pull_request')"
|
||||
uses: actions/checkout@v2
|
||||
- name: check-spelling
|
||||
id: spelling
|
||||
uses: check-spelling/check-spelling@v0.0.21
|
||||
with:
|
||||
ref: refs/pull/${{github.event.pull_request.number}}/merge
|
||||
- name: checkout
|
||||
if: "!contains(github.event_name, 'pull_request')"
|
||||
uses: actions/checkout@v2
|
||||
- uses: check-spelling/check-spelling@v0.0.19
|
||||
suppress_push_for_open_pull_request: 1
|
||||
checkout: true
|
||||
check_file_names: 1
|
||||
spell_check_this: check-spelling/spell-check-this@prerelease
|
||||
post_comment: 0
|
||||
use_magic_file: 1
|
||||
extra_dictionary_limit: 10
|
||||
extra_dictionaries:
|
||||
cspell:software-terms/src/software-terms.txt
|
||||
cspell:python/src/python/python-lib.txt
|
||||
cspell:node/node.txt
|
||||
cspell:cpp/src/stdlib-c.txt
|
||||
cspell:cpp/src/stdlib-cpp.txt
|
||||
cspell:fullstack/fullstack.txt
|
||||
cspell:filetypes/filetypes.txt
|
||||
cspell:html/html.txt
|
||||
cspell:cpp/src/compiler-msvc.txt
|
||||
cspell:python/src/common/extra.txt
|
||||
cspell:powershell/powershell.txt
|
||||
cspell:aws/aws.txt
|
||||
cspell:cpp/src/lang-keywords.txt
|
||||
cspell:npm/npm.txt
|
||||
cspell:dotnet/dotnet.txt
|
||||
cspell:python/src/python/python.txt
|
||||
cspell:css/css.txt
|
||||
cspell:cpp/src/stdlib-cmath.txt
|
||||
check_extra_dictionaries: ''
|
||||
|
||||
comment-push:
|
||||
name: Report (Push)
|
||||
# If your workflow isn't running on push, you can remove this job
|
||||
runs-on: ubuntu-latest
|
||||
needs: spelling
|
||||
permissions:
|
||||
contents: write
|
||||
if: (success() || failure()) && needs.spelling.outputs.followup && github.event_name == 'push'
|
||||
steps:
|
||||
- name: comment
|
||||
uses: check-spelling/check-spelling@v0.0.21
|
||||
with:
|
||||
checkout: true
|
||||
spell_check_this: check-spelling/spell-check-this@prerelease
|
||||
task: ${{ needs.spelling.outputs.followup }}
|
||||
|
||||
comment-pr:
|
||||
name: Report (PR)
|
||||
# If you workflow isn't running on pull_request*, you can remove this job
|
||||
runs-on: ubuntu-latest
|
||||
needs: spelling
|
||||
permissions:
|
||||
pull-requests: write
|
||||
if: (success() || failure()) && needs.spelling.outputs.followup && contains(github.event_name, 'pull_request')
|
||||
steps:
|
||||
- name: comment
|
||||
uses: check-spelling/check-spelling@v0.0.21
|
||||
with:
|
||||
checkout: true
|
||||
spell_check_this: check-spelling/spell-check-this@prerelease
|
||||
task: ${{ needs.spelling.outputs.followup }}
|
||||
|
||||
@@ -164,7 +164,7 @@ jobs:
|
||||
inputs:
|
||||
solution: '**\OpenConsole.sln'
|
||||
vsVersion: 16.0
|
||||
msbuildArgs: /p:WindowsTerminalOfficialBuild=true /p:WindowsTerminalBranding=${{ parameters.branding }};PGOBuildMode=${{ parameters.pgoBuildMode }} /t:Terminal\CascadiaPackage;Terminal\WindowsTerminalUniversal /p:WindowsTerminalReleaseBuild=true /bl:$(Build.SourcesDirectory)\msbuild.binlog
|
||||
msbuildArgs: /p:WindowsTerminalOfficialBuild=true /p:WindowsTerminalBranding=${{ parameters.branding }};PGOBuildMode=${{ parameters.pgoBuildMode }} /t:Terminal\CascadiaPackage /p:WindowsTerminalReleaseBuild=true /bl:$(Build.SourcesDirectory)\msbuild.binlog
|
||||
platform: $(BuildPlatform)
|
||||
configuration: $(BuildConfiguration)
|
||||
clean: true
|
||||
|
||||
@@ -11,8 +11,8 @@
|
||||
// - attr - the default text attribute
|
||||
// Return Value:
|
||||
// - constructed object
|
||||
ATTR_ROW::ATTR_ROW(const uint16_t width, const TextAttribute attr) :
|
||||
_data(width, attr) {}
|
||||
ATTR_ROW::ATTR_ROW(const til::CoordType width, const TextAttribute attr) :
|
||||
_data(gsl::narrow<uint16_t>(width), attr) {}
|
||||
|
||||
// Routine Description:
|
||||
// - Sets all properties of the ATTR_ROW to default values
|
||||
@@ -32,9 +32,9 @@ void ATTR_ROW::Reset(const TextAttribute attr)
|
||||
// - newWidth - The new width of the row.
|
||||
// Return Value:
|
||||
// - <none>, throws exceptions on failures.
|
||||
void ATTR_ROW::Resize(const uint16_t newWidth)
|
||||
void ATTR_ROW::Resize(const til::CoordType newWidth)
|
||||
{
|
||||
_data.resize_trailing_extent(newWidth);
|
||||
_data.resize_trailing_extent(gsl::narrow<uint16_t>(newWidth));
|
||||
}
|
||||
|
||||
// Routine Description:
|
||||
@@ -45,9 +45,9 @@ void ATTR_ROW::Resize(const uint16_t newWidth)
|
||||
// - the text attribute at column
|
||||
// Note:
|
||||
// - will throw on error
|
||||
TextAttribute ATTR_ROW::GetAttrByColumn(const uint16_t column) const
|
||||
TextAttribute ATTR_ROW::GetAttrByColumn(const til::CoordType column) const
|
||||
{
|
||||
return _data.at(column);
|
||||
return _data.at(gsl::narrow_cast<uint16_t>(column));
|
||||
}
|
||||
|
||||
// Routine Description:
|
||||
@@ -74,9 +74,9 @@ std::vector<uint16_t> ATTR_ROW::GetHyperlinks() const
|
||||
// - attr - Attribute (color) to fill remaining characters with
|
||||
// Return Value:
|
||||
// - <none>
|
||||
bool ATTR_ROW::SetAttrToEnd(const uint16_t beginIndex, const TextAttribute attr)
|
||||
bool ATTR_ROW::SetAttrToEnd(const til::CoordType beginIndex, const TextAttribute attr)
|
||||
{
|
||||
_data.replace(gsl::narrow<uint16_t>(beginIndex), _data.size(), attr);
|
||||
_data.replace(gsl::narrow_cast<uint16_t>(beginIndex), _data.size(), attr);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -103,9 +103,9 @@ void ATTR_ROW::ReplaceAttrs(const TextAttribute& toBeReplacedAttr, const TextAtt
|
||||
// - newAttr: The attribute to merge into this row.
|
||||
// Return Value:
|
||||
// - <none>
|
||||
void ATTR_ROW::Replace(const uint16_t beginIndex, const uint16_t endIndex, const TextAttribute& newAttr)
|
||||
void ATTR_ROW::Replace(const til::CoordType beginIndex, const til::CoordType endIndex, const TextAttribute& newAttr)
|
||||
{
|
||||
_data.replace(beginIndex, endIndex, newAttr);
|
||||
_data.replace(gsl::narrow_cast<uint16_t>(beginIndex), gsl::narrow_cast<uint16_t>(endIndex), newAttr);
|
||||
}
|
||||
|
||||
ATTR_ROW::const_iterator ATTR_ROW::begin() const noexcept
|
||||
|
||||
@@ -30,7 +30,7 @@ class ATTR_ROW final
|
||||
public:
|
||||
using const_iterator = rle_vector::const_iterator;
|
||||
|
||||
ATTR_ROW(uint16_t width, TextAttribute attr);
|
||||
ATTR_ROW(til::CoordType width, TextAttribute attr);
|
||||
|
||||
~ATTR_ROW() = default;
|
||||
|
||||
@@ -40,13 +40,13 @@ public:
|
||||
noexcept = default;
|
||||
ATTR_ROW& operator=(ATTR_ROW&&) noexcept = default;
|
||||
|
||||
TextAttribute GetAttrByColumn(uint16_t column) const;
|
||||
TextAttribute GetAttrByColumn(til::CoordType column) const;
|
||||
std::vector<uint16_t> GetHyperlinks() const;
|
||||
|
||||
bool SetAttrToEnd(uint16_t beginIndex, TextAttribute attr);
|
||||
bool SetAttrToEnd(til::CoordType beginIndex, TextAttribute attr);
|
||||
void ReplaceAttrs(const TextAttribute& toBeReplacedAttr, const TextAttribute& replaceWith);
|
||||
void Resize(uint16_t newWidth);
|
||||
void Replace(uint16_t beginIndex, uint16_t endIndex, const TextAttribute& newAttr);
|
||||
void Resize(til::CoordType newWidth);
|
||||
void Replace(til::CoordType beginIndex, til::CoordType endIndex, const TextAttribute& newAttr);
|
||||
|
||||
const_iterator begin() const noexcept;
|
||||
const_iterator end() const noexcept;
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
// Note: will through if unable to allocate char/attribute buffers
|
||||
#pragma warning(push)
|
||||
#pragma warning(disable : 26447) // small_vector's constructor says it can throw but it should not given how we use it. This suppresses this error for the AuditMode build.
|
||||
CharRow::CharRow(size_t rowWidth, ROW* const pParent) noexcept :
|
||||
CharRow::CharRow(til::CoordType rowWidth, ROW* const pParent) noexcept :
|
||||
_data(rowWidth, value_type()),
|
||||
_pParent{ FAIL_FAST_IF_NULL(pParent) }
|
||||
{
|
||||
@@ -30,9 +30,10 @@ CharRow::CharRow(size_t rowWidth, ROW* const pParent) noexcept :
|
||||
// - <none>
|
||||
// Return Value:
|
||||
// - the size of the row
|
||||
size_t CharRow::size() const noexcept
|
||||
til::CoordType CharRow::size() const noexcept
|
||||
{
|
||||
return _data.size();
|
||||
// The constructor only accepts til::CoordType as _data's size(). -> Safe narrowing.
|
||||
return gsl::narrow_cast<til::CoordType>(_data.size());
|
||||
}
|
||||
|
||||
// Routine Description:
|
||||
@@ -55,7 +56,7 @@ void CharRow::Reset() noexcept
|
||||
// - newSize - the new width of the character and attributes rows
|
||||
// Return Value:
|
||||
// - S_OK on success, otherwise relevant error code
|
||||
[[nodiscard]] HRESULT CharRow::Resize(const size_t newSize) noexcept
|
||||
[[nodiscard]] HRESULT CharRow::Resize(const til::CoordType newSize) noexcept
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -93,14 +94,15 @@ typename CharRow::const_iterator CharRow::cend() const noexcept
|
||||
// - <none>
|
||||
// Return Value:
|
||||
// - The calculated left boundary of the internal string.
|
||||
size_t CharRow::MeasureLeft() const noexcept
|
||||
til::CoordType CharRow::MeasureLeft() const noexcept
|
||||
{
|
||||
const_iterator it = _data.cbegin();
|
||||
while (it != _data.cend() && it->IsSpace())
|
||||
{
|
||||
++it;
|
||||
}
|
||||
return it - _data.cbegin();
|
||||
// The constructor only accepts til::CoordType as _data's size(). -> Safe narrowing.
|
||||
return gsl::narrow_cast<til::CoordType>(it - _data.cbegin());
|
||||
}
|
||||
|
||||
// Routine Description:
|
||||
@@ -109,17 +111,18 @@ size_t CharRow::MeasureLeft() const noexcept
|
||||
// - <none>
|
||||
// Return Value:
|
||||
// - The calculated right boundary of the internal string.
|
||||
size_t CharRow::MeasureRight() const
|
||||
til::CoordType CharRow::MeasureRight() const
|
||||
{
|
||||
const_reverse_iterator it = _data.crbegin();
|
||||
while (it != _data.crend() && it->IsSpace())
|
||||
{
|
||||
++it;
|
||||
}
|
||||
return _data.crend() - it;
|
||||
// The constructor only accepts til::CoordType as _data's size(). -> Safe narrowing.
|
||||
return gsl::narrow_cast<til::CoordType>(_data.crend() - it);
|
||||
}
|
||||
|
||||
void CharRow::ClearCell(const size_t column)
|
||||
void CharRow::ClearCell(const til::CoordType column)
|
||||
{
|
||||
_data.at(column).Reset();
|
||||
}
|
||||
@@ -149,7 +152,7 @@ bool CharRow::ContainsText() const noexcept
|
||||
// Return Value:
|
||||
// - the attribute
|
||||
// Note: will throw exception if column is out of bounds
|
||||
const DbcsAttribute& CharRow::DbcsAttrAt(const size_t column) const
|
||||
const DbcsAttribute& CharRow::DbcsAttrAt(const til::CoordType column) const
|
||||
{
|
||||
return _data.at(column).DbcsAttr();
|
||||
}
|
||||
@@ -161,7 +164,7 @@ const DbcsAttribute& CharRow::DbcsAttrAt(const size_t column) const
|
||||
// Return Value:
|
||||
// - the attribute
|
||||
// Note: will throw exception if column is out of bounds
|
||||
DbcsAttribute& CharRow::DbcsAttrAt(const size_t column)
|
||||
DbcsAttribute& CharRow::DbcsAttrAt(const til::CoordType column)
|
||||
{
|
||||
return _data.at(column).DbcsAttr();
|
||||
}
|
||||
@@ -173,7 +176,7 @@ DbcsAttribute& CharRow::DbcsAttrAt(const size_t column)
|
||||
// Return Value:
|
||||
// - <none>
|
||||
// Note: will throw exception if column is out of bounds
|
||||
void CharRow::ClearGlyph(const size_t column)
|
||||
void CharRow::ClearGlyph(const til::CoordType column)
|
||||
{
|
||||
_data.at(column).EraseChars();
|
||||
}
|
||||
@@ -185,7 +188,7 @@ void CharRow::ClearGlyph(const size_t column)
|
||||
// Return Value:
|
||||
// - text data at column
|
||||
// - Note: will throw exception if column is out of bounds
|
||||
const CharRow::reference CharRow::GlyphAt(const size_t column) const
|
||||
const CharRow::reference CharRow::GlyphAt(const til::CoordType column) const
|
||||
{
|
||||
THROW_HR_IF(E_INVALIDARG, column >= _data.size());
|
||||
return { const_cast<CharRow&>(*this), column };
|
||||
@@ -198,7 +201,7 @@ const CharRow::reference CharRow::GlyphAt(const size_t column) const
|
||||
// Return Value:
|
||||
// - text data at column
|
||||
// - Note: will throw exception if column is out of bounds
|
||||
CharRow::reference CharRow::GlyphAt(const size_t column)
|
||||
CharRow::reference CharRow::GlyphAt(const til::CoordType column)
|
||||
{
|
||||
THROW_HR_IF(E_INVALIDARG, column >= _data.size());
|
||||
return { *this, column };
|
||||
@@ -209,7 +212,7 @@ std::wstring CharRow::GetText() const
|
||||
std::wstring wstr;
|
||||
wstr.reserve(_data.size());
|
||||
|
||||
for (size_t i = 0; i < _data.size(); ++i)
|
||||
for (til::CoordType i = 0; i < _data.size(); ++i)
|
||||
{
|
||||
const auto glyph = GlyphAt(i);
|
||||
if (!DbcsAttrAt(i).IsTrailing())
|
||||
@@ -231,7 +234,7 @@ std::wstring CharRow::GetText() const
|
||||
// - wordDelimiters: the delimiters defined as a part of the DelimiterClass::DelimiterChar
|
||||
// Return Value:
|
||||
// - the delimiter class for the given char
|
||||
const DelimiterClass CharRow::DelimiterClassAt(const size_t column, const std::wstring_view wordDelimiters) const
|
||||
const DelimiterClass CharRow::DelimiterClassAt(const til::CoordType column, const std::wstring_view wordDelimiters) const
|
||||
{
|
||||
THROW_HR_IF(E_INVALIDARG, column >= _data.size());
|
||||
|
||||
@@ -265,10 +268,10 @@ const UnicodeStorage& CharRow::GetUnicodeStorage() const noexcept
|
||||
// Arguments:
|
||||
// - column - the column to generate the key for
|
||||
// Return Value:
|
||||
// - the COORD key for data access from UnicodeStorage for the column
|
||||
COORD CharRow::GetStorageKey(const size_t column) const noexcept
|
||||
// - the til::point key for data access from UnicodeStorage for the column
|
||||
til::point CharRow::GetStorageKey(const til::CoordType column) const noexcept
|
||||
{
|
||||
return { gsl::narrow<SHORT>(column), _pParent->GetId() };
|
||||
return { column, _pParent->GetId() };
|
||||
}
|
||||
|
||||
// Routine Description:
|
||||
|
||||
@@ -54,22 +54,22 @@ public:
|
||||
using const_reverse_iterator = typename boost::container::small_vector_base<value_type>::const_reverse_iterator;
|
||||
using reference = typename CharRowCellReference;
|
||||
|
||||
CharRow(size_t rowWidth, ROW* const pParent) noexcept;
|
||||
CharRow(til::CoordType rowWidth, ROW* const pParent) noexcept;
|
||||
|
||||
size_t size() const noexcept;
|
||||
[[nodiscard]] HRESULT Resize(const size_t newSize) noexcept;
|
||||
size_t MeasureLeft() const noexcept;
|
||||
size_t MeasureRight() const;
|
||||
til::CoordType size() const noexcept;
|
||||
[[nodiscard]] HRESULT Resize(const til::CoordType newSize) noexcept;
|
||||
til::CoordType MeasureLeft() const noexcept;
|
||||
til::CoordType MeasureRight() const;
|
||||
bool ContainsText() const noexcept;
|
||||
const DbcsAttribute& DbcsAttrAt(const size_t column) const;
|
||||
DbcsAttribute& DbcsAttrAt(const size_t column);
|
||||
void ClearGlyph(const size_t column);
|
||||
const DbcsAttribute& DbcsAttrAt(const til::CoordType column) const;
|
||||
DbcsAttribute& DbcsAttrAt(const til::CoordType column);
|
||||
void ClearGlyph(const til::CoordType column);
|
||||
|
||||
const DelimiterClass DelimiterClassAt(const size_t column, const std::wstring_view wordDelimiters) const;
|
||||
const DelimiterClass DelimiterClassAt(const til::CoordType column, const std::wstring_view wordDelimiters) const;
|
||||
|
||||
// working with glyphs
|
||||
const reference GlyphAt(const size_t column) const;
|
||||
reference GlyphAt(const size_t column);
|
||||
const reference GlyphAt(const til::CoordType column) const;
|
||||
reference GlyphAt(const til::CoordType column);
|
||||
|
||||
// iterators
|
||||
iterator begin() noexcept;
|
||||
@@ -82,7 +82,7 @@ public:
|
||||
|
||||
UnicodeStorage& GetUnicodeStorage() noexcept;
|
||||
const UnicodeStorage& GetUnicodeStorage() const noexcept;
|
||||
COORD GetStorageKey(const size_t column) const noexcept;
|
||||
til::point GetStorageKey(const til::CoordType column) const noexcept;
|
||||
|
||||
void UpdateParent(ROW* const pParent);
|
||||
|
||||
@@ -91,7 +91,7 @@ public:
|
||||
|
||||
private:
|
||||
void Reset() noexcept;
|
||||
void ClearCell(const size_t column);
|
||||
void ClearCell(const til::CoordType column);
|
||||
std::wstring GetText() const;
|
||||
|
||||
protected:
|
||||
|
||||
@@ -25,7 +25,7 @@ class CharRowCellReference final
|
||||
public:
|
||||
using const_iterator = const wchar_t*;
|
||||
|
||||
CharRowCellReference(CharRow& parent, const size_t index) noexcept :
|
||||
CharRowCellReference(CharRow& parent, const til::CoordType index) noexcept :
|
||||
_parent{ parent },
|
||||
_index{ index }
|
||||
{
|
||||
@@ -51,7 +51,7 @@ private:
|
||||
// what char row the object belongs to
|
||||
CharRow& _parent;
|
||||
// the index of the cell in the parent char row
|
||||
const size_t _index;
|
||||
til::CoordType _index;
|
||||
|
||||
CharRowCell& _cellData();
|
||||
const CharRowCell& _cellData() const;
|
||||
|
||||
@@ -21,16 +21,16 @@ enum class LineRendition
|
||||
DoubleHeightBottom
|
||||
};
|
||||
|
||||
constexpr SMALL_RECT ScreenToBufferLine(const SMALL_RECT& line, const LineRendition lineRendition)
|
||||
constexpr til::inclusive_rect ScreenToBufferLine(const til::inclusive_rect line, const LineRendition lineRendition)
|
||||
{
|
||||
// Use shift right to quickly divide the Left and Right by 2 for double width lines.
|
||||
const auto scale = lineRendition == LineRendition::SingleWidth ? 0 : 1;
|
||||
return { line.Left >> scale, line.Top, line.Right >> scale, line.Bottom };
|
||||
}
|
||||
|
||||
constexpr SMALL_RECT BufferToScreenLine(const SMALL_RECT& line, const LineRendition lineRendition)
|
||||
constexpr til::inclusive_rect BufferToScreenLine(const til::inclusive_rect line, const LineRendition lineRendition)
|
||||
{
|
||||
// Use shift left to quickly multiply the Left and Right by 2 for double width lines.
|
||||
const SHORT scale = lineRendition == LineRendition::SingleWidth ? 0 : 1;
|
||||
const auto scale = lineRendition == LineRendition::SingleWidth ? 0 : 1;
|
||||
return { line.Left << scale, line.Top, (line.Right << scale) + scale, line.Bottom };
|
||||
}
|
||||
|
||||
@@ -533,14 +533,14 @@ OutputCellView OutputCellIterator::s_GenerateView(const OutputCell& cell)
|
||||
// - The number of items of the input run consumed between these two iterators.
|
||||
ptrdiff_t OutputCellIterator::GetInputDistance(OutputCellIterator other) const noexcept
|
||||
{
|
||||
return _pos - other._pos;
|
||||
return gsl::narrow_cast<ptrdiff_t>(_pos) - gsl::narrow_cast<ptrdiff_t>(other._pos);
|
||||
}
|
||||
|
||||
// Routine Description:
|
||||
// - Gets the distance between two iterators relative to the number of cells inserted.
|
||||
// Return Value:
|
||||
// - The number of cells in the backing buffer filled between these two iterators.
|
||||
ptrdiff_t OutputCellIterator::GetCellDistance(OutputCellIterator other) const noexcept
|
||||
til::CoordType OutputCellIterator::GetCellDistance(OutputCellIterator other) const noexcept
|
||||
{
|
||||
return _distance - other._distance;
|
||||
}
|
||||
|
||||
@@ -48,7 +48,7 @@ public:
|
||||
|
||||
operator bool() const noexcept;
|
||||
|
||||
ptrdiff_t GetCellDistance(OutputCellIterator other) const noexcept;
|
||||
til::CoordType GetCellDistance(OutputCellIterator other) const noexcept;
|
||||
ptrdiff_t GetInputDistance(OutputCellIterator other) const noexcept;
|
||||
friend ptrdiff_t operator-(OutputCellIterator one, OutputCellIterator two) = delete;
|
||||
|
||||
@@ -120,6 +120,6 @@ private:
|
||||
OutputCellView _currentView;
|
||||
|
||||
size_t _pos;
|
||||
size_t _distance;
|
||||
til::CoordType _distance;
|
||||
size_t _fillLimit;
|
||||
};
|
||||
|
||||
@@ -5,14 +5,6 @@
|
||||
|
||||
#include "OutputCellRect.hpp"
|
||||
|
||||
// Routine Description:
|
||||
// - Constructs an empty in-memory region for holding output buffer cell data.
|
||||
OutputCellRect::OutputCellRect() noexcept :
|
||||
_rows(0),
|
||||
_cols(0)
|
||||
{
|
||||
}
|
||||
|
||||
// Routine Description:
|
||||
// - Constructs an in-memory region for holding a copy of output buffer cell data.
|
||||
// - NOTE: This creatively skips the constructors for every cell. You must fill
|
||||
@@ -21,14 +13,10 @@ OutputCellRect::OutputCellRect() noexcept :
|
||||
// Arguments:
|
||||
// - rows - Rows in the rectangle (height)
|
||||
// - cols - Columns in the rectangle (width)
|
||||
OutputCellRect::OutputCellRect(const size_t rows, const size_t cols) :
|
||||
_rows(rows),
|
||||
_cols(cols)
|
||||
OutputCellRect::OutputCellRect(const til::size size) :
|
||||
_size(size)
|
||||
{
|
||||
size_t totalCells;
|
||||
THROW_IF_FAILED(SizeTMult(rows, cols, &totalCells));
|
||||
|
||||
_storage.resize(totalCells);
|
||||
_storage.resize(size.area<size_t>());
|
||||
}
|
||||
|
||||
// Routine Description:
|
||||
@@ -37,9 +25,9 @@ OutputCellRect::OutputCellRect(const size_t rows, const size_t cols) :
|
||||
// - row - The Y position or row index in the buffer.
|
||||
// Return Value:
|
||||
// - Read/write span of OutputCells
|
||||
gsl::span<OutputCell> OutputCellRect::GetRow(const size_t row)
|
||||
gsl::span<OutputCell> OutputCellRect::GetRow(const til::CoordType row)
|
||||
{
|
||||
return gsl::span<OutputCell>(_FindRowOffset(row), _cols);
|
||||
return gsl::span<OutputCell>(_FindRowOffset(row), _size.width);
|
||||
}
|
||||
|
||||
// Routine Description:
|
||||
@@ -48,9 +36,9 @@ gsl::span<OutputCell> OutputCellRect::GetRow(const size_t row)
|
||||
// - row - The Y position or row index in the buffer.
|
||||
// Return Value:
|
||||
// - Read-only iterator of OutputCells
|
||||
OutputCellIterator OutputCellRect::GetRowIter(const size_t row) const
|
||||
OutputCellIterator OutputCellRect::GetRowIter(const til::CoordType row) const
|
||||
{
|
||||
const gsl::span<const OutputCell> view(_FindRowOffset(row), _cols);
|
||||
const gsl::span<const OutputCell> view(_FindRowOffset(row), _size.width);
|
||||
|
||||
return OutputCellIterator(view);
|
||||
}
|
||||
@@ -62,9 +50,9 @@ OutputCellIterator OutputCellRect::GetRowIter(const size_t row) const
|
||||
// - row - The Y position or row index in the buffer.
|
||||
// Return Value:
|
||||
// - Pointer to the location in the rectangle that represents the start of the requested row.
|
||||
OutputCell* OutputCellRect::_FindRowOffset(const size_t row)
|
||||
OutputCell* OutputCellRect::_FindRowOffset(const til::CoordType row)
|
||||
{
|
||||
return &_storage.at(row * _cols);
|
||||
return &_storage.at(row * _size.width);
|
||||
}
|
||||
|
||||
// Routine Description:
|
||||
@@ -74,25 +62,25 @@ OutputCell* OutputCellRect::_FindRowOffset(const size_t row)
|
||||
// - row - The Y position or row index in the buffer.
|
||||
// Return Value:
|
||||
// - Pointer to the location in the rectangle that represents the start of the requested row.
|
||||
const OutputCell* OutputCellRect::_FindRowOffset(const size_t row) const
|
||||
const OutputCell* OutputCellRect::_FindRowOffset(const til::CoordType row) const
|
||||
{
|
||||
return &_storage.at(row * _cols);
|
||||
return &_storage.at(row * _size.width);
|
||||
}
|
||||
|
||||
// Routine Description:
|
||||
// - Gets the height of the rectangle
|
||||
// Return Value:
|
||||
// - Height
|
||||
size_t OutputCellRect::Height() const noexcept
|
||||
til::CoordType OutputCellRect::Height() const noexcept
|
||||
{
|
||||
return _rows;
|
||||
return _size.height;
|
||||
}
|
||||
|
||||
// Routine Description:
|
||||
// - Gets the width of the rectangle
|
||||
// Return Value:
|
||||
// - Width
|
||||
size_t OutputCellRect::Width() const noexcept
|
||||
til::CoordType OutputCellRect::Width() const noexcept
|
||||
{
|
||||
return _cols;
|
||||
return _size.width;
|
||||
}
|
||||
|
||||
@@ -29,21 +29,20 @@ Revision History:
|
||||
class OutputCellRect final
|
||||
{
|
||||
public:
|
||||
OutputCellRect() noexcept;
|
||||
OutputCellRect(const size_t rows, const size_t cols);
|
||||
OutputCellRect() noexcept = default;
|
||||
OutputCellRect(const til::size size);
|
||||
|
||||
gsl::span<OutputCell> GetRow(const size_t row);
|
||||
OutputCellIterator GetRowIter(const size_t row) const;
|
||||
gsl::span<OutputCell> GetRow(const til::CoordType row);
|
||||
OutputCellIterator GetRowIter(const til::CoordType row) const;
|
||||
|
||||
size_t Height() const noexcept;
|
||||
size_t Width() const noexcept;
|
||||
til::CoordType Height() const noexcept;
|
||||
til::CoordType Width() const noexcept;
|
||||
|
||||
private:
|
||||
std::vector<OutputCell> _storage;
|
||||
|
||||
OutputCell* _FindRowOffset(const size_t row);
|
||||
const OutputCell* _FindRowOffset(const size_t row) const;
|
||||
OutputCell* _FindRowOffset(const til::CoordType row);
|
||||
const OutputCell* _FindRowOffset(const til::CoordType row) const;
|
||||
|
||||
size_t _cols;
|
||||
size_t _rows;
|
||||
til::size _size;
|
||||
};
|
||||
|
||||
@@ -38,7 +38,7 @@ OutputCellView::OutputCellView(const std::wstring_view view,
|
||||
// - Reports how many columns we expect the Chars() text data to consume
|
||||
// Return Value:
|
||||
// - Count of column cells on the screen
|
||||
size_t OutputCellView::Columns() const noexcept
|
||||
til::CoordType OutputCellView::Columns() const noexcept
|
||||
{
|
||||
if (DbcsAttr().IsSingle())
|
||||
{
|
||||
|
||||
@@ -31,7 +31,7 @@ public:
|
||||
const TextAttributeBehavior behavior) noexcept;
|
||||
|
||||
const std::wstring_view& Chars() const noexcept;
|
||||
size_t Columns() const noexcept;
|
||||
til::CoordType Columns() const noexcept;
|
||||
DbcsAttribute DbcsAttr() const noexcept;
|
||||
TextAttribute TextAttr() const noexcept;
|
||||
TextAttributeBehavior TextAttrBehavior() const noexcept;
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
// - pParent - the text buffer that this row belongs to
|
||||
// Return Value:
|
||||
// - constructed object
|
||||
ROW::ROW(const SHORT rowId, const unsigned short rowWidth, const TextAttribute fillAttribute, TextBuffer* const pParent) :
|
||||
ROW::ROW(const til::CoordType rowId, const til::CoordType rowWidth, const TextAttribute fillAttribute, TextBuffer* const pParent) :
|
||||
_id{ rowId },
|
||||
_rowWidth{ rowWidth },
|
||||
_charRow{ rowWidth, this },
|
||||
@@ -58,7 +58,7 @@ bool ROW::Reset(const TextAttribute Attr)
|
||||
// - width - the new width, in cells
|
||||
// Return Value:
|
||||
// - S_OK if successful, otherwise relevant error
|
||||
[[nodiscard]] HRESULT ROW::Resize(const unsigned short width)
|
||||
[[nodiscard]] HRESULT ROW::Resize(const til::CoordType width)
|
||||
{
|
||||
RETURN_IF_FAILED(_charRow.Resize(width));
|
||||
try
|
||||
@@ -78,7 +78,7 @@ bool ROW::Reset(const TextAttribute Attr)
|
||||
// - column - 0-indexed column index
|
||||
// Return Value:
|
||||
// - <none>
|
||||
void ROW::ClearColumn(const size_t column)
|
||||
void ROW::ClearColumn(const til::CoordType column)
|
||||
{
|
||||
THROW_HR_IF(E_INVALIDARG, column >= _charRow.size());
|
||||
_charRow.ClearCell(column);
|
||||
@@ -103,7 +103,7 @@ const UnicodeStorage& ROW::GetUnicodeStorage() const noexcept
|
||||
// - limitRight - right inclusive column ID for the last write in this row. (optional, will just write to the end of row if nullopt)
|
||||
// Return Value:
|
||||
// - iterator to first cell that was not written to this row.
|
||||
OutputCellIterator ROW::WriteCells(OutputCellIterator it, const size_t index, const std::optional<bool> wrap, std::optional<size_t> limitRight)
|
||||
OutputCellIterator ROW::WriteCells(OutputCellIterator it, const til::CoordType index, const std::optional<bool> wrap, std::optional<til::CoordType> limitRight)
|
||||
{
|
||||
THROW_HR_IF(E_INVALIDARG, index >= _charRow.size());
|
||||
THROW_HR_IF(E_INVALIDARG, limitRight.value_or(0) >= _charRow.size());
|
||||
|
||||
@@ -32,9 +32,9 @@ class TextBuffer;
|
||||
class ROW final
|
||||
{
|
||||
public:
|
||||
ROW(const SHORT rowId, const unsigned short rowWidth, const TextAttribute fillAttribute, TextBuffer* const pParent);
|
||||
ROW(const til::CoordType rowId, const til::CoordType rowWidth, const TextAttribute fillAttribute, TextBuffer* const pParent);
|
||||
|
||||
size_t size() const noexcept { return _rowWidth; }
|
||||
til::CoordType size() const noexcept { return _rowWidth; }
|
||||
|
||||
void SetWrapForced(const bool wrap) noexcept { _wrapForced = wrap; }
|
||||
bool WasWrapForced() const noexcept { return _wrapForced; }
|
||||
@@ -51,19 +51,19 @@ public:
|
||||
LineRendition GetLineRendition() const noexcept { return _lineRendition; }
|
||||
void SetLineRendition(const LineRendition lineRendition) noexcept { _lineRendition = lineRendition; }
|
||||
|
||||
SHORT GetId() const noexcept { return _id; }
|
||||
void SetId(const SHORT id) noexcept { _id = id; }
|
||||
til::CoordType GetId() const noexcept { return _id; }
|
||||
void SetId(const til::CoordType id) noexcept { _id = id; }
|
||||
|
||||
bool Reset(const TextAttribute Attr);
|
||||
[[nodiscard]] HRESULT Resize(const unsigned short width);
|
||||
[[nodiscard]] HRESULT Resize(const til::CoordType width);
|
||||
|
||||
void ClearColumn(const size_t column);
|
||||
void ClearColumn(const til::CoordType column);
|
||||
std::wstring GetText() const { return _charRow.GetText(); }
|
||||
|
||||
UnicodeStorage& GetUnicodeStorage() noexcept;
|
||||
const UnicodeStorage& GetUnicodeStorage() const noexcept;
|
||||
|
||||
OutputCellIterator WriteCells(OutputCellIterator it, const size_t index, const std::optional<bool> wrap = std::nullopt, std::optional<size_t> limitRight = std::nullopt);
|
||||
OutputCellIterator WriteCells(OutputCellIterator it, const til::CoordType index, const std::optional<bool> wrap = std::nullopt, std::optional<til::CoordType> limitRight = std::nullopt);
|
||||
|
||||
#ifdef UNIT_TESTING
|
||||
friend constexpr bool operator==(const ROW& a, const ROW& b) noexcept;
|
||||
@@ -74,8 +74,8 @@ private:
|
||||
CharRow _charRow;
|
||||
ATTR_ROW _attrRow;
|
||||
LineRendition _lineRendition;
|
||||
SHORT _id;
|
||||
unsigned short _rowWidth;
|
||||
til::CoordType _id;
|
||||
til::CoordType _rowWidth;
|
||||
// Occurs when the user runs out of text in a given row and we're forced to wrap the cursor to the next line
|
||||
bool _wrapForced;
|
||||
// Occurs when the user runs out of text to support a double byte character and we're forced to the next line
|
||||
|
||||
@@ -47,7 +47,7 @@ void UnicodeStorage::Erase(const key_type key) noexcept
|
||||
// - rowMap - A map of the old row IDs to the new row IDs.
|
||||
// - width - The width of the new row. Remove any items that are beyond the row width.
|
||||
// - Use nullopt if we're not resizing the width of the row, just renumbering the rows.
|
||||
void UnicodeStorage::Remap(const std::unordered_map<SHORT, SHORT>& rowMap, const std::optional<SHORT> width)
|
||||
void UnicodeStorage::Remap(const std::unordered_map<til::CoordType, til::CoordType>& rowMap, const std::optional<til::CoordType> width)
|
||||
{
|
||||
// Make a temporary map to hold all the new row positioning
|
||||
std::unordered_map<key_type, mapped_type> newMap;
|
||||
@@ -87,7 +87,7 @@ void UnicodeStorage::Remap(const std::unordered_map<SHORT, SHORT>& rowMap, const
|
||||
const auto newRowId = mapIter->second;
|
||||
|
||||
// Generate a new coordinate with the same X as the old one, but a new Y value.
|
||||
const auto newCoord = COORD{ oldCoord.X, newRowId };
|
||||
const auto newCoord = til::point{ oldCoord.X, newRowId };
|
||||
|
||||
// Put the adjusted coordinate into the map with the original value.
|
||||
newMap.emplace(newCoord, pair.second);
|
||||
|
||||
@@ -20,11 +20,11 @@ Author(s):
|
||||
#include <til/bit.h>
|
||||
#include <til/hash.h>
|
||||
|
||||
// std::unordered_map needs help to know how to hash a COORD
|
||||
// std::unordered_map needs help to know how to hash a til::point
|
||||
namespace std
|
||||
{
|
||||
template<>
|
||||
struct hash<COORD>
|
||||
struct hash<til::point>
|
||||
{
|
||||
// Routine Description:
|
||||
// - hashes a coord. coord will be hashed by storing the x and y values consecutively in the lower
|
||||
@@ -33,9 +33,15 @@ namespace std
|
||||
// - coord - the coord to hash
|
||||
// Return Value:
|
||||
// - the hashed coord
|
||||
constexpr size_t operator()(const COORD& coord) const noexcept
|
||||
constexpr size_t operator()(const til::point coord) const noexcept
|
||||
{
|
||||
return til::hash(til::bit_cast<uint32_t>(coord));
|
||||
// til::hash() has a special optimization for hashing a single integer.
|
||||
// But since sizeof(coord) is always 8 this only works on _WIN64.
|
||||
#if defined(_WIN64)
|
||||
return til::hash(til::bit_cast<uint64_t>(coord));
|
||||
#else
|
||||
return til::hash(coord);
|
||||
#endif
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -43,7 +49,7 @@ namespace std
|
||||
class UnicodeStorage final
|
||||
{
|
||||
public:
|
||||
using key_type = typename COORD;
|
||||
using key_type = typename til::point;
|
||||
using mapped_type = typename std::vector<wchar_t>;
|
||||
|
||||
UnicodeStorage() noexcept;
|
||||
@@ -54,7 +60,7 @@ public:
|
||||
|
||||
void Erase(const key_type key) noexcept;
|
||||
|
||||
void Remap(const std::unordered_map<SHORT, SHORT>& rowMap, const std::optional<SHORT> width);
|
||||
void Remap(const std::unordered_map<til::CoordType, til::CoordType>& rowMap, const std::optional<til::CoordType> width);
|
||||
|
||||
private:
|
||||
std::unordered_map<key_type, mapped_type> _map;
|
||||
|
||||
@@ -11,9 +11,8 @@
|
||||
// - Constructor to set default properties for Cursor
|
||||
// Arguments:
|
||||
// - ulSize - The height of the cursor within this buffer
|
||||
Cursor::Cursor(const ULONG ulSize, TextBuffer& parentBuffer) noexcept :
|
||||
Cursor::Cursor(const til::CoordType ulSize, TextBuffer& parentBuffer) noexcept :
|
||||
_parentBuffer{ parentBuffer },
|
||||
_cPosition{ 0 },
|
||||
_fHasMoved(false),
|
||||
_fIsVisible(true),
|
||||
_fIsOn(true),
|
||||
@@ -23,7 +22,6 @@ Cursor::Cursor(const ULONG ulSize, TextBuffer& parentBuffer) noexcept :
|
||||
_fIsConversionArea(false),
|
||||
_fIsPopupShown(false),
|
||||
_fDelayedEolWrap(false),
|
||||
_coordDelayedAt{ 0 },
|
||||
_fDeferCursorRedraw(false),
|
||||
_fHaveDeferredCursorRedraw(false),
|
||||
_ulSize(ulSize),
|
||||
@@ -35,7 +33,7 @@ Cursor::~Cursor()
|
||||
{
|
||||
}
|
||||
|
||||
COORD Cursor::GetPosition() const noexcept
|
||||
til::point Cursor::GetPosition() const noexcept
|
||||
{
|
||||
return _cPosition;
|
||||
}
|
||||
@@ -80,7 +78,7 @@ bool Cursor::GetDelay() const noexcept
|
||||
return _fDelay;
|
||||
}
|
||||
|
||||
ULONG Cursor::GetSize() const noexcept
|
||||
til::CoordType Cursor::GetSize() const noexcept
|
||||
{
|
||||
return _ulSize;
|
||||
}
|
||||
@@ -135,13 +133,13 @@ void Cursor::SetDelay(const bool fDelay) noexcept
|
||||
_fDelay = fDelay;
|
||||
}
|
||||
|
||||
void Cursor::SetSize(const ULONG ulSize) noexcept
|
||||
void Cursor::SetSize(const til::CoordType ulSize) noexcept
|
||||
{
|
||||
_ulSize = ulSize;
|
||||
_RedrawCursor();
|
||||
}
|
||||
|
||||
void Cursor::SetStyle(const ULONG ulSize, const CursorType type) noexcept
|
||||
void Cursor::SetStyle(const til::CoordType ulSize, const CursorType type) noexcept
|
||||
{
|
||||
_ulSize = ulSize;
|
||||
_cursorType = type;
|
||||
@@ -192,59 +190,58 @@ void Cursor::_RedrawCursorAlways() noexcept
|
||||
CATCH_LOG();
|
||||
}
|
||||
|
||||
void Cursor::SetPosition(const COORD cPosition) noexcept
|
||||
void Cursor::SetPosition(const til::point cPosition) noexcept
|
||||
{
|
||||
_RedrawCursor();
|
||||
_cPosition.X = cPosition.X;
|
||||
_cPosition.Y = cPosition.Y;
|
||||
_cPosition = cPosition;
|
||||
_RedrawCursor();
|
||||
ResetDelayEOLWrap();
|
||||
}
|
||||
|
||||
void Cursor::SetXPosition(const int NewX) noexcept
|
||||
void Cursor::SetXPosition(const til::CoordType NewX) noexcept
|
||||
{
|
||||
_RedrawCursor();
|
||||
_cPosition.X = gsl::narrow<SHORT>(NewX);
|
||||
_cPosition.X = NewX;
|
||||
_RedrawCursor();
|
||||
ResetDelayEOLWrap();
|
||||
}
|
||||
|
||||
void Cursor::SetYPosition(const int NewY) noexcept
|
||||
void Cursor::SetYPosition(const til::CoordType NewY) noexcept
|
||||
{
|
||||
_RedrawCursor();
|
||||
_cPosition.Y = gsl::narrow<SHORT>(NewY);
|
||||
_cPosition.Y = NewY;
|
||||
_RedrawCursor();
|
||||
ResetDelayEOLWrap();
|
||||
}
|
||||
|
||||
void Cursor::IncrementXPosition(const int DeltaX) noexcept
|
||||
void Cursor::IncrementXPosition(const til::CoordType DeltaX) noexcept
|
||||
{
|
||||
_RedrawCursor();
|
||||
_cPosition.X += gsl::narrow<SHORT>(DeltaX);
|
||||
_cPosition.X += DeltaX;
|
||||
_RedrawCursor();
|
||||
ResetDelayEOLWrap();
|
||||
}
|
||||
|
||||
void Cursor::IncrementYPosition(const int DeltaY) noexcept
|
||||
void Cursor::IncrementYPosition(const til::CoordType DeltaY) noexcept
|
||||
{
|
||||
_RedrawCursor();
|
||||
_cPosition.Y += gsl::narrow<SHORT>(DeltaY);
|
||||
_cPosition.Y += DeltaY;
|
||||
_RedrawCursor();
|
||||
ResetDelayEOLWrap();
|
||||
}
|
||||
|
||||
void Cursor::DecrementXPosition(const int DeltaX) noexcept
|
||||
void Cursor::DecrementXPosition(const til::CoordType DeltaX) noexcept
|
||||
{
|
||||
_RedrawCursor();
|
||||
_cPosition.X -= gsl::narrow<SHORT>(DeltaX);
|
||||
_cPosition.X -= DeltaX;
|
||||
_RedrawCursor();
|
||||
ResetDelayEOLWrap();
|
||||
}
|
||||
|
||||
void Cursor::DecrementYPosition(const int DeltaY) noexcept
|
||||
void Cursor::DecrementYPosition(const til::CoordType DeltaY) noexcept
|
||||
{
|
||||
_RedrawCursor();
|
||||
_cPosition.Y -= gsl::narrow<SHORT>(DeltaY);
|
||||
_cPosition.Y -= DeltaY;
|
||||
_RedrawCursor();
|
||||
ResetDelayEOLWrap();
|
||||
}
|
||||
@@ -284,7 +281,7 @@ void Cursor::CopyProperties(const Cursor& OtherCursor) noexcept
|
||||
_cursorType = OtherCursor._cursorType;
|
||||
}
|
||||
|
||||
void Cursor::DelayEOLWrap(const COORD coordDelayedAt) noexcept
|
||||
void Cursor::DelayEOLWrap(const til::point coordDelayedAt) noexcept
|
||||
{
|
||||
_coordDelayedAt = coordDelayedAt;
|
||||
_fDelayedEolWrap = true;
|
||||
@@ -292,11 +289,11 @@ void Cursor::DelayEOLWrap(const COORD coordDelayedAt) noexcept
|
||||
|
||||
void Cursor::ResetDelayEOLWrap() noexcept
|
||||
{
|
||||
_coordDelayedAt = { 0 };
|
||||
_coordDelayedAt = {};
|
||||
_fDelayedEolWrap = false;
|
||||
}
|
||||
|
||||
COORD Cursor::GetDelayedAtPosition() const noexcept
|
||||
til::point Cursor::GetDelayedAtPosition() const noexcept
|
||||
{
|
||||
return _coordDelayedAt;
|
||||
}
|
||||
|
||||
@@ -27,7 +27,7 @@ public:
|
||||
// the following values are used to create the textmode cursor.
|
||||
static constexpr unsigned int CURSOR_SMALL_SIZE = 25; // large enough to be one pixel on a six pixel font
|
||||
|
||||
Cursor(const ULONG ulSize, TextBuffer& parentBuffer) noexcept;
|
||||
Cursor(const til::CoordType ulSize, TextBuffer& parentBuffer) noexcept;
|
||||
|
||||
~Cursor();
|
||||
|
||||
@@ -46,8 +46,8 @@ public:
|
||||
bool IsConversionArea() const noexcept;
|
||||
bool IsPopupShown() const noexcept;
|
||||
bool GetDelay() const noexcept;
|
||||
ULONG GetSize() const noexcept;
|
||||
COORD GetPosition() const noexcept;
|
||||
til::CoordType GetSize() const noexcept;
|
||||
til::point GetPosition() const noexcept;
|
||||
|
||||
const CursorType GetType() const noexcept;
|
||||
|
||||
@@ -63,22 +63,22 @@ public:
|
||||
void SetIsConversionArea(const bool fIsConversionArea) noexcept;
|
||||
void SetIsPopupShown(const bool fIsPopupShown) noexcept;
|
||||
void SetDelay(const bool fDelay) noexcept;
|
||||
void SetSize(const ULONG ulSize) noexcept;
|
||||
void SetStyle(const ULONG ulSize, const CursorType type) noexcept;
|
||||
void SetSize(const til::CoordType ulSize) noexcept;
|
||||
void SetStyle(const til::CoordType ulSize, const CursorType type) noexcept;
|
||||
|
||||
void SetPosition(const COORD cPosition) noexcept;
|
||||
void SetXPosition(const int NewX) noexcept;
|
||||
void SetYPosition(const int NewY) noexcept;
|
||||
void IncrementXPosition(const int DeltaX) noexcept;
|
||||
void IncrementYPosition(const int DeltaY) noexcept;
|
||||
void DecrementXPosition(const int DeltaX) noexcept;
|
||||
void DecrementYPosition(const int DeltaY) noexcept;
|
||||
void SetPosition(const til::point cPosition) noexcept;
|
||||
void SetXPosition(const til::CoordType NewX) noexcept;
|
||||
void SetYPosition(const til::CoordType NewY) noexcept;
|
||||
void IncrementXPosition(const til::CoordType DeltaX) noexcept;
|
||||
void IncrementYPosition(const til::CoordType DeltaY) noexcept;
|
||||
void DecrementXPosition(const til::CoordType DeltaX) noexcept;
|
||||
void DecrementYPosition(const til::CoordType DeltaY) noexcept;
|
||||
|
||||
void CopyProperties(const Cursor& OtherCursor) noexcept;
|
||||
|
||||
void DelayEOLWrap(const COORD coordDelayedAt) noexcept;
|
||||
void DelayEOLWrap(const til::point coordDelayedAt) noexcept;
|
||||
void ResetDelayEOLWrap() noexcept;
|
||||
COORD GetDelayedAtPosition() const noexcept;
|
||||
til::point GetDelayedAtPosition() const noexcept;
|
||||
bool IsDelayedEOLWrap() const noexcept;
|
||||
|
||||
void SetType(const CursorType type) noexcept;
|
||||
@@ -90,7 +90,7 @@ private:
|
||||
|
||||
// NOTE: If you are adding a property here, go add it to CopyProperties.
|
||||
|
||||
COORD _cPosition; // current position on screen (in screen buffer coords).
|
||||
til::point _cPosition; // current position on screen (in screen buffer coords).
|
||||
|
||||
bool _fHasMoved;
|
||||
bool _fIsVisible; // whether cursor is visible (set only through the API)
|
||||
@@ -102,12 +102,12 @@ private:
|
||||
bool _fIsPopupShown; // if a popup is being shown, turn off, stop blinking.
|
||||
|
||||
bool _fDelayedEolWrap; // don't wrap at EOL till the next char comes in.
|
||||
COORD _coordDelayedAt; // coordinate the EOL wrap was delayed at.
|
||||
til::point _coordDelayedAt; // coordinate the EOL wrap was delayed at.
|
||||
|
||||
bool _fDeferCursorRedraw; // whether we should defer redrawing the cursor or not
|
||||
bool _fHaveDeferredCursorRedraw; // have we been asked to redraw the cursor while it was being deferred?
|
||||
|
||||
ULONG _ulSize;
|
||||
til::CoordType _ulSize;
|
||||
|
||||
void _RedrawCursor() noexcept;
|
||||
void _RedrawCursorAlways() noexcept;
|
||||
|
||||
@@ -35,7 +35,6 @@ Abstract:
|
||||
#include <intsafe.h>
|
||||
|
||||
// private dependencies
|
||||
#include "../inc/operators.hpp"
|
||||
#include "../inc/unicode.hpp"
|
||||
#pragma warning(pop)
|
||||
|
||||
|
||||
@@ -50,7 +50,7 @@ Search::Search(IUiaData& uiaData,
|
||||
const std::wstring& str,
|
||||
const Direction direction,
|
||||
const Sensitivity sensitivity,
|
||||
const COORD anchor) :
|
||||
const til::point anchor) :
|
||||
_direction(direction),
|
||||
_sensitivity(sensitivity),
|
||||
_needle(s_CreateNeedleFromString(str)),
|
||||
@@ -124,7 +124,7 @@ void Search::Color(const TextAttribute attr) const
|
||||
// been called and returned true.
|
||||
// Return Value:
|
||||
// - pair containing [start, end] coord positions of text found by search
|
||||
std::pair<COORD, COORD> Search::GetFoundLocation() const noexcept
|
||||
std::pair<til::point, til::point> Search::GetFoundLocation() const noexcept
|
||||
{
|
||||
return { _coordSelStart, _coordSelEnd };
|
||||
}
|
||||
@@ -140,10 +140,10 @@ std::pair<COORD, COORD> Search::GetFoundLocation() const noexcept
|
||||
// - direction - The intended direction of the search
|
||||
// Return Value:
|
||||
// - Coordinate to start the search from.
|
||||
COORD Search::s_GetInitialAnchor(IUiaData& uiaData, const Direction direction)
|
||||
til::point Search::s_GetInitialAnchor(IUiaData& uiaData, const Direction direction)
|
||||
{
|
||||
const auto& textBuffer = uiaData.GetTextBuffer();
|
||||
const COORD textBufferEndPosition = uiaData.GetTextBufferEndPosition();
|
||||
const auto textBufferEndPosition = uiaData.GetTextBufferEndPosition();
|
||||
if (uiaData.IsSelectionActive())
|
||||
{
|
||||
// Convert the screen position of the selection anchor into an equivalent
|
||||
@@ -187,12 +187,12 @@ COORD Search::s_GetInitialAnchor(IUiaData& uiaData, const Direction direction)
|
||||
// - end - If we found it, this is filled with the coordinate of the last character of the needle.
|
||||
// Return Value:
|
||||
// - True if we found it. False if not.
|
||||
bool Search::_FindNeedleInHaystackAt(const COORD pos, COORD& start, COORD& end) const
|
||||
bool Search::_FindNeedleInHaystackAt(const til::point pos, til::point& start, til::point& end) const
|
||||
{
|
||||
start = { 0 };
|
||||
end = { 0 };
|
||||
start = {};
|
||||
end = {};
|
||||
|
||||
COORD bufferPos = pos;
|
||||
auto bufferPos = pos;
|
||||
|
||||
for (const auto& needleCell : _needle)
|
||||
{
|
||||
@@ -269,7 +269,7 @@ wchar_t Search::_ApplySensitivity(const wchar_t wch) const noexcept
|
||||
// - Helper to increment a coordinate in respect to the associated screen buffer
|
||||
// Arguments
|
||||
// - coord - Updated by function to increment one position (will wrap X and Y direction)
|
||||
void Search::_IncrementCoord(COORD& coord) const noexcept
|
||||
void Search::_IncrementCoord(til::point& coord) const noexcept
|
||||
{
|
||||
_uiaData.GetTextBuffer().GetSize().IncrementInBoundsCircular(coord);
|
||||
}
|
||||
@@ -278,7 +278,7 @@ void Search::_IncrementCoord(COORD& coord) const noexcept
|
||||
// - Helper to decrement a coordinate in respect to the associated screen buffer
|
||||
// Arguments
|
||||
// - coord - Updated by function to decrement one position (will wrap X and Y direction)
|
||||
void Search::_DecrementCoord(COORD& coord) const noexcept
|
||||
void Search::_DecrementCoord(til::point& coord) const noexcept
|
||||
{
|
||||
_uiaData.GetTextBuffer().GetSize().DecrementInBoundsCircular(coord);
|
||||
}
|
||||
@@ -307,14 +307,14 @@ void Search::_UpdateNextPosition()
|
||||
// We put the next position to:
|
||||
// Forward: (0, 0)
|
||||
// Backward: the position of the end of the text buffer
|
||||
const COORD bufferEndPosition = _uiaData.GetTextBufferEndPosition();
|
||||
const auto bufferEndPosition = _uiaData.GetTextBufferEndPosition();
|
||||
|
||||
if (_coordNext.Y > bufferEndPosition.Y ||
|
||||
(_coordNext.Y == bufferEndPosition.Y && _coordNext.X > bufferEndPosition.X))
|
||||
{
|
||||
if (_direction == Direction::Forward)
|
||||
{
|
||||
_coordNext = { 0 };
|
||||
_coordNext = {};
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -49,36 +49,36 @@ public:
|
||||
const std::wstring& str,
|
||||
const Direction dir,
|
||||
const Sensitivity sensitivity,
|
||||
const COORD anchor);
|
||||
const til::point anchor);
|
||||
|
||||
bool FindNext();
|
||||
void Select() const;
|
||||
void Color(const TextAttribute attr) const;
|
||||
|
||||
std::pair<COORD, COORD> GetFoundLocation() const noexcept;
|
||||
std::pair<til::point, til::point> GetFoundLocation() const noexcept;
|
||||
|
||||
private:
|
||||
wchar_t _ApplySensitivity(const wchar_t wch) const noexcept;
|
||||
bool _FindNeedleInHaystackAt(const COORD pos, COORD& start, COORD& end) const;
|
||||
bool _FindNeedleInHaystackAt(const til::point pos, til::point& start, til::point& end) const;
|
||||
bool _CompareChars(const std::wstring_view one, const std::wstring_view two) const noexcept;
|
||||
void _UpdateNextPosition();
|
||||
|
||||
void _IncrementCoord(COORD& coord) const noexcept;
|
||||
void _DecrementCoord(COORD& coord) const noexcept;
|
||||
void _IncrementCoord(til::point& coord) const noexcept;
|
||||
void _DecrementCoord(til::point& coord) const noexcept;
|
||||
|
||||
static COORD s_GetInitialAnchor(Microsoft::Console::Types::IUiaData& uiaData, const Direction dir);
|
||||
static til::point s_GetInitialAnchor(Microsoft::Console::Types::IUiaData& uiaData, const Direction dir);
|
||||
|
||||
static std::vector<std::vector<wchar_t>> s_CreateNeedleFromString(const std::wstring& wstr);
|
||||
|
||||
bool _reachedEnd = false;
|
||||
COORD _coordNext = { 0 };
|
||||
COORD _coordSelStart = { 0 };
|
||||
COORD _coordSelEnd = { 0 };
|
||||
til::point _coordNext;
|
||||
til::point _coordSelStart;
|
||||
til::point _coordSelEnd;
|
||||
|
||||
const COORD _coordAnchor;
|
||||
const std::vector<std::vector<wchar_t>> _needle;
|
||||
const Direction _direction;
|
||||
const Sensitivity _sensitivity;
|
||||
til::point _coordAnchor;
|
||||
std::vector<std::vector<wchar_t>> _needle;
|
||||
Direction _direction;
|
||||
Sensitivity _sensitivity;
|
||||
Microsoft::Console::Types::IUiaData& _uiaData;
|
||||
|
||||
#ifdef UNIT_TESTING
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
using namespace Microsoft::Console;
|
||||
using namespace Microsoft::Console::Types;
|
||||
|
||||
using PointTree = interval_tree::IntervalTree<til::point, size_t>;
|
||||
using PointTree = interval_tree::IntervalTree<til::point, til::CoordType>;
|
||||
|
||||
// Routine Description:
|
||||
// - Creates a new instance of TextBuffer
|
||||
@@ -28,9 +28,9 @@ using PointTree = interval_tree::IntervalTree<til::point, size_t>;
|
||||
// Return Value:
|
||||
// - constructed object
|
||||
// Note: may throw exception
|
||||
TextBuffer::TextBuffer(const COORD screenBufferSize,
|
||||
TextBuffer::TextBuffer(const til::size screenBufferSize,
|
||||
const TextAttribute defaultAttributes,
|
||||
const UINT cursorSize,
|
||||
const til::CoordType cursorSize,
|
||||
Microsoft::Console::Render::IRenderTarget& renderTarget) :
|
||||
_firstRow{ 0 },
|
||||
_currentAttributes{ defaultAttributes },
|
||||
@@ -43,10 +43,10 @@ TextBuffer::TextBuffer(const COORD screenBufferSize,
|
||||
_currentPatternId{ 0 }
|
||||
{
|
||||
// initialize ROWs
|
||||
_storage.reserve(static_cast<size_t>(screenBufferSize.Y));
|
||||
for (size_t i = 0; i < static_cast<size_t>(screenBufferSize.Y); ++i)
|
||||
_storage.reserve(screenBufferSize.height);
|
||||
for (til::CoordType i = 0; i < screenBufferSize.height; ++i)
|
||||
{
|
||||
_storage.emplace_back(static_cast<SHORT>(i), screenBufferSize.X, _currentAttributes, this);
|
||||
_storage.emplace_back(i, screenBufferSize.width, _currentAttributes, this);
|
||||
}
|
||||
|
||||
_UpdateSize();
|
||||
@@ -70,9 +70,10 @@ void TextBuffer::CopyProperties(const TextBuffer& OtherBuffer) noexcept
|
||||
// - <none>
|
||||
// Return Value:
|
||||
// - Total number of rows in the buffer
|
||||
UINT TextBuffer::TotalRowCount() const noexcept
|
||||
til::CoordType TextBuffer::TotalRowCount() const noexcept
|
||||
{
|
||||
return gsl::narrow<UINT>(_storage.size());
|
||||
// _storage is sized according to a til::CoordType and thus this cast is safe.
|
||||
return gsl::narrow_cast<til::CoordType>(_storage.size());
|
||||
}
|
||||
|
||||
// Routine Description:
|
||||
@@ -82,12 +83,12 @@ UINT TextBuffer::TotalRowCount() const noexcept
|
||||
// - Number of rows down from the first row of the buffer.
|
||||
// Return Value:
|
||||
// - const reference to the requested row. Asserts if out of bounds.
|
||||
const ROW& TextBuffer::GetRowByOffset(const size_t index) const
|
||||
const ROW& TextBuffer::GetRowByOffset(const til::CoordType index) const
|
||||
{
|
||||
const size_t totalRows = TotalRowCount();
|
||||
const auto totalRows = TotalRowCount();
|
||||
|
||||
// Rows are stored circularly, so the index you ask for is offset by the start position and mod the total of rows.
|
||||
const size_t offsetIndex = (_firstRow + index) % totalRows;
|
||||
const auto offsetIndex = (_firstRow + index) % totalRows;
|
||||
return _storage.at(offsetIndex);
|
||||
}
|
||||
|
||||
@@ -98,12 +99,12 @@ const ROW& TextBuffer::GetRowByOffset(const size_t index) const
|
||||
// - Number of rows down from the first row of the buffer.
|
||||
// Return Value:
|
||||
// - reference to the requested row. Asserts if out of bounds.
|
||||
ROW& TextBuffer::GetRowByOffset(const size_t index)
|
||||
ROW& TextBuffer::GetRowByOffset(const til::CoordType index)
|
||||
{
|
||||
const size_t totalRows = TotalRowCount();
|
||||
const auto totalRows = TotalRowCount();
|
||||
|
||||
// Rows are stored circularly, so the index you ask for is offset by the start position and mod the total of rows.
|
||||
const size_t offsetIndex = (_firstRow + index) % totalRows;
|
||||
const auto offsetIndex = (_firstRow + index) % totalRows;
|
||||
return _storage.at(offsetIndex);
|
||||
}
|
||||
|
||||
@@ -113,7 +114,7 @@ ROW& TextBuffer::GetRowByOffset(const size_t index)
|
||||
// - at - X,Y position in buffer for iterator start position
|
||||
// Return Value:
|
||||
// - Read-only iterator of text data only.
|
||||
TextBufferTextIterator TextBuffer::GetTextDataAt(const COORD at) const
|
||||
TextBufferTextIterator TextBuffer::GetTextDataAt(const til::point at) const
|
||||
{
|
||||
return TextBufferTextIterator(GetCellDataAt(at));
|
||||
}
|
||||
@@ -124,7 +125,7 @@ TextBufferTextIterator TextBuffer::GetTextDataAt(const COORD at) const
|
||||
// - at - X,Y position in buffer for iterator start position
|
||||
// Return Value:
|
||||
// - Read-only iterator of cell data.
|
||||
TextBufferCellIterator TextBuffer::GetCellDataAt(const COORD at) const
|
||||
TextBufferCellIterator TextBuffer::GetCellDataAt(const til::point at) const
|
||||
{
|
||||
return TextBufferCellIterator(*this, at);
|
||||
}
|
||||
@@ -136,7 +137,7 @@ TextBufferCellIterator TextBuffer::GetCellDataAt(const COORD at) const
|
||||
// - at - X,Y position in buffer for iterator start position
|
||||
// Return Value:
|
||||
// - Read-only iterator of text data only.
|
||||
TextBufferTextIterator TextBuffer::GetTextLineDataAt(const COORD at) const
|
||||
TextBufferTextIterator TextBuffer::GetTextLineDataAt(const til::point at) const
|
||||
{
|
||||
return TextBufferTextIterator(GetCellLineDataAt(at));
|
||||
}
|
||||
@@ -148,9 +149,9 @@ TextBufferTextIterator TextBuffer::GetTextLineDataAt(const COORD at) const
|
||||
// - at - X,Y position in buffer for iterator start position
|
||||
// Return Value:
|
||||
// - Read-only iterator of cell data.
|
||||
TextBufferCellIterator TextBuffer::GetCellLineDataAt(const COORD at) const
|
||||
TextBufferCellIterator TextBuffer::GetCellLineDataAt(const til::point at) const
|
||||
{
|
||||
SMALL_RECT limit;
|
||||
til::inclusive_rect limit;
|
||||
limit.Top = at.Y;
|
||||
limit.Bottom = at.Y;
|
||||
limit.Left = 0;
|
||||
@@ -167,7 +168,7 @@ TextBufferCellIterator TextBuffer::GetCellLineDataAt(const COORD at) const
|
||||
// - limit - boundaries for the iterator to operate within
|
||||
// Return Value:
|
||||
// - Read-only iterator of text data only.
|
||||
TextBufferTextIterator TextBuffer::GetTextDataAt(const COORD at, const Viewport limit) const
|
||||
TextBufferTextIterator TextBuffer::GetTextDataAt(const til::point at, const Viewport limit) const
|
||||
{
|
||||
return TextBufferTextIterator(GetCellDataAt(at, limit));
|
||||
}
|
||||
@@ -180,7 +181,7 @@ TextBufferTextIterator TextBuffer::GetTextDataAt(const COORD at, const Viewport
|
||||
// - limit - boundaries for the iterator to operate within
|
||||
// Return Value:
|
||||
// - Read-only iterator of cell data.
|
||||
TextBufferCellIterator TextBuffer::GetCellDataAt(const COORD at, const Viewport limit) const
|
||||
TextBufferCellIterator TextBuffer::GetCellDataAt(const til::point at, const Viewport limit) const
|
||||
{
|
||||
return TextBufferCellIterator(*this, at, limit);
|
||||
}
|
||||
@@ -197,7 +198,7 @@ TextBufferCellIterator TextBuffer::GetCellDataAt(const COORD at, const Viewport
|
||||
bool TextBuffer::_AssertValidDoubleByteSequence(const DbcsAttribute dbcsAttribute)
|
||||
{
|
||||
// To figure out if the sequence is valid, we have to look at the character that comes before the current one
|
||||
const COORD coordPrevPosition = _GetPreviousFromCursor();
|
||||
const auto coordPrevPosition = _GetPreviousFromCursor();
|
||||
ROW& prevRow = GetRowByOffset(coordPrevPosition.Y);
|
||||
DbcsAttribute prevDbcsAttr;
|
||||
try
|
||||
@@ -333,7 +334,7 @@ OutputCellIterator TextBuffer::Write(const OutputCellIterator givenIt)
|
||||
// Return Value:
|
||||
// - The final position of the iterator
|
||||
OutputCellIterator TextBuffer::Write(const OutputCellIterator givenIt,
|
||||
const COORD target,
|
||||
const til::point target,
|
||||
const std::optional<bool> wrap)
|
||||
{
|
||||
// Make mutable copy so we can walk.
|
||||
@@ -370,9 +371,9 @@ OutputCellIterator TextBuffer::Write(const OutputCellIterator givenIt,
|
||||
// Return Value:
|
||||
// - The iterator, but advanced to where we stopped writing. Use to find input consumed length or cells written length.
|
||||
OutputCellIterator TextBuffer::WriteLine(const OutputCellIterator givenIt,
|
||||
const COORD target,
|
||||
const til::point target,
|
||||
const std::optional<bool> wrap,
|
||||
std::optional<size_t> limitRight)
|
||||
std::optional<til::CoordType> limitRight)
|
||||
{
|
||||
// If we're not in bounds, exit early.
|
||||
if (!GetSize().IsInBounds(target))
|
||||
@@ -386,7 +387,7 @@ OutputCellIterator TextBuffer::WriteLine(const OutputCellIterator givenIt,
|
||||
|
||||
// Take the cell distance written and notify that it needs to be repainted.
|
||||
const auto written = newIt.GetCellDistance(givenIt);
|
||||
const Viewport paint = Viewport::FromDimensions(target, { gsl::narrow<SHORT>(written), 1 });
|
||||
const Viewport paint = Viewport::FromDimensions(target, { written, 1 });
|
||||
_NotifyPaint(paint);
|
||||
|
||||
return newIt;
|
||||
@@ -411,8 +412,8 @@ bool TextBuffer::InsertCharacter(const std::wstring_view chars,
|
||||
if (fSuccess)
|
||||
{
|
||||
// Get the current cursor position
|
||||
short const iRow = GetCursor().GetPosition().Y; // row stored as logical position, not array position
|
||||
short const iCol = GetCursor().GetPosition().X; // column logical and array positions are equal.
|
||||
const auto iRow = GetCursor().GetPosition().y; // row stored as logical position, not array position
|
||||
const auto iCol = GetCursor().GetPosition().x; // column logical and array positions are equal.
|
||||
|
||||
// Get the row associated with the given logical position
|
||||
ROW& Row = GetRowByOffset(iRow);
|
||||
@@ -478,7 +479,7 @@ void TextBuffer::_SetWrapOnCurrentRow()
|
||||
void TextBuffer::_AdjustWrapOnCurrentRow(const bool fSet)
|
||||
{
|
||||
// The vertical position of the cursor represents the current row we're manipulating.
|
||||
const UINT uiCurrentRowOffset = GetCursor().GetPosition().Y;
|
||||
const auto uiCurrentRowOffset = GetCursor().GetPosition().y;
|
||||
|
||||
// Set the wrap status as appropriate
|
||||
GetRowByOffset(uiCurrentRowOffset).SetWrapForced(fSet);
|
||||
@@ -497,7 +498,7 @@ bool TextBuffer::IncrementCursor()
|
||||
// Cursor position is stored as logical array indices (starts at 0) for the window
|
||||
// Buffer Size is specified as the "length" of the array. It would say 80 for valid values of 0-79.
|
||||
// So subtract 1 from buffer size in each direction to find the index of the final column in the buffer
|
||||
const short iFinalColumnIndex = GetLineWidth(GetCursor().GetPosition().Y) - 1;
|
||||
const auto iFinalColumnIndex = GetLineWidth(GetCursor().GetPosition().y) - 1;
|
||||
|
||||
// Move the cursor one position to the right
|
||||
GetCursor().IncrementXPosition(1);
|
||||
@@ -524,7 +525,7 @@ bool TextBuffer::IncrementCursor()
|
||||
bool TextBuffer::NewlineCursor()
|
||||
{
|
||||
bool fSuccess = false;
|
||||
short const iFinalRowIndex = GetSize().BottomInclusive();
|
||||
const auto iFinalRowIndex = GetSize().BottomInclusive();
|
||||
|
||||
// Reset the cursor position to 0 and move down one line
|
||||
GetCursor().SetXPosition(0);
|
||||
@@ -597,17 +598,17 @@ bool TextBuffer::IncrementCircularBuffer(const bool inVtMode)
|
||||
// - The viewport
|
||||
//Return value:
|
||||
// - Coordinate position (relative to the text buffer)
|
||||
COORD TextBuffer::GetLastNonSpaceCharacter(std::optional<const Microsoft::Console::Types::Viewport> viewOptional) const
|
||||
til::point TextBuffer::GetLastNonSpaceCharacter(std::optional<const Microsoft::Console::Types::Viewport> viewOptional) const
|
||||
{
|
||||
const auto viewport = viewOptional.has_value() ? viewOptional.value() : GetSize();
|
||||
|
||||
COORD coordEndOfText = { 0 };
|
||||
til::point coordEndOfText;
|
||||
// Search the given viewport by starting at the bottom.
|
||||
coordEndOfText.Y = viewport.BottomInclusive();
|
||||
|
||||
const auto& currRow = GetRowByOffset(coordEndOfText.Y);
|
||||
// The X position of the end of the valid text is the Right draw boundary (which is one beyond the final valid character)
|
||||
coordEndOfText.X = gsl::narrow<short>(currRow.GetCharRow().MeasureRight()) - 1;
|
||||
coordEndOfText.X = currRow.GetCharRow().MeasureRight() - 1;
|
||||
|
||||
// If the X coordinate turns out to be -1, the row was empty, we need to search backwards for the real end of text.
|
||||
const auto viewportTop = viewport.Top();
|
||||
@@ -618,13 +619,13 @@ COORD TextBuffer::GetLastNonSpaceCharacter(std::optional<const Microsoft::Consol
|
||||
const auto& backupRow = GetRowByOffset(coordEndOfText.Y);
|
||||
// We need to back up to the previous row if this line is empty, AND there are more rows
|
||||
|
||||
coordEndOfText.X = gsl::narrow<short>(backupRow.GetCharRow().MeasureRight()) - 1;
|
||||
coordEndOfText.X = backupRow.GetCharRow().MeasureRight() - 1;
|
||||
fDoBackUp = (coordEndOfText.X < 0 && coordEndOfText.Y > viewportTop);
|
||||
}
|
||||
|
||||
// don't allow negative results
|
||||
coordEndOfText.Y = std::max(coordEndOfText.Y, 0i16);
|
||||
coordEndOfText.X = std::max(coordEndOfText.X, 0i16);
|
||||
coordEndOfText.Y = std::max(coordEndOfText.Y, 0);
|
||||
coordEndOfText.X = std::max(coordEndOfText.X, 0);
|
||||
|
||||
return coordEndOfText;
|
||||
}
|
||||
@@ -636,9 +637,9 @@ COORD TextBuffer::GetLastNonSpaceCharacter(std::optional<const Microsoft::Consol
|
||||
// Return Value:
|
||||
// - Coordinate position in screen coordinates of the character just before the cursor.
|
||||
// - NOTE: Will return 0,0 if already in the top left corner
|
||||
COORD TextBuffer::_GetPreviousFromCursor() const
|
||||
til::point TextBuffer::_GetPreviousFromCursor() const
|
||||
{
|
||||
COORD coordPosition = GetCursor().GetPosition();
|
||||
auto coordPosition = GetCursor().GetPosition();
|
||||
|
||||
// If we're not at the left edge, simply move the cursor to the left by one
|
||||
if (coordPosition.X > 0)
|
||||
@@ -661,7 +662,7 @@ COORD TextBuffer::_GetPreviousFromCursor() const
|
||||
return coordPosition;
|
||||
}
|
||||
|
||||
const SHORT TextBuffer::GetFirstRowIndex() const noexcept
|
||||
const til::CoordType TextBuffer::GetFirstRowIndex() const noexcept
|
||||
{
|
||||
return _firstRow;
|
||||
}
|
||||
@@ -673,15 +674,15 @@ const Viewport TextBuffer::GetSize() const noexcept
|
||||
|
||||
void TextBuffer::_UpdateSize()
|
||||
{
|
||||
_size = Viewport::FromDimensions({ 0, 0 }, { gsl::narrow<SHORT>(_storage.at(0).size()), gsl::narrow<SHORT>(_storage.size()) });
|
||||
_size = Viewport::FromDimensions({ 0, 0 }, { _storage.at(0).size(), TotalRowCount() });
|
||||
}
|
||||
|
||||
void TextBuffer::_SetFirstRowIndex(const SHORT FirstRowIndex) noexcept
|
||||
void TextBuffer::_SetFirstRowIndex(const til::CoordType FirstRowIndex) noexcept
|
||||
{
|
||||
_firstRow = FirstRowIndex;
|
||||
}
|
||||
|
||||
void TextBuffer::ScrollRows(const SHORT firstRow, const SHORT size, const SHORT delta)
|
||||
void TextBuffer::ScrollRows(const til::CoordType firstRow, const til::CoordType size, const til::CoordType delta)
|
||||
{
|
||||
// If we don't have to move anything, leave early.
|
||||
if (delta == 0)
|
||||
@@ -818,9 +819,9 @@ void TextBuffer::SetCurrentLineRendition(const LineRendition lineRendition)
|
||||
const auto fillChar = L' ';
|
||||
auto fillAttrs = GetCurrentAttributes();
|
||||
fillAttrs.SetStandardErase();
|
||||
const size_t fillOffset = GetLineWidth(rowIndex);
|
||||
const size_t fillLength = GetSize().Width() - fillOffset;
|
||||
const auto fillData = OutputCellIterator{ fillChar, fillAttrs, fillLength };
|
||||
const auto fillOffset = GetLineWidth(rowIndex);
|
||||
const auto fillLength = GetSize().Width() - fillOffset;
|
||||
const auto fillData = OutputCellIterator{ fillChar, fillAttrs, base::saturated_cast<size_t>(fillLength) };
|
||||
row.WriteCells(fillData, fillOffset, false);
|
||||
// We also need to make sure the cursor is clamped within the new width.
|
||||
GetCursor().SetPosition(ClampPositionWithinLine(cursorPosition));
|
||||
@@ -829,7 +830,7 @@ void TextBuffer::SetCurrentLineRendition(const LineRendition lineRendition)
|
||||
}
|
||||
}
|
||||
|
||||
void TextBuffer::ResetLineRenditionRange(const size_t startRow, const size_t endRow)
|
||||
void TextBuffer::ResetLineRenditionRange(const til::CoordType startRow, const til::CoordType endRow)
|
||||
{
|
||||
for (auto row = startRow; row < endRow; row++)
|
||||
{
|
||||
@@ -837,40 +838,40 @@ void TextBuffer::ResetLineRenditionRange(const size_t startRow, const size_t end
|
||||
}
|
||||
}
|
||||
|
||||
LineRendition TextBuffer::GetLineRendition(const size_t row) const
|
||||
LineRendition TextBuffer::GetLineRendition(const til::CoordType row) const
|
||||
{
|
||||
return GetRowByOffset(row).GetLineRendition();
|
||||
}
|
||||
|
||||
bool TextBuffer::IsDoubleWidthLine(const size_t row) const
|
||||
bool TextBuffer::IsDoubleWidthLine(const til::CoordType row) const
|
||||
{
|
||||
return GetLineRendition(row) != LineRendition::SingleWidth;
|
||||
}
|
||||
|
||||
SHORT TextBuffer::GetLineWidth(const size_t row) const
|
||||
til::CoordType TextBuffer::GetLineWidth(const til::CoordType row) const
|
||||
{
|
||||
// Use shift right to quickly divide the width by 2 for double width lines.
|
||||
const SHORT scale = IsDoubleWidthLine(row) ? 1 : 0;
|
||||
const auto scale = IsDoubleWidthLine(row) ? 1 : 0;
|
||||
return GetSize().Width() >> scale;
|
||||
}
|
||||
|
||||
COORD TextBuffer::ClampPositionWithinLine(const COORD position) const
|
||||
til::point TextBuffer::ClampPositionWithinLine(const til::point position) const
|
||||
{
|
||||
const SHORT rightmostColumn = GetLineWidth(position.Y) - 1;
|
||||
const auto rightmostColumn = GetLineWidth(position.Y) - 1;
|
||||
return { std::min(position.X, rightmostColumn), position.Y };
|
||||
}
|
||||
|
||||
COORD TextBuffer::ScreenToBufferPosition(const COORD position) const
|
||||
til::point TextBuffer::ScreenToBufferPosition(const til::point position) const
|
||||
{
|
||||
// Use shift right to quickly divide the X pos by 2 for double width lines.
|
||||
const SHORT scale = IsDoubleWidthLine(position.Y) ? 1 : 0;
|
||||
const auto scale = IsDoubleWidthLine(position.Y) ? 1 : 0;
|
||||
return { position.X >> scale, position.Y };
|
||||
}
|
||||
|
||||
COORD TextBuffer::BufferToScreenPosition(const COORD position) const
|
||||
til::point TextBuffer::BufferToScreenPosition(const til::point position) const
|
||||
{
|
||||
// Use shift left to quickly multiply the X pos by 2 for double width lines.
|
||||
const SHORT scale = IsDoubleWidthLine(position.Y) ? 1 : 0;
|
||||
const auto scale = IsDoubleWidthLine(position.Y) ? 1 : 0;
|
||||
return { position.X << scale, position.Y };
|
||||
}
|
||||
|
||||
@@ -893,21 +894,21 @@ void TextBuffer::Reset()
|
||||
// - newSize - new size of screen.
|
||||
// Return Value:
|
||||
// - Success if successful. Invalid parameter if screen buffer size is unexpected. No memory if allocation failed.
|
||||
[[nodiscard]] NTSTATUS TextBuffer::ResizeTraditional(const COORD newSize) noexcept
|
||||
[[nodiscard]] NTSTATUS TextBuffer::ResizeTraditional(const til::size newSize) noexcept
|
||||
{
|
||||
RETURN_HR_IF(E_INVALIDARG, newSize.X < 0 || newSize.Y < 0);
|
||||
RETURN_HR_IF(E_INVALIDARG, newSize.width < 0 || newSize.height < 0);
|
||||
|
||||
try
|
||||
{
|
||||
const auto currentSize = GetSize().Dimensions();
|
||||
const auto attributes = GetCurrentAttributes();
|
||||
|
||||
SHORT TopRow = 0; // new top row of the screen buffer
|
||||
if (newSize.Y <= GetCursor().GetPosition().Y)
|
||||
til::CoordType TopRow = 0; // new top row of the screen buffer
|
||||
if (newSize.height <= GetCursor().GetPosition().y)
|
||||
{
|
||||
TopRow = GetCursor().GetPosition().Y - newSize.Y + 1;
|
||||
TopRow = GetCursor().GetPosition().y - newSize.height + 1;
|
||||
}
|
||||
const SHORT TopRowIndex = (GetFirstRowIndex() + TopRow) % currentSize.Y;
|
||||
const auto TopRowIndex = (GetFirstRowIndex() + TopRow) % currentSize.height;
|
||||
|
||||
// rotate rows until the top row is at index 0
|
||||
for (int i = 0; i < TopRowIndex; i++)
|
||||
@@ -920,20 +921,20 @@ void TextBuffer::Reset()
|
||||
|
||||
// realloc in the Y direction
|
||||
// remove rows if we're shrinking
|
||||
while (_storage.size() > static_cast<size_t>(newSize.Y))
|
||||
while (_storage.size() > static_cast<size_t>(newSize.height))
|
||||
{
|
||||
_storage.pop_back();
|
||||
}
|
||||
// add rows if we're growing
|
||||
while (_storage.size() < static_cast<size_t>(newSize.Y))
|
||||
while (_storage.size() < static_cast<size_t>(newSize.height))
|
||||
{
|
||||
_storage.emplace_back(static_cast<short>(_storage.size()), newSize.X, attributes, this);
|
||||
_storage.emplace_back(static_cast<til::CoordType>(_storage.size()), newSize.width, attributes, this);
|
||||
}
|
||||
|
||||
// Now that we've tampered with the row placement, refresh all the row IDs.
|
||||
// Also take advantage of the row ID refresh loop to resize the rows in the X dimension
|
||||
// and cleanup the UnicodeStorage characters that might fall outside the resized buffer.
|
||||
_RefreshRowIDs(newSize.X);
|
||||
_RefreshRowIDs(newSize.width);
|
||||
|
||||
// Update the cached size value
|
||||
_UpdateSize();
|
||||
@@ -962,10 +963,10 @@ UnicodeStorage& TextBuffer::GetUnicodeStorage() noexcept
|
||||
// any high unicode (UnicodeStorage) runs while we're already looping through the rows.
|
||||
// Arguments:
|
||||
// - newRowWidth - Optional new value for the row width.
|
||||
void TextBuffer::_RefreshRowIDs(std::optional<SHORT> newRowWidth)
|
||||
void TextBuffer::_RefreshRowIDs(std::optional<til::CoordType> newRowWidth)
|
||||
{
|
||||
std::unordered_map<SHORT, SHORT> rowMap;
|
||||
SHORT i = 0;
|
||||
std::unordered_map<til::CoordType, til::CoordType> rowMap;
|
||||
til::CoordType i = 0;
|
||||
for (auto& it : _storage)
|
||||
{
|
||||
// Build a map so we can update Unicode Storage
|
||||
@@ -1045,23 +1046,23 @@ Microsoft::Console::Render::IRenderTarget& TextBuffer::GetRenderTarget() noexcep
|
||||
// - wordDelimiters: the delimiters defined as a part of the DelimiterClass::DelimiterChar
|
||||
// Return Value:
|
||||
// - the delimiter class for the given char
|
||||
const DelimiterClass TextBuffer::_GetDelimiterClassAt(const COORD pos, const std::wstring_view wordDelimiters) const
|
||||
const DelimiterClass TextBuffer::_GetDelimiterClassAt(const til::point pos, const std::wstring_view wordDelimiters) const
|
||||
{
|
||||
return GetRowByOffset(pos.Y).GetCharRow().DelimiterClassAt(pos.X, wordDelimiters);
|
||||
}
|
||||
|
||||
// Method Description:
|
||||
// - Get the COORD for the beginning of the word you are on
|
||||
// - Get the til::point for the beginning of the word you are on
|
||||
// Arguments:
|
||||
// - target - a COORD on the word you are currently on
|
||||
// - target - a til::point on the word you are currently on
|
||||
// - wordDelimiters - what characters are we considering for the separation of words
|
||||
// - accessibilityMode - when enabled, we continue expanding left until we are at the beginning of a readable word.
|
||||
// Otherwise, expand left until a character of a new delimiter class is found
|
||||
// (or a row boundary is encountered)
|
||||
// - limitOptional - (optional) the last possible position in the buffer that can be explored. This can be used to improve performance.
|
||||
// Return Value:
|
||||
// - The COORD for the first character on the "word" (inclusive)
|
||||
const COORD TextBuffer::GetWordStart(const COORD target, const std::wstring_view wordDelimiters, bool accessibilityMode, std::optional<til::point> limitOptional) const
|
||||
// - The til::point for the first character on the "word" (inclusive)
|
||||
const til::point TextBuffer::GetWordStart(const til::point target, const std::wstring_view wordDelimiters, bool accessibilityMode, std::optional<til::point> limitOptional) const
|
||||
{
|
||||
// Consider a buffer with this text in it:
|
||||
// " word other "
|
||||
@@ -1088,10 +1089,10 @@ const COORD TextBuffer::GetWordStart(const COORD target, const std::wstring_view
|
||||
// that it actually points to a space in the buffer
|
||||
copy = { bufferSize.RightInclusive(), bufferSize.BottomInclusive() };
|
||||
}
|
||||
else if (bufferSize.CompareInBounds(target, limit.to_win32_coord(), true) >= 0)
|
||||
else if (bufferSize.CompareInBounds(target, limit, true) >= 0)
|
||||
{
|
||||
// if at/past the limit --> clamp to limit
|
||||
copy = limitOptional->to_win32_coord();
|
||||
copy = *limitOptional;
|
||||
}
|
||||
|
||||
if (accessibilityMode)
|
||||
@@ -1105,15 +1106,15 @@ const COORD TextBuffer::GetWordStart(const COORD target, const std::wstring_view
|
||||
}
|
||||
|
||||
// Method Description:
|
||||
// - Helper method for GetWordStart(). Get the COORD for the beginning of the word (accessibility definition) you are on
|
||||
// - Helper method for GetWordStart(). Get the til::point for the beginning of the word (accessibility definition) you are on
|
||||
// Arguments:
|
||||
// - target - a COORD on the word you are currently on
|
||||
// - target - a til::point on the word you are currently on
|
||||
// - wordDelimiters - what characters are we considering for the separation of words
|
||||
// Return Value:
|
||||
// - The COORD for the first character on the current/previous READABLE "word" (inclusive)
|
||||
const COORD TextBuffer::_GetWordStartForAccessibility(const COORD target, const std::wstring_view wordDelimiters) const
|
||||
// - The til::point for the first character on the current/previous READABLE "word" (inclusive)
|
||||
const til::point TextBuffer::_GetWordStartForAccessibility(const til::point target, const std::wstring_view wordDelimiters) const
|
||||
{
|
||||
COORD result = target;
|
||||
auto result = target;
|
||||
const auto bufferSize = GetSize();
|
||||
bool stayAtOrigin = false;
|
||||
|
||||
@@ -1150,15 +1151,15 @@ const COORD TextBuffer::_GetWordStartForAccessibility(const COORD target, const
|
||||
}
|
||||
|
||||
// Method Description:
|
||||
// - Helper method for GetWordStart(). Get the COORD for the beginning of the word (selection definition) you are on
|
||||
// - Helper method for GetWordStart(). Get the til::point for the beginning of the word (selection definition) you are on
|
||||
// Arguments:
|
||||
// - target - a COORD on the word you are currently on
|
||||
// - target - a til::point on the word you are currently on
|
||||
// - wordDelimiters - what characters are we considering for the separation of words
|
||||
// Return Value:
|
||||
// - The COORD for the first character on the current word or delimiter run (stopped by the left margin)
|
||||
const COORD TextBuffer::_GetWordStartForSelection(const COORD target, const std::wstring_view wordDelimiters) const
|
||||
// - The til::point for the first character on the current word or delimiter run (stopped by the left margin)
|
||||
const til::point TextBuffer::_GetWordStartForSelection(const til::point target, const std::wstring_view wordDelimiters) const
|
||||
{
|
||||
COORD result = target;
|
||||
auto result = target;
|
||||
const auto bufferSize = GetSize();
|
||||
|
||||
const auto initialDelimiter = _GetDelimiterClassAt(result, wordDelimiters);
|
||||
@@ -1179,17 +1180,17 @@ const COORD TextBuffer::_GetWordStartForSelection(const COORD target, const std:
|
||||
}
|
||||
|
||||
// Method Description:
|
||||
// - Get the COORD for the beginning of the NEXT word
|
||||
// - Get the til::point for the beginning of the NEXT word
|
||||
// Arguments:
|
||||
// - target - a COORD on the word you are currently on
|
||||
// - target - a til::point on the word you are currently on
|
||||
// - wordDelimiters - what characters are we considering for the separation of words
|
||||
// - accessibilityMode - when enabled, we continue expanding right until we are at the beginning of the next READABLE word
|
||||
// Otherwise, expand right until a character of a new delimiter class is found
|
||||
// (or a row boundary is encountered)
|
||||
// - limitOptional - (optional) the last possible position in the buffer that can be explored. This can be used to improve performance.
|
||||
// Return Value:
|
||||
// - The COORD for the last character on the "word" (inclusive)
|
||||
const COORD TextBuffer::GetWordEnd(const COORD target, const std::wstring_view wordDelimiters, bool accessibilityMode, std::optional<til::point> limitOptional) const
|
||||
// - The til::point for the last character on the "word" (inclusive)
|
||||
const til::point TextBuffer::GetWordEnd(const til::point target, const std::wstring_view wordDelimiters, bool accessibilityMode, std::optional<til::point> limitOptional) const
|
||||
{
|
||||
// Consider a buffer with this text in it:
|
||||
// " word other "
|
||||
@@ -1204,14 +1205,14 @@ const COORD TextBuffer::GetWordEnd(const COORD target, const std::wstring_view w
|
||||
// Already at/past the limit. Can't move forward.
|
||||
const auto bufferSize{ GetSize() };
|
||||
const auto limit{ limitOptional.value_or(til::point{ bufferSize.EndExclusive() }) };
|
||||
if (bufferSize.CompareInBounds(target, limit.to_win32_coord(), true) >= 0)
|
||||
if (bufferSize.CompareInBounds(target, limit, true) >= 0)
|
||||
{
|
||||
return target;
|
||||
}
|
||||
|
||||
if (accessibilityMode)
|
||||
{
|
||||
return _GetWordEndForAccessibility(target, wordDelimiters, limit.to_win32_coord());
|
||||
return _GetWordEndForAccessibility(target, wordDelimiters, limit);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1220,17 +1221,17 @@ const COORD TextBuffer::GetWordEnd(const COORD target, const std::wstring_view w
|
||||
}
|
||||
|
||||
// Method Description:
|
||||
// - Helper method for GetWordEnd(). Get the COORD for the beginning of the next READABLE word
|
||||
// - Helper method for GetWordEnd(). Get the til::point for the beginning of the next READABLE word
|
||||
// Arguments:
|
||||
// - target - a COORD on the word you are currently on
|
||||
// - target - a til::point on the word you are currently on
|
||||
// - wordDelimiters - what characters are we considering for the separation of words
|
||||
// - limit - the last "valid" position in the text buffer (to improve performance)
|
||||
// Return Value:
|
||||
// - The COORD for the first character of the next readable "word". If no next word, return one past the end of the buffer
|
||||
const COORD TextBuffer::_GetWordEndForAccessibility(const COORD target, const std::wstring_view wordDelimiters, const COORD limit) const
|
||||
// - The til::point for the first character of the next readable "word". If no next word, return one past the end of the buffer
|
||||
const til::point TextBuffer::_GetWordEndForAccessibility(const til::point target, const std::wstring_view wordDelimiters, const til::point limit) const
|
||||
{
|
||||
const auto bufferSize{ GetSize() };
|
||||
COORD result{ target };
|
||||
til::point result{ target };
|
||||
|
||||
if (bufferSize.CompareInBounds(target, limit, true) >= 0)
|
||||
{
|
||||
@@ -1271,13 +1272,13 @@ const COORD TextBuffer::_GetWordEndForAccessibility(const COORD target, const st
|
||||
}
|
||||
|
||||
// Method Description:
|
||||
// - Helper method for GetWordEnd(). Get the COORD for the beginning of the NEXT word
|
||||
// - Helper method for GetWordEnd(). Get the til::point for the beginning of the NEXT word
|
||||
// Arguments:
|
||||
// - target - a COORD on the word you are currently on
|
||||
// - target - a til::point on the word you are currently on
|
||||
// - wordDelimiters - what characters are we considering for the separation of words
|
||||
// Return Value:
|
||||
// - The COORD for the last character of the current word or delimiter run (stopped by right margin)
|
||||
const COORD TextBuffer::_GetWordEndForSelection(const COORD target, const std::wstring_view wordDelimiters) const
|
||||
// - The til::point for the last character of the current word or delimiter run (stopped by right margin)
|
||||
const til::point TextBuffer::_GetWordEndForSelection(const til::point target, const std::wstring_view wordDelimiters) const
|
||||
{
|
||||
const auto bufferSize = GetSize();
|
||||
|
||||
@@ -1287,7 +1288,7 @@ const COORD TextBuffer::_GetWordEndForSelection(const COORD target, const std::w
|
||||
return target;
|
||||
}
|
||||
|
||||
COORD result = target;
|
||||
auto result = target;
|
||||
const auto initialDelimiter = _GetDelimiterClassAt(result, wordDelimiters);
|
||||
|
||||
// expand right until we hit the right boundary or a different delimiter class
|
||||
@@ -1326,7 +1327,7 @@ void TextBuffer::_PruneHyperlinks()
|
||||
// we have found all hyperlink references in the first row and put them in refs,
|
||||
// now we need to search the rest of the buffer (i.e. all the rows except the first)
|
||||
// to see if those references are anywhere else
|
||||
for (size_t i = 1; i != total; ++i)
|
||||
for (til::CoordType i = 1; i != total; ++i)
|
||||
{
|
||||
const auto nextRowRefs = GetRowByOffset(i).GetAttrRow().GetHyperlinks();
|
||||
for (auto id : nextRowRefs)
|
||||
@@ -1354,22 +1355,22 @@ void TextBuffer::_PruneHyperlinks()
|
||||
// Method Description:
|
||||
// - Update pos to be the position of the first character of the next word. This is used for accessibility
|
||||
// Arguments:
|
||||
// - pos - a COORD on the word you are currently on
|
||||
// - pos - a til::point on the word you are currently on
|
||||
// - wordDelimiters - what characters are we considering for the separation of words
|
||||
// - limitOptional - (optional) the last possible position in the buffer that can be explored. This can be used to improve performance.
|
||||
// Return Value:
|
||||
// - true, if successfully updated pos. False, if we are unable to move (usually due to a buffer boundary)
|
||||
// - pos - The COORD for the first character on the "word" (inclusive)
|
||||
bool TextBuffer::MoveToNextWord(COORD& pos, const std::wstring_view wordDelimiters, std::optional<til::point> limitOptional) const
|
||||
// - pos - The til::point for the first character on the "word" (inclusive)
|
||||
bool TextBuffer::MoveToNextWord(til::point& pos, const std::wstring_view wordDelimiters, std::optional<til::point> limitOptional) const
|
||||
{
|
||||
// move to the beginning of the next word
|
||||
// NOTE: _GetWordEnd...() returns the exclusive position of the "end of the word"
|
||||
// This is also the inclusive start of the next word.
|
||||
const auto bufferSize{ GetSize() };
|
||||
const auto limit{ limitOptional.value_or(til::point{ bufferSize.EndExclusive() }) };
|
||||
const auto copy{ _GetWordEndForAccessibility(pos, wordDelimiters, limit.to_win32_coord()) };
|
||||
const auto copy{ _GetWordEndForAccessibility(pos, wordDelimiters, limit) };
|
||||
|
||||
if (bufferSize.CompareInBounds(copy, limit.to_win32_coord(), true) >= 0)
|
||||
if (bufferSize.CompareInBounds(copy, limit, true) >= 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@@ -1381,12 +1382,12 @@ bool TextBuffer::MoveToNextWord(COORD& pos, const std::wstring_view wordDelimite
|
||||
// Method Description:
|
||||
// - Update pos to be the position of the first character of the previous word. This is used for accessibility
|
||||
// Arguments:
|
||||
// - pos - a COORD on the word you are currently on
|
||||
// - pos - a til::point on the word you are currently on
|
||||
// - wordDelimiters - what characters are we considering for the separation of words
|
||||
// Return Value:
|
||||
// - true, if successfully updated pos. False, if we are unable to move (usually due to a buffer boundary)
|
||||
// - pos - The COORD for the first character on the "word" (inclusive)
|
||||
bool TextBuffer::MoveToPreviousWord(COORD& pos, std::wstring_view wordDelimiters) const
|
||||
// - pos - The til::point for the first character on the "word" (inclusive)
|
||||
bool TextBuffer::MoveToPreviousWord(til::point& pos, std::wstring_view wordDelimiters) const
|
||||
{
|
||||
// move to the beginning of the current word
|
||||
auto copy{ GetWordStart(pos, wordDelimiters, true) };
|
||||
@@ -1405,51 +1406,51 @@ bool TextBuffer::MoveToPreviousWord(COORD& pos, std::wstring_view wordDelimiters
|
||||
// Method Description:
|
||||
// - Update pos to be the beginning of the current glyph/character. This is used for accessibility
|
||||
// Arguments:
|
||||
// - pos - a COORD on the word you are currently on
|
||||
// - pos - a til::point on the word you are currently on
|
||||
// - limitOptional - (optional) the last possible position in the buffer that can be explored. This can be used to improve performance.
|
||||
// Return Value:
|
||||
// - pos - The COORD for the first cell of the current glyph (inclusive)
|
||||
// - pos - The til::point for the first cell of the current glyph (inclusive)
|
||||
const til::point TextBuffer::GetGlyphStart(const til::point pos, std::optional<til::point> limitOptional) const
|
||||
{
|
||||
COORD resultPos = pos.to_win32_coord();
|
||||
auto resultPos = pos;
|
||||
const auto bufferSize = GetSize();
|
||||
const auto limit{ limitOptional.value_or(til::point{ bufferSize.EndExclusive() }) };
|
||||
|
||||
// Clamp pos to limit
|
||||
if (bufferSize.CompareInBounds(resultPos, limit.to_win32_coord(), true) > 0)
|
||||
if (bufferSize.CompareInBounds(resultPos, limit, true) > 0)
|
||||
{
|
||||
resultPos = limit.to_win32_coord();
|
||||
resultPos = limit;
|
||||
}
|
||||
|
||||
// limit is exclusive, so we need to move back to be within valid bounds
|
||||
if (resultPos != limit.to_win32_coord() && GetCellDataAt(resultPos)->DbcsAttr().IsTrailing())
|
||||
if (resultPos != limit && GetCellDataAt(resultPos)->DbcsAttr().IsTrailing())
|
||||
{
|
||||
bufferSize.DecrementInBounds(resultPos, true);
|
||||
}
|
||||
|
||||
return til::point{ resultPos };
|
||||
return resultPos;
|
||||
}
|
||||
|
||||
// Method Description:
|
||||
// - Update pos to be the end of the current glyph/character.
|
||||
// Arguments:
|
||||
// - pos - a COORD on the word you are currently on
|
||||
// - pos - a til::point on the word you are currently on
|
||||
// - accessibilityMode - this is being used for accessibility; make the end exclusive.
|
||||
// Return Value:
|
||||
// - pos - The COORD for the last cell of the current glyph (exclusive)
|
||||
// - pos - The til::point for the last cell of the current glyph (exclusive)
|
||||
const til::point TextBuffer::GetGlyphEnd(const til::point pos, bool accessibilityMode, std::optional<til::point> limitOptional) const
|
||||
{
|
||||
COORD resultPos = pos.to_win32_coord();
|
||||
auto resultPos = pos;
|
||||
const auto bufferSize = GetSize();
|
||||
const auto limit{ limitOptional.value_or(til::point{ bufferSize.EndExclusive() }) };
|
||||
|
||||
// Clamp pos to limit
|
||||
if (bufferSize.CompareInBounds(resultPos, limit.to_win32_coord(), true) > 0)
|
||||
if (bufferSize.CompareInBounds(resultPos, limit, true) > 0)
|
||||
{
|
||||
resultPos = limit.to_win32_coord();
|
||||
resultPos = limit;
|
||||
}
|
||||
|
||||
if (resultPos != limit.to_win32_coord() && GetCellDataAt(resultPos)->DbcsAttr().IsLeading())
|
||||
if (resultPos != limit && GetCellDataAt(resultPos)->DbcsAttr().IsLeading())
|
||||
{
|
||||
bufferSize.IncrementInBounds(resultPos, true);
|
||||
}
|
||||
@@ -1459,24 +1460,24 @@ const til::point TextBuffer::GetGlyphEnd(const til::point pos, bool accessibilit
|
||||
{
|
||||
bufferSize.IncrementInBounds(resultPos, true);
|
||||
}
|
||||
return til::point{ resultPos };
|
||||
return resultPos;
|
||||
}
|
||||
|
||||
// Method Description:
|
||||
// - Update pos to be the beginning of the next glyph/character. This is used for accessibility
|
||||
// Arguments:
|
||||
// - pos - a COORD on the word you are currently on
|
||||
// - pos - a til::point on the word you are currently on
|
||||
// - allowExclusiveEnd - allow result to be the exclusive limit (one past limit)
|
||||
// - limit - boundaries for the iterator to operate within
|
||||
// Return Value:
|
||||
// - true, if successfully updated pos. False, if we are unable to move (usually due to a buffer boundary)
|
||||
// - pos - The COORD for the first cell of the current glyph (inclusive)
|
||||
// - pos - The til::point for the first cell of the current glyph (inclusive)
|
||||
bool TextBuffer::MoveToNextGlyph(til::point& pos, bool allowExclusiveEnd, std::optional<til::point> limitOptional) const
|
||||
{
|
||||
const auto bufferSize = GetSize();
|
||||
const auto limit{ limitOptional.value_or(til::point{ bufferSize.EndExclusive() }) };
|
||||
|
||||
const auto distanceToLimit{ bufferSize.CompareInBounds(pos.to_win32_coord(), limit.to_win32_coord(), true) };
|
||||
const auto distanceToLimit{ bufferSize.CompareInBounds(pos, limit, true) };
|
||||
if (distanceToLimit >= 0)
|
||||
{
|
||||
// Corner Case: we're on/past the limit
|
||||
@@ -1493,7 +1494,7 @@ bool TextBuffer::MoveToNextGlyph(til::point& pos, bool allowExclusiveEnd, std::o
|
||||
}
|
||||
|
||||
// Try to move forward, but if we hit the buffer boundary, we fail to move.
|
||||
auto iter{ GetCellDataAt(pos.to_win32_coord(), bufferSize) };
|
||||
auto iter{ GetCellDataAt(pos, bufferSize) };
|
||||
const bool success{ ++iter };
|
||||
|
||||
// Move again if we're on a wide glyph
|
||||
@@ -1502,24 +1503,24 @@ bool TextBuffer::MoveToNextGlyph(til::point& pos, bool allowExclusiveEnd, std::o
|
||||
++iter;
|
||||
}
|
||||
|
||||
pos = til::point{ iter.Pos() };
|
||||
pos = iter.Pos();
|
||||
return success;
|
||||
}
|
||||
|
||||
// Method Description:
|
||||
// - Update pos to be the beginning of the previous glyph/character. This is used for accessibility
|
||||
// Arguments:
|
||||
// - pos - a COORD on the word you are currently on
|
||||
// - pos - a til::point on the word you are currently on
|
||||
// Return Value:
|
||||
// - true, if successfully updated pos. False, if we are unable to move (usually due to a buffer boundary)
|
||||
// - pos - The COORD for the first cell of the previous glyph (inclusive)
|
||||
// - pos - The til::point for the first cell of the previous glyph (inclusive)
|
||||
bool TextBuffer::MoveToPreviousGlyph(til::point& pos, std::optional<til::point> limitOptional) const
|
||||
{
|
||||
COORD resultPos = pos.to_win32_coord();
|
||||
auto resultPos = pos;
|
||||
const auto bufferSize = GetSize();
|
||||
const auto limit{ limitOptional.value_or(til::point{ bufferSize.EndExclusive() }) };
|
||||
|
||||
if (bufferSize.CompareInBounds(pos.to_win32_coord(), limit.to_win32_coord(), true) > 0)
|
||||
if (bufferSize.CompareInBounds(pos, limit, true) > 0)
|
||||
{
|
||||
// we're past the end
|
||||
// clamp us to the limit
|
||||
@@ -1552,9 +1553,9 @@ bool TextBuffer::MoveToPreviousGlyph(til::point& pos, std::optional<til::point>
|
||||
// the buffer rather than the screen.
|
||||
// Return Value:
|
||||
// - the delimiter class for the given char
|
||||
const std::vector<SMALL_RECT> TextBuffer::GetTextRects(COORD start, COORD end, bool blockSelection, bool bufferCoordinates) const
|
||||
const std::vector<til::inclusive_rect> TextBuffer::GetTextRects(til::point start, til::point end, bool blockSelection, bool bufferCoordinates) const
|
||||
{
|
||||
std::vector<SMALL_RECT> textRects;
|
||||
std::vector<til::inclusive_rect> textRects;
|
||||
|
||||
const auto bufferSize = GetSize();
|
||||
|
||||
@@ -1565,11 +1566,10 @@ const std::vector<SMALL_RECT> TextBuffer::GetTextRects(COORD start, COORD end, b
|
||||
std::make_tuple(start, end) :
|
||||
std::make_tuple(end, start);
|
||||
|
||||
const auto textRectSize = base::ClampedNumeric<short>(1) + lowerCoord.Y - higherCoord.Y;
|
||||
textRects.reserve(textRectSize);
|
||||
textRects.reserve(lowerCoord.Y - higherCoord.Y + 1);
|
||||
for (auto row = higherCoord.Y; row <= lowerCoord.Y; row++)
|
||||
{
|
||||
SMALL_RECT textRow;
|
||||
til::inclusive_rect textRow;
|
||||
|
||||
textRow.Top = row;
|
||||
textRow.Bottom = row;
|
||||
@@ -1607,12 +1607,12 @@ const std::vector<SMALL_RECT> TextBuffer::GetTextRects(COORD start, COORD end, b
|
||||
// - selectionRow: the selection row to be expanded
|
||||
// Return Value:
|
||||
// - modifies selectionRow's Left and Right values to expand properly
|
||||
void TextBuffer::_ExpandTextRow(SMALL_RECT& textRow) const
|
||||
void TextBuffer::_ExpandTextRow(til::inclusive_rect& textRow) const
|
||||
{
|
||||
const auto bufferSize = GetSize();
|
||||
|
||||
// expand left side of rect
|
||||
COORD targetPoint{ textRow.Left, textRow.Top };
|
||||
til::point targetPoint{ textRow.Left, textRow.Top };
|
||||
if (GetCellDataAt(targetPoint)->DbcsAttr().IsTrailing())
|
||||
{
|
||||
if (targetPoint.X == bufferSize.Left())
|
||||
@@ -1654,7 +1654,7 @@ void TextBuffer::_ExpandTextRow(SMALL_RECT& textRow) const
|
||||
// - The text, background color, and foreground color data of the selected region of the text buffer.
|
||||
const TextBuffer::TextAndColor TextBuffer::GetText(const bool includeCRLF,
|
||||
const bool trimTrailingWhitespace,
|
||||
const std::vector<SMALL_RECT>& selectionRects,
|
||||
const std::vector<til::inclusive_rect>& selectionRects,
|
||||
std::function<std::pair<COLORREF, COLORREF>(const TextAttribute&)> GetAttributeColors,
|
||||
const bool formatWrappedRows) const
|
||||
{
|
||||
@@ -1662,7 +1662,7 @@ const TextBuffer::TextAndColor TextBuffer::GetText(const bool includeCRLF,
|
||||
const bool copyTextColor = GetAttributeColors != nullptr;
|
||||
|
||||
// preallocate our vectors to reduce reallocs
|
||||
size_t const rows = selectionRects.size();
|
||||
const auto rows = selectionRects.size();
|
||||
data.text.reserve(rows);
|
||||
if (copyTextColor)
|
||||
{
|
||||
@@ -1671,11 +1671,10 @@ const TextBuffer::TextAndColor TextBuffer::GetText(const bool includeCRLF,
|
||||
}
|
||||
|
||||
// for each row in the selection
|
||||
for (UINT i = 0; i < rows; i++)
|
||||
for (til::CoordType i = 0; i < rows; i++)
|
||||
{
|
||||
const UINT iRow = selectionRects.at(i).Top;
|
||||
|
||||
const Viewport highlight = Viewport::FromInclusive(selectionRects.at(i));
|
||||
const auto iRow = selectionRects.at(i).top;
|
||||
const auto highlight = Viewport::FromInclusive(selectionRects.at(i));
|
||||
|
||||
// retrieve the data from the screen buffer
|
||||
auto it = GetCellDataAt(highlight.Origin(), highlight);
|
||||
@@ -1686,11 +1685,11 @@ const TextBuffer::TextAndColor TextBuffer::GetText(const bool includeCRLF,
|
||||
std::vector<COLORREF> selectionBkAttr;
|
||||
|
||||
// preallocate to avoid reallocs
|
||||
selectionText.reserve(gsl::narrow<size_t>(highlight.Width()) + 2); // + 2 for \r\n if we munged it
|
||||
selectionText.reserve(highlight.Width() + 2); // + 2 for \r\n if we munged it
|
||||
if (copyTextColor)
|
||||
{
|
||||
selectionFgAttr.reserve(gsl::narrow<size_t>(highlight.Width()) + 2);
|
||||
selectionBkAttr.reserve(gsl::narrow<size_t>(highlight.Width()) + 2);
|
||||
selectionFgAttr.reserve(highlight.Width() + 2);
|
||||
selectionBkAttr.reserve(highlight.Width() + 2);
|
||||
}
|
||||
|
||||
// copy char data into the string buffer, skipping trailing bytes
|
||||
@@ -1707,7 +1706,7 @@ const TextBuffer::TextAndColor TextBuffer::GetText(const bool includeCRLF,
|
||||
{
|
||||
const auto cellData = cell.TextAttr();
|
||||
const auto [CellFgAttr, CellBkAttr] = GetAttributeColors(cellData);
|
||||
for (size_t j = 0; j < chars.size(); ++j)
|
||||
for (til::CoordType j = 0; j < chars.size(); ++j)
|
||||
{
|
||||
selectionFgAttr.push_back(CellFgAttr);
|
||||
selectionBkAttr.push_back(CellBkAttr);
|
||||
@@ -1832,16 +1831,16 @@ std::string TextBuffer::GenHTML(const TextAndColor& rows,
|
||||
bool hasWrittenAnyText = false;
|
||||
std::optional<COLORREF> fgColor = std::nullopt;
|
||||
std::optional<COLORREF> bkColor = std::nullopt;
|
||||
for (size_t row = 0; row < rows.text.size(); row++)
|
||||
for (til::CoordType row = 0; row < rows.text.size(); row++)
|
||||
{
|
||||
size_t startOffset = 0;
|
||||
til::CoordType startOffset = 0;
|
||||
|
||||
if (row != 0)
|
||||
{
|
||||
htmlBuilder << "<BR>";
|
||||
}
|
||||
|
||||
for (size_t col = 0; col < rows.text.at(row).length(); col++)
|
||||
for (til::CoordType col = 0; col < rows.text.at(row).length(); col++)
|
||||
{
|
||||
const auto writeAccumulatedChars = [&](bool includeCurrent) {
|
||||
if (col >= startOffset)
|
||||
@@ -1933,13 +1932,13 @@ std::string TextBuffer::GenHTML(const TextAndColor& rows,
|
||||
htmlBuilder << HtmlFooter;
|
||||
|
||||
// once filled with values, there will be exactly 157 bytes in the clipboard header
|
||||
constexpr size_t ClipboardHeaderSize = 157;
|
||||
constexpr auto ClipboardHeaderSize = 157;
|
||||
|
||||
// these values are byte offsets from start of clipboard
|
||||
const size_t htmlStartPos = ClipboardHeaderSize;
|
||||
const size_t htmlEndPos = ClipboardHeaderSize + gsl::narrow<size_t>(htmlBuilder.tellp());
|
||||
const size_t fragStartPos = ClipboardHeaderSize + gsl::narrow<size_t>(htmlHeader.length());
|
||||
const size_t fragEndPos = htmlEndPos - HtmlFooter.length();
|
||||
const auto htmlStartPos = ClipboardHeaderSize;
|
||||
const auto htmlEndPos = ClipboardHeaderSize + htmlBuilder.tellp();
|
||||
const auto fragStartPos = ClipboardHeaderSize + htmlHeader.length();
|
||||
const auto fragEndPos = htmlEndPos - HtmlFooter.length();
|
||||
|
||||
// header required by HTML 0.9 format
|
||||
std::ostringstream clipHeaderBuilder;
|
||||
@@ -2020,16 +2019,16 @@ std::string TextBuffer::GenRTF(const TextAndColor& rows, const int fontHeightPoi
|
||||
|
||||
std::optional<COLORREF> fgColor = std::nullopt;
|
||||
std::optional<COLORREF> bkColor = std::nullopt;
|
||||
for (size_t row = 0; row < rows.text.size(); ++row)
|
||||
for (til::CoordType row = 0; row < rows.text.size(); ++row)
|
||||
{
|
||||
size_t startOffset = 0;
|
||||
til::CoordType startOffset = 0;
|
||||
|
||||
if (row != 0)
|
||||
{
|
||||
contentBuilder << "\\line "; // new line
|
||||
}
|
||||
|
||||
for (size_t col = 0; col < rows.text.at(row).length(); ++col)
|
||||
for (til::CoordType col = 0; col < rows.text.at(row).length(); ++col)
|
||||
{
|
||||
const auto writeAccumulatedChars = [&](bool includeCurrent) {
|
||||
if (col >= startOffset)
|
||||
@@ -2173,24 +2172,24 @@ HRESULT TextBuffer::Reflow(TextBuffer& oldBuffer,
|
||||
// We need to save the old cursor position so that we can
|
||||
// place the new cursor back on the equivalent character in
|
||||
// the new buffer.
|
||||
const COORD cOldCursorPos = oldCursor.GetPosition();
|
||||
const COORD cOldLastChar = oldBuffer.GetLastNonSpaceCharacter(lastCharacterViewport);
|
||||
const auto cOldCursorPos = oldCursor.GetPosition();
|
||||
const auto cOldLastChar = oldBuffer.GetLastNonSpaceCharacter(lastCharacterViewport);
|
||||
|
||||
const short cOldRowsTotal = cOldLastChar.Y + 1;
|
||||
const auto cOldRowsTotal = cOldLastChar.Y + 1;
|
||||
|
||||
COORD cNewCursorPos = { 0 };
|
||||
til::point cNewCursorPos;
|
||||
bool fFoundCursorPos = false;
|
||||
bool foundOldMutable = false;
|
||||
bool foundOldVisible = false;
|
||||
HRESULT hr = S_OK;
|
||||
// Loop through all the rows of the old buffer and reprint them into the new buffer
|
||||
for (short iOldRow = 0; iOldRow < cOldRowsTotal; iOldRow++)
|
||||
for (auto iOldRow = 0; iOldRow < cOldRowsTotal; iOldRow++)
|
||||
{
|
||||
// Fetch the row and its "right" which is the last printable character.
|
||||
const ROW& row = oldBuffer.GetRowByOffset(iOldRow);
|
||||
const short cOldColsTotal = oldBuffer.GetLineWidth(iOldRow);
|
||||
const auto cOldColsTotal = oldBuffer.GetLineWidth(iOldRow);
|
||||
const CharRow& charRow = row.GetCharRow();
|
||||
short iRight = gsl::narrow_cast<short>(charRow.MeasureRight());
|
||||
auto iRight = charRow.MeasureRight();
|
||||
|
||||
// If we're starting a new row, try and preserve the line rendition
|
||||
// from the row in the original buffer.
|
||||
@@ -2228,7 +2227,7 @@ HRESULT TextBuffer::Reflow(TextBuffer& oldBuffer,
|
||||
// Loop through every character in the current row (up to
|
||||
// the "right" boundary, which is one past the final valid
|
||||
// character)
|
||||
for (short iOldCol = 0; iOldCol < iRight; iOldCol++)
|
||||
for (auto iOldCol = 0; iOldCol < iRight; iOldCol++)
|
||||
{
|
||||
if (iOldCol == cOldCursorPos.X && iOldRow == cOldCursorPos.Y)
|
||||
{
|
||||
@@ -2324,10 +2323,10 @@ HRESULT TextBuffer::Reflow(TextBuffer& oldBuffer,
|
||||
// |aaaaaaaaaaaaaaaaaaa| no wrap at the end (preserved hard newline)
|
||||
// | |
|
||||
// ^ and the cursor is now here.
|
||||
const COORD coordNewCursor = newCursor.GetPosition();
|
||||
const auto coordNewCursor = newCursor.GetPosition();
|
||||
if (coordNewCursor.X == 0 && coordNewCursor.Y > 0)
|
||||
{
|
||||
if (newBuffer.GetRowByOffset(gsl::narrow_cast<size_t>(coordNewCursor.Y) - 1).WasWrapForced())
|
||||
if (newBuffer.GetRowByOffset(coordNewCursor.Y - 1).WasWrapForced())
|
||||
{
|
||||
hr = newBuffer.NewlineCursor() ? hr : E_OUTOFMEMORY;
|
||||
}
|
||||
@@ -2356,7 +2355,7 @@ HRESULT TextBuffer::Reflow(TextBuffer& oldBuffer,
|
||||
// then advance that many newlines and chars
|
||||
int iNewlines = cOldCursorPos.Y - cOldLastChar.Y;
|
||||
const int iIncrements = cOldCursorPos.X - cOldLastChar.X;
|
||||
const COORD cNewLastChar = newBuffer.GetLastNonSpaceCharacter();
|
||||
const auto cNewLastChar = newBuffer.GetLastNonSpaceCharacter();
|
||||
|
||||
// If the last row of the new buffer wrapped, there's going to be one less newline needed,
|
||||
// because the cursor is already on the next line
|
||||
@@ -2521,7 +2520,7 @@ void TextBuffer::CopyHyperlinkMaps(const TextBuffer& other)
|
||||
// - The regex pattern
|
||||
// Return value:
|
||||
// - An ID that the caller should associate with the given pattern
|
||||
const size_t TextBuffer::AddPatternRecognizer(const std::wstring_view regexString)
|
||||
const til::CoordType TextBuffer::AddPatternRecognizer(const std::wstring_view regexString)
|
||||
{
|
||||
++_currentPatternId;
|
||||
_idsAndPatterns.emplace(std::make_pair(_currentPatternId, regexString));
|
||||
@@ -2553,7 +2552,7 @@ void TextBuffer::CopyPatterns(const TextBuffer& OtherBuffer)
|
||||
// - The lastRow to search
|
||||
// Return value:
|
||||
// - An interval tree containing the patterns found
|
||||
PointTree TextBuffer::GetPatterns(const size_t firstRow, const size_t lastRow) const
|
||||
PointTree TextBuffer::GetPatterns(const til::CoordType firstRow, const til::CoordType lastRow) const
|
||||
{
|
||||
PointTree::interval_vector intervals;
|
||||
|
||||
@@ -2578,21 +2577,21 @@ PointTree TextBuffer::GetPatterns(const size_t firstRow, const size_t lastRow) c
|
||||
auto words_begin = std::wsregex_iterator(concatAll.begin(), concatAll.end(), regexObj);
|
||||
auto words_end = std::wsregex_iterator();
|
||||
|
||||
size_t lenUpToThis = 0;
|
||||
til::CoordType lenUpToThis = 0;
|
||||
for (auto i = words_begin; i != words_end; ++i)
|
||||
{
|
||||
// record the locations -
|
||||
// when we find a match, the prefix is text that is between this
|
||||
// match and the previous match, so we use the size of the prefix
|
||||
// along with the size of the match to determine the locations
|
||||
size_t prefixSize = 0;
|
||||
til::CoordType prefixSize = 0;
|
||||
for (const std::vector<wchar_t> parsedGlyph : Utf16Parser::Parse(i->prefix().str()))
|
||||
{
|
||||
const std::wstring_view glyph{ parsedGlyph.data(), parsedGlyph.size() };
|
||||
prefixSize += IsGlyphFullWidth(glyph) ? 2 : 1;
|
||||
}
|
||||
const auto start = lenUpToThis + prefixSize;
|
||||
size_t matchSize = 0;
|
||||
til::CoordType matchSize = 0;
|
||||
for (const std::vector<wchar_t> parsedGlyph : Utf16Parser::Parse(i->str()))
|
||||
{
|
||||
const std::wstring_view glyph{ parsedGlyph.data(), parsedGlyph.size() };
|
||||
@@ -2601,8 +2600,8 @@ PointTree TextBuffer::GetPatterns(const size_t firstRow, const size_t lastRow) c
|
||||
const auto end = start + matchSize;
|
||||
lenUpToThis = end;
|
||||
|
||||
const til::point startCoord{ gsl::narrow<SHORT>(start % rowSize), gsl::narrow<SHORT>(start / rowSize) };
|
||||
const til::point endCoord{ gsl::narrow<SHORT>(end % rowSize), gsl::narrow<SHORT>(end / rowSize) };
|
||||
const til::point startCoord{ start % rowSize, start / rowSize };
|
||||
const til::point endCoord{ end % rowSize, end / rowSize };
|
||||
|
||||
// store the intervals
|
||||
// NOTE: these intervals are relative to the VIEWPORT not the buffer
|
||||
|
||||
@@ -65,9 +65,9 @@ filling in the last row, and updating the screen.
|
||||
class TextBuffer final
|
||||
{
|
||||
public:
|
||||
TextBuffer(const COORD screenBufferSize,
|
||||
TextBuffer(const til::size screenBufferSize,
|
||||
const TextAttribute defaultAttributes,
|
||||
const UINT cursorSize,
|
||||
const til::CoordType cursorSize,
|
||||
Microsoft::Console::Render::IRenderTarget& renderTarget);
|
||||
TextBuffer(const TextBuffer& a) = delete;
|
||||
|
||||
@@ -75,27 +75,27 @@ public:
|
||||
void CopyProperties(const TextBuffer& OtherBuffer) noexcept;
|
||||
|
||||
// row manipulation
|
||||
const ROW& GetRowByOffset(const size_t index) const;
|
||||
ROW& GetRowByOffset(const size_t index);
|
||||
const ROW& GetRowByOffset(const til::CoordType index) const;
|
||||
ROW& GetRowByOffset(const til::CoordType index);
|
||||
|
||||
TextBufferCellIterator GetCellDataAt(const COORD at) const;
|
||||
TextBufferCellIterator GetCellLineDataAt(const COORD at) const;
|
||||
TextBufferCellIterator GetCellDataAt(const COORD at, const Microsoft::Console::Types::Viewport limit) const;
|
||||
TextBufferTextIterator GetTextDataAt(const COORD at) const;
|
||||
TextBufferTextIterator GetTextLineDataAt(const COORD at) const;
|
||||
TextBufferTextIterator GetTextDataAt(const COORD at, const Microsoft::Console::Types::Viewport limit) const;
|
||||
TextBufferCellIterator GetCellDataAt(const til::point at) const;
|
||||
TextBufferCellIterator GetCellLineDataAt(const til::point at) const;
|
||||
TextBufferCellIterator GetCellDataAt(const til::point at, const Microsoft::Console::Types::Viewport limit) const;
|
||||
TextBufferTextIterator GetTextDataAt(const til::point at) const;
|
||||
TextBufferTextIterator GetTextLineDataAt(const til::point at) const;
|
||||
TextBufferTextIterator GetTextDataAt(const til::point at, const Microsoft::Console::Types::Viewport limit) const;
|
||||
|
||||
// Text insertion functions
|
||||
OutputCellIterator Write(const OutputCellIterator givenIt);
|
||||
|
||||
OutputCellIterator Write(const OutputCellIterator givenIt,
|
||||
const COORD target,
|
||||
const til::point target,
|
||||
const std::optional<bool> wrap = true);
|
||||
|
||||
OutputCellIterator WriteLine(const OutputCellIterator givenIt,
|
||||
const COORD target,
|
||||
const til::point target,
|
||||
const std::optional<bool> setWrap = std::nullopt,
|
||||
const std::optional<size_t> limitRight = std::nullopt);
|
||||
const std::optional<til::CoordType> limitRight = std::nullopt);
|
||||
|
||||
bool InsertCharacter(const wchar_t wch, const DbcsAttribute dbcsAttribute, const TextAttribute attr);
|
||||
bool InsertCharacter(const std::wstring_view chars, const DbcsAttribute dbcsAttribute, const TextAttribute attr);
|
||||
@@ -105,53 +105,53 @@ public:
|
||||
// Scroll needs access to this to quickly rotate around the buffer.
|
||||
bool IncrementCircularBuffer(const bool inVtMode = false);
|
||||
|
||||
COORD GetLastNonSpaceCharacter(std::optional<const Microsoft::Console::Types::Viewport> viewOptional = std::nullopt) const;
|
||||
til::point GetLastNonSpaceCharacter(std::optional<const Microsoft::Console::Types::Viewport> viewOptional = std::nullopt) const;
|
||||
|
||||
Cursor& GetCursor() noexcept;
|
||||
const Cursor& GetCursor() const noexcept;
|
||||
|
||||
const SHORT GetFirstRowIndex() const noexcept;
|
||||
const til::CoordType GetFirstRowIndex() const noexcept;
|
||||
|
||||
const Microsoft::Console::Types::Viewport GetSize() const noexcept;
|
||||
|
||||
void ScrollRows(const SHORT firstRow, const SHORT size, const SHORT delta);
|
||||
void ScrollRows(const til::CoordType firstRow, const til::CoordType size, const til::CoordType delta);
|
||||
|
||||
UINT TotalRowCount() const noexcept;
|
||||
til::CoordType TotalRowCount() const noexcept;
|
||||
|
||||
[[nodiscard]] TextAttribute GetCurrentAttributes() const noexcept;
|
||||
|
||||
void SetCurrentAttributes(const TextAttribute& currentAttributes) noexcept;
|
||||
|
||||
void SetCurrentLineRendition(const LineRendition lineRendition);
|
||||
void ResetLineRenditionRange(const size_t startRow, const size_t endRow);
|
||||
LineRendition GetLineRendition(const size_t row) const;
|
||||
bool IsDoubleWidthLine(const size_t row) const;
|
||||
void ResetLineRenditionRange(const til::CoordType startRow, const til::CoordType endRow);
|
||||
LineRendition GetLineRendition(const til::CoordType row) const;
|
||||
bool IsDoubleWidthLine(const til::CoordType row) const;
|
||||
|
||||
SHORT GetLineWidth(const size_t row) const;
|
||||
COORD ClampPositionWithinLine(const COORD position) const;
|
||||
COORD ScreenToBufferPosition(const COORD position) const;
|
||||
COORD BufferToScreenPosition(const COORD position) const;
|
||||
til::CoordType GetLineWidth(const til::CoordType row) const;
|
||||
til::point ClampPositionWithinLine(const til::point position) const;
|
||||
til::point ScreenToBufferPosition(const til::point position) const;
|
||||
til::point BufferToScreenPosition(const til::point position) const;
|
||||
|
||||
void Reset();
|
||||
|
||||
[[nodiscard]] HRESULT ResizeTraditional(const COORD newSize) noexcept;
|
||||
[[nodiscard]] HRESULT ResizeTraditional(const til::size newSize) noexcept;
|
||||
|
||||
const UnicodeStorage& GetUnicodeStorage() const noexcept;
|
||||
UnicodeStorage& GetUnicodeStorage() noexcept;
|
||||
|
||||
Microsoft::Console::Render::IRenderTarget& GetRenderTarget() noexcept;
|
||||
|
||||
const COORD GetWordStart(const COORD target, const std::wstring_view wordDelimiters, bool accessibilityMode = false, std::optional<til::point> limitOptional = std::nullopt) const;
|
||||
const COORD GetWordEnd(const COORD target, const std::wstring_view wordDelimiters, bool accessibilityMode = false, std::optional<til::point> limitOptional = std::nullopt) const;
|
||||
bool MoveToNextWord(COORD& pos, const std::wstring_view wordDelimiters, std::optional<til::point> limitOptional = std::nullopt) const;
|
||||
bool MoveToPreviousWord(COORD& pos, const std::wstring_view wordDelimiters) const;
|
||||
const til::point GetWordStart(const til::point target, const std::wstring_view wordDelimiters, bool accessibilityMode = false, std::optional<til::point> limitOptional = std::nullopt) const;
|
||||
const til::point GetWordEnd(const til::point target, const std::wstring_view wordDelimiters, bool accessibilityMode = false, std::optional<til::point> limitOptional = std::nullopt) const;
|
||||
bool MoveToNextWord(til::point& pos, const std::wstring_view wordDelimiters, std::optional<til::point> limitOptional = std::nullopt) const;
|
||||
bool MoveToPreviousWord(til::point& pos, const std::wstring_view wordDelimiters) const;
|
||||
|
||||
const til::point GetGlyphStart(const til::point pos, std::optional<til::point> limitOptional = std::nullopt) const;
|
||||
const til::point GetGlyphEnd(const til::point pos, bool accessibilityMode = false, std::optional<til::point> limitOptional = std::nullopt) const;
|
||||
bool MoveToNextGlyph(til::point& pos, bool allowBottomExclusive = false, std::optional<til::point> limitOptional = std::nullopt) const;
|
||||
bool MoveToPreviousGlyph(til::point& pos, std::optional<til::point> limitOptional = std::nullopt) const;
|
||||
|
||||
const std::vector<SMALL_RECT> GetTextRects(COORD start, COORD end, bool blockSelection, bool bufferCoordinates) const;
|
||||
const std::vector<til::inclusive_rect> GetTextRects(til::point start, til::point end, bool blockSelection, bool bufferCoordinates) const;
|
||||
|
||||
void AddHyperlinkToMap(std::wstring_view uri, uint16_t id);
|
||||
std::wstring GetHyperlinkUriFromId(uint16_t id) const;
|
||||
@@ -170,7 +170,7 @@ public:
|
||||
|
||||
const TextAndColor GetText(const bool includeCRLF,
|
||||
const bool trimTrailingWhitespace,
|
||||
const std::vector<SMALL_RECT>& textRects,
|
||||
const std::vector<til::inclusive_rect>& textRects,
|
||||
std::function<std::pair<COLORREF, COLORREF>(const TextAttribute&)> GetAttributeColors = nullptr,
|
||||
const bool formatWrappedRows = false) const;
|
||||
|
||||
@@ -186,8 +186,8 @@ public:
|
||||
|
||||
struct PositionInformation
|
||||
{
|
||||
short mutableViewportTop{ 0 };
|
||||
short visibleViewportTop{ 0 };
|
||||
til::CoordType mutableViewportTop{ 0 };
|
||||
til::CoordType visibleViewportTop{ 0 };
|
||||
};
|
||||
|
||||
static HRESULT Reflow(TextBuffer& oldBuffer,
|
||||
@@ -195,10 +195,10 @@ public:
|
||||
const std::optional<Microsoft::Console::Types::Viewport> lastCharacterViewport,
|
||||
std::optional<std::reference_wrapper<PositionInformation>> positionInfo);
|
||||
|
||||
const size_t AddPatternRecognizer(const std::wstring_view regexString);
|
||||
const til::CoordType AddPatternRecognizer(const std::wstring_view regexString);
|
||||
void ClearPatternRecognizers() noexcept;
|
||||
void CopyPatterns(const TextBuffer& OtherBuffer);
|
||||
interval_tree::IntervalTree<til::point, size_t> GetPatterns(const size_t firstRow, const size_t lastRow) const;
|
||||
interval_tree::IntervalTree<til::point, til::CoordType> GetPatterns(const til::CoordType firstRow, const til::CoordType lastRow) const;
|
||||
|
||||
private:
|
||||
void _UpdateSize();
|
||||
@@ -206,7 +206,7 @@ private:
|
||||
std::vector<ROW> _storage;
|
||||
Cursor _cursor;
|
||||
|
||||
SHORT _firstRow; // indexes top row (not necessarily 0)
|
||||
til::CoordType _firstRow; // indexes top row (not necessarily 0)
|
||||
|
||||
TextAttribute _currentAttributes;
|
||||
|
||||
@@ -217,13 +217,13 @@ private:
|
||||
std::unordered_map<std::wstring, uint16_t> _hyperlinkCustomIdMap;
|
||||
uint16_t _currentHyperlinkId;
|
||||
|
||||
void _RefreshRowIDs(std::optional<SHORT> newRowWidth);
|
||||
void _RefreshRowIDs(std::optional<til::CoordType> newRowWidth);
|
||||
|
||||
Microsoft::Console::Render::IRenderTarget& _renderTarget;
|
||||
|
||||
void _SetFirstRowIndex(const SHORT FirstRowIndex) noexcept;
|
||||
void _SetFirstRowIndex(const til::CoordType FirstRowIndex) noexcept;
|
||||
|
||||
COORD _GetPreviousFromCursor() const;
|
||||
til::point _GetPreviousFromCursor() const;
|
||||
|
||||
void _SetWrapOnCurrentRow();
|
||||
void _AdjustWrapOnCurrentRow(const bool fSet);
|
||||
@@ -237,18 +237,18 @@ private:
|
||||
ROW& _GetFirstRow();
|
||||
ROW& _GetPrevRowNoWrap(const ROW& row);
|
||||
|
||||
void _ExpandTextRow(SMALL_RECT& selectionRow) const;
|
||||
void _ExpandTextRow(til::inclusive_rect& selectionRow) const;
|
||||
|
||||
const DelimiterClass _GetDelimiterClassAt(const COORD pos, const std::wstring_view wordDelimiters) const;
|
||||
const COORD _GetWordStartForAccessibility(const COORD target, const std::wstring_view wordDelimiters) const;
|
||||
const COORD _GetWordStartForSelection(const COORD target, const std::wstring_view wordDelimiters) const;
|
||||
const COORD _GetWordEndForAccessibility(const COORD target, const std::wstring_view wordDelimiters, const COORD limit) const;
|
||||
const COORD _GetWordEndForSelection(const COORD target, const std::wstring_view wordDelimiters) const;
|
||||
const DelimiterClass _GetDelimiterClassAt(const til::point pos, const std::wstring_view wordDelimiters) const;
|
||||
const til::point _GetWordStartForAccessibility(const til::point target, const std::wstring_view wordDelimiters) const;
|
||||
const til::point _GetWordStartForSelection(const til::point target, const std::wstring_view wordDelimiters) const;
|
||||
const til::point _GetWordEndForAccessibility(const til::point target, const std::wstring_view wordDelimiters, const til::point limit) const;
|
||||
const til::point _GetWordEndForSelection(const til::point target, const std::wstring_view wordDelimiters) const;
|
||||
|
||||
void _PruneHyperlinks();
|
||||
|
||||
std::unordered_map<size_t, std::wstring> _idsAndPatterns;
|
||||
size_t _currentPatternId;
|
||||
std::unordered_map<til::CoordType, std::wstring> _idsAndPatterns;
|
||||
til::CoordType _currentPatternId;
|
||||
|
||||
#ifdef UNIT_TESTING
|
||||
friend class TextBufferTests;
|
||||
|
||||
@@ -19,7 +19,7 @@ using namespace Microsoft::Console::Types;
|
||||
// Arguments:
|
||||
// - buffer - Text buffer to seek through
|
||||
// - pos - Starting position to retrieve text data from (within screen buffer bounds)
|
||||
TextBufferCellIterator::TextBufferCellIterator(const TextBuffer& buffer, COORD pos) :
|
||||
TextBufferCellIterator::TextBufferCellIterator(const TextBuffer& buffer, til::point pos) :
|
||||
TextBufferCellIterator(buffer, pos, buffer.GetSize())
|
||||
{
|
||||
}
|
||||
@@ -30,7 +30,7 @@ TextBufferCellIterator::TextBufferCellIterator(const TextBuffer& buffer, COORD p
|
||||
// - buffer - Pointer to screen buffer to seek through
|
||||
// - pos - Starting position to retrieve text data from (within screen buffer bounds)
|
||||
// - limits - Viewport limits to restrict the iterator within the buffer bounds (smaller than the buffer itself)
|
||||
TextBufferCellIterator::TextBufferCellIterator(const TextBuffer& buffer, COORD pos, const Viewport limits) :
|
||||
TextBufferCellIterator::TextBufferCellIterator(const TextBuffer& buffer, til::point pos, const Viewport limits) :
|
||||
_buffer(buffer),
|
||||
_pos(pos),
|
||||
_pRow(s_GetRow(buffer, pos)),
|
||||
@@ -126,7 +126,7 @@ TextBufferCellIterator& TextBufferCellIterator::operator+=(const ptrdiff_t& move
|
||||
const auto oldX = _pos.X;
|
||||
const auto oldY = _pos.Y;
|
||||
|
||||
// Under MSVC writing the individual members of a COORD generates worse assembly
|
||||
// Under MSVC writing the individual members of a til::point generates worse assembly
|
||||
// compared to having them be local variables. This causes a performance impact.
|
||||
auto newX = oldX;
|
||||
auto newY = oldY;
|
||||
@@ -289,7 +289,7 @@ ptrdiff_t TextBufferCellIterator::operator-(const TextBufferCellIterator& it)
|
||||
// - Sets the coordinate position that this iterator will inspect within the text buffer on dereference.
|
||||
// Arguments:
|
||||
// - newPos - The new coordinate position.
|
||||
void TextBufferCellIterator::_SetPos(const COORD newPos)
|
||||
void TextBufferCellIterator::_SetPos(const til::point newPos)
|
||||
{
|
||||
if (newPos.Y != _pos.Y)
|
||||
{
|
||||
@@ -317,7 +317,7 @@ void TextBufferCellIterator::_SetPos(const COORD newPos)
|
||||
// - pos - Position inside screen buffer bounds to retrieve row
|
||||
// Return Value:
|
||||
// - Pointer to the underlying CharRow structure
|
||||
const ROW* TextBufferCellIterator::s_GetRow(const TextBuffer& buffer, const COORD pos)
|
||||
const ROW* TextBufferCellIterator::s_GetRow(const TextBuffer& buffer, const til::point pos)
|
||||
{
|
||||
return &buffer.GetRowByOffset(pos.Y);
|
||||
}
|
||||
@@ -354,7 +354,7 @@ const OutputCellView* TextBufferCellIterator::operator->() const noexcept
|
||||
return &_view;
|
||||
}
|
||||
|
||||
COORD TextBufferCellIterator::Pos() const noexcept
|
||||
til::point TextBufferCellIterator::Pos() const noexcept
|
||||
{
|
||||
return _pos;
|
||||
}
|
||||
|
||||
@@ -25,8 +25,8 @@ class TextBuffer;
|
||||
class TextBufferCellIterator
|
||||
{
|
||||
public:
|
||||
TextBufferCellIterator(const TextBuffer& buffer, COORD pos);
|
||||
TextBufferCellIterator(const TextBuffer& buffer, COORD pos, const Microsoft::Console::Types::Viewport limits);
|
||||
TextBufferCellIterator(const TextBuffer& buffer, til::point pos);
|
||||
TextBufferCellIterator(const TextBuffer& buffer, til::point pos, const Microsoft::Console::Types::Viewport limits);
|
||||
|
||||
operator bool() const noexcept;
|
||||
|
||||
@@ -47,12 +47,12 @@ public:
|
||||
const OutputCellView& operator*() const noexcept;
|
||||
const OutputCellView* operator->() const noexcept;
|
||||
|
||||
COORD Pos() const noexcept;
|
||||
til::point Pos() const noexcept;
|
||||
|
||||
protected:
|
||||
void _SetPos(const COORD newPos);
|
||||
void _SetPos(const til::point newPos);
|
||||
void _GenerateView();
|
||||
static const ROW* s_GetRow(const TextBuffer& buffer, const COORD pos);
|
||||
static const ROW* s_GetRow(const TextBuffer& buffer, const til::point pos);
|
||||
|
||||
OutputCellView _view;
|
||||
|
||||
@@ -61,7 +61,7 @@ protected:
|
||||
const TextBuffer& _buffer;
|
||||
const Microsoft::Console::Types::Viewport _bounds;
|
||||
bool _exceeded;
|
||||
COORD _pos;
|
||||
til::point _pos;
|
||||
|
||||
#if UNIT_TESTING
|
||||
friend class TextBufferIteratorTests;
|
||||
|
||||
@@ -36,9 +36,9 @@ namespace
|
||||
|
||||
struct TestBuffer
|
||||
{
|
||||
COORD size;
|
||||
til::size size;
|
||||
std::vector<TestRow> rows;
|
||||
COORD cursor;
|
||||
til::point cursor;
|
||||
};
|
||||
|
||||
struct TestCase
|
||||
@@ -737,7 +737,7 @@ class ReflowTests
|
||||
{
|
||||
auto buffer = std::make_unique<TextBuffer>(testBuffer.size, TextAttribute{ 0x7 }, 0, target);
|
||||
|
||||
size_t i{};
|
||||
til::CoordType i = 0;
|
||||
for (const auto& testRow : testBuffer.rows)
|
||||
{
|
||||
auto& row{ buffer->GetRowByOffset(i) };
|
||||
@@ -771,7 +771,7 @@ class ReflowTests
|
||||
return buffer;
|
||||
}
|
||||
|
||||
static std::unique_ptr<TextBuffer> _textBufferByReflowingTextBuffer(TextBuffer& originalBuffer, const COORD newSize)
|
||||
static std::unique_ptr<TextBuffer> _textBufferByReflowingTextBuffer(TextBuffer& originalBuffer, const til::size newSize)
|
||||
{
|
||||
auto buffer = std::make_unique<TextBuffer>(newSize, TextAttribute{ 0x7 }, 0, target);
|
||||
TextBuffer::Reflow(originalBuffer, *buffer, std::nullopt, std::nullopt);
|
||||
@@ -783,7 +783,7 @@ class ReflowTests
|
||||
VERIFY_ARE_EQUAL(testBuffer.cursor, buffer.GetCursor().GetPosition());
|
||||
VERIFY_ARE_EQUAL(testBuffer.size, buffer.GetSize().Dimensions());
|
||||
|
||||
size_t i{};
|
||||
til::CoordType i = 0;
|
||||
for (const auto& testRow : testBuffer.rows)
|
||||
{
|
||||
NoThrowString indexString;
|
||||
@@ -841,7 +841,7 @@ class ReflowTests
|
||||
for (size_t bufferIndex{ 1 }; bufferIndex < testCase.buffers.size(); ++bufferIndex)
|
||||
{
|
||||
const auto& testBuffer{ til::at(testCase.buffers, bufferIndex) };
|
||||
Log::Comment(NoThrowString().Format(L"[%zu.%zu] Resizing to %dx%d", i, bufferIndex, testBuffer.size.X, testBuffer.size.Y));
|
||||
Log::Comment(NoThrowString().Format(L"[%d.%d] Resizing to %dx%d", i, bufferIndex, testBuffer.size.width, testBuffer.size.height));
|
||||
|
||||
auto newBuffer{ _textBufferByReflowingTextBuffer(*textBuffer, testBuffer.size) };
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ class UnicodeStorageTests
|
||||
TEST_METHOD(CanOverwriteEmoji)
|
||||
{
|
||||
UnicodeStorage storage;
|
||||
const COORD coord{ 1, 3 };
|
||||
const til::point coord{ 1, 3 };
|
||||
const std::vector<wchar_t> newMoon{ 0xD83C, 0xDF11 };
|
||||
const std::vector<wchar_t> fullMoon{ 0xD83C, 0xDF15 };
|
||||
|
||||
|
||||
@@ -37,7 +37,6 @@ Abstract:
|
||||
|
||||
// private dependencies
|
||||
#include "../host/conddkrefs.h"
|
||||
#include "../inc/operators.hpp"
|
||||
#include "../inc/unicode.hpp"
|
||||
#pragma warning(pop)
|
||||
|
||||
|
||||
@@ -228,18 +228,18 @@ HRESULT HwndTerminal::Initialize()
|
||||
RECT windowRect;
|
||||
GetWindowRect(_hwnd.get(), &windowRect);
|
||||
|
||||
const COORD windowSize{ gsl::narrow<short>(windowRect.right - windowRect.left), gsl::narrow<short>(windowRect.bottom - windowRect.top) };
|
||||
const til::size windowSize{ windowRect.right - windowRect.left, windowRect.bottom - windowRect.top };
|
||||
|
||||
// Fist set up the dx engine with the window size in pixels.
|
||||
// Then, using the font, get the number of characters that can fit.
|
||||
const auto viewInPixels = Viewport::FromDimensions({ 0, 0 }, windowSize);
|
||||
const auto viewInPixels = Viewport::FromDimensions({}, windowSize);
|
||||
RETURN_IF_FAILED(dxEngine->SetWindowSize({ viewInPixels.Width(), viewInPixels.Height() }));
|
||||
|
||||
_renderEngine = std::move(dxEngine);
|
||||
|
||||
_terminal->SetBackgroundCallback([](auto) {});
|
||||
|
||||
_terminal->Create(COORD{ 80, 25 }, 1000, *_renderer);
|
||||
_terminal->Create(til::size{ 80, 25 }, 1000, *_renderer);
|
||||
_terminal->SetColorTableEntry(TextColor::DEFAULT_BACKGROUND, RGB(12, 12, 12));
|
||||
_terminal->SetColorTableEntry(TextColor::DEFAULT_FOREGROUND, RGB(204, 204, 204));
|
||||
_terminal->SetWriteInputCallback([=](std::wstring& input) noexcept { _WriteTextToConnection(input); });
|
||||
@@ -345,7 +345,7 @@ IRawElementProviderSimple* HwndTerminal::_GetUiaProvider() noexcept
|
||||
return _uiaProvider.Get();
|
||||
}
|
||||
|
||||
HRESULT HwndTerminal::Refresh(const SIZE windowSize, _Out_ COORD* dimensions)
|
||||
HRESULT HwndTerminal::Refresh(const til::size windowSize, _Out_ til::size* dimensions)
|
||||
{
|
||||
RETURN_HR_IF_NULL(E_INVALIDARG, dimensions);
|
||||
|
||||
@@ -359,8 +359,7 @@ HRESULT HwndTerminal::Refresh(const SIZE windowSize, _Out_ COORD* dimensions)
|
||||
_renderer->TriggerRedrawAll();
|
||||
|
||||
// Convert our new dimensions to characters
|
||||
const auto viewInPixels = Viewport::FromDimensions({ 0, 0 },
|
||||
{ gsl::narrow<short>(windowSize.cx), gsl::narrow<short>(windowSize.cy) });
|
||||
const auto viewInPixels = Viewport::FromDimensions({}, windowSize);
|
||||
const auto vp = _renderEngine->GetViewportInCharacters(viewInPixels);
|
||||
|
||||
// If this function succeeds with S_FALSE, then the terminal didn't
|
||||
@@ -370,8 +369,8 @@ HRESULT HwndTerminal::Refresh(const SIZE windowSize, _Out_ COORD* dimensions)
|
||||
// I believe we'll need support for CSI 2J, and additionally I think
|
||||
// we're resetting the viewport to the top
|
||||
RETURN_IF_FAILED(_terminal->UserResize({ vp.Width(), vp.Height() }));
|
||||
dimensions->X = vp.Width();
|
||||
dimensions->Y = vp.Height();
|
||||
dimensions->width = vp.Width();
|
||||
dimensions->height = vp.Height();
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
@@ -437,7 +436,7 @@ void _stdcall TerminalSendOutput(void* terminal, LPCWSTR data)
|
||||
/// <param name="height">New height of the terminal in pixels</param>
|
||||
/// <param name="dimensions">Out parameter containing the columns and rows that fit the new size.</param>
|
||||
/// <returns>HRESULT of the attempted resize.</returns>
|
||||
HRESULT _stdcall TerminalTriggerResize(_In_ void* terminal, _In_ short width, _In_ short height, _Out_ COORD* dimensions)
|
||||
HRESULT _stdcall TerminalTriggerResize(_In_ void* terminal, _In_ til::size windowSize, _Out_ til::size* dimensions)
|
||||
{
|
||||
const auto publicTerminal = static_cast<HwndTerminal*>(terminal);
|
||||
|
||||
@@ -446,11 +445,10 @@ HRESULT _stdcall TerminalTriggerResize(_In_ void* terminal, _In_ short width, _I
|
||||
nullptr,
|
||||
0,
|
||||
0,
|
||||
static_cast<int>(width),
|
||||
static_cast<int>(height),
|
||||
windowSize.width,
|
||||
windowSize.height,
|
||||
0));
|
||||
|
||||
const SIZE windowSize{ width, height };
|
||||
return publicTerminal->Refresh(windowSize, dimensions);
|
||||
}
|
||||
|
||||
@@ -461,21 +459,21 @@ HRESULT _stdcall TerminalTriggerResize(_In_ void* terminal, _In_ short width, _I
|
||||
/// <param name="dimensionsInCharacters">New terminal size in row and column count.</param>
|
||||
/// <param name="dimensionsInPixels">Out parameter with the new size of the renderer.</param>
|
||||
/// <returns>HRESULT of the attempted resize.</returns>
|
||||
HRESULT _stdcall TerminalTriggerResizeWithDimension(_In_ void* terminal, _In_ COORD dimensionsInCharacters, _Out_ SIZE* dimensionsInPixels)
|
||||
HRESULT _stdcall TerminalTriggerResizeWithDimension(_In_ void* terminal, _In_ til::size dimensionsInCharacters, _Out_ til::size* dimensionsInPixels)
|
||||
{
|
||||
RETURN_HR_IF_NULL(E_INVALIDARG, dimensionsInPixels);
|
||||
|
||||
const auto publicTerminal = static_cast<const HwndTerminal*>(terminal);
|
||||
|
||||
const auto viewInCharacters = Viewport::FromDimensions({ 0, 0 }, { (dimensionsInCharacters.X), (dimensionsInCharacters.Y) });
|
||||
const auto viewInCharacters = Viewport::FromDimensions({}, dimensionsInCharacters);
|
||||
const auto viewInPixels = publicTerminal->_renderEngine->GetViewportInPixels(viewInCharacters);
|
||||
|
||||
dimensionsInPixels->cx = viewInPixels.Width();
|
||||
dimensionsInPixels->cy = viewInPixels.Height();
|
||||
dimensionsInPixels->width = viewInPixels.Width();
|
||||
dimensionsInPixels->height = viewInPixels.Height();
|
||||
|
||||
COORD unused{ 0, 0 };
|
||||
til::size unused;
|
||||
|
||||
return TerminalTriggerResize(terminal, viewInPixels.Width(), viewInPixels.Height(), &unused);
|
||||
return TerminalTriggerResize(terminal, viewInPixels.Dimensions(), &unused);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -486,15 +484,15 @@ HRESULT _stdcall TerminalTriggerResizeWithDimension(_In_ void* terminal, _In_ CO
|
||||
/// <param name="height">Height of the terminal area to calculate.</param>
|
||||
/// <param name="dimensions">Out parameter containing the columns and rows that fit the new size.</param>
|
||||
/// <returns>HRESULT of the calculation.</returns>
|
||||
HRESULT _stdcall TerminalCalculateResize(_In_ void* terminal, _In_ short width, _In_ short height, _Out_ COORD* dimensions)
|
||||
HRESULT _stdcall TerminalCalculateResize(_In_ void* terminal, _In_ til::size windowSize, _Out_ til::size* dimensions)
|
||||
{
|
||||
const auto publicTerminal = static_cast<const HwndTerminal*>(terminal);
|
||||
|
||||
const auto viewInPixels = Viewport::FromDimensions({ 0, 0 }, { width, height });
|
||||
const auto viewInPixels = Viewport::FromDimensions({}, windowSize);
|
||||
const auto viewInCharacters = publicTerminal->_renderEngine->GetViewportInCharacters(viewInPixels);
|
||||
|
||||
dimensions->X = viewInCharacters.Width();
|
||||
dimensions->Y = viewInCharacters.Height();
|
||||
dimensions->width = viewInCharacters.Width();
|
||||
dimensions->height = viewInCharacters.Height();
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
@@ -550,11 +548,11 @@ try
|
||||
|
||||
if (multiClickMapper == 3)
|
||||
{
|
||||
_terminal->MultiClickSelection((cursorPosition / fontSize).to_win32_coord(), ::Terminal::SelectionExpansion::Line);
|
||||
_terminal->MultiClickSelection(cursorPosition / fontSize, ::Terminal::SelectionExpansion::Line);
|
||||
}
|
||||
else if (multiClickMapper == 2)
|
||||
{
|
||||
_terminal->MultiClickSelection((cursorPosition / fontSize).to_win32_coord(), ::Terminal::SelectionExpansion::Word);
|
||||
_terminal->MultiClickSelection(cursorPosition / fontSize, ::Terminal::SelectionExpansion::Word);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -595,13 +593,13 @@ try
|
||||
|
||||
if (distanceSquared >= maxDistanceSquared)
|
||||
{
|
||||
_terminal->SetSelectionAnchor((touchdownPoint / fontSize).to_win32_coord());
|
||||
_terminal->SetSelectionAnchor(touchdownPoint / fontSize);
|
||||
// stop tracking the touchdown point
|
||||
_singleClickTouchdownPos = std::nullopt;
|
||||
}
|
||||
}
|
||||
|
||||
this->_terminal->SetSelectionEnd((cursorPosition / fontSize).to_win32_coord());
|
||||
this->_terminal->SetSelectionEnd(cursorPosition / fontSize);
|
||||
this->_renderer->TriggerSelection();
|
||||
|
||||
return S_OK;
|
||||
@@ -714,7 +712,7 @@ try
|
||||
WI_IsFlagSet(GetKeyState(VK_RBUTTON), KeyPressed)
|
||||
};
|
||||
|
||||
return _terminal->SendMouseEvent((cursorPosition / fontSize).to_win32_coord(), uMsg, getControlKeyState(), wheelDelta, state);
|
||||
return _terminal->SendMouseEvent(cursorPosition / fontSize, uMsg, getControlKeyState(), wheelDelta, state);
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
@@ -810,8 +808,8 @@ void _stdcall TerminalSetTheme(void* terminal, TerminalTheme theme, LPCWSTR font
|
||||
RECT windowRect;
|
||||
GetWindowRect(publicTerminal->_hwnd.get(), &windowRect);
|
||||
|
||||
COORD dimensions = {};
|
||||
const SIZE windowSize{ windowRect.right - windowRect.left, windowRect.bottom - windowRect.top };
|
||||
til::size dimensions;
|
||||
const til::size windowSize{ windowRect.right - windowRect.left, windowRect.bottom - windowRect.top };
|
||||
publicTerminal->Refresh(windowSize, &dimensions);
|
||||
}
|
||||
|
||||
@@ -889,7 +887,7 @@ try
|
||||
if (fAlsoCopyFormatting)
|
||||
{
|
||||
const auto& fontData = _actualFont;
|
||||
int const iFontHeightPoints = fontData.GetUnscaledSize().Y; // this renderer uses points already
|
||||
int const iFontHeightPoints = fontData.GetUnscaledSize().height; // this renderer uses points already
|
||||
const COLORREF bgColor = _terminal->GetAttributeColors({}).second;
|
||||
|
||||
std::string HTMLToPlaceOnClip = TextBuffer::GenHTML(rows, iFontHeightPoints, fontData.GetFaceName(), bgColor);
|
||||
@@ -984,21 +982,21 @@ void HwndTerminal::_StringPaste(const wchar_t* const pData) noexcept
|
||||
CATCH_LOG();
|
||||
}
|
||||
|
||||
COORD HwndTerminal::GetFontSize() const noexcept
|
||||
til::size HwndTerminal::GetFontSize() const noexcept
|
||||
{
|
||||
return _actualFont.GetSize();
|
||||
}
|
||||
|
||||
RECT HwndTerminal::GetBounds() const noexcept
|
||||
til::rect HwndTerminal::GetBounds() const noexcept
|
||||
{
|
||||
RECT windowRect;
|
||||
GetWindowRect(_hwnd.get(), &windowRect);
|
||||
return windowRect;
|
||||
return til::rect{ windowRect };
|
||||
}
|
||||
|
||||
RECT HwndTerminal::GetPadding() const noexcept
|
||||
til::rect HwndTerminal::GetPadding() const noexcept
|
||||
{
|
||||
return { 0 };
|
||||
return {};
|
||||
}
|
||||
|
||||
double HwndTerminal::GetScaleFactor() const noexcept
|
||||
@@ -1006,7 +1004,7 @@ double HwndTerminal::GetScaleFactor() const noexcept
|
||||
return static_cast<double>(_currentDpi) / static_cast<double>(USER_DEFAULT_SCREEN_DPI);
|
||||
}
|
||||
|
||||
void HwndTerminal::ChangeViewport(const SMALL_RECT NewWindow)
|
||||
void HwndTerminal::ChangeViewport(const til::inclusive_rect NewWindow)
|
||||
{
|
||||
_terminal->UserScrollViewport(NewWindow.Top);
|
||||
}
|
||||
|
||||
@@ -27,9 +27,9 @@ extern "C" {
|
||||
__declspec(dllexport) HRESULT _stdcall CreateTerminal(HWND parentHwnd, _Out_ void** hwnd, _Out_ void** terminal);
|
||||
__declspec(dllexport) void _stdcall TerminalSendOutput(void* terminal, LPCWSTR data);
|
||||
__declspec(dllexport) void _stdcall TerminalRegisterScrollCallback(void* terminal, void __stdcall callback(int, int, int));
|
||||
__declspec(dllexport) HRESULT _stdcall TerminalTriggerResize(_In_ void* terminal, _In_ short width, _In_ short height, _Out_ COORD* dimensions);
|
||||
__declspec(dllexport) HRESULT _stdcall TerminalTriggerResizeWithDimension(_In_ void* terminal, _In_ COORD dimensions, _Out_ SIZE* dimensionsInPixels);
|
||||
__declspec(dllexport) HRESULT _stdcall TerminalCalculateResize(_In_ void* terminal, _In_ short width, _In_ short height, _Out_ COORD* dimensions);
|
||||
__declspec(dllexport) HRESULT _stdcall TerminalTriggerResize(_In_ void* terminal, _In_ til::size windowSize, _Out_ til::size* dimensions);
|
||||
__declspec(dllexport) HRESULT _stdcall TerminalTriggerResizeWithDimension(_In_ void* terminal, _In_ til::size dimensions, _Out_ til::size* dimensionsInPixels);
|
||||
__declspec(dllexport) HRESULT _stdcall TerminalCalculateResize(_In_ void* terminal, _In_ til::size windowSize, _Out_ til::size* dimensions);
|
||||
__declspec(dllexport) void _stdcall TerminalDpiChanged(void* terminal, int newDpi);
|
||||
__declspec(dllexport) void _stdcall TerminalUserScroll(void* terminal, int viewTop);
|
||||
__declspec(dllexport) void _stdcall TerminalClearSelection(void* terminal);
|
||||
@@ -60,7 +60,7 @@ public:
|
||||
HRESULT Initialize();
|
||||
void Teardown() noexcept;
|
||||
void SendOutput(std::wstring_view data);
|
||||
HRESULT Refresh(const SIZE windowSize, _Out_ COORD* dimensions);
|
||||
HRESULT Refresh(const til::size windowSize, _Out_ til::size* dimensions);
|
||||
void RegisterScrollCallback(std::function<void(int, int, int)> callback);
|
||||
void RegisterWriteCallback(const void _stdcall callback(wchar_t*));
|
||||
::Microsoft::Console::Types::IUiaData* GetUiaData() const noexcept;
|
||||
@@ -91,9 +91,9 @@ private:
|
||||
std::optional<til::point> _singleClickTouchdownPos;
|
||||
|
||||
friend HRESULT _stdcall CreateTerminal(HWND parentHwnd, _Out_ void** hwnd, _Out_ void** terminal);
|
||||
friend HRESULT _stdcall TerminalTriggerResize(_In_ void* terminal, _In_ short width, _In_ short height, _Out_ COORD* dimensions);
|
||||
friend HRESULT _stdcall TerminalTriggerResizeWithDimension(_In_ void* terminal, _In_ COORD dimensions, _Out_ SIZE* dimensionsInPixels);
|
||||
friend HRESULT _stdcall TerminalCalculateResize(_In_ void* terminal, _In_ short width, _In_ short height, _Out_ COORD* dimensions);
|
||||
friend HRESULT _stdcall TerminalTriggerResize(_In_ void* terminal, _In_ til::size windowSize, _Out_ til::size* dimensions);
|
||||
friend HRESULT _stdcall TerminalTriggerResizeWithDimension(_In_ void* terminal, _In_ til::size dimensions, _Out_ til::size* dimensionsInPixels);
|
||||
friend HRESULT _stdcall TerminalCalculateResize(_In_ void* terminal, _In_ til::size windowSize, _Out_ til::size* dimensions);
|
||||
friend void _stdcall TerminalDpiChanged(void* terminal, int newDpi);
|
||||
friend void _stdcall TerminalUserScroll(void* terminal, int viewTop);
|
||||
friend void _stdcall TerminalClearSelection(void* terminal);
|
||||
@@ -128,10 +128,10 @@ private:
|
||||
void _SendCharEvent(wchar_t ch, WORD scanCode, WORD flags) noexcept;
|
||||
|
||||
// Inherited via IControlAccessibilityInfo
|
||||
COORD GetFontSize() const noexcept override;
|
||||
RECT GetBounds() const noexcept override;
|
||||
til::size GetFontSize() const noexcept override;
|
||||
til::rect GetBounds() const noexcept override;
|
||||
double GetScaleFactor() const noexcept override;
|
||||
void ChangeViewport(const SMALL_RECT NewWindow) override;
|
||||
void ChangeViewport(const til::inclusive_rect NewWindow) override;
|
||||
HRESULT GetHostUiaProvider(IRawElementProviderSimple** provider) noexcept override;
|
||||
RECT GetPadding() const noexcept override;
|
||||
til::rect GetPadding() const noexcept override;
|
||||
};
|
||||
|
||||
@@ -9,7 +9,7 @@ using namespace winrt;
|
||||
using namespace winrt::Windows::Foundation;
|
||||
using namespace winrt::Microsoft::Terminal::TerminalConnection;
|
||||
|
||||
static COORD GetConsoleScreenSize(HANDLE outputHandle)
|
||||
static til::size GetConsoleScreenSize(HANDLE outputHandle)
|
||||
{
|
||||
CONSOLE_SCREEN_BUFFER_INFOEX csbiex{};
|
||||
csbiex.cbSize = sizeof(csbiex);
|
||||
@@ -34,7 +34,7 @@ static ConnectionState RunConnectionToCompletion(const ITerminalConnection& conn
|
||||
reader.SetWindowSizeChangedCallback([&]() {
|
||||
const auto size = GetConsoleScreenSize(outputHandle);
|
||||
|
||||
connection.Resize(size.Y, size.X);
|
||||
connection.Resize(size.height, size.width);
|
||||
});
|
||||
|
||||
while (true)
|
||||
@@ -98,8 +98,8 @@ int wmain(int /*argc*/, wchar_t** /*argv*/)
|
||||
|
||||
AzureConnection azureConn{};
|
||||
winrt::Windows::Foundation::Collections::ValueSet vs{};
|
||||
vs.Insert(L"initialRows", winrt::Windows::Foundation::PropertyValue::CreateUInt32(gsl::narrow_cast<uint32_t>(size.Y)));
|
||||
vs.Insert(L"initialCols", winrt::Windows::Foundation::PropertyValue::CreateUInt32(gsl::narrow_cast<uint32_t>(size.X)));
|
||||
vs.Insert(L"initialRows", winrt::Windows::Foundation::PropertyValue::CreateUInt32(gsl::narrow_cast<uint32_t>(size.height)));
|
||||
vs.Insert(L"initialCols", winrt::Windows::Foundation::PropertyValue::CreateUInt32(gsl::narrow_cast<uint32_t>(size.width)));
|
||||
azureConn.Initialize(vs);
|
||||
|
||||
const auto state = RunConnectionToCompletion(azureConn, conOut, conIn);
|
||||
|
||||
@@ -45,7 +45,7 @@ namespace winrt::Microsoft::Terminal::TerminalConnection::implementation
|
||||
// - phOutput: Receives the handle to the newly-created anonymous pipe for reading the output of the conpty.
|
||||
// - phPc: Receives a token value to identify this conpty
|
||||
#pragma warning(suppress : 26430) // This statement sufficiently checks the out parameters. Analyzer cannot find this.
|
||||
static HRESULT _CreatePseudoConsoleAndPipes(const COORD size, const DWORD dwFlags, HANDLE* phInput, HANDLE* phOutput, HPCON* phPC) noexcept
|
||||
static HRESULT _CreatePseudoConsoleAndPipes(const til::point size, const DWORD dwFlags, HANDLE* phInput, HANDLE* phOutput, HPCON* phPC) noexcept
|
||||
{
|
||||
RETURN_HR_IF(E_INVALIDARG, phPC == nullptr || phInput == nullptr || phOutput == nullptr);
|
||||
|
||||
@@ -289,7 +289,7 @@ namespace winrt::Microsoft::Terminal::TerminalConnection::implementation
|
||||
{
|
||||
_transitionToState(ConnectionState::Connecting);
|
||||
|
||||
const COORD dimensions{ gsl::narrow_cast<SHORT>(_initialCols), gsl::narrow_cast<SHORT>(_initialRows) };
|
||||
const til::point dimensions{ _initialCols, _initialRows };
|
||||
|
||||
// If we do not have pipes already, then this is a fresh connection... not an inbound one that is a received
|
||||
// handoff from an already-started PTY process.
|
||||
|
||||
@@ -63,8 +63,8 @@ namespace winrt::Microsoft::Terminal::TerminalConnection::implementation
|
||||
void _indicateExitWithStatus(unsigned int status) noexcept;
|
||||
void _ClientTerminated() noexcept;
|
||||
|
||||
uint32_t _initialRows{};
|
||||
uint32_t _initialCols{};
|
||||
til::CoordType _initialRows{};
|
||||
til::CoordType _initialCols{};
|
||||
hstring _commandline{};
|
||||
hstring _startingDirectory{};
|
||||
hstring _startingTitle{};
|
||||
|
||||
@@ -245,8 +245,7 @@ namespace winrt::Microsoft::Terminal::Control::implementation
|
||||
// and react accordingly.
|
||||
_updateFont(true);
|
||||
|
||||
const COORD windowSize{ static_cast<short>(windowWidth),
|
||||
static_cast<short>(windowHeight) };
|
||||
const til::size windowSize{ til::math::flooring, windowWidth, windowHeight };
|
||||
|
||||
// First set up the dx engine with the window size in pixels.
|
||||
// Then, using the font, get the number of characters that can fit.
|
||||
@@ -423,7 +422,7 @@ namespace winrt::Microsoft::Terminal::Control::implementation
|
||||
const short wheelDelta,
|
||||
const TerminalInput::MouseButtonState state)
|
||||
{
|
||||
return _terminal->SendMouseEvent(viewportPos.to_win32_coord(), uiButton, states, wheelDelta, state);
|
||||
return _terminal->SendMouseEvent(viewportPos, uiButton, states, wheelDelta, state);
|
||||
}
|
||||
|
||||
void ControlCore::UserScrollViewport(const int viewTop)
|
||||
@@ -546,12 +545,12 @@ namespace winrt::Microsoft::Terminal::Control::implementation
|
||||
_lastHoveredCell = terminalPosition;
|
||||
uint16_t newId{ 0u };
|
||||
// we can't use auto here because we're pre-declaring newInterval.
|
||||
decltype(_terminal->GetHyperlinkIntervalFromPosition(COORD{})) newInterval{ std::nullopt };
|
||||
decltype(_terminal->GetHyperlinkIntervalFromPosition(til::point{})) newInterval{ std::nullopt };
|
||||
if (terminalPosition.has_value())
|
||||
{
|
||||
auto lock = _terminal->LockForReading(); // Lock for the duration of our reads.
|
||||
newId = _terminal->GetHyperlinkIdAtPosition(terminalPosition->to_win32_coord());
|
||||
newInterval = _terminal->GetHyperlinkIntervalFromPosition(terminalPosition->to_win32_coord());
|
||||
newId = _terminal->GetHyperlinkIdAtPosition(*terminalPosition);
|
||||
newInterval = _terminal->GetHyperlinkIntervalFromPosition(*terminalPosition);
|
||||
}
|
||||
|
||||
// If the hyperlink ID changed or the interval changed, trigger a redraw all
|
||||
@@ -581,7 +580,7 @@ namespace winrt::Microsoft::Terminal::Control::implementation
|
||||
{
|
||||
// Lock for the duration of our reads.
|
||||
auto lock = _terminal->LockForReading();
|
||||
return winrt::hstring{ _terminal->GetHyperlinkAtPosition(til::point{ pos }.to_win32_coord()) };
|
||||
return winrt::hstring{ _terminal->GetHyperlinkAtPosition(til::point{ pos }) };
|
||||
}
|
||||
|
||||
winrt::hstring ControlCore::HoveredUriText() const
|
||||
@@ -589,7 +588,7 @@ namespace winrt::Microsoft::Terminal::Control::implementation
|
||||
auto lock = _terminal->LockForReading(); // Lock for the duration of our reads.
|
||||
if (_lastHoveredCell.has_value())
|
||||
{
|
||||
return winrt::hstring{ _terminal->GetHyperlinkAtPosition(_lastHoveredCell->to_win32_coord()) };
|
||||
return winrt::hstring{ _terminal->GetHyperlinkAtPosition(*_lastHoveredCell) };
|
||||
}
|
||||
return {};
|
||||
}
|
||||
@@ -621,7 +620,7 @@ namespace winrt::Microsoft::Terminal::Control::implementation
|
||||
|
||||
// Initialize our font information.
|
||||
const auto fontFace = _settings->FontFace();
|
||||
const short fontHeight = ::base::saturated_cast<short>(_settings->FontSize());
|
||||
const auto fontHeight = _settings->FontSize();
|
||||
const auto fontWeight = _settings->FontWeight();
|
||||
// The font width doesn't terribly matter, we'll only be using the
|
||||
// height to look it up
|
||||
@@ -760,7 +759,7 @@ namespace winrt::Microsoft::Terminal::Control::implementation
|
||||
}
|
||||
|
||||
const auto actualNewSize = _actualFont.GetSize();
|
||||
_FontSizeChangedHandlers(actualNewSize.X, actualNewSize.Y, initialUpdate);
|
||||
_FontSizeChangedHandlers(actualNewSize.width, actualNewSize.height, initialUpdate);
|
||||
}
|
||||
|
||||
// Method Description:
|
||||
@@ -772,7 +771,7 @@ namespace winrt::Microsoft::Terminal::Control::implementation
|
||||
try
|
||||
{
|
||||
// Make sure we have a non-zero font size
|
||||
const auto newSize = std::max<short>(gsl::narrow_cast<short>(fontSize), 1);
|
||||
const auto newSize = std::max(fontSize, 1);
|
||||
const auto fontFace = _settings->FontFace();
|
||||
const auto fontWeight = _settings->FontWeight();
|
||||
_actualFont = { fontFace, 0, fontWeight.Weight, { 0, newSize }, CP_UTF8, false };
|
||||
@@ -808,7 +807,7 @@ namespace winrt::Microsoft::Terminal::Control::implementation
|
||||
// - fontSizeDelta: The amount to increase or decrease the font size by.
|
||||
void ControlCore::AdjustFontSize(int fontSizeDelta)
|
||||
{
|
||||
const auto newSize = _desiredFont.GetEngineSize().Y + fontSizeDelta;
|
||||
const auto newSize = _desiredFont.GetEngineSize().height + fontSizeDelta;
|
||||
_setFontSize(newSize);
|
||||
}
|
||||
|
||||
@@ -844,20 +843,17 @@ namespace winrt::Microsoft::Terminal::Control::implementation
|
||||
void ControlCore::_doResizeUnderLock(const double newWidth,
|
||||
const double newHeight)
|
||||
{
|
||||
SIZE size;
|
||||
size.cx = static_cast<long>(newWidth);
|
||||
size.cy = static_cast<long>(newHeight);
|
||||
til::size size{ til::math::flooring, newWidth, newHeight };
|
||||
|
||||
// Don't actually resize so small that a single character wouldn't fit
|
||||
// in either dimension. The buffer really doesn't like being size 0.
|
||||
if (size.cx < _actualFont.GetSize().X || size.cy < _actualFont.GetSize().Y)
|
||||
if (size.width < _actualFont.GetSize().width || size.height < _actualFont.GetSize().height)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Convert our new dimensions to characters
|
||||
const auto viewInPixels = Viewport::FromDimensions({ 0, 0 },
|
||||
{ static_cast<short>(size.cx), static_cast<short>(size.cy) });
|
||||
const auto viewInPixels = Viewport::FromExclusive({ 0, 0, size.width, size.height });
|
||||
const auto vp = _renderEngine->GetViewportInCharacters(viewInPixels);
|
||||
const auto currentVP = _terminal->GetViewport();
|
||||
|
||||
@@ -934,17 +930,17 @@ namespace winrt::Microsoft::Terminal::Control::implementation
|
||||
}
|
||||
}
|
||||
|
||||
void ControlCore::SetSelectionAnchor(til::point const& position)
|
||||
void ControlCore::SetSelectionAnchor(const til::point position)
|
||||
{
|
||||
auto lock = _terminal->LockForWriting();
|
||||
_terminal->SetSelectionAnchor(position.to_win32_coord());
|
||||
_terminal->SetSelectionAnchor(position);
|
||||
}
|
||||
|
||||
// Method Description:
|
||||
// - Sets selection's end position to match supplied cursor position, e.g. while mouse dragging.
|
||||
// Arguments:
|
||||
// - position: the point in terminal coordinates (in cells, not pixels)
|
||||
void ControlCore::SetEndSelectionPoint(til::point const& position)
|
||||
void ControlCore::SetEndSelectionPoint(const til::point position)
|
||||
{
|
||||
if (!_terminal->IsSelectionActive())
|
||||
{
|
||||
@@ -961,7 +957,7 @@ namespace winrt::Microsoft::Terminal::Control::implementation
|
||||
};
|
||||
|
||||
// save location (for rendering) + render
|
||||
_terminal->SetSelectionEnd(terminalPosition.to_win32_coord());
|
||||
_terminal->SetSelectionEnd(terminalPosition);
|
||||
_renderer->TriggerSelection();
|
||||
}
|
||||
|
||||
@@ -1008,7 +1004,7 @@ namespace winrt::Microsoft::Terminal::Control::implementation
|
||||
// content, which is unexpected.
|
||||
const auto htmlData = formats == nullptr || WI_IsFlagSet(formats.Value(), CopyFormat::HTML) ?
|
||||
TextBuffer::GenHTML(bufferData,
|
||||
_actualFont.GetUnscaledSize().Y,
|
||||
_actualFont.GetUnscaledSize().height,
|
||||
_actualFont.GetFaceName(),
|
||||
bgColor) :
|
||||
"";
|
||||
@@ -1016,7 +1012,7 @@ namespace winrt::Microsoft::Terminal::Control::implementation
|
||||
// convert to RTF format
|
||||
const auto rtfData = formats == nullptr || WI_IsFlagSet(formats.Value(), CopyFormat::RTF) ?
|
||||
TextBuffer::GenRTF(bufferData,
|
||||
_actualFont.GetUnscaledSize().Y,
|
||||
_actualFont.GetUnscaledSize().height,
|
||||
_actualFont.GetFaceName(),
|
||||
bgColor) :
|
||||
"";
|
||||
@@ -1056,8 +1052,8 @@ namespace winrt::Microsoft::Terminal::Control::implementation
|
||||
{
|
||||
const auto fontSize = _actualFont.GetSize();
|
||||
return {
|
||||
::base::saturated_cast<float>(fontSize.X),
|
||||
::base::saturated_cast<float>(fontSize.Y)
|
||||
static_cast<float>(fontSize.width),
|
||||
static_cast<float>(fontSize.height)
|
||||
};
|
||||
}
|
||||
winrt::hstring ControlCore::FontFaceName() const noexcept
|
||||
@@ -1490,7 +1486,7 @@ namespace winrt::Microsoft::Terminal::Control::implementation
|
||||
{
|
||||
// If shift is pressed and there is a selection we extend it using
|
||||
// the selection mode (expand the "end" selection point)
|
||||
_terminal->SetSelectionEnd(terminalPosition.to_win32_coord(), mode);
|
||||
_terminal->SetSelectionEnd(terminalPosition, mode);
|
||||
selectionNeedsToBeCopied = true;
|
||||
}
|
||||
else if (mode != ::Terminal::SelectionExpansion::Char || shiftEnabled)
|
||||
@@ -1498,7 +1494,7 @@ namespace winrt::Microsoft::Terminal::Control::implementation
|
||||
// If we are handling a double / triple-click or shift+single click
|
||||
// we establish selection using the selected mode
|
||||
// (expand both "start" and "end" selection points)
|
||||
_terminal->MultiClickSelection(terminalPosition.to_win32_coord(), mode);
|
||||
_terminal->MultiClickSelection(terminalPosition, mode);
|
||||
selectionNeedsToBeCopied = true;
|
||||
}
|
||||
|
||||
|
||||
@@ -143,8 +143,8 @@ namespace winrt::Microsoft::Terminal::Control::implementation
|
||||
bool HasSelection() const;
|
||||
bool CopyOnSelect() const;
|
||||
Windows::Foundation::Collections::IVector<winrt::hstring> SelectedText(bool trimTrailingWhitespace) const;
|
||||
void SetSelectionAnchor(til::point const& position);
|
||||
void SetEndSelectionPoint(til::point const& position);
|
||||
void SetSelectionAnchor(const til::point position);
|
||||
void SetEndSelectionPoint(const til::point position);
|
||||
|
||||
void Search(const winrt::hstring& text,
|
||||
const bool goForward,
|
||||
@@ -226,7 +226,7 @@ namespace winrt::Microsoft::Terminal::Control::implementation
|
||||
|
||||
bool _isReadOnly{ false };
|
||||
|
||||
std::optional<interval_tree::IntervalTree<til::point, size_t>::interval> _lastHoveredInterval{ std::nullopt };
|
||||
std::optional<interval_tree::IntervalTree<til::point, til::CoordType>::interval> _lastHoveredInterval{ std::nullopt };
|
||||
|
||||
// These members represent the size of the surface that we should be
|
||||
// rendering to.
|
||||
|
||||
@@ -194,7 +194,7 @@ namespace winrt::Microsoft::Terminal::Control::implementation
|
||||
const ::Microsoft::Terminal::Core::ControlKeyStates modifiers,
|
||||
const Core::Point pixelPosition)
|
||||
{
|
||||
const til::point terminalPosition = _getTerminalPosition(til::point{ pixelPosition });
|
||||
const auto terminalPosition = _getTerminalPosition(til::point{ pixelPosition });
|
||||
|
||||
const auto altEnabled = modifiers.IsAltPressed();
|
||||
const auto shiftEnabled = modifiers.IsShiftPressed();
|
||||
@@ -277,7 +277,7 @@ namespace winrt::Microsoft::Terminal::Control::implementation
|
||||
const Core::Point pixelPosition,
|
||||
const bool pointerPressedInBounds)
|
||||
{
|
||||
const til::point terminalPosition = _getTerminalPosition(til::point{ pixelPosition });
|
||||
const auto terminalPosition = _getTerminalPosition(til::point{ pixelPosition });
|
||||
|
||||
// Short-circuit isReadOnly check to avoid warning dialog
|
||||
if (focused && !_core->IsInReadOnlyMode() && _canSendVTMouseInput(modifiers))
|
||||
|
||||
@@ -123,11 +123,11 @@ namespace winrt::Microsoft::Terminal::Control::implementation
|
||||
// terminal.
|
||||
bool _selectionNeedsToBeCopied;
|
||||
|
||||
std::optional<COORD> _lastHoveredCell{ std::nullopt };
|
||||
std::optional<til::point> _lastHoveredCell{ std::nullopt };
|
||||
// Track the last hyperlink ID we hovered over
|
||||
uint16_t _lastHoveredId{ 0 };
|
||||
|
||||
std::optional<interval_tree::IntervalTree<til::point, size_t>::interval> _lastHoveredInterval{ std::nullopt };
|
||||
std::optional<interval_tree::IntervalTree<til::point, til::CoordType>::interval> _lastHoveredInterval{ std::nullopt };
|
||||
|
||||
unsigned int _numberOfClicks(Core::Point clickPos, Timestamp clickTime);
|
||||
void _updateSystemParameterSettings() noexcept;
|
||||
|
||||
@@ -141,14 +141,14 @@ namespace winrt::Microsoft::Terminal::Control::implementation
|
||||
#pragma endregion
|
||||
|
||||
#pragma region IControlAccessibilityInfo
|
||||
COORD InteractivityAutomationPeer::GetFontSize() const noexcept
|
||||
til::size InteractivityAutomationPeer::GetFontSize() const noexcept
|
||||
{
|
||||
return til::size{ til::math::rounding, _interactivity->Core().FontSize() }.to_win32_coord();
|
||||
return til::size{ til::math::rounding, _interactivity->Core().FontSize() };
|
||||
}
|
||||
|
||||
RECT InteractivityAutomationPeer::GetBounds() const noexcept
|
||||
til::rect InteractivityAutomationPeer::GetBounds() const noexcept
|
||||
{
|
||||
return _controlBounds.to_win32_rect();
|
||||
return _controlBounds;
|
||||
}
|
||||
|
||||
HRESULT InteractivityAutomationPeer::GetHostUiaProvider(IRawElementProviderSimple** provider)
|
||||
@@ -159,9 +159,9 @@ namespace winrt::Microsoft::Terminal::Control::implementation
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
RECT InteractivityAutomationPeer::GetPadding() const noexcept
|
||||
til::rect InteractivityAutomationPeer::GetPadding() const noexcept
|
||||
{
|
||||
return _controlPadding.to_win32_rect();
|
||||
return _controlPadding;
|
||||
}
|
||||
|
||||
double InteractivityAutomationPeer::GetScaleFactor() const noexcept
|
||||
@@ -169,7 +169,7 @@ namespace winrt::Microsoft::Terminal::Control::implementation
|
||||
return DisplayInformation::GetForCurrentView().RawPixelsPerViewPixel();
|
||||
}
|
||||
|
||||
void InteractivityAutomationPeer::ChangeViewport(const SMALL_RECT NewWindow)
|
||||
void InteractivityAutomationPeer::ChangeViewport(const til::inclusive_rect NewWindow)
|
||||
{
|
||||
_interactivity->UpdateScrollbar(NewWindow.Top);
|
||||
}
|
||||
|
||||
@@ -62,11 +62,11 @@ namespace winrt::Microsoft::Terminal::Control::implementation
|
||||
|
||||
#pragma region IControlAccessibilityInfo Pattern
|
||||
// Inherited via IControlAccessibilityInfo
|
||||
virtual COORD GetFontSize() const noexcept override;
|
||||
virtual RECT GetBounds() const noexcept override;
|
||||
virtual RECT GetPadding() const noexcept override;
|
||||
virtual til::size GetFontSize() const noexcept override;
|
||||
virtual til::rect GetBounds() const noexcept override;
|
||||
virtual til::rect GetPadding() const noexcept override;
|
||||
virtual double GetScaleFactor() const noexcept override;
|
||||
virtual void ChangeViewport(SMALL_RECT NewWindow) override;
|
||||
virtual void ChangeViewport(const til::inclusive_rect NewWindow) override;
|
||||
virtual HRESULT GetHostUiaProvider(IRawElementProviderSimple** provider) override;
|
||||
#pragma endregion
|
||||
|
||||
|
||||
@@ -1146,7 +1146,7 @@ namespace winrt::Microsoft::Terminal::Control::implementation
|
||||
TermControl::GetPointerUpdateKind(point),
|
||||
point.Timestamp(),
|
||||
ControlKeyStates{ args.KeyModifiers() },
|
||||
_toTerminalOrigin(cursorPosition).to_core_point());
|
||||
_toTerminalOrigin(cursorPosition));
|
||||
}
|
||||
|
||||
args.Handled(true);
|
||||
@@ -1185,7 +1185,7 @@ namespace winrt::Microsoft::Terminal::Control::implementation
|
||||
TermControl::GetPointerUpdateKind(point),
|
||||
ControlKeyStates(args.KeyModifiers()),
|
||||
_focused,
|
||||
pixelPosition.to_core_point(),
|
||||
pixelPosition,
|
||||
_pointerPressedInBounds);
|
||||
|
||||
// GH#9109 - Only start an auto-scroll when the drag actually
|
||||
@@ -1263,7 +1263,7 @@ namespace winrt::Microsoft::Terminal::Control::implementation
|
||||
_interactivity.PointerReleased(TermControl::GetPressedMouseButtons(point),
|
||||
TermControl::GetPointerUpdateKind(point),
|
||||
ControlKeyStates(args.KeyModifiers()),
|
||||
pixelPosition.to_core_point());
|
||||
pixelPosition);
|
||||
}
|
||||
else if (type == Windows::Devices::Input::PointerDeviceType::Touch)
|
||||
{
|
||||
@@ -1303,7 +1303,7 @@ namespace winrt::Microsoft::Terminal::Control::implementation
|
||||
|
||||
auto result = _interactivity.MouseWheel(ControlKeyStates{ args.KeyModifiers() },
|
||||
point.Properties().MouseWheelDelta(),
|
||||
_toTerminalOrigin(point.Position()).to_core_point(),
|
||||
_toTerminalOrigin(point.Position()),
|
||||
TermControl::GetPressedMouseButtons(point));
|
||||
if (result)
|
||||
{
|
||||
@@ -1334,7 +1334,7 @@ namespace winrt::Microsoft::Terminal::Control::implementation
|
||||
WI_SetFlagIf(state, Control::MouseButtonState::IsMiddleButtonDown, midButtonDown);
|
||||
WI_SetFlagIf(state, Control::MouseButtonState::IsRightButtonDown, rightButtonDown);
|
||||
|
||||
return _interactivity.MouseWheel(modifiers, delta, _toTerminalOrigin(location).to_core_point(), state);
|
||||
return _interactivity.MouseWheel(modifiers, delta, _toTerminalOrigin(location), state);
|
||||
}
|
||||
|
||||
// Method Description:
|
||||
@@ -1704,7 +1704,7 @@ namespace winrt::Microsoft::Terminal::Control::implementation
|
||||
// - cursorPosition: in pixels, relative to the origin of the control
|
||||
void TermControl::_SetEndSelectionPointAtCursor(Windows::Foundation::Point const& cursorPosition)
|
||||
{
|
||||
_interactivity.SetEndSelectionPoint(_toTerminalOrigin(cursorPosition).to_core_point());
|
||||
_interactivity.SetEndSelectionPoint(_toTerminalOrigin(cursorPosition));
|
||||
}
|
||||
|
||||
// Method Description:
|
||||
@@ -1933,7 +1933,7 @@ namespace winrt::Microsoft::Terminal::Control::implementation
|
||||
// ComCtl scrollbars, but it's certainly close enough.
|
||||
const auto scrollbarSize = GetSystemMetricsForDpi(SM_CXVSCROLL, dpi);
|
||||
|
||||
double width = cols * actualFontSize.X;
|
||||
double width = cols * actualFontSize.width;
|
||||
|
||||
// Reserve additional space if scrollbar is intended to be visible
|
||||
if (scrollState == ScrollbarState::Visible)
|
||||
@@ -1941,7 +1941,7 @@ namespace winrt::Microsoft::Terminal::Control::implementation
|
||||
width += scrollbarSize;
|
||||
}
|
||||
|
||||
double height = rows * actualFontSize.Y;
|
||||
double height = rows * actualFontSize.height;
|
||||
const auto thickness = ParseThicknessFromPadding(padding);
|
||||
// GH#2061 - make sure to account for the size the padding _will be_ scaled to
|
||||
width += scale * (thickness.Left + thickness.Right);
|
||||
@@ -2147,7 +2147,7 @@ namespace winrt::Microsoft::Terminal::Control::implementation
|
||||
// NOTE: origin (0,0) is top-left.
|
||||
// Return Value:
|
||||
// - the corresponding viewport terminal position (in pixels) for the given Point parameter
|
||||
const til::point TermControl::_toTerminalOrigin(winrt::Windows::Foundation::Point cursorPosition)
|
||||
Core::Point TermControl::_toTerminalOrigin(winrt::Windows::Foundation::Point cursorPosition)
|
||||
{
|
||||
// cursorPosition is DIPs, relative to SwapChainPanel origin
|
||||
const til::point cursorPosInDIPs{ til::math::rounding, cursorPosition };
|
||||
@@ -2164,7 +2164,7 @@ namespace winrt::Microsoft::Terminal::Control::implementation
|
||||
relativeToMarginInDIPs.y * scale,
|
||||
};
|
||||
|
||||
return relativeToMarginInPixels;
|
||||
return { relativeToMarginInPixels.X, relativeToMarginInPixels.Y };
|
||||
}
|
||||
|
||||
// Method Description:
|
||||
|
||||
@@ -256,7 +256,7 @@ namespace winrt::Microsoft::Terminal::Control::implementation
|
||||
static void _ClearKeyboardState(const WORD vkey, const WORD scanCode) noexcept;
|
||||
bool _TrySendKeyEvent(const WORD vkey, const WORD scanCode, ::Microsoft::Terminal::Core::ControlKeyStates modifiers, const bool keyDown);
|
||||
|
||||
const til::point _toTerminalOrigin(winrt::Windows::Foundation::Point cursorPosition);
|
||||
Core::Point _toTerminalOrigin(winrt::Windows::Foundation::Point cursorPosition);
|
||||
double _GetAutoScrollSpeed(double cursorDistanceFromBorder) const;
|
||||
|
||||
void _Search(const winrt::hstring& text, const bool goForward, const bool caseSensitive);
|
||||
|
||||
@@ -26,15 +26,15 @@ namespace Microsoft::Terminal::Core
|
||||
virtual void SetTextAttributes(const TextAttribute& attrs) noexcept = 0;
|
||||
|
||||
virtual Microsoft::Console::Types::Viewport GetBufferSize() noexcept = 0;
|
||||
virtual bool SetCursorPosition(short x, short y) noexcept = 0;
|
||||
virtual COORD GetCursorPosition() noexcept = 0;
|
||||
virtual bool SetCursorPosition(til::point pos) noexcept = 0;
|
||||
virtual til::point GetCursorPosition() noexcept = 0;
|
||||
virtual bool SetCursorVisibility(const bool visible) noexcept = 0;
|
||||
virtual bool CursorLineFeed(const bool withReturn) noexcept = 0;
|
||||
virtual bool EnableCursorBlinking(const bool enable) noexcept = 0;
|
||||
|
||||
virtual bool DeleteCharacter(const size_t count) noexcept = 0;
|
||||
virtual bool InsertCharacter(const size_t count) noexcept = 0;
|
||||
virtual bool EraseCharacters(const size_t numChars) noexcept = 0;
|
||||
virtual bool DeleteCharacter(const til::CoordType count) noexcept = 0;
|
||||
virtual bool InsertCharacter(const til::CoordType count) noexcept = 0;
|
||||
virtual bool EraseCharacters(const til::CoordType numChars) noexcept = 0;
|
||||
virtual bool EraseInLine(const ::Microsoft::Console::VirtualTerminal::DispatchTypes::EraseType eraseType) noexcept = 0;
|
||||
virtual bool EraseInDisplay(const ::Microsoft::Console::VirtualTerminal::DispatchTypes::EraseType eraseType) noexcept = 0;
|
||||
|
||||
|
||||
@@ -17,10 +17,10 @@ namespace Microsoft::Terminal::Core
|
||||
ITerminalInput& operator=(ITerminalInput&&) = default;
|
||||
|
||||
virtual bool SendKeyEvent(const WORD vkey, const WORD scanCode, const ControlKeyStates states, const bool keyDown) = 0;
|
||||
virtual bool SendMouseEvent(const COORD viewportPos, const unsigned int uiButton, const ControlKeyStates states, const short wheelDelta, const Microsoft::Console::VirtualTerminal::TerminalInput::MouseButtonState state) = 0;
|
||||
virtual bool SendMouseEvent(const til::point viewportPos, const unsigned int uiButton, const ControlKeyStates states, const short wheelDelta, const Microsoft::Console::VirtualTerminal::TerminalInput::MouseButtonState state) = 0;
|
||||
virtual bool SendCharEvent(const wchar_t ch, const WORD scanCode, const ControlKeyStates states) = 0;
|
||||
|
||||
[[nodiscard]] virtual HRESULT UserResize(const COORD size) noexcept = 0;
|
||||
[[nodiscard]] virtual HRESULT UserResize(const til::size size) noexcept = 0;
|
||||
virtual void UserScrollViewport(const int viewTop) = 0;
|
||||
virtual int GetScrollOffset() = 0;
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ using namespace Microsoft::Console::Render;
|
||||
using namespace Microsoft::Console::Types;
|
||||
using namespace Microsoft::Console::VirtualTerminal;
|
||||
|
||||
using PointTree = interval_tree::IntervalTree<til::point, size_t>;
|
||||
using PointTree = interval_tree::IntervalTree<til::point, til::CoordType>;
|
||||
|
||||
static std::wstring _KeyEventsToText(std::deque<std::unique_ptr<IInputEvent>>& inEventsToWrite)
|
||||
{
|
||||
@@ -77,12 +77,12 @@ Terminal::Terminal() :
|
||||
_renderSettings.SetColorAlias(ColorAlias::DefaultBackground, TextColor::DEFAULT_BACKGROUND, RGB(0, 0, 0));
|
||||
}
|
||||
|
||||
void Terminal::Create(COORD viewportSize, SHORT scrollbackLines, IRenderTarget& renderTarget)
|
||||
void Terminal::Create(til::size viewportSize, til::CoordType scrollbackLines, IRenderTarget& renderTarget)
|
||||
{
|
||||
_mutableViewport = Viewport::FromDimensions({ 0, 0 }, viewportSize);
|
||||
_scrollbackLines = scrollbackLines;
|
||||
const COORD bufferSize{ viewportSize.X,
|
||||
Utils::ClampToShortMax(viewportSize.Y + scrollbackLines, 1) };
|
||||
const til::size bufferSize{ viewportSize.width,
|
||||
Utils::ClampToShortMax(viewportSize.height + scrollbackLines, 1) };
|
||||
const TextAttribute attr{};
|
||||
const UINT cursorSize = 12;
|
||||
_buffer = std::make_unique<TextBuffer>(bufferSize, attr, cursorSize, renderTarget);
|
||||
@@ -96,8 +96,8 @@ void Terminal::Create(COORD viewportSize, SHORT scrollbackLines, IRenderTarget&
|
||||
void Terminal::CreateFromSettings(ICoreSettings settings,
|
||||
IRenderTarget& renderTarget)
|
||||
{
|
||||
const COORD viewportSize{ Utils::ClampToShortMax(settings.InitialCols(), 1),
|
||||
Utils::ClampToShortMax(settings.InitialRows(), 1) };
|
||||
const til::size viewportSize{ Utils::ClampToShortMax(settings.InitialCols(), 1),
|
||||
Utils::ClampToShortMax(settings.InitialRows(), 1) };
|
||||
|
||||
// TODO:MSFT:20642297 - Support infinite scrollback here, if HistorySize is -1
|
||||
Create(viewportSize, Utils::ClampToShortMax(settings.HistorySize(), 0), renderTarget);
|
||||
@@ -229,7 +229,7 @@ void Terminal::UpdateAppearance(const ICoreAppearance& appearance)
|
||||
// - S_OK if we successfully resized the terminal, S_FALSE if there was
|
||||
// nothing to do (the viewportSize is the same as our current size), or an
|
||||
// appropriate HRESULT for failing to resize.
|
||||
[[nodiscard]] HRESULT Terminal::UserResize(const COORD viewportSize) noexcept
|
||||
[[nodiscard]] HRESULT Terminal::UserResize(const til::size viewportSize) noexcept
|
||||
{
|
||||
const auto oldDimensions = _mutableViewport.Dimensions();
|
||||
if (viewportSize == oldDimensions)
|
||||
@@ -237,15 +237,15 @@ void Terminal::UpdateAppearance(const ICoreAppearance& appearance)
|
||||
return S_FALSE;
|
||||
}
|
||||
|
||||
const auto dx = ::base::ClampSub(viewportSize.X, oldDimensions.X);
|
||||
const short newBufferHeight = ::base::ClampAdd(viewportSize.Y, _scrollbackLines);
|
||||
const auto dx = ::base::ClampSub(viewportSize.width, oldDimensions.width);
|
||||
const auto newBufferHeight = ::base::ClampAdd(viewportSize.height, _scrollbackLines);
|
||||
|
||||
COORD bufferSize{ viewportSize.X, newBufferHeight };
|
||||
til::size bufferSize{ viewportSize.width, newBufferHeight };
|
||||
|
||||
// This will be used to determine where the viewport should be in the new buffer.
|
||||
const short oldViewportTop = _mutableViewport.Top();
|
||||
short newViewportTop = oldViewportTop;
|
||||
short newVisibleTop = ::base::saturated_cast<short>(_VisibleStartIndex());
|
||||
const auto oldViewportTop = _mutableViewport.Top();
|
||||
auto newViewportTop = oldViewportTop;
|
||||
auto newVisibleTop = _VisibleStartIndex();
|
||||
|
||||
// If the original buffer had _no_ scroll offset, then we should be at the
|
||||
// bottom in the new buffer as well. Track that case now.
|
||||
@@ -287,7 +287,6 @@ void Terminal::UpdateAppearance(const ICoreAppearance& appearance)
|
||||
oldRows.mutableViewportTop = oldViewportTop;
|
||||
oldRows.visibleViewportTop = newVisibleTop;
|
||||
|
||||
const std::optional<short> oldViewStart{ oldViewportTop };
|
||||
RETURN_IF_FAILED(TextBuffer::Reflow(*_buffer.get(),
|
||||
*newTextBuffer.get(),
|
||||
_mutableViewport,
|
||||
@@ -328,10 +327,10 @@ void Terminal::UpdateAppearance(const ICoreAppearance& appearance)
|
||||
// * Where the bottom of the text in the new buffer is (and using that to
|
||||
// calculate another proposed top location).
|
||||
|
||||
const COORD newCursorPos = newTextBuffer->GetCursor().GetPosition();
|
||||
const auto newCursorPos = newTextBuffer->GetCursor().GetPosition();
|
||||
#pragma warning(push)
|
||||
#pragma warning(disable : 26496) // cpp core checks wants this const, but it's assigned immediately below...
|
||||
COORD newLastChar = newCursorPos;
|
||||
auto newLastChar = newCursorPos;
|
||||
try
|
||||
{
|
||||
newLastChar = newTextBuffer->GetLastNonSpaceCharacter();
|
||||
@@ -341,11 +340,11 @@ void Terminal::UpdateAppearance(const ICoreAppearance& appearance)
|
||||
|
||||
const auto maxRow = std::max(newLastChar.Y, newCursorPos.Y);
|
||||
|
||||
const short proposedTopFromLastLine = ::base::ClampAdd(::base::ClampSub(maxRow, viewportSize.Y), 1);
|
||||
const short proposedTopFromScrollback = newViewportTop;
|
||||
const til::CoordType proposedTopFromLastLine = ::base::ClampAdd(::base::ClampSub(maxRow, viewportSize.height), 1);
|
||||
const auto proposedTopFromScrollback = newViewportTop;
|
||||
|
||||
short proposedTop = std::max(proposedTopFromLastLine,
|
||||
proposedTopFromScrollback);
|
||||
auto proposedTop = std::max(proposedTopFromLastLine,
|
||||
proposedTopFromScrollback);
|
||||
|
||||
// If we're using the new location of the old top line to place the
|
||||
// viewport, we might need to make an adjustment to it.
|
||||
@@ -391,15 +390,15 @@ void Terminal::UpdateAppearance(const ICoreAppearance& appearance)
|
||||
|
||||
// Make sure the proposed viewport is within the bounds of the buffer.
|
||||
// First make sure the top is >=0
|
||||
proposedTop = std::max(static_cast<short>(0), proposedTop);
|
||||
proposedTop = std::max(0, proposedTop);
|
||||
|
||||
// If the new bottom would be below the bottom of the buffer, then slide the
|
||||
// top up so that we'll still fit within the buffer.
|
||||
const auto newView = Viewport::FromDimensions({ 0, proposedTop }, viewportSize);
|
||||
const auto proposedBottom = newView.BottomExclusive();
|
||||
if (proposedBottom > bufferSize.Y)
|
||||
if (proposedBottom > bufferSize.height)
|
||||
{
|
||||
proposedTop = ::base::ClampSub(proposedTop, ::base::ClampSub(proposedBottom, bufferSize.Y));
|
||||
proposedTop = ::base::ClampSub(proposedTop, ::base::ClampSub(proposedBottom, bufferSize.height));
|
||||
}
|
||||
|
||||
_mutableViewport = Viewport::FromDimensions({ 0, proposedTop }, viewportSize);
|
||||
@@ -410,7 +409,7 @@ void Terminal::UpdateAppearance(const ICoreAppearance& appearance)
|
||||
// Make sure that we don't scroll past the mutableViewport at the bottom of the buffer
|
||||
newVisibleTop = std::min(newVisibleTop, _mutableViewport.Top());
|
||||
// Make sure we don't scroll past the top of the scrollback
|
||||
newVisibleTop = std::max<short>(newVisibleTop, 0);
|
||||
newVisibleTop = std::max(newVisibleTop, 0);
|
||||
|
||||
// If the old scrolloffset was 0, then we weren't scrolled back at all
|
||||
// before, and shouldn't be now either.
|
||||
@@ -485,7 +484,7 @@ bool Terminal::IsTrackingMouseInput() const noexcept
|
||||
// - Given a coord, get the URI at that location
|
||||
// Arguments:
|
||||
// - The position
|
||||
std::wstring Terminal::GetHyperlinkAtPosition(const COORD position)
|
||||
std::wstring Terminal::GetHyperlinkAtPosition(const til::point position)
|
||||
{
|
||||
auto attr = _buffer->GetCellDataAt(_ConvertToBufferCell(position))->TextAttr();
|
||||
if (attr.IsHyperlink())
|
||||
@@ -501,8 +500,8 @@ std::wstring Terminal::GetHyperlinkAtPosition(const COORD position)
|
||||
const auto end = result->stop;
|
||||
std::wstring uri;
|
||||
|
||||
const auto startIter = _buffer->GetCellDataAt(_ConvertToBufferCell(start.to_win32_coord()));
|
||||
const auto endIter = _buffer->GetCellDataAt(_ConvertToBufferCell(end.to_win32_coord()));
|
||||
const auto startIter = _buffer->GetCellDataAt(_ConvertToBufferCell(start));
|
||||
const auto endIter = _buffer->GetCellDataAt(_ConvertToBufferCell(end));
|
||||
for (auto iter = startIter; iter != endIter; ++iter)
|
||||
{
|
||||
uri += iter->Chars();
|
||||
@@ -518,7 +517,7 @@ std::wstring Terminal::GetHyperlinkAtPosition(const COORD position)
|
||||
// - The position of the text
|
||||
// Return value:
|
||||
// - The hyperlink ID
|
||||
uint16_t Terminal::GetHyperlinkIdAtPosition(const COORD position)
|
||||
uint16_t Terminal::GetHyperlinkIdAtPosition(const til::point position)
|
||||
{
|
||||
return _buffer->GetCellDataAt(_ConvertToBufferCell(position))->TextAttr().GetHyperlinkId();
|
||||
}
|
||||
@@ -529,9 +528,9 @@ uint16_t Terminal::GetHyperlinkIdAtPosition(const COORD position)
|
||||
// - The position
|
||||
// Return value:
|
||||
// - The interval representing the start and end coordinates
|
||||
std::optional<PointTree::interval> Terminal::GetHyperlinkIntervalFromPosition(const COORD position)
|
||||
std::optional<PointTree::interval> Terminal::GetHyperlinkIntervalFromPosition(const til::point position)
|
||||
{
|
||||
const auto results = _patternIntervalTree.findOverlapping(til::point{ position.X + 1, position.Y }, til::point{ position });
|
||||
const auto results = _patternIntervalTree.findOverlapping(til::point{ position.X + 1, position.Y }, position);
|
||||
if (results.size() > 0)
|
||||
{
|
||||
for (const auto& result : results)
|
||||
@@ -646,7 +645,7 @@ bool Terminal::SendKeyEvent(const WORD vkey,
|
||||
// Return Value:
|
||||
// - true if we translated the key event, and it should not be processed any further.
|
||||
// - false if we did not translate the key, and it should be processed into a character.
|
||||
bool Terminal::SendMouseEvent(const COORD viewportPos, const unsigned int uiButton, const ControlKeyStates states, const short wheelDelta, const TerminalInput::MouseButtonState state)
|
||||
bool Terminal::SendMouseEvent(const til::point viewportPos, const unsigned int uiButton, const ControlKeyStates states, const short wheelDelta, const TerminalInput::MouseButtonState state)
|
||||
{
|
||||
// GH#6401: VT applications should be able to receive mouse events from outside the
|
||||
// terminal buffer. This is likely to happen when the user drags the cursor offscreen.
|
||||
@@ -697,12 +696,12 @@ bool Terminal::SendCharEvent(const wchar_t ch, const WORD scanCode, const Contro
|
||||
// - Invalidates the regions described in the given pattern tree for the rendering purposes
|
||||
// Arguments:
|
||||
// - The interval tree containing regions that need to be invalidated
|
||||
void Terminal::_InvalidatePatternTree(interval_tree::IntervalTree<til::point, size_t>& tree)
|
||||
void Terminal::_InvalidatePatternTree(interval_tree::IntervalTree<til::point, til::CoordType>& tree)
|
||||
{
|
||||
const auto vis = _VisibleStartIndex();
|
||||
auto invalidate = [=](const PointTree::interval& interval) {
|
||||
COORD startCoord{ gsl::narrow<SHORT>(interval.start.x), gsl::narrow<SHORT>(interval.start.y + vis) };
|
||||
COORD endCoord{ gsl::narrow<SHORT>(interval.stop.x), gsl::narrow<SHORT>(interval.stop.y + vis) };
|
||||
til::point startCoord{ interval.start.X, interval.start.Y + vis };
|
||||
til::point endCoord{ interval.stop.X, interval.stop.Y + vis };
|
||||
_InvalidateFromCoords(startCoord, endCoord);
|
||||
};
|
||||
tree.visit_all(invalidate);
|
||||
@@ -712,30 +711,30 @@ void Terminal::_InvalidatePatternTree(interval_tree::IntervalTree<til::point, si
|
||||
// - Given start and end coords, invalidates all the regions between them
|
||||
// Arguments:
|
||||
// - The start and end coords
|
||||
void Terminal::_InvalidateFromCoords(const COORD start, const COORD end)
|
||||
void Terminal::_InvalidateFromCoords(const til::point start, const til::point end)
|
||||
{
|
||||
if (start.Y == end.Y)
|
||||
{
|
||||
SMALL_RECT region{ start.X, start.Y, end.X, end.Y };
|
||||
til::inclusive_rect region{ start.X, start.Y, end.X, end.Y };
|
||||
_buffer->GetRenderTarget().TriggerRedraw(Viewport::FromInclusive(region));
|
||||
}
|
||||
else
|
||||
{
|
||||
const auto rowSize = gsl::narrow<SHORT>(_buffer->GetRowByOffset(0).size());
|
||||
const auto rowSize = _buffer->GetRowByOffset(0).size();
|
||||
|
||||
// invalidate the first line
|
||||
SMALL_RECT region{ start.X, start.Y, gsl::narrow<short>(rowSize - 1), gsl::narrow<short>(start.Y) };
|
||||
til::inclusive_rect region{ start.X, start.Y, rowSize - 1, start.Y };
|
||||
_buffer->GetRenderTarget().TriggerRedraw(Viewport::FromInclusive(region));
|
||||
|
||||
if ((end.Y - start.Y) > 1)
|
||||
{
|
||||
// invalidate the lines in between the first and last line
|
||||
region = SMALL_RECT{ 0, start.Y + 1, gsl::narrow<short>(rowSize - 1), gsl::narrow<short>(end.Y - 1) };
|
||||
region = til::inclusive_rect{ 0, start.Y + 1, rowSize - 1, end.Y - 1 };
|
||||
_buffer->GetRenderTarget().TriggerRedraw(Viewport::FromInclusive(region));
|
||||
}
|
||||
|
||||
// invalidate the last line
|
||||
region = SMALL_RECT{ 0, end.Y, end.X, end.Y };
|
||||
region = til::inclusive_rect{ 0, end.Y, end.X, end.Y };
|
||||
_buffer->GetRenderTarget().TriggerRedraw(Viewport::FromInclusive(region));
|
||||
}
|
||||
}
|
||||
@@ -885,36 +884,36 @@ Viewport Terminal::_GetMutableViewport() const noexcept
|
||||
return _mutableViewport;
|
||||
}
|
||||
|
||||
short Terminal::GetBufferHeight() const noexcept
|
||||
til::CoordType Terminal::GetBufferHeight() const noexcept
|
||||
{
|
||||
return _mutableViewport.BottomExclusive();
|
||||
}
|
||||
|
||||
// ViewStartIndex is also the length of the scrollback
|
||||
int Terminal::ViewStartIndex() const noexcept
|
||||
til::CoordType Terminal::ViewStartIndex() const noexcept
|
||||
{
|
||||
return _mutableViewport.Top();
|
||||
}
|
||||
|
||||
int Terminal::ViewEndIndex() const noexcept
|
||||
til::CoordType Terminal::ViewEndIndex() const noexcept
|
||||
{
|
||||
return _mutableViewport.BottomInclusive();
|
||||
}
|
||||
|
||||
// _VisibleStartIndex is the first visible line of the buffer
|
||||
int Terminal::_VisibleStartIndex() const noexcept
|
||||
til::CoordType Terminal::_VisibleStartIndex() const noexcept
|
||||
{
|
||||
return std::max(0, ViewStartIndex() - _scrollOffset);
|
||||
}
|
||||
|
||||
int Terminal::_VisibleEndIndex() const noexcept
|
||||
til::CoordType Terminal::_VisibleEndIndex() const noexcept
|
||||
{
|
||||
return std::max(0, ViewEndIndex() - _scrollOffset);
|
||||
}
|
||||
|
||||
Viewport Terminal::_GetVisibleViewport() const noexcept
|
||||
{
|
||||
const COORD origin{ 0, gsl::narrow<short>(_VisibleStartIndex()) };
|
||||
const til::point origin{ 0, _VisibleStartIndex() };
|
||||
return Viewport::FromDimensions(origin,
|
||||
_mutableViewport.Dimensions());
|
||||
}
|
||||
@@ -938,8 +937,8 @@ void Terminal::_WriteBuffer(const std::wstring_view& stringView)
|
||||
for (size_t i = 0; i < stringView.size(); i++)
|
||||
{
|
||||
const auto wch = stringView.at(i);
|
||||
const COORD cursorPosBefore = cursor.GetPosition();
|
||||
COORD proposedCursorPosition = cursorPosBefore;
|
||||
const auto cursorPosBefore = cursor.GetPosition();
|
||||
auto proposedCursorPosition = cursorPosBefore;
|
||||
|
||||
// TODO: MSFT 21006766
|
||||
// This is not great but I need it demoable. Fix by making a buffer stream writer.
|
||||
@@ -957,7 +956,7 @@ void Terminal::_WriteBuffer(const std::wstring_view& stringView)
|
||||
{
|
||||
// If "wch" was a surrogate character, we just consumed 2 code units above.
|
||||
// -> Increment "i" by 1 in that case and thus by 2 in total in this iteration.
|
||||
proposedCursorPosition.X += gsl::narrow<SHORT>(cellDistance);
|
||||
proposedCursorPosition.X += cellDistance;
|
||||
i += inputDistance - 1;
|
||||
}
|
||||
else
|
||||
@@ -991,7 +990,7 @@ void Terminal::_WriteBuffer(const std::wstring_view& stringView)
|
||||
cursor.EndDeferDrawing();
|
||||
}
|
||||
|
||||
void Terminal::_AdjustCursorPosition(const COORD proposedPosition)
|
||||
void Terminal::_AdjustCursorPosition(const til::point proposedPosition)
|
||||
{
|
||||
#pragma warning(suppress : 26496) // cpp core checks wants this const but it's modified below.
|
||||
auto proposedCursorPosition = proposedPosition;
|
||||
@@ -1000,7 +999,7 @@ void Terminal::_AdjustCursorPosition(const COORD proposedPosition)
|
||||
|
||||
// If we're about to scroll past the bottom of the buffer, instead cycle the
|
||||
// buffer.
|
||||
SHORT rowsPushedOffTopOfBuffer = 0;
|
||||
auto rowsPushedOffTopOfBuffer = 0;
|
||||
const auto newRows = std::max(0, proposedCursorPosition.Y - bufferSize.Height() + 1);
|
||||
if (proposedCursorPosition.Y >= bufferSize.Height())
|
||||
{
|
||||
@@ -1051,7 +1050,7 @@ void Terminal::_AdjustCursorPosition(const COORD proposedPosition)
|
||||
const auto newViewTop = std::max(0, proposedCursorPosition.Y - (_mutableViewport.Height() - 1));
|
||||
if (newViewTop != _mutableViewport.Top())
|
||||
{
|
||||
_mutableViewport = Viewport::FromDimensions({ 0, gsl::narrow<short>(newViewTop) },
|
||||
_mutableViewport = Viewport::FromDimensions({ 0, newViewTop },
|
||||
_mutableViewport.Dimensions());
|
||||
updatedViewport = true;
|
||||
}
|
||||
@@ -1090,7 +1089,7 @@ void Terminal::_AdjustCursorPosition(const COORD proposedPosition)
|
||||
// We have to report the delta here because we might have circled the text buffer.
|
||||
// That didn't change the viewport and therefore the TriggerScroll(void)
|
||||
// method can't detect the delta on its own.
|
||||
COORD delta{ 0, gsl::narrow_cast<short>(-rowsPushedOffTopOfBuffer) };
|
||||
til::point delta{ 0, -rowsPushedOffTopOfBuffer };
|
||||
_buffer->GetRenderTarget().TriggerScroll(&delta);
|
||||
}
|
||||
|
||||
|
||||
@@ -65,8 +65,8 @@ public:
|
||||
Terminal& operator=(const Terminal&) = default;
|
||||
Terminal& operator=(Terminal&&) = default;
|
||||
|
||||
void Create(COORD viewportSize,
|
||||
SHORT scrollbackLines,
|
||||
void Create(til::size viewportSize,
|
||||
til::CoordType scrollbackLines,
|
||||
Microsoft::Console::Render::IRenderTarget& renderTarget);
|
||||
|
||||
void CreateFromSettings(winrt::Microsoft::Terminal::Core::ICoreSettings settings,
|
||||
@@ -85,10 +85,10 @@ public:
|
||||
[[nodiscard]] std::unique_lock<til::ticket_lock> LockForReading();
|
||||
[[nodiscard]] std::unique_lock<til::ticket_lock> LockForWriting();
|
||||
|
||||
short GetBufferHeight() const noexcept;
|
||||
til::CoordType GetBufferHeight() const noexcept;
|
||||
|
||||
int ViewStartIndex() const noexcept;
|
||||
int ViewEndIndex() const noexcept;
|
||||
til::CoordType ViewStartIndex() const noexcept;
|
||||
til::CoordType ViewEndIndex() const noexcept;
|
||||
|
||||
RenderSettings& GetRenderSettings() noexcept { return _renderSettings; };
|
||||
const RenderSettings& GetRenderSettings() const noexcept { return _renderSettings; };
|
||||
@@ -100,14 +100,14 @@ public:
|
||||
TextAttribute GetTextAttributes() const noexcept override;
|
||||
void SetTextAttributes(const TextAttribute& attrs) noexcept override;
|
||||
Microsoft::Console::Types::Viewport GetBufferSize() noexcept override;
|
||||
bool SetCursorPosition(short x, short y) noexcept override;
|
||||
COORD GetCursorPosition() noexcept override;
|
||||
bool SetCursorPosition(til::point pos) noexcept override;
|
||||
til::point GetCursorPosition() noexcept override;
|
||||
bool SetCursorVisibility(const bool visible) noexcept override;
|
||||
bool EnableCursorBlinking(const bool enable) noexcept override;
|
||||
bool CursorLineFeed(const bool withReturn) noexcept override;
|
||||
bool DeleteCharacter(const size_t count) noexcept override;
|
||||
bool InsertCharacter(const size_t count) noexcept override;
|
||||
bool EraseCharacters(const size_t numChars) noexcept override;
|
||||
bool DeleteCharacter(const til::CoordType count) noexcept override;
|
||||
bool InsertCharacter(const til::CoordType count) noexcept override;
|
||||
bool EraseCharacters(const til::CoordType numChars) noexcept override;
|
||||
bool EraseInLine(const ::Microsoft::Console::VirtualTerminal::DispatchTypes::EraseType eraseType) noexcept override;
|
||||
bool EraseInDisplay(const ::Microsoft::Console::VirtualTerminal::DispatchTypes::EraseType eraseType) noexcept override;
|
||||
bool WarningBell() noexcept override;
|
||||
@@ -142,24 +142,24 @@ public:
|
||||
#pragma region ITerminalInput
|
||||
// These methods are defined in Terminal.cpp
|
||||
bool SendKeyEvent(const WORD vkey, const WORD scanCode, const Microsoft::Terminal::Core::ControlKeyStates states, const bool keyDown) override;
|
||||
bool SendMouseEvent(const COORD viewportPos, const unsigned int uiButton, const ControlKeyStates states, const short wheelDelta, const Microsoft::Console::VirtualTerminal::TerminalInput::MouseButtonState state) override;
|
||||
bool SendMouseEvent(const til::point viewportPos, const unsigned int uiButton, const ControlKeyStates states, const short wheelDelta, const Microsoft::Console::VirtualTerminal::TerminalInput::MouseButtonState state) override;
|
||||
bool SendCharEvent(const wchar_t ch, const WORD scanCode, const ControlKeyStates states) override;
|
||||
|
||||
[[nodiscard]] HRESULT UserResize(const COORD viewportSize) noexcept override;
|
||||
[[nodiscard]] HRESULT UserResize(const til::size viewportSize) noexcept override;
|
||||
void UserScrollViewport(const int viewTop) override;
|
||||
int GetScrollOffset() noexcept override;
|
||||
|
||||
void TrySnapOnInput() override;
|
||||
bool IsTrackingMouseInput() const noexcept;
|
||||
|
||||
std::wstring GetHyperlinkAtPosition(const COORD position);
|
||||
uint16_t GetHyperlinkIdAtPosition(const COORD position);
|
||||
std::optional<interval_tree::IntervalTree<til::point, size_t>::interval> GetHyperlinkIntervalFromPosition(const COORD position);
|
||||
std::wstring GetHyperlinkAtPosition(const til::point position);
|
||||
uint16_t GetHyperlinkIdAtPosition(const til::point position);
|
||||
std::optional<interval_tree::IntervalTree<til::point, til::CoordType>::interval> GetHyperlinkIntervalFromPosition(const til::point position);
|
||||
#pragma endregion
|
||||
|
||||
#pragma region IBaseData(base to IRenderData and IUiaData)
|
||||
Microsoft::Console::Types::Viewport GetViewport() noexcept override;
|
||||
COORD GetTextBufferEndPosition() const noexcept override;
|
||||
til::point GetTextBufferEndPosition() const noexcept override;
|
||||
const TextBuffer& GetTextBuffer() noexcept override;
|
||||
const FontInfo& GetFontInfo() noexcept override;
|
||||
|
||||
@@ -169,7 +169,7 @@ public:
|
||||
|
||||
#pragma region IRenderData
|
||||
// These methods are defined in TerminalRenderData.cpp
|
||||
COORD GetCursorPosition() const noexcept override;
|
||||
til::point GetCursorPosition() const noexcept override;
|
||||
bool IsCursorVisible() const noexcept override;
|
||||
bool IsCursorOn() const noexcept override;
|
||||
ULONG GetCursorHeight() const noexcept override;
|
||||
@@ -180,7 +180,7 @@ public:
|
||||
const bool IsGridLineDrawingAllowed() noexcept override;
|
||||
const std::wstring GetHyperlinkUri(uint16_t id) const noexcept override;
|
||||
const std::wstring GetHyperlinkCustomId(uint16_t id) const noexcept override;
|
||||
const std::vector<size_t> GetPatternId(const COORD location) const noexcept override;
|
||||
const std::vector<size_t> GetPatternId(const til::point location) const noexcept override;
|
||||
#pragma endregion
|
||||
|
||||
#pragma region IUiaData
|
||||
@@ -189,11 +189,11 @@ public:
|
||||
const bool IsSelectionActive() const noexcept override;
|
||||
const bool IsBlockSelection() const noexcept override;
|
||||
void ClearSelection() override;
|
||||
void SelectNewRegion(const COORD coordStart, const COORD coordEnd) override;
|
||||
const COORD GetSelectionAnchor() const noexcept override;
|
||||
const COORD GetSelectionEnd() const noexcept override;
|
||||
void SelectNewRegion(const til::point coordStart, const til::point coordEnd) override;
|
||||
const til::point GetSelectionAnchor() const noexcept override;
|
||||
const til::point GetSelectionEnd() const noexcept override;
|
||||
const std::wstring_view GetConsoleTitle() const noexcept override;
|
||||
void ColorSelection(const COORD coordSelectionStart, const COORD coordSelectionEnd, const TextAttribute) override;
|
||||
void ColorSelection(const til::point coordSelectionStart, const til::point coordSelectionEnd, const TextAttribute) override;
|
||||
const bool IsUiaDataInitialized() const noexcept override;
|
||||
#pragma endregion
|
||||
|
||||
@@ -239,9 +239,9 @@ public:
|
||||
Viewport,
|
||||
Buffer
|
||||
};
|
||||
void MultiClickSelection(const COORD viewportPos, SelectionExpansion expansionMode);
|
||||
void SetSelectionAnchor(const COORD position);
|
||||
void SetSelectionEnd(const COORD position, std::optional<SelectionExpansion> newExpansionMode = std::nullopt);
|
||||
void MultiClickSelection(const til::point viewportPos, SelectionExpansion expansionMode);
|
||||
void SetSelectionAnchor(const til::point position);
|
||||
void SetSelectionEnd(const til::point position, std::optional<SelectionExpansion> newExpansionMode = std::nullopt);
|
||||
void SetBlockSelection(const bool isEnabled) noexcept;
|
||||
void UpdateSelection(SelectionDirection direction, SelectionExpansion mode);
|
||||
|
||||
@@ -303,14 +303,14 @@ private:
|
||||
FontInfo _fontInfo{ DEFAULT_FONT_FACE, TMPF_TRUETYPE, 10, { 0, DEFAULT_FONT_SIZE }, CP_UTF8, false };
|
||||
#pragma region Text Selection
|
||||
// a selection is represented as a range between two COORDs (start and end)
|
||||
// the pivot is the COORD that remains selected when you extend a selection in any direction
|
||||
// the pivot is the til::point that remains selected when you extend a selection in any direction
|
||||
// this is particularly useful when a word selection is extended over its starting point
|
||||
// see TerminalSelection.cpp for more information
|
||||
struct SelectionAnchors
|
||||
{
|
||||
COORD start;
|
||||
COORD end;
|
||||
COORD pivot;
|
||||
til::point start;
|
||||
til::point end;
|
||||
til::point pivot;
|
||||
};
|
||||
std::optional<SelectionAnchors> _selection;
|
||||
bool _blockSelection;
|
||||
@@ -322,7 +322,7 @@ private:
|
||||
// encapsulated, such that a Terminal can have both a main and alt buffer.
|
||||
std::unique_ptr<TextBuffer> _buffer;
|
||||
Microsoft::Console::Types::Viewport _mutableViewport;
|
||||
SHORT _scrollbackLines;
|
||||
til::CoordType _scrollbackLines;
|
||||
|
||||
// _scrollOffset is the number of lines above the viewport that are currently visible
|
||||
// If _scrollOffset is 0, then the visible region of the buffer is the viewport.
|
||||
@@ -340,9 +340,9 @@ private:
|
||||
// underneath them, while others would prefer to anchor it in place.
|
||||
// Either way, we should make this behavior controlled by a setting.
|
||||
|
||||
interval_tree::IntervalTree<til::point, size_t> _patternIntervalTree;
|
||||
void _InvalidatePatternTree(interval_tree::IntervalTree<til::point, size_t>& tree);
|
||||
void _InvalidateFromCoords(const COORD start, const COORD end);
|
||||
interval_tree::IntervalTree<til::point, til::CoordType> _patternIntervalTree;
|
||||
void _InvalidatePatternTree(interval_tree::IntervalTree<til::point, til::CoordType>& tree);
|
||||
void _InvalidateFromCoords(const til::point start, const til::point end);
|
||||
|
||||
// Since virtual keys are non-zero, you assume that this field is empty/invalid if it is.
|
||||
struct KeyEventCodes
|
||||
@@ -360,15 +360,15 @@ private:
|
||||
void _StoreKeyEvent(const WORD vkey, const WORD scanCode);
|
||||
WORD _TakeVirtualKeyFromLastKeyEvent(const WORD scanCode) noexcept;
|
||||
|
||||
int _VisibleStartIndex() const noexcept;
|
||||
int _VisibleEndIndex() const noexcept;
|
||||
til::CoordType _VisibleStartIndex() const noexcept;
|
||||
til::CoordType _VisibleEndIndex() const noexcept;
|
||||
|
||||
Microsoft::Console::Types::Viewport _GetMutableViewport() const noexcept;
|
||||
Microsoft::Console::Types::Viewport _GetVisibleViewport() const noexcept;
|
||||
|
||||
void _WriteBuffer(const std::wstring_view& stringView);
|
||||
|
||||
void _AdjustCursorPosition(const COORD proposedPosition);
|
||||
void _AdjustCursorPosition(const til::point proposedPosition);
|
||||
|
||||
void _NotifyScrollEvent() noexcept;
|
||||
|
||||
@@ -376,14 +376,14 @@ private:
|
||||
|
||||
#pragma region TextSelection
|
||||
// These methods are defined in TerminalSelection.cpp
|
||||
std::vector<SMALL_RECT> _GetSelectionRects() const noexcept;
|
||||
std::pair<COORD, COORD> _PivotSelection(const COORD targetPos, bool& targetStart) const;
|
||||
std::pair<COORD, COORD> _ExpandSelectionAnchors(std::pair<COORD, COORD> anchors) const;
|
||||
COORD _ConvertToBufferCell(const COORD viewportPos) const;
|
||||
void _MoveByChar(SelectionDirection direction, COORD& pos);
|
||||
void _MoveByWord(SelectionDirection direction, COORD& pos);
|
||||
void _MoveByViewport(SelectionDirection direction, COORD& pos);
|
||||
void _MoveByBuffer(SelectionDirection direction, COORD& pos);
|
||||
std::vector<til::inclusive_rect> _GetSelectionRects() const noexcept;
|
||||
std::pair<til::point, til::point> _PivotSelection(const til::point targetPos, bool& targetStart) const;
|
||||
std::pair<til::point, til::point> _ExpandSelectionAnchors(std::pair<til::point, til::point> anchors) const;
|
||||
til::point _ConvertToBufferCell(const til::point viewportPos) const;
|
||||
void _MoveByChar(SelectionDirection direction, til::point& pos);
|
||||
void _MoveByWord(SelectionDirection direction, til::point& pos);
|
||||
void _MoveByViewport(SelectionDirection direction, til::point& pos);
|
||||
void _MoveByBuffer(SelectionDirection direction, til::point& pos);
|
||||
#pragma endregion
|
||||
|
||||
Microsoft::Console::VirtualTerminal::SgrStack _sgrStack;
|
||||
|
||||
@@ -42,14 +42,12 @@ Viewport Terminal::GetBufferSize() noexcept
|
||||
return _buffer->GetSize();
|
||||
}
|
||||
|
||||
bool Terminal::SetCursorPosition(short x, short y) noexcept
|
||||
bool Terminal::SetCursorPosition(til::point pos) noexcept
|
||||
try
|
||||
{
|
||||
const auto viewport = _GetMutableViewport();
|
||||
const auto viewOrigin = viewport.Origin();
|
||||
const short absoluteX = viewOrigin.X + x;
|
||||
const short absoluteY = viewOrigin.Y + y;
|
||||
COORD newPos{ absoluteX, absoluteY };
|
||||
auto newPos = viewOrigin + pos;
|
||||
viewport.Clamp(newPos);
|
||||
_buffer->GetCursor().SetPosition(newPos);
|
||||
|
||||
@@ -57,17 +55,13 @@ try
|
||||
}
|
||||
CATCH_RETURN_FALSE()
|
||||
|
||||
COORD Terminal::GetCursorPosition() noexcept
|
||||
til::point Terminal::GetCursorPosition() noexcept
|
||||
{
|
||||
const auto absoluteCursorPos = _buffer->GetCursor().GetPosition();
|
||||
const auto viewport = _GetMutableViewport();
|
||||
const auto viewOrigin = viewport.Origin();
|
||||
const short relativeX = absoluteCursorPos.X - viewOrigin.X;
|
||||
const short relativeY = absoluteCursorPos.Y - viewOrigin.Y;
|
||||
COORD newPos{ relativeX, relativeY };
|
||||
|
||||
// TODO assert that the coord is > (0, 0) && <(view.W, view.H)
|
||||
return newPos;
|
||||
return absoluteCursorPos - viewOrigin;
|
||||
}
|
||||
|
||||
// Method Description:
|
||||
@@ -106,26 +100,16 @@ CATCH_RETURN_FALSE()
|
||||
// - count, the number of characters to delete
|
||||
// Return value:
|
||||
// - true if succeeded, false otherwise
|
||||
bool Terminal::DeleteCharacter(const size_t count) noexcept
|
||||
bool Terminal::DeleteCharacter(const til::CoordType count) noexcept
|
||||
try
|
||||
{
|
||||
SHORT dist;
|
||||
if (!SUCCEEDED(SizeTToShort(count, &dist)))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
const auto cursorPos = _buffer->GetCursor().GetPosition();
|
||||
const auto copyToPos = cursorPos;
|
||||
const COORD copyFromPos{ cursorPos.X + dist, cursorPos.Y };
|
||||
const til::point copyFromPos{ cursorPos.X + count, cursorPos.Y };
|
||||
const auto sourceWidth = _mutableViewport.RightExclusive() - copyFromPos.X;
|
||||
SHORT width;
|
||||
if (!SUCCEEDED(UIntToShort(sourceWidth, &width)))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// Get a rectangle of the source
|
||||
auto source = Viewport::FromDimensions(copyFromPos, width, 1);
|
||||
auto source = Viewport::FromDimensions(copyFromPos, sourceWidth, 1);
|
||||
|
||||
// Get a rectangle of the target
|
||||
const auto target = Viewport::FromDimensions(copyToPos, source.Dimensions());
|
||||
@@ -154,31 +138,21 @@ CATCH_RETURN_FALSE()
|
||||
// - count, the number of spaces to insert
|
||||
// Return value:
|
||||
// - true if succeeded, false otherwise
|
||||
bool Terminal::InsertCharacter(const size_t count) noexcept
|
||||
bool Terminal::InsertCharacter(const til::CoordType count) noexcept
|
||||
try
|
||||
{
|
||||
// NOTE: the code below is _extremely_ similar to DeleteCharacter
|
||||
// We will want to use this same logic and implement a helper function instead
|
||||
// that does the 'move a region from here to there' operation
|
||||
// TODO: Github issue #2163
|
||||
SHORT dist;
|
||||
if (!SUCCEEDED(SizeTToShort(count, &dist)))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
const auto cursorPos = _buffer->GetCursor().GetPosition();
|
||||
const auto copyFromPos = cursorPos;
|
||||
const COORD copyToPos{ cursorPos.X + dist, cursorPos.Y };
|
||||
const til::point copyToPos{ cursorPos.X + count, cursorPos.Y };
|
||||
const auto sourceWidth = _mutableViewport.RightExclusive() - copyFromPos.X;
|
||||
SHORT width;
|
||||
if (!SUCCEEDED(UIntToShort(sourceWidth, &width)))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// Get a rectangle of the source
|
||||
auto source = Viewport::FromDimensions(copyFromPos, width, 1);
|
||||
const auto sourceOrigin = source.Origin();
|
||||
auto source = Viewport::FromDimensions(copyFromPos, sourceWidth, 1);
|
||||
|
||||
// Get a rectangle of the target
|
||||
const auto target = Viewport::FromDimensions(copyToPos, source.Dimensions());
|
||||
@@ -193,20 +167,20 @@ try
|
||||
const auto data = OutputCell(*(_buffer->GetCellDataAt(sourcePos)));
|
||||
_buffer->Write(OutputCellIterator({ &data, 1 }), targetPos);
|
||||
} while (source.WalkInBounds(sourcePos, walkDirection) && target.WalkInBounds(targetPos, walkDirection));
|
||||
const auto eraseIter = OutputCellIterator(UNICODE_SPACE, _buffer->GetCurrentAttributes(), dist);
|
||||
const auto eraseIter = OutputCellIterator(UNICODE_SPACE, _buffer->GetCurrentAttributes(), count);
|
||||
_buffer->Write(eraseIter, cursorPos);
|
||||
|
||||
return true;
|
||||
}
|
||||
CATCH_RETURN_FALSE()
|
||||
|
||||
bool Terminal::EraseCharacters(const size_t numChars) noexcept
|
||||
bool Terminal::EraseCharacters(const til::CoordType numChars) noexcept
|
||||
try
|
||||
{
|
||||
const auto absoluteCursorPos = _buffer->GetCursor().GetPosition();
|
||||
const auto viewport = _GetMutableViewport();
|
||||
const short distanceToRight = viewport.RightExclusive() - absoluteCursorPos.X;
|
||||
const short fillLimit = std::min(static_cast<short>(numChars), distanceToRight);
|
||||
const auto distanceToRight = viewport.RightExclusive() - absoluteCursorPos.X;
|
||||
const auto fillLimit = std::min(numChars, distanceToRight);
|
||||
const auto eraseIter = OutputCellIterator(UNICODE_SPACE, _buffer->GetCurrentAttributes(), fillLimit);
|
||||
_buffer->Write(eraseIter, absoluteCursorPos);
|
||||
return true;
|
||||
@@ -228,7 +202,7 @@ try
|
||||
{
|
||||
const auto cursorPos = _buffer->GetCursor().GetPosition();
|
||||
const auto viewport = _GetMutableViewport();
|
||||
COORD startPos = { 0 };
|
||||
til::point startPos;
|
||||
startPos.Y = cursorPos.Y;
|
||||
// nlength determines the number of spaces we need to write
|
||||
DWORD nlength = 0;
|
||||
@@ -272,13 +246,12 @@ try
|
||||
{
|
||||
// Store the relative cursor position so we can restore it later after we move the viewport
|
||||
const auto cursorPos = _buffer->GetCursor().GetPosition();
|
||||
#pragma warning(suppress : 26496) // This is written by ConvertToOrigin, cpp core checks is wrong saying it should be const.
|
||||
auto relativeCursor = cursorPos;
|
||||
_mutableViewport.ConvertToOrigin(&relativeCursor);
|
||||
|
||||
// Initialize the new location of the viewport
|
||||
// the top and bottom parameters are determined by the eraseType
|
||||
SMALL_RECT newWin;
|
||||
til::rect newWin;
|
||||
newWin.Left = _mutableViewport.Left();
|
||||
newWin.Right = _mutableViewport.RightExclusive();
|
||||
|
||||
@@ -293,10 +266,10 @@ try
|
||||
return true;
|
||||
}
|
||||
|
||||
short sNewTop = coordLastChar.Y + 1;
|
||||
auto sNewTop = coordLastChar.Y + 1;
|
||||
|
||||
// Increment the circular buffer only if the new location of the viewport would be 'below' the buffer
|
||||
const short delta = (sNewTop + _mutableViewport.Height()) - (_buffer->GetSize().Height());
|
||||
const auto delta = (sNewTop + _mutableViewport.Height()) - (_buffer->GetSize().Height());
|
||||
for (auto i = 0; i < delta; i++)
|
||||
{
|
||||
_buffer->IncrementCircularBuffer();
|
||||
@@ -310,7 +283,7 @@ try
|
||||
{
|
||||
// We only want to erase the scrollback, and leave everything else on the screen as it is
|
||||
// so we grab the text in the viewport and rotate it up to the top of the buffer
|
||||
COORD scrollFromPos{ 0, 0 };
|
||||
til::point scrollFromPos{ 0, 0 };
|
||||
_mutableViewport.ConvertFromOrigin(&scrollFromPos);
|
||||
_buffer->ScrollRows(scrollFromPos.Y, _mutableViewport.Height(), -scrollFromPos.Y);
|
||||
|
||||
@@ -318,7 +291,7 @@ try
|
||||
// and we have to make sure we erase that text
|
||||
const auto eraseStart = _mutableViewport.Height();
|
||||
const auto eraseEnd = _buffer->GetLastNonSpaceCharacter(_mutableViewport).Y;
|
||||
for (SHORT i = eraseStart; i <= eraseEnd; i++)
|
||||
for (auto i = eraseStart; i <= eraseEnd; i++)
|
||||
{
|
||||
_buffer->GetRowByOffset(i).Reset(_buffer->GetCurrentAttributes());
|
||||
}
|
||||
@@ -337,7 +310,7 @@ try
|
||||
// Move the viewport, adjust the scroll bar if needed, and restore the old cursor position
|
||||
_mutableViewport = Viewport::FromExclusive(newWin);
|
||||
Terminal::_NotifyScrollEvent();
|
||||
SetCursorPosition(relativeCursor.X, relativeCursor.Y);
|
||||
SetCursorPosition(relativeCursor);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -34,22 +34,14 @@ void TerminalDispatch::PrintString(const std::wstring_view string) noexcept
|
||||
_terminalApi.PrintString(string);
|
||||
}
|
||||
|
||||
bool TerminalDispatch::CursorPosition(const size_t line,
|
||||
const size_t column) noexcept
|
||||
try
|
||||
bool TerminalDispatch::CursorPosition(VTInt line,
|
||||
VTInt column) noexcept
|
||||
{
|
||||
SHORT x{ 0 };
|
||||
SHORT y{ 0 };
|
||||
RETURN_BOOL_IF_FALSE(SUCCEEDED(IntSub(line, 1, &line)) &&
|
||||
SUCCEEDED(IntSub(column, 1, &column)));
|
||||
|
||||
RETURN_BOOL_IF_FALSE(SUCCEEDED(SizeTToShort(column, &x)) &&
|
||||
SUCCEEDED(SizeTToShort(line, &y)));
|
||||
|
||||
RETURN_BOOL_IF_FALSE(SUCCEEDED(ShortSub(x, 1, &x)) &&
|
||||
SUCCEEDED(ShortSub(y, 1, &y)));
|
||||
|
||||
return _terminalApi.SetCursorPosition(x, y);
|
||||
return _terminalApi.SetCursorPosition({ column, line });
|
||||
}
|
||||
CATCH_LOG_RETURN_FALSE()
|
||||
|
||||
bool TerminalDispatch::CursorVisibility(const bool isVisible) noexcept
|
||||
{
|
||||
@@ -61,30 +53,30 @@ bool TerminalDispatch::EnableCursorBlinking(const bool enable) noexcept
|
||||
return _terminalApi.EnableCursorBlinking(enable);
|
||||
}
|
||||
|
||||
bool TerminalDispatch::CursorForward(const size_t distance) noexcept
|
||||
bool TerminalDispatch::CursorForward(const VTInt distance) noexcept
|
||||
try
|
||||
{
|
||||
const auto cursorPos = _terminalApi.GetCursorPosition();
|
||||
const COORD newCursorPos{ cursorPos.X + gsl::narrow<short>(distance), cursorPos.Y };
|
||||
return _terminalApi.SetCursorPosition(newCursorPos.X, newCursorPos.Y);
|
||||
const til::point newCursorPos{ cursorPos.X + distance, cursorPos.Y };
|
||||
return _terminalApi.SetCursorPosition(newCursorPos);
|
||||
}
|
||||
CATCH_LOG_RETURN_FALSE()
|
||||
|
||||
bool TerminalDispatch::CursorBackward(const size_t distance) noexcept
|
||||
bool TerminalDispatch::CursorBackward(const VTInt distance) noexcept
|
||||
try
|
||||
{
|
||||
const auto cursorPos = _terminalApi.GetCursorPosition();
|
||||
const COORD newCursorPos{ cursorPos.X - gsl::narrow<short>(distance), cursorPos.Y };
|
||||
return _terminalApi.SetCursorPosition(newCursorPos.X, newCursorPos.Y);
|
||||
const til::point newCursorPos{ cursorPos.X - distance, cursorPos.Y };
|
||||
return _terminalApi.SetCursorPosition(newCursorPos);
|
||||
}
|
||||
CATCH_LOG_RETURN_FALSE()
|
||||
|
||||
bool TerminalDispatch::CursorUp(const size_t distance) noexcept
|
||||
bool TerminalDispatch::CursorUp(const VTInt distance) noexcept
|
||||
try
|
||||
{
|
||||
const auto cursorPos = _terminalApi.GetCursorPosition();
|
||||
const COORD newCursorPos{ cursorPos.X, cursorPos.Y + gsl::narrow<short>(distance) };
|
||||
return _terminalApi.SetCursorPosition(newCursorPos.X, newCursorPos.Y);
|
||||
const til::point newCursorPos{ cursorPos.X, cursorPos.Y + distance };
|
||||
return _terminalApi.SetCursorPosition(newCursorPos);
|
||||
}
|
||||
CATCH_LOG_RETURN_FALSE()
|
||||
|
||||
@@ -106,7 +98,7 @@ try
|
||||
}
|
||||
CATCH_LOG_RETURN_FALSE()
|
||||
|
||||
bool TerminalDispatch::EraseCharacters(const size_t numChars) noexcept
|
||||
bool TerminalDispatch::EraseCharacters(const VTInt numChars) noexcept
|
||||
try
|
||||
{
|
||||
return _terminalApi.EraseCharacters(numChars);
|
||||
@@ -124,7 +116,7 @@ bool TerminalDispatch::CarriageReturn() noexcept
|
||||
try
|
||||
{
|
||||
const auto cursorPos = _terminalApi.GetCursorPosition();
|
||||
return _terminalApi.SetCursorPosition(0, cursorPos.Y);
|
||||
return _terminalApi.SetCursorPosition({ 0, cursorPos.Y });
|
||||
}
|
||||
CATCH_LOG_RETURN_FALSE()
|
||||
|
||||
@@ -137,7 +129,7 @@ CATCH_LOG_RETURN_FALSE()
|
||||
|
||||
bool TerminalDispatch::HorizontalTabSet() noexcept
|
||||
{
|
||||
const auto width = _terminalApi.GetBufferSize().Dimensions().X;
|
||||
const auto width = _terminalApi.GetBufferSize().Dimensions().width;
|
||||
const auto column = _terminalApi.GetCursorPosition().X;
|
||||
|
||||
_InitTabStopsForWidth(width);
|
||||
@@ -145,13 +137,13 @@ bool TerminalDispatch::HorizontalTabSet() noexcept
|
||||
return true;
|
||||
}
|
||||
|
||||
bool TerminalDispatch::ForwardTab(const size_t numTabs) noexcept
|
||||
bool TerminalDispatch::ForwardTab(const VTInt numTabs) noexcept
|
||||
{
|
||||
const auto width = _terminalApi.GetBufferSize().Dimensions().X;
|
||||
const auto width = _terminalApi.GetBufferSize().Dimensions().width;
|
||||
const auto cursorPosition = _terminalApi.GetCursorPosition();
|
||||
auto column = cursorPosition.X;
|
||||
const auto row = cursorPosition.Y;
|
||||
auto tabsPerformed = 0u;
|
||||
VTInt tabsPerformed = 0;
|
||||
_InitTabStopsForWidth(width);
|
||||
while (column + 1 < width && tabsPerformed < numTabs)
|
||||
{
|
||||
@@ -162,16 +154,16 @@ bool TerminalDispatch::ForwardTab(const size_t numTabs) noexcept
|
||||
}
|
||||
}
|
||||
|
||||
return _terminalApi.SetCursorPosition(column, row);
|
||||
return _terminalApi.SetCursorPosition({ column, row });
|
||||
}
|
||||
|
||||
bool TerminalDispatch::BackwardsTab(const size_t numTabs) noexcept
|
||||
bool TerminalDispatch::BackwardsTab(const VTInt numTabs) noexcept
|
||||
{
|
||||
const auto width = _terminalApi.GetBufferSize().Dimensions().X;
|
||||
const auto width = _terminalApi.GetBufferSize().Dimensions().width;
|
||||
const auto cursorPosition = _terminalApi.GetCursorPosition();
|
||||
auto column = cursorPosition.X;
|
||||
const auto row = cursorPosition.Y;
|
||||
auto tabsPerformed = 0u;
|
||||
VTInt tabsPerformed = 0;
|
||||
_InitTabStopsForWidth(width);
|
||||
while (column > 0 && tabsPerformed < numTabs)
|
||||
{
|
||||
@@ -182,7 +174,7 @@ bool TerminalDispatch::BackwardsTab(const size_t numTabs) noexcept
|
||||
}
|
||||
}
|
||||
|
||||
return _terminalApi.SetCursorPosition(column, row);
|
||||
return _terminalApi.SetCursorPosition({ column, row });
|
||||
}
|
||||
|
||||
bool TerminalDispatch::TabClear(const DispatchTypes::TabClearType clearType) noexcept
|
||||
@@ -286,7 +278,7 @@ CATCH_LOG_RETURN_FALSE()
|
||||
// - count, the number of characters to delete
|
||||
// Return Value:
|
||||
// True if handled successfully. False otherwise.
|
||||
bool TerminalDispatch::DeleteCharacter(const size_t count) noexcept
|
||||
bool TerminalDispatch::DeleteCharacter(const VTInt count) noexcept
|
||||
try
|
||||
{
|
||||
return _terminalApi.DeleteCharacter(count);
|
||||
@@ -299,7 +291,7 @@ CATCH_LOG_RETURN_FALSE()
|
||||
// - count, the number of spaces to add
|
||||
// Return Value:
|
||||
// True if handled successfully, false otherwise
|
||||
bool TerminalDispatch::InsertCharacter(const size_t count) noexcept
|
||||
bool TerminalDispatch::InsertCharacter(const VTInt count) noexcept
|
||||
try
|
||||
{
|
||||
return _terminalApi.InsertCharacter(count);
|
||||
@@ -623,7 +615,7 @@ bool TerminalDispatch::_ModeParamsHelper(const DispatchTypes::ModeParams param,
|
||||
|
||||
bool TerminalDispatch::_ClearSingleTabStop() noexcept
|
||||
{
|
||||
const auto width = _terminalApi.GetBufferSize().Dimensions().X;
|
||||
const auto width = _terminalApi.GetBufferSize().Dimensions().width;
|
||||
const auto column = _terminalApi.GetCursorPosition().X;
|
||||
|
||||
_InitTabStopsForWidth(width);
|
||||
|
||||
@@ -21,28 +21,28 @@ public:
|
||||
bool PushGraphicsRendition(const ::Microsoft::Console::VirtualTerminal::VTParameters options) noexcept override;
|
||||
bool PopGraphicsRendition() noexcept override;
|
||||
|
||||
bool CursorPosition(const size_t line,
|
||||
const size_t column) noexcept override; // CUP
|
||||
bool CursorPosition(const VTInt line,
|
||||
const VTInt column) noexcept override; // CUP
|
||||
|
||||
bool EnableWin32InputMode(const bool win32InputMode) noexcept override; // win32-input-mode
|
||||
|
||||
bool CursorVisibility(const bool isVisible) noexcept override; // DECTCEM
|
||||
bool EnableCursorBlinking(const bool enable) noexcept override; // ATT610
|
||||
|
||||
bool CursorForward(const size_t distance) noexcept override;
|
||||
bool CursorBackward(const size_t distance) noexcept override;
|
||||
bool CursorUp(const size_t distance) noexcept override;
|
||||
bool CursorForward(const VTInt distance) noexcept override;
|
||||
bool CursorBackward(const VTInt distance) noexcept override;
|
||||
bool CursorUp(const VTInt distance) noexcept override;
|
||||
|
||||
bool LineFeed(const ::Microsoft::Console::VirtualTerminal::DispatchTypes::LineFeedType lineFeedType) noexcept override;
|
||||
|
||||
bool EraseCharacters(const size_t numChars) noexcept override;
|
||||
bool EraseCharacters(const VTInt numChars) noexcept override;
|
||||
bool WarningBell() noexcept override;
|
||||
bool CarriageReturn() noexcept override;
|
||||
bool SetWindowTitle(std::wstring_view title) noexcept override;
|
||||
|
||||
bool HorizontalTabSet() noexcept override; // HTS
|
||||
bool ForwardTab(const size_t numTabs) noexcept override; // CHT, HT
|
||||
bool BackwardsTab(const size_t numTabs) noexcept override; // CBT
|
||||
bool ForwardTab(const VTInt numTabs) noexcept override; // CHT, HT
|
||||
bool BackwardsTab(const VTInt numTabs) noexcept override; // CBT
|
||||
bool TabClear(const ::Microsoft::Console::VirtualTerminal::DispatchTypes::TabClearType clearType) noexcept override; // TBC
|
||||
|
||||
bool SetColorTableEntry(const size_t tableIndex, const DWORD color) noexcept override;
|
||||
@@ -54,8 +54,8 @@ public:
|
||||
bool SetDefaultForeground(const DWORD color) noexcept override;
|
||||
bool SetDefaultBackground(const DWORD color) noexcept override;
|
||||
bool EraseInLine(const ::Microsoft::Console::VirtualTerminal::DispatchTypes::EraseType eraseType) noexcept override; // ED
|
||||
bool DeleteCharacter(const size_t count) noexcept override;
|
||||
bool InsertCharacter(const size_t count) noexcept override;
|
||||
bool DeleteCharacter(const VTInt count) noexcept override;
|
||||
bool InsertCharacter(const VTInt count) noexcept override;
|
||||
bool EraseInDisplay(const ::Microsoft::Console::VirtualTerminal::DispatchTypes::EraseType eraseType) noexcept override;
|
||||
|
||||
bool SetCursorKeysMode(const bool applicationMode) noexcept override; // DECCKM
|
||||
|
||||
@@ -43,9 +43,9 @@ using namespace Microsoft::Terminal::Core;
|
||||
// - Helper to determine the selected region of the buffer. Used for rendering.
|
||||
// Return Value:
|
||||
// - A vector of rectangles representing the regions to select, line by line. They are absolute coordinates relative to the buffer origin.
|
||||
std::vector<SMALL_RECT> Terminal::_GetSelectionRects() const noexcept
|
||||
std::vector<til::inclusive_rect> Terminal::_GetSelectionRects() const noexcept
|
||||
{
|
||||
std::vector<SMALL_RECT> result;
|
||||
std::vector<til::inclusive_rect> result;
|
||||
|
||||
if (!IsSelectionActive())
|
||||
{
|
||||
@@ -66,7 +66,7 @@ std::vector<SMALL_RECT> Terminal::_GetSelectionRects() const noexcept
|
||||
// - None
|
||||
// Return Value:
|
||||
// - None
|
||||
const COORD Terminal::GetSelectionAnchor() const noexcept
|
||||
const til::point Terminal::GetSelectionAnchor() const noexcept
|
||||
{
|
||||
return _selection->start;
|
||||
}
|
||||
@@ -77,7 +77,7 @@ const COORD Terminal::GetSelectionAnchor() const noexcept
|
||||
// - None
|
||||
// Return Value:
|
||||
// - None
|
||||
const COORD Terminal::GetSelectionEnd() const noexcept
|
||||
const til::point Terminal::GetSelectionEnd() const noexcept
|
||||
{
|
||||
return _selection->end;
|
||||
}
|
||||
@@ -101,7 +101,7 @@ const bool Terminal::IsBlockSelection() const noexcept
|
||||
// Arguments:
|
||||
// - viewportPos: the (x,y) coordinate on the visible viewport
|
||||
// - expansionMode: the SelectionExpansion to dictate the boundaries of the selection anchors
|
||||
void Terminal::MultiClickSelection(const COORD viewportPos, SelectionExpansion expansionMode)
|
||||
void Terminal::MultiClickSelection(const til::point viewportPos, SelectionExpansion expansionMode)
|
||||
{
|
||||
// set the selection pivot to expand the selection using SetSelectionEnd()
|
||||
_selection = SelectionAnchors{};
|
||||
@@ -119,7 +119,7 @@ void Terminal::MultiClickSelection(const COORD viewportPos, SelectionExpansion e
|
||||
// - Record the position of the beginning of a selection
|
||||
// Arguments:
|
||||
// - position: the (x,y) coordinate on the visible viewport
|
||||
void Terminal::SetSelectionAnchor(const COORD viewportPos)
|
||||
void Terminal::SetSelectionAnchor(const til::point viewportPos)
|
||||
{
|
||||
_selection = SelectionAnchors{};
|
||||
_selection->pivot = _ConvertToBufferCell(viewportPos);
|
||||
@@ -136,7 +136,7 @@ void Terminal::SetSelectionAnchor(const COORD viewportPos)
|
||||
// Arguments:
|
||||
// - viewportPos: the (x,y) coordinate on the visible viewport
|
||||
// - newExpansionMode: overwrites the _multiClickSelectionMode for this function call. Used for ShiftClick
|
||||
void Terminal::SetSelectionEnd(const COORD viewportPos, std::optional<SelectionExpansion> newExpansionMode)
|
||||
void Terminal::SetSelectionEnd(const til::point viewportPos, std::optional<SelectionExpansion> newExpansionMode)
|
||||
{
|
||||
if (!_selection.has_value())
|
||||
{
|
||||
@@ -180,7 +180,7 @@ void Terminal::SetSelectionEnd(const COORD viewportPos, std::optional<SelectionE
|
||||
// - targetStart: if true, target will be the new start. Otherwise, target will be the new end.
|
||||
// Return Value:
|
||||
// - the new start/end for a selection
|
||||
std::pair<COORD, COORD> Terminal::_PivotSelection(const COORD targetPos, bool& targetStart) const
|
||||
std::pair<til::point, til::point> Terminal::_PivotSelection(const til::point targetPos, bool& targetStart) const
|
||||
{
|
||||
if (targetStart = _buffer->GetSize().CompareInBounds(targetPos, _selection->pivot) <= 0)
|
||||
{
|
||||
@@ -202,10 +202,10 @@ std::pair<COORD, COORD> Terminal::_PivotSelection(const COORD targetPos, bool& t
|
||||
// - anchors: a pair of selection anchors representing a desired selection
|
||||
// Return Value:
|
||||
// - the new start/end for a selection
|
||||
std::pair<COORD, COORD> Terminal::_ExpandSelectionAnchors(std::pair<COORD, COORD> anchors) const
|
||||
std::pair<til::point, til::point> Terminal::_ExpandSelectionAnchors(std::pair<til::point, til::point> anchors) const
|
||||
{
|
||||
COORD start = anchors.first;
|
||||
COORD end = anchors.second;
|
||||
auto start = anchors.first;
|
||||
auto end = anchors.second;
|
||||
|
||||
const auto bufferSize = _buffer->GetSize();
|
||||
switch (_multiClickSelectionMode)
|
||||
@@ -329,38 +329,39 @@ void Terminal::UpdateSelection(SelectionDirection direction, SelectionExpansion
|
||||
}
|
||||
}
|
||||
|
||||
void Terminal::_MoveByChar(SelectionDirection direction, COORD& pos)
|
||||
void Terminal::_MoveByChar(SelectionDirection direction, til::point& pos)
|
||||
{
|
||||
switch (direction)
|
||||
{
|
||||
case SelectionDirection::Left:
|
||||
_buffer->GetSize().DecrementInBounds(pos);
|
||||
pos = _buffer->GetGlyphStart(til::point{ pos }).to_win32_coord();
|
||||
pos = _buffer->GetGlyphStart(pos);
|
||||
break;
|
||||
case SelectionDirection::Right:
|
||||
_buffer->GetSize().IncrementInBounds(pos);
|
||||
pos = _buffer->GetGlyphEnd(til::point{ pos }).to_win32_coord();
|
||||
pos = _buffer->GetGlyphEnd(pos);
|
||||
break;
|
||||
case SelectionDirection::Up:
|
||||
{
|
||||
const auto bufferSize{ _buffer->GetSize() };
|
||||
pos = { pos.X, std::clamp(base::ClampSub<short, short>(pos.Y, 1).RawValue(), bufferSize.Top(), bufferSize.BottomInclusive()) };
|
||||
pos = { pos.X, std::clamp(pos.Y + 1, bufferSize.Top(), bufferSize.BottomInclusive()) };
|
||||
break;
|
||||
}
|
||||
case SelectionDirection::Down:
|
||||
{
|
||||
const auto bufferSize{ _buffer->GetSize() };
|
||||
pos = { pos.X, std::clamp(base::ClampAdd<short, short>(pos.Y, 1).RawValue(), bufferSize.Top(), bufferSize.BottomInclusive()) };
|
||||
pos = { pos.X, std::clamp(pos.Y + 1, bufferSize.Top(), bufferSize.BottomInclusive()) };
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Terminal::_MoveByWord(SelectionDirection direction, COORD& pos)
|
||||
void Terminal::_MoveByWord(SelectionDirection direction, til::point& pos)
|
||||
{
|
||||
switch (direction)
|
||||
{
|
||||
case SelectionDirection::Left:
|
||||
{
|
||||
const auto wordStartPos{ _buffer->GetWordStart(pos, _wordDelimiters) };
|
||||
if (_buffer->GetSize().CompareInBounds(_selection->pivot, pos) < 0)
|
||||
{
|
||||
@@ -381,7 +382,9 @@ void Terminal::_MoveByWord(SelectionDirection direction, COORD& pos)
|
||||
pos = wordStartPos;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case SelectionDirection::Right:
|
||||
{
|
||||
const auto wordEndPos{ _buffer->GetWordEnd(pos, _wordDelimiters) };
|
||||
if (_buffer->GetSize().CompareInBounds(pos, _selection->pivot) < 0)
|
||||
{
|
||||
@@ -402,6 +405,7 @@ void Terminal::_MoveByWord(SelectionDirection direction, COORD& pos)
|
||||
pos = wordEndPos;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case SelectionDirection::Up:
|
||||
_MoveByChar(direction, pos);
|
||||
pos = _buffer->GetWordStart(pos, _wordDelimiters);
|
||||
@@ -413,7 +417,7 @@ void Terminal::_MoveByWord(SelectionDirection direction, COORD& pos)
|
||||
}
|
||||
}
|
||||
|
||||
void Terminal::_MoveByViewport(SelectionDirection direction, COORD& pos)
|
||||
void Terminal::_MoveByViewport(SelectionDirection direction, til::point& pos)
|
||||
{
|
||||
const auto bufferSize{ _buffer->GetSize() };
|
||||
switch (direction)
|
||||
@@ -427,22 +431,22 @@ void Terminal::_MoveByViewport(SelectionDirection direction, COORD& pos)
|
||||
case SelectionDirection::Up:
|
||||
{
|
||||
const auto viewportHeight{ _mutableViewport.Height() };
|
||||
const auto newY{ base::ClampSub<short, short>(pos.Y, viewportHeight) };
|
||||
pos = newY < bufferSize.Top() ? bufferSize.Origin() : COORD{ pos.X, newY };
|
||||
const auto newY{ pos.Y + viewportHeight };
|
||||
pos = newY < bufferSize.Top() ? bufferSize.Origin() : til::point{ pos.X, newY };
|
||||
break;
|
||||
}
|
||||
case SelectionDirection::Down:
|
||||
{
|
||||
const auto viewportHeight{ _mutableViewport.Height() };
|
||||
const auto mutableBottom{ _mutableViewport.BottomInclusive() };
|
||||
const auto newY{ base::ClampAdd<short, short>(pos.Y, viewportHeight) };
|
||||
pos = newY > mutableBottom ? COORD{ bufferSize.RightInclusive(), mutableBottom } : COORD{ pos.X, newY };
|
||||
const auto newY{ pos.Y + viewportHeight };
|
||||
pos = newY > mutableBottom ? til::point{ bufferSize.RightInclusive(), mutableBottom } : til::point{ pos.X, newY };
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Terminal::_MoveByBuffer(SelectionDirection direction, COORD& pos)
|
||||
void Terminal::_MoveByBuffer(SelectionDirection direction, til::point& pos)
|
||||
{
|
||||
const auto bufferSize{ _buffer->GetSize() };
|
||||
switch (direction)
|
||||
@@ -498,10 +502,10 @@ const TextBuffer::TextAndColor Terminal::RetrieveSelectedTextFromBuffer(bool sin
|
||||
// - viewportPos: a coordinate on the viewport
|
||||
// Return Value:
|
||||
// - the corresponding location on the buffer
|
||||
COORD Terminal::_ConvertToBufferCell(const COORD viewportPos) const
|
||||
til::point Terminal::_ConvertToBufferCell(const til::point viewportPos) const
|
||||
{
|
||||
const auto yPos = base::ClampedNumeric<short>(_VisibleStartIndex()) + viewportPos.Y;
|
||||
COORD bufferPos = { viewportPos.X, yPos };
|
||||
til::point bufferPos{ viewportPos.X, yPos };
|
||||
_buffer->GetSize().Clamp(bufferPos);
|
||||
return bufferPos;
|
||||
}
|
||||
@@ -513,7 +517,7 @@ COORD Terminal::_ConvertToBufferCell(const COORD viewportPos) const
|
||||
// - coordSelectionStart - Not used
|
||||
// - coordSelectionEnd - Not used
|
||||
// - attr - Not used.
|
||||
void Terminal::ColorSelection(const COORD, const COORD, const TextAttribute)
|
||||
void Terminal::ColorSelection(const til::point, const til::point, const TextAttribute)
|
||||
{
|
||||
THROW_HR(E_NOTIMPL);
|
||||
}
|
||||
|
||||
@@ -14,12 +14,12 @@ Viewport Terminal::GetViewport() noexcept
|
||||
return _GetVisibleViewport();
|
||||
}
|
||||
|
||||
COORD Terminal::GetTextBufferEndPosition() const noexcept
|
||||
til::point Terminal::GetTextBufferEndPosition() const noexcept
|
||||
{
|
||||
// We use the end line of mutableViewport as the end
|
||||
// of the text buffer, it always moves with the written
|
||||
// text
|
||||
COORD endPosition{ _GetMutableViewport().Width() - 1, gsl::narrow<short>(ViewEndIndex()) };
|
||||
til::point endPosition{ _GetMutableViewport().Width() - 1, ViewEndIndex() };
|
||||
return endPosition;
|
||||
}
|
||||
|
||||
@@ -38,7 +38,7 @@ void Terminal::SetFontInfo(const FontInfo& fontInfo)
|
||||
_fontInfo = fontInfo;
|
||||
}
|
||||
|
||||
COORD Terminal::GetCursorPosition() const noexcept
|
||||
til::point Terminal::GetCursorPosition() const noexcept
|
||||
{
|
||||
const auto& cursor = _buffer->GetCursor();
|
||||
return cursor.GetPosition();
|
||||
@@ -104,10 +104,10 @@ const std::wstring Microsoft::Terminal::Core::Terminal::GetHyperlinkCustomId(uin
|
||||
// - The location
|
||||
// Return value:
|
||||
// - The pattern IDs of the location
|
||||
const std::vector<size_t> Terminal::GetPatternId(const COORD location) const noexcept
|
||||
const std::vector<size_t> Terminal::GetPatternId(const til::point location) const noexcept
|
||||
{
|
||||
// Look through our interval tree for this location
|
||||
const auto intervals = _patternIntervalTree.findOverlapping(til::point{ location.X + 1, location.Y }, til::point{ location });
|
||||
const auto intervals = _patternIntervalTree.findOverlapping(til::point{ location.X + 1, location.Y }, location);
|
||||
if (intervals.size() == 0)
|
||||
{
|
||||
return {};
|
||||
@@ -147,12 +147,12 @@ catch (...)
|
||||
return {};
|
||||
}
|
||||
|
||||
void Terminal::SelectNewRegion(const COORD coordStart, const COORD coordEnd)
|
||||
void Terminal::SelectNewRegion(const til::point coordStart, const til::point coordEnd)
|
||||
{
|
||||
#pragma warning(push)
|
||||
#pragma warning(disable : 26496) // cpp core checks wants these const, but they're decremented below.
|
||||
COORD realCoordStart = coordStart;
|
||||
COORD realCoordEnd = coordEnd;
|
||||
auto realCoordStart = coordStart;
|
||||
auto realCoordEnd = coordEnd;
|
||||
#pragma warning(pop)
|
||||
|
||||
bool notifyScrollChange = false;
|
||||
@@ -178,8 +178,8 @@ void Terminal::SelectNewRegion(const COORD coordStart, const COORD coordEnd)
|
||||
_NotifyScrollEvent();
|
||||
}
|
||||
|
||||
realCoordStart.Y -= gsl::narrow<short>(_VisibleStartIndex());
|
||||
realCoordEnd.Y -= gsl::narrow<short>(_VisibleStartIndex());
|
||||
realCoordStart.Y -= _VisibleStartIndex();
|
||||
realCoordEnd.Y -= _VisibleStartIndex();
|
||||
|
||||
SetSelectionAnchor(realCoordStart);
|
||||
SetSelectionEnd(realCoordEnd, SelectionExpansion::Char);
|
||||
|
||||
@@ -416,7 +416,7 @@ namespace ControlUnitTests
|
||||
Log::Comment(L"Verify the location of the selection");
|
||||
// The viewport is on row 21, so the selection will be on:
|
||||
// {(5, 5)+(0, 21)} to {(5, 5)+(0, 21)}
|
||||
COORD expectedAnchor{ 5, 26 };
|
||||
til::point expectedAnchor{ 5, 26 };
|
||||
VERIFY_ARE_EQUAL(expectedAnchor, core->_terminal->GetSelectionAnchor());
|
||||
VERIFY_ARE_EQUAL(expectedAnchor, core->_terminal->GetSelectionEnd());
|
||||
|
||||
@@ -429,7 +429,7 @@ namespace ControlUnitTests
|
||||
Log::Comment(L"Verify the location of the selection");
|
||||
// The viewport is now on row 20, so the selection will be on:
|
||||
// {(5, 5)+(0, 20)} to {(5, 5)+(0, 21)}
|
||||
COORD newExpectedAnchor{ 5, 25 };
|
||||
til::point newExpectedAnchor{ 5, 25 };
|
||||
// Remember, the anchor is always before the end in the buffer. So yes,
|
||||
// se started the selection on 5,26, but now that's the end.
|
||||
VERIFY_ARE_EQUAL(newExpectedAnchor, core->_terminal->GetSelectionAnchor());
|
||||
@@ -562,7 +562,7 @@ namespace ControlUnitTests
|
||||
VERIFY_ARE_EQUAL(1u, core->_terminal->GetSelectionRects().size());
|
||||
|
||||
Log::Comment(L"Verify that it started on the first cell we clicked on, not the one we dragged to");
|
||||
COORD expectedAnchor{ 0, 0 };
|
||||
til::point expectedAnchor{ 0, 0 };
|
||||
VERIFY_ARE_EQUAL(expectedAnchor, core->_terminal->GetSelectionAnchor());
|
||||
}
|
||||
|
||||
@@ -607,9 +607,9 @@ namespace ControlUnitTests
|
||||
VERIFY_ARE_EQUAL(1u, core->_terminal->GetSelectionRects().size());
|
||||
|
||||
Log::Comment(L"Verify that it started on the first cell we clicked on, not the one we dragged to");
|
||||
COORD expectedAnchor{ 0, 0 };
|
||||
til::point expectedAnchor{ 0, 0 };
|
||||
VERIFY_ARE_EQUAL(expectedAnchor, core->_terminal->GetSelectionAnchor());
|
||||
COORD expectedEnd{ 2, 0 };
|
||||
til::point expectedEnd{ 2, 0 };
|
||||
VERIFY_ARE_EQUAL(expectedEnd, core->_terminal->GetSelectionEnd());
|
||||
|
||||
interactivity->PointerReleased(noMouseDown,
|
||||
@@ -777,7 +777,7 @@ namespace ControlUnitTests
|
||||
Log::Comment(L"Verify the location of the selection");
|
||||
// The viewport is on row (historySize + 5), so the selection will be on:
|
||||
// {(5, (historySize+5))+(0, 21)} to {(5, (historySize+5))+(0, 21)}
|
||||
COORD expectedAnchor{ 5, gsl::narrow_cast<SHORT>(settings->HistorySize()) + 5 };
|
||||
til::point expectedAnchor{ 5, settings->HistorySize() + 5 };
|
||||
VERIFY_ARE_EQUAL(expectedAnchor, core->_terminal->GetSelectionAnchor());
|
||||
VERIFY_ARE_EQUAL(expectedAnchor, core->_terminal->GetSelectionEnd());
|
||||
|
||||
|
||||
@@ -52,8 +52,8 @@ class TerminalCoreUnitTests::ConptyRoundtripTests final
|
||||
// !!! DANGER: Many tests in this class expect the Terminal and Host buffers
|
||||
// to be 80x32. If you change these, you'll probably inadvertently break a
|
||||
// bunch of tests !!!
|
||||
static const SHORT TerminalViewWidth = 80;
|
||||
static const SHORT TerminalViewHeight = 32;
|
||||
static const auto TerminalViewWidth = 80;
|
||||
static const auto TerminalViewHeight = 32;
|
||||
|
||||
// This test class is for tests that are supposed to emit something in the PTY layer
|
||||
// and then check that they've been staged for presentation correctly inside
|
||||
@@ -105,7 +105,7 @@ class TerminalCoreUnitTests::ConptyRoundtripTests final
|
||||
// Make sure a test hasn't left us in the alt buffer on accident
|
||||
VERIFY_IS_FALSE(currentBuffer._IsAltBuffer());
|
||||
VERIFY_SUCCEEDED(currentBuffer.SetViewportOrigin(true, { 0, 0 }, true));
|
||||
VERIFY_ARE_EQUAL(COORD({ 0, 0 }), currentBuffer.GetTextBuffer().GetCursor().GetPosition());
|
||||
VERIFY_ARE_EQUAL(til::point{}, currentBuffer.GetTextBuffer().GetCursor().GetPosition());
|
||||
|
||||
g.pRender = new Renderer(gci.GetRenderSettings(), &gci.renderData, nullptr, 0, nullptr);
|
||||
|
||||
@@ -223,7 +223,7 @@ class TerminalCoreUnitTests::ConptyRoundtripTests final
|
||||
private:
|
||||
bool _writeCallback(const char* const pch, size_t const cch);
|
||||
void _flushFirstFrame();
|
||||
void _resizeConpty(const unsigned short sx, const unsigned short sy);
|
||||
void _resizeConpty(const til::CoordType sx, const til::CoordType sy);
|
||||
void _clearConpty();
|
||||
|
||||
[[nodiscard]] std::tuple<TextBuffer*, TextBuffer*> _performResize(const til::size newSize);
|
||||
@@ -288,8 +288,8 @@ void ConptyRoundtripTests::_flushFirstFrame()
|
||||
VERIFY_SUCCEEDED(renderer.PaintFrame());
|
||||
}
|
||||
|
||||
void ConptyRoundtripTests::_resizeConpty(const unsigned short sx,
|
||||
const unsigned short sy)
|
||||
void ConptyRoundtripTests::_resizeConpty(const til::CoordType sx,
|
||||
const til::CoordType sy)
|
||||
{
|
||||
// Largely taken from implementation in PtySignalInputThread::_InputThread
|
||||
if (DispatchCommon::s_ResizeWindow(*_pConApi, sx, sy))
|
||||
@@ -314,9 +314,9 @@ void ConptyRoundtripTests::_clearConpty()
|
||||
|
||||
Log::Comment(L"========== Resize the Terminal and conpty ==========");
|
||||
|
||||
auto resizeResult = term->UserResize(newSize.to_win32_coord());
|
||||
auto resizeResult = term->UserResize(newSize);
|
||||
VERIFY_SUCCEEDED(resizeResult);
|
||||
_resizeConpty(newSize.narrow_width<unsigned short>(), newSize.narrow_height<unsigned short>());
|
||||
_resizeConpty(newSize.width, newSize.height);
|
||||
|
||||
// After we resize, make sure to get the new textBuffers
|
||||
return { &ServiceLocator::LocateGlobals().getConsoleInformation().GetActiveOutputBuffer().GetTextBuffer(),
|
||||
@@ -448,7 +448,7 @@ void ConptyRoundtripTests::TestWrappingALongString()
|
||||
|
||||
const auto initialTermView = term->GetViewport();
|
||||
|
||||
const auto charsToWrite = gsl::narrow_cast<short>(TestUtils::Test100CharsString.size());
|
||||
const auto charsToWrite = TestUtils::Test100CharsString.size();
|
||||
VERIFY_ARE_EQUAL(100, charsToWrite);
|
||||
|
||||
VERIFY_ARE_EQUAL(0, initialTermView.Top());
|
||||
@@ -497,7 +497,7 @@ void ConptyRoundtripTests::TestAdvancedWrapping()
|
||||
|
||||
_flushFirstFrame();
|
||||
|
||||
const auto charsToWrite = gsl::narrow_cast<short>(TestUtils::Test100CharsString.size());
|
||||
const auto charsToWrite = TestUtils::Test100CharsString.size();
|
||||
VERIFY_ARE_EQUAL(100, charsToWrite);
|
||||
|
||||
hostSm.ProcessString(TestUtils::Test100CharsString);
|
||||
@@ -794,9 +794,7 @@ void ConptyRoundtripTests::TestResizeHeight()
|
||||
// If we've printed more lines than the height of the buffer, then we're
|
||||
// expecting the viewport to have moved down. Otherwise, the terminal's
|
||||
// viewport will stay at 0,0.
|
||||
const auto expectedTerminalViewBottom = std::max(std::min(::base::saturated_cast<short>(printedRows + 1),
|
||||
term->GetBufferHeight()),
|
||||
term->GetViewport().Height());
|
||||
const auto expectedTerminalViewBottom = std::clamp(printedRows + 1, term->GetViewport().Height(), term->GetBufferHeight());
|
||||
|
||||
VERIFY_ARE_EQUAL(expectedTerminalViewBottom, secondTermView.BottomExclusive());
|
||||
VERIFY_ARE_EQUAL(expectedTerminalViewBottom - initialTermView.Height(), secondTermView.Top());
|
||||
@@ -805,14 +803,11 @@ void ConptyRoundtripTests::TestResizeHeight()
|
||||
// Some number of lines of text were lost from the scrollback. The
|
||||
// number of lines lost will be determined by whichever of the initial
|
||||
// or current buffer is smaller.
|
||||
const auto numLostRows = std::max(0,
|
||||
printedRows - std::min(term->GetTextBuffer().GetSize().Height(), initialTerminalBufferHeight) + 1);
|
||||
const auto numLostRows = std::max(0, printedRows - std::min(term->GetTextBuffer().GetSize().Height(), initialTerminalBufferHeight) + 1);
|
||||
|
||||
const auto rowsWithText = std::min(::base::saturated_cast<short>(printedRows),
|
||||
expectedTerminalViewBottom) -
|
||||
1 + std::min(resizeDy, 0);
|
||||
const auto rowsWithText = std::min(printedRows, expectedTerminalViewBottom) - 1 + std::min(resizeDy, 0);
|
||||
|
||||
for (short row = 0; row < rowsWithText; row++)
|
||||
for (auto row = 0; row < rowsWithText; row++)
|
||||
{
|
||||
SetVerifyOutput settings(VerifyOutputSettings::LogOnlyFailures);
|
||||
auto iter = termTb.GetCellDataAt({ 0, row });
|
||||
@@ -846,9 +841,7 @@ void ConptyRoundtripTests::TestResizeHeight()
|
||||
// characters, but then we'll want to look for more blank rows at the
|
||||
// bottom. The characters in the initial viewport won't have moved.
|
||||
|
||||
const short originalViewHeight = ::base::saturated_cast<short>(resizeDy < 0 ?
|
||||
initialHostView.Height() + resizeDy :
|
||||
initialHostView.Height());
|
||||
const auto originalViewHeight = resizeDy < 0 ? initialHostView.Height() + resizeDy : initialHostView.Height();
|
||||
const auto rowsWithText = std::min(originalViewHeight - 1, printedRows);
|
||||
const bool scrolled = printedRows > initialHostView.Height();
|
||||
// The last row of the viewport should be empty
|
||||
@@ -856,11 +849,9 @@ void ConptyRoundtripTests::TestResizeHeight()
|
||||
// The third last row will have '0'+49
|
||||
// ...
|
||||
// The <height> last row will have '0'+(50-height+1)
|
||||
const auto firstChar = static_cast<wchar_t>(scrolled ?
|
||||
(printedRows - originalViewHeight + 1) :
|
||||
0);
|
||||
const auto firstChar = static_cast<wchar_t>(scrolled ? (printedRows - originalViewHeight + 1) : 0);
|
||||
|
||||
short row = 0;
|
||||
auto row = 0;
|
||||
// Don't include the last row of the viewport in this check, since it'll
|
||||
// be blank. We'll check it in the below loop.
|
||||
for (; row < rowsWithText; row++)
|
||||
@@ -1021,7 +1012,7 @@ void ConptyRoundtripTests::PassthroughClearScrollback()
|
||||
|
||||
// Verify that we've printed height*2 lines of X's to the Terminal
|
||||
const auto termFirstView = term->GetViewport();
|
||||
for (short y = 0; y < 2 * termFirstView.Height(); y++)
|
||||
for (auto y = 0; y < 2 * termFirstView.Height(); y++)
|
||||
{
|
||||
TestUtils::VerifyExpectedString(termTb, L"X ", { 0, y });
|
||||
}
|
||||
@@ -1038,13 +1029,13 @@ void ConptyRoundtripTests::PassthroughClearScrollback()
|
||||
VERIFY_ARE_EQUAL(0, termSecondView.Top());
|
||||
|
||||
// Verify the top of the Terminal viewport contains the contents of the old viewport
|
||||
for (short y = 0; y < termSecondView.BottomInclusive(); y++)
|
||||
for (auto y = 0; y < termSecondView.BottomInclusive(); y++)
|
||||
{
|
||||
TestUtils::VerifyExpectedString(termTb, L"X ", { 0, y });
|
||||
}
|
||||
|
||||
// Verify below the new viewport (the old viewport) has been cleared out
|
||||
for (short y = termSecondView.BottomInclusive(); y < termFirstView.BottomInclusive(); y++)
|
||||
for (auto y = termSecondView.BottomInclusive(); y < termFirstView.BottomInclusive(); y++)
|
||||
{
|
||||
TestUtils::VerifyExpectedString(termTb, std::wstring(TerminalViewWidth, L' '), { 0, y });
|
||||
}
|
||||
@@ -1086,15 +1077,15 @@ void ConptyRoundtripTests::PassthroughClearAll()
|
||||
}
|
||||
|
||||
auto verifyBuffer = [&](const TextBuffer& tb, const til::rect& viewport, const bool afterClear = false) {
|
||||
const auto width = viewport.narrow_width<short>();
|
||||
const auto width = viewport.width();
|
||||
|
||||
// "~" rows
|
||||
for (short row = 0; row < viewport.narrow_bottom<short>(); row++)
|
||||
for (auto row = 0; row < viewport.Bottom; row++)
|
||||
{
|
||||
Log::Comment(NoThrowString().Format(L"Checking row %d", row));
|
||||
VERIFY_IS_FALSE(tb.GetRowByOffset(row).WasWrapForced());
|
||||
auto iter = tb.GetCellDataAt({ 0, row });
|
||||
if (afterClear && row >= viewport.narrow_top<short>())
|
||||
if (afterClear && row >= viewport.Top)
|
||||
{
|
||||
TestUtils::VerifySpanOfText(L" ", iter, 0, width);
|
||||
}
|
||||
@@ -1127,7 +1118,7 @@ void ConptyRoundtripTests::PassthroughClearAll()
|
||||
// Make sure that the terminal's new viewport is actually just lower than it
|
||||
// used to be.
|
||||
const til::rect newTerminalView{ term->_mutableViewport.ToInclusive() };
|
||||
VERIFY_ARE_EQUAL(end, newTerminalView.narrow_top<short>());
|
||||
VERIFY_ARE_EQUAL(end, newTerminalView.Top);
|
||||
VERIFY_IS_GREATER_THAN(newTerminalView.top, originalTerminalView.top);
|
||||
|
||||
Log::Comment(L"========== Checking the host buffer state (after) ==========");
|
||||
@@ -1185,7 +1176,7 @@ void ConptyRoundtripTests::PassthroughHardReset()
|
||||
|
||||
// Verify that we've printed height*2 lines of X's to the Terminal
|
||||
const auto termFirstView = term->GetViewport();
|
||||
for (short y = 0; y < 2 * termFirstView.Height(); y++)
|
||||
for (auto y = 0; y < 2 * termFirstView.Height(); y++)
|
||||
{
|
||||
TestUtils::VerifyExpectedString(termTb, L"X ", { 0, y });
|
||||
}
|
||||
@@ -1198,7 +1189,7 @@ void ConptyRoundtripTests::PassthroughHardReset()
|
||||
VERIFY_ARE_EQUAL(0, termSecondView.Top());
|
||||
|
||||
// Verify everything has been cleared out
|
||||
for (short y = 0; y < termFirstView.BottomInclusive(); y++)
|
||||
for (auto y = 0; y < termFirstView.BottomInclusive(); y++)
|
||||
{
|
||||
TestUtils::VerifyExpectedString(termTb, std::wstring(TerminalViewWidth, L' '), { 0, y });
|
||||
}
|
||||
@@ -1351,7 +1342,7 @@ void ConptyRoundtripTests::OutputWrappedLinesAtBottomOfBuffer()
|
||||
|
||||
hostSm.ProcessString(std::wstring(wrappedLineLength, L'A'));
|
||||
|
||||
auto verifyBuffer = [](const TextBuffer& tb, const short wrappedRow) {
|
||||
auto verifyBuffer = [](const TextBuffer& tb, const auto wrappedRow) {
|
||||
// Buffer contents should look like the following: (80 wide)
|
||||
// (w) means we hard wrapped the line
|
||||
// (b) means the line is _not_ wrapped (it's broken, the default state.)
|
||||
@@ -1369,9 +1360,9 @@ void ConptyRoundtripTests::OutputWrappedLinesAtBottomOfBuffer()
|
||||
|
||||
auto iter0 = tb.GetCellDataAt({ 0, wrappedRow });
|
||||
TestUtils::VerifySpanOfText(L"A", iter0, 0, TerminalViewWidth);
|
||||
auto iter1 = tb.GetCellDataAt({ 0, gsl::narrow<short>(wrappedRow + 1) });
|
||||
auto iter1 = tb.GetCellDataAt({ 0, wrappedRow + 1 });
|
||||
TestUtils::VerifySpanOfText(L"A", iter1, 0, 20);
|
||||
auto iter2 = tb.GetCellDataAt({ 20, gsl::narrow<short>(wrappedRow + 1) });
|
||||
auto iter2 = tb.GetCellDataAt({ 20, wrappedRow + 1 });
|
||||
TestUtils::VerifySpanOfText(L" ", iter2, 0, TerminalViewWidth - 20);
|
||||
};
|
||||
|
||||
@@ -1457,9 +1448,9 @@ void ConptyRoundtripTests::ScrollWithChangesInMiddle()
|
||||
hostSm.ProcessString(std::wstring(wrappedLineLength, L'A')); // Print 100 'A's
|
||||
|
||||
auto verifyBuffer = [](const TextBuffer& tb, const til::rect& viewport) {
|
||||
const auto wrappedRow = gsl::narrow<short>(viewport.bottom - 2);
|
||||
const short start = viewport.narrow_top<short>();
|
||||
for (short i = start; i < wrappedRow; i++)
|
||||
const auto wrappedRow = viewport.Bottom - 2;
|
||||
const auto start = viewport.Top;
|
||||
for (auto i = start; i < wrappedRow; i++)
|
||||
{
|
||||
Log::Comment(NoThrowString().Format(L"Checking row %d", i));
|
||||
TestUtils::VerifyExpectedString(tb, i == start + 13 ? L"Y" : L"X", { 0, i });
|
||||
@@ -1471,9 +1462,9 @@ void ConptyRoundtripTests::ScrollWithChangesInMiddle()
|
||||
auto iter0 = tb.GetCellDataAt({ 0, wrappedRow });
|
||||
TestUtils::VerifySpanOfText(L"A", iter0, 0, TerminalViewWidth);
|
||||
|
||||
auto iter1 = tb.GetCellDataAt({ 0, gsl::narrow<short>(wrappedRow + 1) });
|
||||
auto iter1 = tb.GetCellDataAt({ 0, wrappedRow + 1 });
|
||||
TestUtils::VerifySpanOfText(L"A", iter1, 0, 20);
|
||||
auto iter2 = tb.GetCellDataAt({ 20, gsl::narrow<short>(wrappedRow + 1) });
|
||||
auto iter2 = tb.GetCellDataAt({ 20, wrappedRow + 1 });
|
||||
TestUtils::VerifySpanOfText(L" ", iter2, 0, TerminalViewWidth - 20);
|
||||
};
|
||||
|
||||
@@ -1550,13 +1541,13 @@ void ConptyRoundtripTests::ScrollWithMargins()
|
||||
for (auto i = 0; i < rowsToWrite; ++i)
|
||||
{
|
||||
const std::wstring expectedString(4, static_cast<wchar_t>(L'A' + i));
|
||||
const COORD expectedPos{ 0, gsl::narrow<SHORT>(i) };
|
||||
const til::point expectedPos{ 0, i };
|
||||
TestUtils::VerifyExpectedString(tb, expectedString, expectedPos);
|
||||
}
|
||||
|
||||
// For the last row, verify we have an entire row of asterisks for the mode line.
|
||||
const std::wstring expectedModeLine(initialTermView.Width() - 1, L'*');
|
||||
const COORD expectedPos{ 0, gsl::narrow<SHORT>(rowsToWrite) };
|
||||
const til::point expectedPos{ 0, rowsToWrite };
|
||||
TestUtils::VerifyExpectedString(tb, expectedModeLine, expectedPos);
|
||||
};
|
||||
|
||||
@@ -1667,21 +1658,21 @@ void ConptyRoundtripTests::ScrollWithMargins()
|
||||
{
|
||||
// Start with B this time because the A line got scrolled off the top.
|
||||
const std::wstring expectedString(4, static_cast<wchar_t>(L'B' + i));
|
||||
const COORD expectedPos{ 0, gsl::narrow<SHORT>(i) };
|
||||
const til::point expectedPos{ 0, i };
|
||||
TestUtils::VerifyExpectedString(tb, expectedString, expectedPos);
|
||||
}
|
||||
|
||||
// For the second to last row, verify that it is blank.
|
||||
{
|
||||
const std::wstring expectedBlankLine(initialTermView.Width(), L' ');
|
||||
const COORD blankLinePos{ 0, gsl::narrow<SHORT>(rowsToWrite - 1) };
|
||||
const til::point blankLinePos{ 0, rowsToWrite - 1 };
|
||||
TestUtils::VerifyExpectedString(tb, expectedBlankLine, blankLinePos);
|
||||
}
|
||||
|
||||
// For the last row, verify we have an entire row of asterisks for the mode line.
|
||||
{
|
||||
const std::wstring expectedModeLine(initialTermView.Width() - 1, L'*');
|
||||
const COORD modeLinePos{ 0, gsl::narrow<SHORT>(rowsToWrite) };
|
||||
const til::point modeLinePos{ 0, rowsToWrite };
|
||||
TestUtils::VerifyExpectedString(tb, expectedModeLine, modeLinePos);
|
||||
}
|
||||
};
|
||||
@@ -1749,7 +1740,7 @@ void ConptyRoundtripTests::DontWrapMoveCursorInSingleFrame()
|
||||
// Simple verification: Make sure the cursor is in the correct place,
|
||||
// and that it's visible. We don't care so much about the buffer
|
||||
// contents in this test.
|
||||
const COORD expectedCursor{ 8, 3 };
|
||||
const til::point expectedCursor{ 8, 3 };
|
||||
VERIFY_ARE_EQUAL(expectedCursor, tb.GetCursor().GetPosition());
|
||||
VERIFY_IS_TRUE(tb.GetCursor().IsVisible());
|
||||
};
|
||||
@@ -1839,15 +1830,15 @@ void ConptyRoundtripTests::ClearHostTrickeryTest()
|
||||
_flushFirstFrame();
|
||||
|
||||
auto verifyBuffer = [&cursorOnNextLine, &useLongSpaces, &printTextAfterSpaces](const TextBuffer& tb,
|
||||
const til::rect viewport) {
|
||||
const til::rect& viewport) {
|
||||
// We _would_ expect the Terminal's cursor to be on { 8, 0 }, but this
|
||||
// is currently broken due to #381/#4676. So we'll use the viewport
|
||||
// provided to find the actual Y position of the cursor.
|
||||
const short viewTop = viewport.origin().narrow_y<short>();
|
||||
const short cursorRow = viewTop + (cursorOnNextLine ? 1 : 0);
|
||||
const short cursorCol = (cursorOnNextLine ? 5 :
|
||||
(10 + (useLongSpaces ? 5 : 0) + (printTextAfterSpaces ? 5 : 0)));
|
||||
const COORD expectedCursor{ cursorCol, cursorRow };
|
||||
const auto viewTop = viewport.origin().y;
|
||||
const auto cursorRow = viewTop + (cursorOnNextLine ? 1 : 0);
|
||||
const auto cursorCol = (cursorOnNextLine ? 5 :
|
||||
(10 + (useLongSpaces ? 5 : 0) + (printTextAfterSpaces ? 5 : 0)));
|
||||
const til::point expectedCursor{ cursorCol, cursorRow };
|
||||
|
||||
VERIFY_ARE_EQUAL(expectedCursor, tb.GetCursor().GetPosition());
|
||||
VERIFY_IS_TRUE(tb.GetCursor().IsVisible());
|
||||
@@ -1947,15 +1938,15 @@ void ConptyRoundtripTests::OverstrikeAtBottomOfBuffer()
|
||||
_flushFirstFrame();
|
||||
|
||||
auto verifyBuffer = [](const TextBuffer& tb,
|
||||
const til::rect viewport) {
|
||||
const til::rect& viewport) {
|
||||
const auto lastRow = viewport.bottom - 1;
|
||||
const til::point expectedCursor{ 0, lastRow - 1 };
|
||||
VERIFY_ARE_EQUAL(expectedCursor, til::point{ tb.GetCursor().GetPosition() });
|
||||
VERIFY_IS_TRUE(tb.GetCursor().IsVisible());
|
||||
|
||||
TestUtils::VerifyExpectedString(tb, L"AAAAAAAAAA DDDDDDDDDD", COORD{ 0, gsl::narrow<short>(lastRow - 2) });
|
||||
TestUtils::VerifyExpectedString(tb, L"BBBBBBBBBB", COORD{ 0, gsl::narrow<short>(lastRow - 1) });
|
||||
TestUtils::VerifyExpectedString(tb, L"FFFFFFFFFE", COORD{ 0, gsl::narrow<short>(lastRow) });
|
||||
TestUtils::VerifyExpectedString(tb, L"AAAAAAAAAA DDDDDDDDDD", til::point{ 0, lastRow - 2 });
|
||||
TestUtils::VerifyExpectedString(tb, L"BBBBBBBBBB", til::point{ 0, lastRow - 1 });
|
||||
TestUtils::VerifyExpectedString(tb, L"FFFFFFFFFE", til::point{ 0, lastRow });
|
||||
};
|
||||
|
||||
_logConpty = true;
|
||||
@@ -2025,17 +2016,17 @@ void ConptyRoundtripTests::MarginsWithStatusLine()
|
||||
_flushFirstFrame();
|
||||
|
||||
auto verifyBuffer = [](const TextBuffer& tb,
|
||||
const til::rect viewport) {
|
||||
const auto lastRow = gsl::narrow<short>(viewport.bottom - 1);
|
||||
const til::rect& viewport) {
|
||||
const auto lastRow = viewport.Bottom - 1;
|
||||
const til::point expectedCursor{ 1, lastRow };
|
||||
VERIFY_ARE_EQUAL(expectedCursor, til::point{ tb.GetCursor().GetPosition() });
|
||||
VERIFY_IS_TRUE(tb.GetCursor().IsVisible());
|
||||
|
||||
TestUtils::VerifyExpectedString(tb, L"EEEEEEEEEE", COORD{ 0, gsl::narrow<short>(lastRow - 4) });
|
||||
TestUtils::VerifyExpectedString(tb, L"AAAAAAAAAA", COORD{ 0, gsl::narrow<short>(lastRow - 3) });
|
||||
TestUtils::VerifyExpectedString(tb, L" ", COORD{ 0, gsl::narrow<short>(lastRow - 2) });
|
||||
TestUtils::VerifyExpectedString(tb, L"XBBBBBBBBB", COORD{ 0, gsl::narrow<short>(lastRow - 1) });
|
||||
TestUtils::VerifyExpectedString(tb, L"YCCCCCCCCC", COORD{ 0, lastRow });
|
||||
TestUtils::VerifyExpectedString(tb, L"EEEEEEEEEE", til::point{ 0, lastRow - 4 });
|
||||
TestUtils::VerifyExpectedString(tb, L"AAAAAAAAAA", til::point{ 0, lastRow - 3 });
|
||||
TestUtils::VerifyExpectedString(tb, L" ", til::point{ 0, lastRow - 2 });
|
||||
TestUtils::VerifyExpectedString(tb, L"XBBBBBBBBB", til::point{ 0, lastRow - 1 });
|
||||
TestUtils::VerifyExpectedString(tb, L"YCCCCCCCCC", til::point{ 0, lastRow });
|
||||
};
|
||||
|
||||
// We're _not_ checking the conpty output during this test, only the side effects.
|
||||
@@ -2044,7 +2035,7 @@ void ConptyRoundtripTests::MarginsWithStatusLine()
|
||||
// Use DECALN to fill the buffer with 'E's.
|
||||
hostSm.ProcessString(L"\x1b#8");
|
||||
|
||||
const short originalBottom = si.GetViewport().BottomInclusive();
|
||||
const auto originalBottom = si.GetViewport().BottomInclusive();
|
||||
// Print 3 lines into the bottom of the buffer:
|
||||
// AAAAAAAAAA
|
||||
// BBBBBBBBBB
|
||||
@@ -2065,17 +2056,17 @@ void ConptyRoundtripTests::MarginsWithStatusLine()
|
||||
// After printing the 'C' line, the cursor is on the bottom line of the viewport.
|
||||
// Emit a newline here to get a new line at the bottom of the viewport.
|
||||
hostSm.ProcessString(L"\n");
|
||||
const short newBottom = si.GetViewport().BottomInclusive();
|
||||
const auto newBottom = si.GetViewport().BottomInclusive();
|
||||
|
||||
{
|
||||
// Emulate calling ScrollConsoleScreenBuffer to scroll the B and C lines
|
||||
// down one line.
|
||||
SMALL_RECT src;
|
||||
til::inclusive_rect src;
|
||||
src.Top = newBottom - 2;
|
||||
src.Left = 0;
|
||||
src.Right = si.GetViewport().Width();
|
||||
src.Bottom = originalBottom;
|
||||
COORD tgt{ 0, gsl::narrow<short>(newBottom - 1) };
|
||||
til::point tgt{ 0, newBottom - 1 };
|
||||
TextAttribute useThisAttr(0x07); // We don't terribly care about the attributes so this is arbitrary
|
||||
ScrollRegion(si, src, std::nullopt, tgt, L' ', useThisAttr);
|
||||
}
|
||||
@@ -2281,7 +2272,7 @@ void ConptyRoundtripTests::OutputWrappedLineWithSpaceAtBottomOfBuffer()
|
||||
// | B_ ... | (b) (cursor is on the '_')
|
||||
// | ... | (b)
|
||||
|
||||
const auto wrappedRow = gsl::narrow<short>(viewport.bottom - 2);
|
||||
const auto wrappedRow = viewport.Bottom - 2;
|
||||
VERIFY_IS_TRUE(tb.GetRowByOffset(wrappedRow).WasWrapForced());
|
||||
VERIFY_IS_FALSE(tb.GetRowByOffset(wrappedRow + 1).WasWrapForced());
|
||||
|
||||
@@ -2291,9 +2282,9 @@ void ConptyRoundtripTests::OutputWrappedLineWithSpaceAtBottomOfBuffer()
|
||||
TestUtils::VerifySpanOfText(L" ", iter0, 0, 2);
|
||||
|
||||
// Second row
|
||||
auto iter1 = tb.GetCellDataAt({ 0, gsl::narrow<short>(wrappedRow + 1) });
|
||||
auto iter1 = tb.GetCellDataAt({ 0, wrappedRow + 1 });
|
||||
TestUtils::VerifySpanOfText(L" ", iter1, 0, 1);
|
||||
auto iter2 = tb.GetCellDataAt({ 1, gsl::narrow<short>(wrappedRow + 1) });
|
||||
auto iter2 = tb.GetCellDataAt({ 1, wrappedRow + 1 });
|
||||
TestUtils::VerifySpanOfText(L"B", iter2, 0, secondTextLength);
|
||||
};
|
||||
|
||||
@@ -2343,22 +2334,22 @@ void ConptyRoundtripTests::BreakLinesOnCursorMovement()
|
||||
(cursorMovementMode == MoveCursorWithCUB_LF);
|
||||
|
||||
auto verifyBuffer = [&](const TextBuffer& tb,
|
||||
const til::rect viewport) {
|
||||
const auto lastRow = gsl::narrow<short>(viewport.bottom - 1);
|
||||
const til::rect& viewport) {
|
||||
const auto lastRow = viewport.Bottom - 1;
|
||||
const til::point expectedCursor{ 5, lastRow };
|
||||
VERIFY_ARE_EQUAL(expectedCursor, til::point{ tb.GetCursor().GetPosition() });
|
||||
VERIFY_IS_TRUE(tb.GetCursor().IsVisible());
|
||||
|
||||
for (auto y = viewport.narrow_top<short>(); y < lastRow; y++)
|
||||
for (auto y = viewport.Top; y < lastRow; y++)
|
||||
{
|
||||
// We're using CUP to move onto the status line _always_, so the
|
||||
// second-last row will always be marked as wrapped.
|
||||
const auto rowWrapped = (!expectHardBreak) || (y == lastRow - 1);
|
||||
VERIFY_ARE_EQUAL(rowWrapped, tb.GetRowByOffset(y).WasWrapForced());
|
||||
TestUtils::VerifyExpectedString(tb, L"~ ", COORD{ 0, y });
|
||||
TestUtils::VerifyExpectedString(tb, L"~ ", til::point{ 0, y });
|
||||
}
|
||||
|
||||
TestUtils::VerifyExpectedString(tb, L"AAAAA", COORD{ 0, lastRow });
|
||||
TestUtils::VerifyExpectedString(tb, L"AAAAA", til::point{ 0, lastRow });
|
||||
};
|
||||
|
||||
// We're _not_ checking the conpty output during this test, only the side effects.
|
||||
@@ -2497,7 +2488,7 @@ void ConptyRoundtripTests::TestCursorInDeferredEOLPositionOnNewLineWithSpaces()
|
||||
// fill width-1 with "A", then add one space and another character..
|
||||
hostSm.ProcessString(std::wstring(gsl::narrow_cast<size_t>(TerminalViewWidth) - 1, L'A') + L" B");
|
||||
|
||||
auto verifyBuffer = [&](const TextBuffer& tb, SHORT bottomRow) {
|
||||
auto verifyBuffer = [&](const TextBuffer& tb, til::CoordType bottomRow) {
|
||||
// Buffer contents should look like the following: (80 wide)
|
||||
// (w) means we hard wrapped the line
|
||||
// (b) means the line is _not_ wrapped (it's broken, the default state.)
|
||||
@@ -2518,7 +2509,7 @@ void ConptyRoundtripTests::TestCursorInDeferredEOLPositionOnNewLineWithSpaces()
|
||||
VERIFY_IS_FALSE(lastRow.WasWrapForced());
|
||||
|
||||
auto expectedStringSecondToLastRow{ std::wstring(gsl::narrow_cast<size_t>(tb.GetSize().Width()) - 1, L'A') + L" " };
|
||||
TestUtils::VerifyExpectedString(tb, expectedStringSecondToLastRow, { 0, gsl::narrow<short>(bottomRow - 1) });
|
||||
TestUtils::VerifyExpectedString(tb, expectedStringSecondToLastRow, { 0, bottomRow - 1 });
|
||||
TestUtils::VerifyExpectedString(tb, L"B", { 0, bottomRow });
|
||||
};
|
||||
|
||||
@@ -2588,8 +2579,8 @@ void ConptyRoundtripTests::ResizeRepaintVimExeBuffer()
|
||||
drawVim();
|
||||
|
||||
auto verifyBuffer = [&](const TextBuffer& tb, const til::rect& viewport) {
|
||||
const auto firstRow = viewport.narrow_top<short>();
|
||||
const auto width = viewport.narrow_width<short>();
|
||||
const auto firstRow = viewport.Top;
|
||||
const auto width = viewport.width();
|
||||
|
||||
// First row
|
||||
VERIFY_IS_FALSE(tb.GetRowByOffset(firstRow).WasWrapForced());
|
||||
@@ -2599,12 +2590,12 @@ void ConptyRoundtripTests::ResizeRepaintVimExeBuffer()
|
||||
|
||||
// Second row
|
||||
VERIFY_IS_FALSE(tb.GetRowByOffset(firstRow + 1).WasWrapForced());
|
||||
auto iter1 = tb.GetCellDataAt({ 0, gsl::narrow<short>(firstRow + 1) });
|
||||
auto iter1 = tb.GetCellDataAt({ 0, firstRow + 1 });
|
||||
TestUtils::VerifySpanOfText(L"B", iter1, 0, 3);
|
||||
TestUtils::VerifySpanOfText(L" ", iter1, 0, width - 3);
|
||||
|
||||
// "~" rows
|
||||
for (short row = firstRow + 2; row < viewport.bottom - 1; row++)
|
||||
for (auto row = firstRow + 2; row < viewport.Bottom - 1; row++)
|
||||
{
|
||||
Log::Comment(NoThrowString().Format(L"Checking row %d", row));
|
||||
VERIFY_IS_TRUE(tb.GetRowByOffset(row).WasWrapForced());
|
||||
@@ -2615,7 +2606,7 @@ void ConptyRoundtripTests::ResizeRepaintVimExeBuffer()
|
||||
|
||||
// Last row
|
||||
{
|
||||
const auto row = gsl::narrow<short>(viewport.bottom - 1);
|
||||
auto row = viewport.Bottom - 1;
|
||||
Log::Comment(NoThrowString().Format(L"Checking row %d", row));
|
||||
VERIFY_IS_TRUE(tb.GetRowByOffset(row).WasWrapForced());
|
||||
auto iter = tb.GetCellDataAt({ 0, row });
|
||||
@@ -2698,10 +2689,10 @@ void ConptyRoundtripTests::ClsAndClearHostClearsScrollbackTest()
|
||||
}
|
||||
|
||||
auto verifyBuffer = [&](const TextBuffer& tb, const til::rect& viewport, const bool afterClear = false) {
|
||||
const auto width = viewport.narrow_width<short>();
|
||||
const auto width = viewport.width();
|
||||
|
||||
// "~" rows
|
||||
for (short row = 0; row < viewport.narrow_bottom<short>(); row++)
|
||||
for (auto row = 0; row < viewport.Bottom; row++)
|
||||
{
|
||||
Log::Comment(NoThrowString().Format(L"Checking row %d", row));
|
||||
VERIFY_IS_FALSE(tb.GetRowByOffset(row).WasWrapForced());
|
||||
@@ -2738,13 +2729,13 @@ void ConptyRoundtripTests::ClsAndClearHostClearsScrollbackTest()
|
||||
csbiex.cbSize = sizeof(CONSOLE_SCREEN_BUFFER_INFOEX);
|
||||
_apiRoutines.GetConsoleScreenBufferInfoExImpl(si, csbiex);
|
||||
|
||||
SMALL_RECT src{ 0 };
|
||||
til::inclusive_rect src{ 0 };
|
||||
src.Top = 0;
|
||||
src.Left = 0;
|
||||
src.Right = csbiex.dwSize.X;
|
||||
src.Bottom = csbiex.dwSize.Y;
|
||||
|
||||
COORD tgt{ 0, -csbiex.dwSize.Y };
|
||||
til::point tgt{ 0, -csbiex.dwSize.Y };
|
||||
VERIFY_SUCCEEDED(_apiRoutines.ScrollConsoleScreenBufferWImpl(si,
|
||||
src,
|
||||
tgt,
|
||||
@@ -2934,12 +2925,12 @@ void ConptyRoundtripTests::ResizeInitializeBufferWithDefaultAttrs()
|
||||
}
|
||||
|
||||
auto verifyBuffer = [&](const TextBuffer& tb, const til::rect& viewport, const bool isTerminal, const bool afterResize) {
|
||||
const auto width = viewport.narrow_width<short>();
|
||||
const auto width = viewport.width();
|
||||
|
||||
// Conhost and Terminal attributes are potentially different.
|
||||
const auto greenAttrs = isTerminal ? terminalGreenAttrs : conhostGreenAttrs;
|
||||
|
||||
for (short row = 0; row < tb.GetSize().Height(); row++)
|
||||
for (auto row = 0; row < tb.GetSize().Height(); row++)
|
||||
{
|
||||
Log::Comment(NoThrowString().Format(L"Checking row %d...", row));
|
||||
|
||||
@@ -2966,7 +2957,7 @@ void ConptyRoundtripTests::ResizeInitializeBufferWithDefaultAttrs()
|
||||
}
|
||||
else
|
||||
{
|
||||
TestUtils::VerifyLineContains(tb, { 0, row }, L' ', actualDefaultAttrs, viewport.narrow_width<size_t>());
|
||||
TestUtils::VerifyLineContains(tb, { 0, row }, L' ', actualDefaultAttrs, viewport.width());
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -3072,13 +3063,13 @@ void ConptyRoundtripTests::NewLinesAtBottomWithBackground()
|
||||
}
|
||||
|
||||
auto verifyBuffer = [&](const TextBuffer& tb, const til::rect& viewport) {
|
||||
const auto width = viewport.narrow_width<short>();
|
||||
const auto width = viewport.width();
|
||||
const auto isTerminal = viewport.top != 0;
|
||||
|
||||
// Conhost and Terminal attributes are potentially different.
|
||||
const auto blueAttrs = isTerminal ? terminalBlueAttrs : conhostBlueAttrs;
|
||||
|
||||
for (short row = 0; row < viewport.bottom - 2; row++)
|
||||
for (auto row = 0; row < viewport.Bottom - 2; row++)
|
||||
{
|
||||
Log::Comment(NoThrowString().Format(L"Checking row %d", row));
|
||||
VERIFY_IS_FALSE(tb.GetRowByOffset(row).WasWrapForced());
|
||||
@@ -3094,7 +3085,7 @@ void ConptyRoundtripTests::NewLinesAtBottomWithBackground()
|
||||
|
||||
if (isBlank)
|
||||
{
|
||||
TestUtils::VerifyLineContains(tb, { 0, row }, L' ', actualDefaultAttrs, viewport.narrow_width<size_t>());
|
||||
TestUtils::VerifyLineContains(tb, { 0, row }, L' ', actualDefaultAttrs, viewport.width());
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -3272,10 +3263,10 @@ void ConptyRoundtripTests::WrapNewLineAtBottom()
|
||||
// row[5]: |~~~~~~ | <break>
|
||||
|
||||
auto verifyBuffer = [&](const TextBuffer& tb, const til::rect& viewport) {
|
||||
const auto width = viewport.narrow_width<short>();
|
||||
const auto width = viewport.width();
|
||||
const auto isTerminal = viewport.top != 0;
|
||||
|
||||
for (short row = 0; row < viewport.narrow_bottom<short>(); row++)
|
||||
for (til::CoordType row = 0; row < viewport.Bottom; row++)
|
||||
{
|
||||
Log::Comment(NoThrowString().Format(L"Checking row %d", row));
|
||||
|
||||
@@ -3289,11 +3280,11 @@ void ConptyRoundtripTests::WrapNewLineAtBottom()
|
||||
VERIFY_ARE_EQUAL(isWrapped, tb.GetRowByOffset(row).WasWrapForced());
|
||||
if (isWrapped)
|
||||
{
|
||||
TestUtils::VerifyExpectedString(tb, std::wstring(charsInFirstLine, L'~'), COORD{ 0, row });
|
||||
TestUtils::VerifyExpectedString(tb, std::wstring(charsInFirstLine, L'~'), til::point{ 0, row });
|
||||
}
|
||||
else
|
||||
{
|
||||
auto iter = TestUtils::VerifyExpectedString(tb, std::wstring(charsInSecondLine, L'~'), COORD{ 0, row });
|
||||
auto iter = TestUtils::VerifyExpectedString(tb, std::wstring(charsInSecondLine, L'~'), til::point{ 0, row });
|
||||
TestUtils::VerifyExpectedString(std::wstring(width - charsInSecondLine, L' '), iter);
|
||||
}
|
||||
}
|
||||
@@ -3474,10 +3465,10 @@ void ConptyRoundtripTests::WrapNewLineAtBottomLikeMSYS()
|
||||
}
|
||||
|
||||
auto verifyBuffer = [&](const TextBuffer& tb, const til::rect& viewport) {
|
||||
const auto width = viewport.narrow_width<short>();
|
||||
const auto width = viewport.width();
|
||||
const auto isTerminal = viewport.top != 0;
|
||||
auto lastRow = gsl::narrow<short>(viewport.bottom - 1);
|
||||
for (short row = 0; row < lastRow; row++)
|
||||
auto lastRow = viewport.Bottom - 1;
|
||||
for (til::CoordType row = 0; row < lastRow; row++)
|
||||
{
|
||||
Log::Comment(NoThrowString().Format(L"Checking row %d", row));
|
||||
|
||||
@@ -3496,16 +3487,16 @@ void ConptyRoundtripTests::WrapNewLineAtBottomLikeMSYS()
|
||||
VERIFY_ARE_EQUAL(isWrapped, tb.GetRowByOffset(row).WasWrapForced());
|
||||
if (isWrapped)
|
||||
{
|
||||
TestUtils::VerifyExpectedString(tb, std::wstring(charsInFirstLine, L'~'), COORD{ 0, row });
|
||||
TestUtils::VerifyExpectedString(tb, std::wstring(charsInFirstLine, L'~'), til::point{ 0, row });
|
||||
}
|
||||
else
|
||||
{
|
||||
auto iter = TestUtils::VerifyExpectedString(tb, std::wstring(charsInSecondLine, L'~'), COORD{ 0, row });
|
||||
auto iter = TestUtils::VerifyExpectedString(tb, std::wstring(charsInSecondLine, L'~'), til::point{ 0, row });
|
||||
TestUtils::VerifyExpectedString(std::wstring(width - charsInSecondLine, L' '), iter);
|
||||
}
|
||||
}
|
||||
VERIFY_IS_FALSE(tb.GetRowByOffset(lastRow).WasWrapForced());
|
||||
auto iter = TestUtils::VerifyExpectedString(tb, std::wstring(1, L':'), COORD{ 0, lastRow });
|
||||
auto iter = TestUtils::VerifyExpectedString(tb, std::wstring(1, L':'), til::point{ 0, lastRow });
|
||||
TestUtils::VerifyExpectedString(std::wstring(width - 1, L' '), iter);
|
||||
};
|
||||
|
||||
@@ -3550,7 +3541,7 @@ void ConptyRoundtripTests::DeleteWrappedWord()
|
||||
sm.ProcessString(L"\x1b[?25h");
|
||||
|
||||
auto verifyBuffer = [&](const TextBuffer& tb, const til::rect& viewport, const bool after) {
|
||||
const auto width = viewport.narrow_width<short>();
|
||||
const auto width = viewport.width();
|
||||
|
||||
auto iter1 = tb.GetCellDataAt({ 0, 0 });
|
||||
TestUtils::VerifySpanOfText(L"A", iter1, 0, 50);
|
||||
@@ -3712,21 +3703,21 @@ void ConptyRoundtripTests::ClearBufferSignal()
|
||||
sm.ProcessString(L"\x1b[?25h");
|
||||
|
||||
auto verifyBuffer = [&](const TextBuffer& tb, const til::rect& viewport, const bool before) {
|
||||
const short width = viewport.narrow_width<short>();
|
||||
const short numCharsOnSecondLine = 50 - (width - 51);
|
||||
const auto width = viewport.width();
|
||||
const auto numCharsOnSecondLine = 50 - (width - 51);
|
||||
auto iter1 = tb.GetCellDataAt({ 0, 0 });
|
||||
if (before)
|
||||
{
|
||||
TestUtils::VerifySpanOfText(L"A", iter1, 0, 50);
|
||||
TestUtils::VerifySpanOfText(L" ", iter1, 0, 1);
|
||||
TestUtils::VerifySpanOfText(L"B", iter1, 0, 50);
|
||||
COORD expectedCursor{ numCharsOnSecondLine, 1 };
|
||||
til::point expectedCursor{ numCharsOnSecondLine, 1 };
|
||||
VERIFY_ARE_EQUAL(expectedCursor, tb.GetCursor().GetPosition());
|
||||
}
|
||||
else
|
||||
{
|
||||
TestUtils::VerifySpanOfText(L"B", iter1, 0, numCharsOnSecondLine);
|
||||
COORD expectedCursor{ numCharsOnSecondLine, 0 };
|
||||
til::point expectedCursor{ numCharsOnSecondLine, 0 };
|
||||
VERIFY_ARE_EQUAL(expectedCursor, tb.GetCursor().GetPosition());
|
||||
}
|
||||
};
|
||||
|
||||
@@ -42,17 +42,17 @@ void ScreenSizeLimitsTest::ScreenWidthAndHeightAreClampedToBounds()
|
||||
auto negativeColumnsSettings = winrt::make<MockTermSettings>(10000, 9999999, -1234);
|
||||
Terminal negativeColumnsTerminal;
|
||||
negativeColumnsTerminal.CreateFromSettings(negativeColumnsSettings, emptyRenderTarget);
|
||||
COORD actualDimensions = negativeColumnsTerminal.GetViewport().Dimensions();
|
||||
VERIFY_ARE_EQUAL(actualDimensions.Y, SHRT_MAX, L"Row count clamped to SHRT_MAX == " WCS(SHRT_MAX));
|
||||
VERIFY_ARE_EQUAL(actualDimensions.X, 1, L"Column count clamped to 1");
|
||||
auto actualDimensions = negativeColumnsTerminal.GetViewport().Dimensions();
|
||||
VERIFY_ARE_EQUAL(actualDimensions.height, SHRT_MAX, L"Row count clamped to SHRT_MAX == " WCS(SHRT_MAX));
|
||||
VERIFY_ARE_EQUAL(actualDimensions.width, 1, L"Column count clamped to 1");
|
||||
|
||||
// Zero values are clamped to 1 as well.
|
||||
auto zeroRowsSettings = winrt::make<MockTermSettings>(10000, 0, 9999999);
|
||||
Terminal zeroRowsTerminal;
|
||||
zeroRowsTerminal.CreateFromSettings(zeroRowsSettings, emptyRenderTarget);
|
||||
actualDimensions = zeroRowsTerminal.GetViewport().Dimensions();
|
||||
VERIFY_ARE_EQUAL(actualDimensions.Y, 1, L"Row count clamped to 1");
|
||||
VERIFY_ARE_EQUAL(actualDimensions.X, SHRT_MAX, L"Column count clamped to SHRT_MAX == " WCS(SHRT_MAX));
|
||||
VERIFY_ARE_EQUAL(actualDimensions.height, 1, L"Row count clamped to 1");
|
||||
VERIFY_ARE_EQUAL(actualDimensions.width, SHRT_MAX, L"Column count clamped to SHRT_MAX == " WCS(SHRT_MAX));
|
||||
}
|
||||
|
||||
void ScreenSizeLimitsTest::ScrollbackHistorySizeIsClampedToBounds()
|
||||
@@ -61,7 +61,7 @@ void ScreenSizeLimitsTest::ScrollbackHistorySizeIsClampedToBounds()
|
||||
// which is the *sum* of the history size plus the number of rows
|
||||
// actually visible on screen at the moment.
|
||||
|
||||
const unsigned int visibleRowCount = 100;
|
||||
const til::CoordType visibleRowCount = 100;
|
||||
DummyRenderTarget emptyRenderTarget;
|
||||
|
||||
// Zero history size is acceptable.
|
||||
@@ -80,19 +80,19 @@ void ScreenSizeLimitsTest::ScrollbackHistorySizeIsClampedToBounds()
|
||||
auto maxHistorySizeSettings = winrt::make<MockTermSettings>(SHRT_MAX - visibleRowCount, visibleRowCount, 100);
|
||||
Terminal maxHistorySizeTerminal;
|
||||
maxHistorySizeTerminal.CreateFromSettings(maxHistorySizeSettings, emptyRenderTarget);
|
||||
VERIFY_ARE_EQUAL(maxHistorySizeTerminal.GetTextBuffer().TotalRowCount(), static_cast<unsigned int>(SHRT_MAX), L"History size == SHRT_MAX - initial row count is accepted");
|
||||
VERIFY_ARE_EQUAL(maxHistorySizeTerminal.GetTextBuffer().TotalRowCount(), static_cast<til::CoordType>(SHRT_MAX), L"History size == SHRT_MAX - initial row count is accepted");
|
||||
|
||||
// History size + initial visible rows == SHRT_MAX + 1 will be clamped slightly.
|
||||
auto justTooBigHistorySizeSettings = winrt::make<MockTermSettings>(SHRT_MAX - visibleRowCount + 1, visibleRowCount, 100);
|
||||
Terminal justTooBigHistorySizeTerminal;
|
||||
justTooBigHistorySizeTerminal.CreateFromSettings(justTooBigHistorySizeSettings, emptyRenderTarget);
|
||||
VERIFY_ARE_EQUAL(justTooBigHistorySizeTerminal.GetTextBuffer().TotalRowCount(), static_cast<unsigned int>(SHRT_MAX), L"History size == 1 + SHRT_MAX - initial row count is clamped to SHRT_MAX - initial row count");
|
||||
VERIFY_ARE_EQUAL(justTooBigHistorySizeTerminal.GetTextBuffer().TotalRowCount(), static_cast<til::CoordType>(SHRT_MAX), L"History size == 1 + SHRT_MAX - initial row count is clamped to SHRT_MAX - initial row count");
|
||||
|
||||
// Ridiculously large history sizes are also clamped.
|
||||
auto farTooBigHistorySizeSettings = winrt::make<MockTermSettings>(99999999, visibleRowCount, 100);
|
||||
Terminal farTooBigHistorySizeTerminal;
|
||||
farTooBigHistorySizeTerminal.CreateFromSettings(farTooBigHistorySizeSettings, emptyRenderTarget);
|
||||
VERIFY_ARE_EQUAL(farTooBigHistorySizeTerminal.GetTextBuffer().TotalRowCount(), static_cast<unsigned int>(SHRT_MAX), L"History size that is far too large is clamped to SHRT_MAX - initial row count");
|
||||
VERIFY_ARE_EQUAL(farTooBigHistorySizeTerminal.GetTextBuffer().TotalRowCount(), static_cast<til::CoordType>(SHRT_MAX), L"History size that is far too large is clamped to SHRT_MAX - initial row count");
|
||||
}
|
||||
|
||||
void ScreenSizeLimitsTest::ResizeIsClampedToBounds()
|
||||
@@ -103,8 +103,8 @@ void ScreenSizeLimitsTest::ResizeIsClampedToBounds()
|
||||
//
|
||||
// This is a test for GH#2630, GH#2815.
|
||||
|
||||
const unsigned int initialVisibleColCount = 50;
|
||||
const unsigned int initialVisibleRowCount = 50;
|
||||
const til::CoordType initialVisibleColCount = 50;
|
||||
const til::CoordType initialVisibleRowCount = 50;
|
||||
const auto historySize = SHRT_MAX - (initialVisibleRowCount * 2);
|
||||
DummyRenderTarget emptyRenderTarget;
|
||||
|
||||
@@ -115,18 +115,18 @@ void ScreenSizeLimitsTest::ResizeIsClampedToBounds()
|
||||
Log::Comment(L"First create a terminal with fewer than SHRT_MAX lines");
|
||||
Terminal terminal;
|
||||
terminal.CreateFromSettings(settings, emptyRenderTarget);
|
||||
VERIFY_ARE_EQUAL(terminal.GetTextBuffer().TotalRowCount(), static_cast<unsigned int>(historySize + initialVisibleRowCount));
|
||||
VERIFY_ARE_EQUAL(terminal.GetTextBuffer().TotalRowCount(), static_cast<til::CoordType>(historySize + initialVisibleRowCount));
|
||||
|
||||
Log::Comment(L"Resize the terminal to have exactly SHRT_MAX lines");
|
||||
VERIFY_SUCCEEDED(terminal.UserResize({ initialVisibleColCount, initialVisibleRowCount * 2 }));
|
||||
|
||||
VERIFY_ARE_EQUAL(terminal.GetTextBuffer().TotalRowCount(), static_cast<unsigned int>(SHRT_MAX));
|
||||
VERIFY_ARE_EQUAL(terminal.GetTextBuffer().TotalRowCount(), static_cast<til::CoordType>(SHRT_MAX));
|
||||
|
||||
Log::Comment(L"Resize the terminal to have MORE than SHRT_MAX lines - we should clamp to SHRT_MAX");
|
||||
VERIFY_SUCCEEDED(terminal.UserResize({ initialVisibleColCount, initialVisibleRowCount * 3 }));
|
||||
VERIFY_ARE_EQUAL(terminal.GetTextBuffer().TotalRowCount(), static_cast<unsigned int>(SHRT_MAX));
|
||||
VERIFY_ARE_EQUAL(terminal.GetTextBuffer().TotalRowCount(), static_cast<til::CoordType>(SHRT_MAX));
|
||||
|
||||
Log::Comment(L"Resize back down to the original size");
|
||||
VERIFY_SUCCEEDED(terminal.UserResize({ initialVisibleColCount, initialVisibleRowCount }));
|
||||
VERIFY_ARE_EQUAL(terminal.GetTextBuffer().TotalRowCount(), static_cast<unsigned int>(historySize + initialVisibleRowCount));
|
||||
VERIFY_ARE_EQUAL(terminal.GetTextBuffer().TotalRowCount(), static_cast<til::CoordType>(historySize + initialVisibleRowCount));
|
||||
}
|
||||
|
||||
@@ -30,7 +30,7 @@ namespace
|
||||
public:
|
||||
~MockScrollRenderTarget() override{};
|
||||
|
||||
std::optional<COORD> TriggerScrollDelta() const
|
||||
std::optional<til::point> TriggerScrollDelta() const
|
||||
{
|
||||
return _triggerScrollDelta;
|
||||
}
|
||||
@@ -41,13 +41,13 @@ namespace
|
||||
}
|
||||
|
||||
virtual void TriggerRedraw(const Microsoft::Console::Types::Viewport&){};
|
||||
virtual void TriggerRedraw(const COORD* const){};
|
||||
virtual void TriggerRedrawCursor(const COORD* const){};
|
||||
virtual void TriggerRedraw(const til::point* const){};
|
||||
virtual void TriggerRedrawCursor(const til::point* const){};
|
||||
virtual void TriggerRedrawAll(){};
|
||||
virtual void TriggerTeardown() noexcept {};
|
||||
virtual void TriggerSelection(){};
|
||||
virtual void TriggerScroll(){};
|
||||
virtual void TriggerScroll(const COORD* const delta)
|
||||
virtual void TriggerScroll(const til::point* const delta)
|
||||
{
|
||||
_triggerScrollDelta = { *delta };
|
||||
};
|
||||
@@ -55,7 +55,7 @@ namespace
|
||||
void TriggerTitleChange(){};
|
||||
|
||||
private:
|
||||
std::optional<COORD> _triggerScrollDelta;
|
||||
std::optional<til::point> _triggerScrollDelta;
|
||||
};
|
||||
|
||||
struct ScrollBarNotification
|
||||
@@ -77,11 +77,11 @@ class TerminalCoreUnitTests::ScrollTest final
|
||||
// !!! DANGER: Many tests in this class expect the Terminal buffer
|
||||
// to be 80x32. If you change these, you'll probably inadvertently break a
|
||||
// bunch of tests !!!
|
||||
static const SHORT TerminalViewWidth = 80;
|
||||
static const SHORT TerminalViewHeight = 32;
|
||||
static const til::CoordType TerminalViewWidth = 80;
|
||||
static const til::CoordType TerminalViewHeight = 32;
|
||||
// For TestNotifyScrolling, it's important that this value is ~=9000.
|
||||
// Something smaller like 100 won't cause the test to fail.
|
||||
static const SHORT TerminalHistoryLength = 9001;
|
||||
static const til::CoordType TerminalHistoryLength = 9001;
|
||||
|
||||
TEST_CLASS(ScrollTest);
|
||||
|
||||
@@ -182,7 +182,7 @@ void ScrollTest::TestNotifyScrolling()
|
||||
VERIFY_IS_TRUE(_renderTarget->TriggerScrollDelta().has_value(),
|
||||
fmt::format(L"Expected a 'trigger scroll' notification in RenderTarget for row {}", currentRow).c_str());
|
||||
|
||||
COORD expectedDelta;
|
||||
til::point expectedDelta;
|
||||
expectedDelta.X = 0;
|
||||
expectedDelta.Y = -1;
|
||||
VERIFY_ARE_EQUAL(expectedDelta, _renderTarget->TriggerScrollDelta().value(), fmt::format(L"Wrong value in 'trigger scroll' notification in RenderTarget for row {}", currentRow).c_str());
|
||||
|
||||
@@ -32,7 +32,7 @@ namespace TerminalCoreUnitTests
|
||||
// - expected: the expected value of the selection rect
|
||||
// Return Value:
|
||||
// - N/A
|
||||
void ValidateSingleRowSelection(Terminal& term, SMALL_RECT expected)
|
||||
void ValidateSingleRowSelection(Terminal& term, const til::inclusive_rect expected)
|
||||
{
|
||||
// Simulate renderer calling TriggerSelection and acquiring selection area
|
||||
auto selectionRects = term.GetSelectionRects();
|
||||
@@ -51,7 +51,7 @@ namespace TerminalCoreUnitTests
|
||||
term.Create({ 100, 100 }, 0, emptyRT);
|
||||
|
||||
// Simulate click at (x,y) = (5,10)
|
||||
auto clickPos = COORD{ 5, 10 };
|
||||
auto clickPos = til::point{ 5, 10 };
|
||||
term.SetSelectionAnchor(clickPos);
|
||||
|
||||
ValidateSingleRowSelection(term, { 5, 10, 5, 10 });
|
||||
@@ -66,7 +66,7 @@ namespace TerminalCoreUnitTests
|
||||
// Used for two things:
|
||||
// - click y-pos
|
||||
// - keep track of row we're verifying
|
||||
SHORT rowValue = 10;
|
||||
auto rowValue = 10;
|
||||
|
||||
// Simulate click at (x,y) = (5,10)
|
||||
term.SetSelectionAnchor({ 5, rowValue });
|
||||
@@ -81,7 +81,7 @@ namespace TerminalCoreUnitTests
|
||||
VERIFY_ARE_EQUAL(selectionRects.size(), static_cast<size_t>(11));
|
||||
|
||||
auto viewport = term.GetViewport();
|
||||
SHORT rightBoundary = viewport.RightInclusive();
|
||||
auto rightBoundary = viewport.RightInclusive();
|
||||
for (auto selectionRect : selectionRects)
|
||||
{
|
||||
auto selection = viewport.ConvertToOrigin(selectionRect).ToInclusive();
|
||||
@@ -89,17 +89,17 @@ namespace TerminalCoreUnitTests
|
||||
if (rowValue == 10)
|
||||
{
|
||||
// Verify top line
|
||||
VERIFY_ARE_EQUAL(selection, SMALL_RECT({ 5, 10, rightBoundary, 10 }));
|
||||
VERIFY_ARE_EQUAL(selection, til::inclusive_rect({ 5, 10, rightBoundary, 10 }));
|
||||
}
|
||||
else if (rowValue == 20)
|
||||
{
|
||||
// Verify bottom line
|
||||
VERIFY_ARE_EQUAL(selection, SMALL_RECT({ 0, 20, 15, 20 }));
|
||||
VERIFY_ARE_EQUAL(selection, til::inclusive_rect({ 0, 20, 15, 20 }));
|
||||
}
|
||||
else
|
||||
{
|
||||
// Verify other lines (full)
|
||||
VERIFY_ARE_EQUAL(selection, SMALL_RECT({ 0, rowValue, rightBoundary, rowValue }));
|
||||
VERIFY_ARE_EQUAL(selection, til::inclusive_rect({ 0, rowValue, rightBoundary, rowValue }));
|
||||
}
|
||||
|
||||
rowValue++;
|
||||
@@ -108,16 +108,16 @@ namespace TerminalCoreUnitTests
|
||||
|
||||
TEST_METHOD(OverflowTests)
|
||||
{
|
||||
const COORD maxCoord = { SHRT_MAX, SHRT_MAX };
|
||||
const til::point maxCoord{ SHRT_MAX, SHRT_MAX };
|
||||
|
||||
// Test SetSelectionAnchor(COORD) and SetSelectionEnd(COORD)
|
||||
// Test SetSelectionAnchor(til::point) and SetSelectionEnd(til::point)
|
||||
// Behavior: clamp coord to viewport.
|
||||
auto ValidateSingleClickSelection = [&](SHORT scrollback, SMALL_RECT expected) {
|
||||
auto ValidateSingleClickSelection = [&](SHORT scrollback, const til::inclusive_rect expected) {
|
||||
Terminal term;
|
||||
DummyRenderTarget emptyRT;
|
||||
term.Create({ 10, 10 }, scrollback, emptyRT);
|
||||
|
||||
// NOTE: SetSelectionEnd(COORD) is called within SetSelectionAnchor(COORD)
|
||||
// NOTE: SetSelectionEnd(til::point) is called within SetSelectionAnchor(til::point)
|
||||
term.SetSelectionAnchor(maxCoord);
|
||||
ValidateSingleRowSelection(term, expected);
|
||||
};
|
||||
@@ -125,7 +125,7 @@ namespace TerminalCoreUnitTests
|
||||
// Test a Double Click Selection
|
||||
// Behavior: clamp coord to viewport.
|
||||
// Then, do double click selection.
|
||||
auto ValidateDoubleClickSelection = [&](SHORT scrollback, SMALL_RECT expected) {
|
||||
auto ValidateDoubleClickSelection = [&](SHORT scrollback, const til::inclusive_rect expected) {
|
||||
Terminal term;
|
||||
DummyRenderTarget emptyRT;
|
||||
term.Create({ 10, 10 }, scrollback, emptyRT);
|
||||
@@ -137,7 +137,7 @@ namespace TerminalCoreUnitTests
|
||||
// Test a Triple Click Selection
|
||||
// Behavior: clamp coord to viewport.
|
||||
// Then, do triple click selection.
|
||||
auto ValidateTripleClickSelection = [&](SHORT scrollback, SMALL_RECT expected) {
|
||||
auto ValidateTripleClickSelection = [&](SHORT scrollback, const til::inclusive_rect expected) {
|
||||
Terminal term;
|
||||
DummyRenderTarget emptyRT;
|
||||
term.Create({ 10, 10 }, scrollback, emptyRT);
|
||||
@@ -155,7 +155,7 @@ namespace TerminalCoreUnitTests
|
||||
ValidateTripleClickSelection(0, { 0, 9, 9, 9 });
|
||||
|
||||
// Test with max scrollback
|
||||
const SHORT expected_row = SHRT_MAX - 1;
|
||||
const auto expected_row = SHRT_MAX - 1;
|
||||
Log::Comment(L"Single click selection with MAXIMUM scrollback value");
|
||||
ValidateSingleClickSelection(SHRT_MAX, { 9, expected_row, 9, expected_row });
|
||||
Log::Comment(L"Double click selection with MAXIMUM scrollback value");
|
||||
@@ -176,10 +176,10 @@ namespace TerminalCoreUnitTests
|
||||
term.Create({ 10, 10 }, 0, emptyRT);
|
||||
|
||||
auto viewport = term.GetViewport();
|
||||
const SHORT leftBoundary = viewport.Left();
|
||||
const SHORT rightBoundary = viewport.RightInclusive();
|
||||
const SHORT topBoundary = viewport.Top();
|
||||
const SHORT bottomBoundary = viewport.BottomInclusive();
|
||||
const auto leftBoundary = viewport.Left();
|
||||
const auto rightBoundary = viewport.RightInclusive();
|
||||
const auto topBoundary = viewport.Top();
|
||||
const auto bottomBoundary = viewport.BottomInclusive();
|
||||
|
||||
// Case 1: Simulate click past right (x,y) = (20,5)
|
||||
// should clamp to right boundary
|
||||
@@ -218,8 +218,8 @@ namespace TerminalCoreUnitTests
|
||||
term.Create({ 10, 10 }, 0, emptyRT);
|
||||
|
||||
auto viewport = term.GetViewport();
|
||||
const SHORT leftBoundary = 0;
|
||||
const SHORT rightBoundary = viewport.RightInclusive();
|
||||
const til::CoordType leftBoundary = 0;
|
||||
const auto rightBoundary = viewport.RightInclusive();
|
||||
|
||||
// Simulate click at (x,y) = (5,5)
|
||||
term.SetSelectionAnchor({ 5, 5 });
|
||||
@@ -227,7 +227,7 @@ namespace TerminalCoreUnitTests
|
||||
// Case 1: Move out of right boundary
|
||||
Log::Comment(L"Out of bounds: X-value too large");
|
||||
term.SetSelectionEnd({ 20, 5 });
|
||||
ValidateSingleRowSelection(term, SMALL_RECT({ 5, 5, rightBoundary, 5 }));
|
||||
ValidateSingleRowSelection(term, til::inclusive_rect({ 5, 5, rightBoundary, 5 }));
|
||||
|
||||
// Case 2: Move out of left boundary
|
||||
Log::Comment(L"Out of bounds: X-value negative");
|
||||
@@ -250,17 +250,17 @@ namespace TerminalCoreUnitTests
|
||||
if (rowValue == 0)
|
||||
{
|
||||
// Verify top line
|
||||
VERIFY_ARE_EQUAL(selection, SMALL_RECT({ 5, rowValue, rightBoundary, rowValue }));
|
||||
VERIFY_ARE_EQUAL(selection, til::inclusive_rect({ 5, rowValue, rightBoundary, rowValue }));
|
||||
}
|
||||
else if (rowValue == 5)
|
||||
{
|
||||
// Verify last line
|
||||
VERIFY_ARE_EQUAL(selection, SMALL_RECT({ leftBoundary, rowValue, 5, rowValue }));
|
||||
VERIFY_ARE_EQUAL(selection, til::inclusive_rect({ leftBoundary, rowValue, 5, rowValue }));
|
||||
}
|
||||
else
|
||||
{
|
||||
// Verify other lines (full)
|
||||
VERIFY_ARE_EQUAL(selection, SMALL_RECT({ leftBoundary, rowValue, rightBoundary, rowValue }));
|
||||
VERIFY_ARE_EQUAL(selection, til::inclusive_rect({ leftBoundary, rowValue, rightBoundary, rowValue }));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -281,17 +281,17 @@ namespace TerminalCoreUnitTests
|
||||
if (rowValue == 5)
|
||||
{
|
||||
// Verify top line
|
||||
VERIFY_ARE_EQUAL(selection, SMALL_RECT({ 5, 5, rightBoundary, 5 }));
|
||||
VERIFY_ARE_EQUAL(selection, til::inclusive_rect({ 5, 5, rightBoundary, 5 }));
|
||||
}
|
||||
else if (rowValue == 9)
|
||||
{
|
||||
// Verify bottom line
|
||||
VERIFY_ARE_EQUAL(selection, SMALL_RECT({ leftBoundary, rowValue, 5, rowValue }));
|
||||
VERIFY_ARE_EQUAL(selection, til::inclusive_rect({ leftBoundary, rowValue, 5, rowValue }));
|
||||
}
|
||||
else
|
||||
{
|
||||
// Verify other lines (full)
|
||||
VERIFY_ARE_EQUAL(selection, SMALL_RECT({ leftBoundary, rowValue, rightBoundary, rowValue }));
|
||||
VERIFY_ARE_EQUAL(selection, til::inclusive_rect({ leftBoundary, rowValue, rightBoundary, rowValue }));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -306,7 +306,7 @@ namespace TerminalCoreUnitTests
|
||||
// Used for two things:
|
||||
// - click y-pos
|
||||
// - keep track of row we're verifying
|
||||
SHORT rowValue = 10;
|
||||
auto rowValue = 10;
|
||||
|
||||
// Simulate ALT + click at (x,y) = (5,10)
|
||||
term.SetSelectionAnchor({ 5, rowValue });
|
||||
@@ -327,7 +327,7 @@ namespace TerminalCoreUnitTests
|
||||
auto selection = viewport.ConvertToOrigin(selectionRect).ToInclusive();
|
||||
|
||||
// Verify all lines
|
||||
VERIFY_ARE_EQUAL(selection, SMALL_RECT({ 5, rowValue, 15, rowValue }));
|
||||
VERIFY_ARE_EQUAL(selection, til::inclusive_rect({ 5, rowValue, 15, rowValue }));
|
||||
|
||||
rowValue++;
|
||||
}
|
||||
@@ -337,13 +337,13 @@ namespace TerminalCoreUnitTests
|
||||
{
|
||||
Terminal term;
|
||||
DummyRenderTarget emptyRT;
|
||||
SHORT scrollbackLines = 5;
|
||||
auto scrollbackLines = 5;
|
||||
term.Create({ 100, 100 }, scrollbackLines, emptyRT);
|
||||
|
||||
// Used for two things:
|
||||
// - click y-pos
|
||||
// - keep track of row we're verifying
|
||||
SHORT rowValue = 10;
|
||||
auto rowValue = 10;
|
||||
|
||||
// Simulate click at (x,y) = (5,10)
|
||||
term.SetSelectionAnchor({ 5, rowValue });
|
||||
@@ -358,7 +358,7 @@ namespace TerminalCoreUnitTests
|
||||
VERIFY_ARE_EQUAL(selectionRects.size(), static_cast<size_t>(11));
|
||||
|
||||
auto viewport = term.GetViewport();
|
||||
SHORT rightBoundary = viewport.RightInclusive();
|
||||
auto rightBoundary = viewport.RightInclusive();
|
||||
for (auto selectionRect : selectionRects)
|
||||
{
|
||||
auto selection = viewport.ConvertToOrigin(selectionRect).ToInclusive();
|
||||
@@ -366,17 +366,17 @@ namespace TerminalCoreUnitTests
|
||||
if (rowValue == 10)
|
||||
{
|
||||
// Verify top line
|
||||
VERIFY_ARE_EQUAL(selection, SMALL_RECT({ 5, 10, rightBoundary, 10 }));
|
||||
VERIFY_ARE_EQUAL(selection, til::inclusive_rect({ 5, 10, rightBoundary, 10 }));
|
||||
}
|
||||
else if (rowValue == 20)
|
||||
{
|
||||
// Verify bottom line
|
||||
VERIFY_ARE_EQUAL(selection, SMALL_RECT({ 0, 20, 15, 20 }));
|
||||
VERIFY_ARE_EQUAL(selection, til::inclusive_rect({ 0, 20, 15, 20 }));
|
||||
}
|
||||
else
|
||||
{
|
||||
// Verify other lines (full)
|
||||
VERIFY_ARE_EQUAL(selection, SMALL_RECT({ 0, rowValue, rightBoundary, rowValue }));
|
||||
VERIFY_ARE_EQUAL(selection, til::inclusive_rect({ 0, rowValue, rightBoundary, rowValue }));
|
||||
}
|
||||
|
||||
rowValue++;
|
||||
@@ -394,11 +394,11 @@ namespace TerminalCoreUnitTests
|
||||
const auto burrito = L"\xD83C\xDF2F";
|
||||
|
||||
// Insert wide glyph at position (4,10)
|
||||
term.SetCursorPosition(4, 10);
|
||||
term.SetCursorPosition({ 4, 10 });
|
||||
term.Write(burrito);
|
||||
|
||||
// Simulate click at (x,y) = (5,10)
|
||||
auto clickPos = COORD{ 5, 10 };
|
||||
auto clickPos = til::point{ 5, 10 };
|
||||
term.SetSelectionAnchor(clickPos);
|
||||
|
||||
// Validate selection area
|
||||
@@ -417,11 +417,11 @@ namespace TerminalCoreUnitTests
|
||||
const auto burrito = L"\xD83C\xDF2F";
|
||||
|
||||
// Insert wide glyph at position (4,10)
|
||||
term.SetCursorPosition(4, 10);
|
||||
term.SetCursorPosition({ 4, 10 });
|
||||
term.Write(burrito);
|
||||
|
||||
// Simulate click at (x,y) = (5,10)
|
||||
auto clickPos = COORD{ 4, 10 };
|
||||
auto clickPos = til::point{ 4, 10 };
|
||||
term.SetSelectionAnchor(clickPos);
|
||||
|
||||
// Validate selection area
|
||||
@@ -440,11 +440,11 @@ namespace TerminalCoreUnitTests
|
||||
const auto burrito = L"\xD83C\xDF2F";
|
||||
|
||||
// Insert wide glyph at position (4,10)
|
||||
term.SetCursorPosition(4, 10);
|
||||
term.SetCursorPosition({ 4, 10 });
|
||||
term.Write(burrito);
|
||||
|
||||
// Insert wide glyph at position (7,11)
|
||||
term.SetCursorPosition(7, 11);
|
||||
term.SetCursorPosition({ 7, 11 });
|
||||
term.Write(burrito);
|
||||
|
||||
// Simulate ALT + click at (x,y) = (5,8)
|
||||
@@ -461,23 +461,23 @@ namespace TerminalCoreUnitTests
|
||||
VERIFY_ARE_EQUAL(selectionRects.size(), static_cast<size_t>(5));
|
||||
|
||||
auto viewport = term.GetViewport();
|
||||
SHORT rowValue = 8;
|
||||
auto rowValue = 8;
|
||||
for (auto selectionRect : selectionRects)
|
||||
{
|
||||
auto selection = viewport.ConvertToOrigin(selectionRect).ToInclusive();
|
||||
|
||||
if (rowValue == 10)
|
||||
{
|
||||
VERIFY_ARE_EQUAL(selection, SMALL_RECT({ 4, rowValue, 7, rowValue }));
|
||||
VERIFY_ARE_EQUAL(selection, til::inclusive_rect({ 4, rowValue, 7, rowValue }));
|
||||
}
|
||||
else if (rowValue == 11)
|
||||
{
|
||||
VERIFY_ARE_EQUAL(selection, SMALL_RECT({ 5, rowValue, 8, rowValue }));
|
||||
VERIFY_ARE_EQUAL(selection, til::inclusive_rect({ 5, rowValue, 8, rowValue }));
|
||||
}
|
||||
else
|
||||
{
|
||||
// Verify all lines
|
||||
VERIFY_ARE_EQUAL(selection, SMALL_RECT({ 5, rowValue, 7, rowValue }));
|
||||
VERIFY_ARE_EQUAL(selection, til::inclusive_rect({ 5, rowValue, 7, rowValue }));
|
||||
}
|
||||
|
||||
rowValue++;
|
||||
@@ -496,15 +496,15 @@ namespace TerminalCoreUnitTests
|
||||
|
||||
// Insert text at position (4,10)
|
||||
const std::wstring_view text = L"doubleClickMe";
|
||||
term.SetCursorPosition(4, 10);
|
||||
term.SetCursorPosition({ 4, 10 });
|
||||
term.Write(text);
|
||||
|
||||
// Simulate double click at (x,y) = (5,10)
|
||||
auto clickPos = COORD{ 5, 10 };
|
||||
auto clickPos = til::point{ 5, 10 };
|
||||
term.MultiClickSelection(clickPos, Terminal::SelectionExpansion::Word);
|
||||
|
||||
// Validate selection area
|
||||
ValidateSingleRowSelection(term, SMALL_RECT({ 4, 10, (4 + gsl::narrow<SHORT>(text.size()) - 1), 10 }));
|
||||
ValidateSingleRowSelection(term, til::inclusive_rect{ 4, 10, (4 + gsl::narrow_cast<til::CoordType>(text.size()) - 1), 10 });
|
||||
}
|
||||
|
||||
TEST_METHOD(DoubleClick_Delimiter)
|
||||
@@ -518,14 +518,14 @@ namespace TerminalCoreUnitTests
|
||||
term.UpdateSettings(settings);
|
||||
|
||||
// Simulate click at (x,y) = (5,10)
|
||||
auto clickPos = COORD{ 5, 10 };
|
||||
auto clickPos = til::point{ 5, 10 };
|
||||
term.MultiClickSelection(clickPos, Terminal::SelectionExpansion::Word);
|
||||
|
||||
// Simulate renderer calling TriggerSelection and acquiring selection area
|
||||
auto selectionRects = term.GetSelectionRects();
|
||||
|
||||
// Validate selection area
|
||||
ValidateSingleRowSelection(term, SMALL_RECT({ 0, 10, 99, 10 }));
|
||||
ValidateSingleRowSelection(term, til::inclusive_rect({ 0, 10, 99, 10 }));
|
||||
}
|
||||
|
||||
TEST_METHOD(DoubleClick_DelimiterClass)
|
||||
@@ -540,12 +540,12 @@ namespace TerminalCoreUnitTests
|
||||
|
||||
// Insert text at position (4,10)
|
||||
const std::wstring_view text = L"C:\\Terminal>";
|
||||
term.SetCursorPosition(4, 10);
|
||||
term.SetCursorPosition({ 4, 10 });
|
||||
term.Write(text);
|
||||
|
||||
// Simulate click at (x,y) = (15,10)
|
||||
// this is over the '>' char
|
||||
auto clickPos = COORD{ 15, 10 };
|
||||
auto clickPos = til::point{ 15, 10 };
|
||||
term.MultiClickSelection(clickPos, Terminal::SelectionExpansion::Word);
|
||||
|
||||
// ---Validate selection area---
|
||||
@@ -553,7 +553,7 @@ namespace TerminalCoreUnitTests
|
||||
// ">" is in class 1
|
||||
// the white space to the right of the ">" is in class 0
|
||||
// Double-clicking the ">" should only highlight that cell
|
||||
ValidateSingleRowSelection(term, SMALL_RECT({ 15, 10, 15, 10 }));
|
||||
ValidateSingleRowSelection(term, til::inclusive_rect({ 15, 10, 15, 10 }));
|
||||
}
|
||||
|
||||
TEST_METHOD(DoubleClickDrag_Right)
|
||||
@@ -568,7 +568,7 @@ namespace TerminalCoreUnitTests
|
||||
|
||||
// Insert text at position (4,10)
|
||||
const std::wstring_view text = L"doubleClickMe dragThroughHere";
|
||||
term.SetCursorPosition(4, 10);
|
||||
term.SetCursorPosition({ 4, 10 });
|
||||
term.Write(text);
|
||||
|
||||
// Simulate double click at (x,y) = (5,10)
|
||||
@@ -582,7 +582,7 @@ namespace TerminalCoreUnitTests
|
||||
term.SetSelectionEnd({ 21, 10 });
|
||||
|
||||
// Validate selection area
|
||||
ValidateSingleRowSelection(term, SMALL_RECT({ 4, 10, 32, 10 }));
|
||||
ValidateSingleRowSelection(term, til::inclusive_rect({ 4, 10, 32, 10 }));
|
||||
}
|
||||
|
||||
TEST_METHOD(DoubleClickDrag_Left)
|
||||
@@ -597,7 +597,7 @@ namespace TerminalCoreUnitTests
|
||||
|
||||
// Insert text at position (21,10)
|
||||
const std::wstring_view text = L"doubleClickMe dragThroughHere";
|
||||
term.SetCursorPosition(4, 10);
|
||||
term.SetCursorPosition({ 4, 10 });
|
||||
term.Write(text);
|
||||
|
||||
// Simulate double click at (x,y) = (21,10)
|
||||
@@ -611,7 +611,7 @@ namespace TerminalCoreUnitTests
|
||||
term.SetSelectionEnd({ 5, 10 });
|
||||
|
||||
// Validate selection area
|
||||
ValidateSingleRowSelection(term, SMALL_RECT({ 4, 10, 32, 10 }));
|
||||
ValidateSingleRowSelection(term, til::inclusive_rect({ 4, 10, 32, 10 }));
|
||||
}
|
||||
|
||||
TEST_METHOD(TripleClick_GeneralCase)
|
||||
@@ -621,11 +621,11 @@ namespace TerminalCoreUnitTests
|
||||
term.Create({ 100, 100 }, 0, emptyRT);
|
||||
|
||||
// Simulate click at (x,y) = (5,10)
|
||||
auto clickPos = COORD{ 5, 10 };
|
||||
auto clickPos = til::point{ 5, 10 };
|
||||
term.MultiClickSelection(clickPos, Terminal::SelectionExpansion::Line);
|
||||
|
||||
// Validate selection area
|
||||
ValidateSingleRowSelection(term, SMALL_RECT({ 0, 10, 99, 10 }));
|
||||
ValidateSingleRowSelection(term, til::inclusive_rect({ 0, 10, 99, 10 }));
|
||||
}
|
||||
|
||||
TEST_METHOD(TripleClickDrag_Horizontal)
|
||||
@@ -635,14 +635,14 @@ namespace TerminalCoreUnitTests
|
||||
term.Create({ 100, 100 }, 0, emptyRT);
|
||||
|
||||
// Simulate click at (x,y) = (5,10)
|
||||
auto clickPos = COORD{ 5, 10 };
|
||||
auto clickPos = til::point{ 5, 10 };
|
||||
term.MultiClickSelection(clickPos, Terminal::SelectionExpansion::Line);
|
||||
|
||||
// Simulate move to (x,y) = (7,10)
|
||||
term.SetSelectionEnd({ 7, 10 });
|
||||
|
||||
// Validate selection area
|
||||
ValidateSingleRowSelection(term, SMALL_RECT({ 0, 10, 99, 10 }));
|
||||
ValidateSingleRowSelection(term, til::inclusive_rect({ 0, 10, 99, 10 }));
|
||||
}
|
||||
|
||||
TEST_METHOD(TripleClickDrag_Vertical)
|
||||
@@ -652,7 +652,7 @@ namespace TerminalCoreUnitTests
|
||||
term.Create({ 100, 100 }, 0, emptyRT);
|
||||
|
||||
// Simulate click at (x,y) = (5,10)
|
||||
auto clickPos = COORD{ 5, 10 };
|
||||
auto clickPos = til::point{ 5, 10 };
|
||||
term.MultiClickSelection(clickPos, Terminal::SelectionExpansion::Line);
|
||||
|
||||
// Simulate move to (x,y) = (5,11)
|
||||
@@ -666,11 +666,11 @@ namespace TerminalCoreUnitTests
|
||||
|
||||
// verify first selection rect
|
||||
auto selection = term.GetViewport().ConvertToOrigin(selectionRects.at(0)).ToInclusive();
|
||||
VERIFY_ARE_EQUAL(selection, SMALL_RECT({ 0, 10, 99, 10 }));
|
||||
VERIFY_ARE_EQUAL(selection, til::inclusive_rect({ 0, 10, 99, 10 }));
|
||||
|
||||
// verify second selection rect
|
||||
selection = term.GetViewport().ConvertToOrigin(selectionRects.at(1)).ToInclusive();
|
||||
VERIFY_ARE_EQUAL(selection, SMALL_RECT({ 0, 11, 99, 11 }));
|
||||
VERIFY_ARE_EQUAL(selection, til::inclusive_rect({ 0, 11, 99, 11 }));
|
||||
}
|
||||
|
||||
TEST_METHOD(ShiftClick)
|
||||
@@ -685,7 +685,7 @@ namespace TerminalCoreUnitTests
|
||||
|
||||
// Insert text at position (4,10)
|
||||
const std::wstring_view text = L"doubleClickMe dragThroughHere";
|
||||
term.SetCursorPosition(4, 10);
|
||||
term.SetCursorPosition({ 4, 10 });
|
||||
term.Write(text);
|
||||
|
||||
// Step 1: Create a selection on "doubleClickMe"
|
||||
@@ -694,7 +694,7 @@ namespace TerminalCoreUnitTests
|
||||
term.MultiClickSelection({ 5, 10 }, Terminal::SelectionExpansion::Word);
|
||||
|
||||
// Validate selection area: "doubleClickMe" selected
|
||||
ValidateSingleRowSelection(term, SMALL_RECT({ 4, 10, 16, 10 }));
|
||||
ValidateSingleRowSelection(term, til::inclusive_rect({ 4, 10, 16, 10 }));
|
||||
}
|
||||
|
||||
// Step 2: Shift+Click to "dragThroughHere"
|
||||
@@ -707,7 +707,7 @@ namespace TerminalCoreUnitTests
|
||||
term.SetSelectionEnd({ 21, 10 }, Terminal::SelectionExpansion::Char);
|
||||
|
||||
// Validate selection area: "doubleClickMe drag" selected
|
||||
ValidateSingleRowSelection(term, SMALL_RECT({ 4, 10, 21, 10 }));
|
||||
ValidateSingleRowSelection(term, til::inclusive_rect({ 4, 10, 21, 10 }));
|
||||
}
|
||||
|
||||
// Step 3: Shift+Double-Click at "dragThroughHere"
|
||||
@@ -720,7 +720,7 @@ namespace TerminalCoreUnitTests
|
||||
term.SetSelectionEnd({ 21, 10 }, Terminal::SelectionExpansion::Word);
|
||||
|
||||
// Validate selection area: "doubleClickMe dragThroughHere" selected
|
||||
ValidateSingleRowSelection(term, SMALL_RECT({ 4, 10, 32, 10 }));
|
||||
ValidateSingleRowSelection(term, til::inclusive_rect({ 4, 10, 32, 10 }));
|
||||
}
|
||||
|
||||
// Step 4: Shift+Triple-Click at "dragThroughHere"
|
||||
@@ -733,7 +733,7 @@ namespace TerminalCoreUnitTests
|
||||
term.SetSelectionEnd({ 21, 10 }, Terminal::SelectionExpansion::Line);
|
||||
|
||||
// Validate selection area: "doubleClickMe dragThroughHere..." selected
|
||||
ValidateSingleRowSelection(term, SMALL_RECT({ 4, 10, 99, 10 }));
|
||||
ValidateSingleRowSelection(term, til::inclusive_rect({ 4, 10, 99, 10 }));
|
||||
}
|
||||
|
||||
// Step 5: Shift+Double-Click at "dragThroughHere"
|
||||
@@ -746,7 +746,7 @@ namespace TerminalCoreUnitTests
|
||||
term.SetSelectionEnd({ 21, 10 }, Terminal::SelectionExpansion::Word);
|
||||
|
||||
// Validate selection area: "doubleClickMe dragThroughHere" selected
|
||||
ValidateSingleRowSelection(term, SMALL_RECT({ 4, 10, 32, 10 }));
|
||||
ValidateSingleRowSelection(term, til::inclusive_rect({ 4, 10, 32, 10 }));
|
||||
}
|
||||
|
||||
// Step 6: Drag past "dragThroughHere"
|
||||
@@ -760,7 +760,7 @@ namespace TerminalCoreUnitTests
|
||||
term.SetSelectionEnd({ 35, 10 });
|
||||
|
||||
// Validate selection area: "doubleClickMe dragThroughHere..." selected
|
||||
ValidateSingleRowSelection(term, SMALL_RECT({ 4, 10, 99, 10 }));
|
||||
ValidateSingleRowSelection(term, til::inclusive_rect({ 4, 10, 99, 10 }));
|
||||
}
|
||||
|
||||
// Step 6: Drag back to "dragThroughHere"
|
||||
@@ -773,7 +773,7 @@ namespace TerminalCoreUnitTests
|
||||
term.SetSelectionEnd({ 21, 10 });
|
||||
|
||||
// Validate selection area: "doubleClickMe dragThroughHere" selected
|
||||
ValidateSingleRowSelection(term, SMALL_RECT({ 4, 10, 32, 10 }));
|
||||
ValidateSingleRowSelection(term, til::inclusive_rect({ 4, 10, 32, 10 }));
|
||||
}
|
||||
|
||||
// Step 7: Drag within "dragThroughHere"
|
||||
@@ -786,7 +786,7 @@ namespace TerminalCoreUnitTests
|
||||
term.SetSelectionEnd({ 25, 10 });
|
||||
|
||||
// Validate selection area: "doubleClickMe dragThroughHere" still selected
|
||||
ValidateSingleRowSelection(term, SMALL_RECT({ 4, 10, 32, 10 }));
|
||||
ValidateSingleRowSelection(term, til::inclusive_rect({ 4, 10, 32, 10 }));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -802,7 +802,7 @@ namespace TerminalCoreUnitTests
|
||||
term.SelectNewRegion({ 10, 10 }, { 20, 10 });
|
||||
|
||||
// Validate selection area
|
||||
ValidateSingleRowSelection(term, SMALL_RECT({ 10, 10, 20, 10 }));
|
||||
ValidateSingleRowSelection(term, til::inclusive_rect({ 10, 10, 20, 10 }));
|
||||
}
|
||||
|
||||
// Step 2: Drag to (5,10)
|
||||
@@ -811,7 +811,7 @@ namespace TerminalCoreUnitTests
|
||||
|
||||
// Validate selection area
|
||||
// NOTE: Pivot should be (10, 10)
|
||||
ValidateSingleRowSelection(term, SMALL_RECT({ 5, 10, 10, 10 }));
|
||||
ValidateSingleRowSelection(term, til::inclusive_rect({ 5, 10, 10, 10 }));
|
||||
}
|
||||
|
||||
// Step 3: Drag back to (20,10)
|
||||
@@ -820,7 +820,7 @@ namespace TerminalCoreUnitTests
|
||||
|
||||
// Validate selection area
|
||||
// NOTE: Pivot should still be (10, 10)
|
||||
ValidateSingleRowSelection(term, SMALL_RECT({ 10, 10, 20, 10 }));
|
||||
ValidateSingleRowSelection(term, til::inclusive_rect({ 10, 10, 20, 10 }));
|
||||
}
|
||||
|
||||
// Step 4: Shift+Click at (5,10)
|
||||
@@ -829,7 +829,7 @@ namespace TerminalCoreUnitTests
|
||||
|
||||
// Validate selection area
|
||||
// NOTE: Pivot should still be (10, 10)
|
||||
ValidateSingleRowSelection(term, SMALL_RECT({ 5, 10, 10, 10 }));
|
||||
ValidateSingleRowSelection(term, til::inclusive_rect({ 5, 10, 10, 10 }));
|
||||
}
|
||||
|
||||
// Step 5: Shift+Click back at (20,10)
|
||||
@@ -838,7 +838,7 @@ namespace TerminalCoreUnitTests
|
||||
|
||||
// Validate selection area
|
||||
// NOTE: Pivot should still be (10, 10)
|
||||
ValidateSingleRowSelection(term, SMALL_RECT({ 10, 10, 20, 10 }));
|
||||
ValidateSingleRowSelection(term, til::inclusive_rect({ 10, 10, 20, 10 }));
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -242,19 +242,19 @@ void TerminalApiTest::CheckDoubleWidthCursor()
|
||||
stateMachine.ProcessString(doubleWidthText);
|
||||
|
||||
// The last 'A'
|
||||
term.SetCursorPosition(97, 0);
|
||||
term.SetCursorPosition({ 97, 0 });
|
||||
VERIFY_IS_FALSE(term.IsCursorDoubleWidth());
|
||||
|
||||
// This and the next CursorPos are taken up by '我‘
|
||||
term.SetCursorPosition(98, 0);
|
||||
term.SetCursorPosition({ 98, 0 });
|
||||
VERIFY_IS_TRUE(term.IsCursorDoubleWidth());
|
||||
term.SetCursorPosition(99, 0);
|
||||
term.SetCursorPosition({ 99, 0 });
|
||||
VERIFY_IS_TRUE(term.IsCursorDoubleWidth());
|
||||
|
||||
// This and the next CursorPos are taken up by ’愛‘
|
||||
term.SetCursorPosition(0, 1);
|
||||
term.SetCursorPosition({ 0, 1 });
|
||||
VERIFY_IS_TRUE(term.IsCursorDoubleWidth());
|
||||
term.SetCursorPosition(1, 1);
|
||||
term.SetCursorPosition({ 1, 1 });
|
||||
VERIFY_IS_TRUE(term.IsCursorDoubleWidth());
|
||||
}
|
||||
|
||||
|
||||
@@ -28,9 +28,9 @@ class TerminalCoreUnitTests::TerminalBufferTests final
|
||||
// !!! DANGER: Many tests in this class expect the Terminal buffer
|
||||
// to be 80x32. If you change these, you'll probably inadvertently break a
|
||||
// bunch of tests !!!
|
||||
static const SHORT TerminalViewWidth = 80;
|
||||
static const SHORT TerminalViewHeight = 32;
|
||||
static const SHORT TerminalHistoryLength = 100;
|
||||
static const auto TerminalViewWidth = 80;
|
||||
static const auto TerminalViewHeight = 32;
|
||||
static const auto TerminalHistoryLength = 100;
|
||||
|
||||
TEST_CLASS(TerminalBufferTests);
|
||||
|
||||
@@ -66,8 +66,8 @@ class TerminalCoreUnitTests::TerminalBufferTests final
|
||||
}
|
||||
|
||||
private:
|
||||
void _SetTabStops(std::list<short> columns, bool replace);
|
||||
std::list<short> _GetTabStops();
|
||||
void _SetTabStops(const std::list<til::CoordType>& columns, bool replace);
|
||||
std::list<til::CoordType> _GetTabStops();
|
||||
|
||||
DummyRenderTarget emptyRT;
|
||||
std::unique_ptr<Terminal> term;
|
||||
@@ -99,7 +99,7 @@ void TerminalBufferTests::TestWrappingCharByChar()
|
||||
const auto initialView = term->GetViewport();
|
||||
auto& cursor = termTb.GetCursor();
|
||||
|
||||
const auto charsToWrite = gsl::narrow_cast<short>(TestUtils::Test100CharsString.size());
|
||||
const auto charsToWrite = TestUtils::Test100CharsString.size();
|
||||
|
||||
VERIFY_ARE_EQUAL(0, initialView.Top());
|
||||
VERIFY_ARE_EQUAL(32, initialView.BottomExclusive());
|
||||
@@ -138,7 +138,7 @@ void TerminalBufferTests::TestWrappingALongString()
|
||||
const auto initialView = term->GetViewport();
|
||||
auto& cursor = termTb.GetCursor();
|
||||
|
||||
const auto charsToWrite = gsl::narrow_cast<short>(TestUtils::Test100CharsString.size());
|
||||
const auto charsToWrite = TestUtils::Test100CharsString.size();
|
||||
VERIFY_ARE_EQUAL(100, charsToWrite);
|
||||
|
||||
VERIFY_ARE_EQUAL(0, initialView.Top());
|
||||
@@ -247,7 +247,7 @@ void TerminalBufferTests::DontSnapToOutputTest()
|
||||
VERIFY_ARE_EQUAL(TerminalHistoryLength, term->_scrollOffset);
|
||||
}
|
||||
|
||||
void TerminalBufferTests::_SetTabStops(std::list<short> columns, bool replace)
|
||||
void TerminalBufferTests::_SetTabStops(const std::list<til::CoordType>& columns, bool replace)
|
||||
{
|
||||
auto& termTb = *term->_buffer;
|
||||
auto& termSm = *term->_stateMachine;
|
||||
@@ -268,9 +268,9 @@ void TerminalBufferTests::_SetTabStops(std::list<short> columns, bool replace)
|
||||
}
|
||||
}
|
||||
|
||||
std::list<short> TerminalBufferTests::_GetTabStops()
|
||||
std::list<til::CoordType> TerminalBufferTests::_GetTabStops()
|
||||
{
|
||||
std::list<short> columns;
|
||||
std::list<til::CoordType> columns;
|
||||
auto& termTb = *term->_buffer;
|
||||
auto& termSm = *term->_stateMachine;
|
||||
const auto initialView = term->GetViewport();
|
||||
@@ -301,7 +301,7 @@ void TerminalBufferTests::TestResetClearTabStops()
|
||||
const auto resetToInitialState = L"\033c";
|
||||
|
||||
Log::Comment(L"Default tabs every 8 columns.");
|
||||
std::list<short> expectedStops{ 8, 16, 24, 32, 40, 48, 56, 64, 72 };
|
||||
std::list<til::CoordType> expectedStops{ 8, 16, 24, 32, 40, 48, 56, 64, 72 };
|
||||
VERIFY_ARE_EQUAL(expectedStops, _GetTabStops());
|
||||
|
||||
Log::Comment(L"Clear all tabs.");
|
||||
@@ -326,7 +326,7 @@ void TerminalBufferTests::TestAddTabStop()
|
||||
|
||||
Log::Comment(L"Clear all tabs.");
|
||||
termSm.ProcessString(clearTabStops);
|
||||
std::list<short> expectedStops{};
|
||||
std::list<til::CoordType> expectedStops{};
|
||||
VERIFY_ARE_EQUAL(expectedStops, _GetTabStops());
|
||||
|
||||
Log::Comment(L"Add tab to empty list.");
|
||||
@@ -415,7 +415,7 @@ void TerminalBufferTests::TestClearTabStop()
|
||||
|
||||
Log::Comment(L"Allocate many (5) list items and clear head.");
|
||||
{
|
||||
std::list<short> inputData = { 3, 5, 6, 10, 15, 17 };
|
||||
std::list<til::CoordType> inputData = { 3, 5, 6, 10, 15, 17 };
|
||||
_SetTabStops(inputData, false);
|
||||
cursor.SetXPosition(inputData.front());
|
||||
termSm.ProcessString(clearTabStop);
|
||||
@@ -429,7 +429,7 @@ void TerminalBufferTests::TestClearTabStop()
|
||||
|
||||
Log::Comment(L"Allocate many (5) list items and clear middle.");
|
||||
{
|
||||
std::list<short> inputData = { 3, 5, 6, 10, 15, 17 };
|
||||
std::list<til::CoordType> inputData = { 3, 5, 6, 10, 15, 17 };
|
||||
_SetTabStops(inputData, false);
|
||||
cursor.SetXPosition(*std::next(inputData.begin()));
|
||||
termSm.ProcessString(clearTabStop);
|
||||
@@ -443,7 +443,7 @@ void TerminalBufferTests::TestClearTabStop()
|
||||
|
||||
Log::Comment(L"Allocate many (5) list items and clear tail.");
|
||||
{
|
||||
std::list<short> inputData = { 3, 5, 6, 10, 15, 17 };
|
||||
std::list<til::CoordType> inputData = { 3, 5, 6, 10, 15, 17 };
|
||||
_SetTabStops(inputData, false);
|
||||
cursor.SetXPosition(inputData.back());
|
||||
termSm.ProcessString(clearTabStop);
|
||||
@@ -457,7 +457,7 @@ void TerminalBufferTests::TestClearTabStop()
|
||||
|
||||
Log::Comment(L"Allocate many (5) list items and clear nonexistent item.");
|
||||
{
|
||||
std::list<short> inputData = { 3, 5, 6, 10, 15, 17 };
|
||||
std::list<til::CoordType> inputData = { 3, 5, 6, 10, 15, 17 };
|
||||
_SetTabStops(inputData, false);
|
||||
cursor.SetXPosition(0);
|
||||
termSm.ProcessString(clearTabStop);
|
||||
@@ -478,20 +478,20 @@ void TerminalBufferTests::TestGetForwardTab()
|
||||
|
||||
const auto nextForwardTab = L"\033[I";
|
||||
|
||||
std::list<short> inputData = { 3, 5, 6, 10, 15, 17 };
|
||||
std::list<til::CoordType> inputData = { 3, 5, 6, 10, 15, 17 };
|
||||
_SetTabStops(inputData, true);
|
||||
|
||||
const COORD coordScreenBufferSize = initialView.Dimensions();
|
||||
const auto coordScreenBufferSize = initialView.Dimensions();
|
||||
|
||||
Log::Comment(L"Find next tab from before front.");
|
||||
{
|
||||
cursor.SetXPosition(0);
|
||||
|
||||
COORD coordCursorExpected = cursor.GetPosition();
|
||||
auto coordCursorExpected = cursor.GetPosition();
|
||||
coordCursorExpected.X = inputData.front();
|
||||
|
||||
termSm.ProcessString(nextForwardTab);
|
||||
COORD const coordCursorResult = cursor.GetPosition();
|
||||
const auto coordCursorResult = cursor.GetPosition();
|
||||
VERIFY_ARE_EQUAL(coordCursorExpected,
|
||||
coordCursorResult,
|
||||
L"Cursor advanced to first tab stop from sample list.");
|
||||
@@ -501,11 +501,11 @@ void TerminalBufferTests::TestGetForwardTab()
|
||||
{
|
||||
cursor.SetXPosition(6);
|
||||
|
||||
COORD coordCursorExpected = cursor.GetPosition();
|
||||
auto coordCursorExpected = cursor.GetPosition();
|
||||
coordCursorExpected.X = *std::next(inputData.begin(), 3);
|
||||
|
||||
termSm.ProcessString(nextForwardTab);
|
||||
COORD const coordCursorResult = cursor.GetPosition();
|
||||
const auto coordCursorResult = cursor.GetPosition();
|
||||
VERIFY_ARE_EQUAL(coordCursorExpected,
|
||||
coordCursorResult,
|
||||
L"Cursor advanced to middle tab stop from sample list.");
|
||||
@@ -515,11 +515,11 @@ void TerminalBufferTests::TestGetForwardTab()
|
||||
{
|
||||
cursor.SetXPosition(30);
|
||||
|
||||
COORD coordCursorExpected = cursor.GetPosition();
|
||||
coordCursorExpected.X = coordScreenBufferSize.X - 1;
|
||||
auto coordCursorExpected = cursor.GetPosition();
|
||||
coordCursorExpected.X = coordScreenBufferSize.width - 1;
|
||||
|
||||
termSm.ProcessString(nextForwardTab);
|
||||
COORD const coordCursorResult = cursor.GetPosition();
|
||||
const auto coordCursorResult = cursor.GetPosition();
|
||||
VERIFY_ARE_EQUAL(coordCursorExpected,
|
||||
coordCursorResult,
|
||||
L"Cursor advanced to end of screen buffer.");
|
||||
@@ -527,12 +527,12 @@ void TerminalBufferTests::TestGetForwardTab()
|
||||
|
||||
Log::Comment(L"Find next tab from rightmost column.");
|
||||
{
|
||||
cursor.SetXPosition(coordScreenBufferSize.X - 1);
|
||||
cursor.SetXPosition(coordScreenBufferSize.width - 1);
|
||||
|
||||
COORD coordCursorExpected = cursor.GetPosition();
|
||||
auto coordCursorExpected = cursor.GetPosition();
|
||||
|
||||
termSm.ProcessString(nextForwardTab);
|
||||
COORD const coordCursorResult = cursor.GetPosition();
|
||||
const auto coordCursorResult = cursor.GetPosition();
|
||||
VERIFY_ARE_EQUAL(coordCursorExpected,
|
||||
coordCursorResult,
|
||||
L"Cursor remains in rightmost column.");
|
||||
@@ -547,18 +547,18 @@ void TerminalBufferTests::TestGetReverseTab()
|
||||
|
||||
const auto nextReverseTab = L"\033[Z";
|
||||
|
||||
std::list<short> inputData = { 3, 5, 6, 10, 15, 17 };
|
||||
std::list<til::CoordType> inputData = { 3, 5, 6, 10, 15, 17 };
|
||||
_SetTabStops(inputData, true);
|
||||
|
||||
Log::Comment(L"Find previous tab from before front.");
|
||||
{
|
||||
cursor.SetXPosition(1);
|
||||
|
||||
COORD coordCursorExpected = cursor.GetPosition();
|
||||
auto coordCursorExpected = cursor.GetPosition();
|
||||
coordCursorExpected.X = 0;
|
||||
|
||||
termSm.ProcessString(nextReverseTab);
|
||||
COORD const coordCursorResult = cursor.GetPosition();
|
||||
const auto coordCursorResult = cursor.GetPosition();
|
||||
VERIFY_ARE_EQUAL(coordCursorExpected,
|
||||
coordCursorResult,
|
||||
L"Cursor adjusted to beginning of the buffer when it started before sample list.");
|
||||
@@ -568,11 +568,11 @@ void TerminalBufferTests::TestGetReverseTab()
|
||||
{
|
||||
cursor.SetXPosition(6);
|
||||
|
||||
COORD coordCursorExpected = cursor.GetPosition();
|
||||
auto coordCursorExpected = cursor.GetPosition();
|
||||
coordCursorExpected.X = *std::next(inputData.begin());
|
||||
|
||||
termSm.ProcessString(nextReverseTab);
|
||||
COORD const coordCursorResult = cursor.GetPosition();
|
||||
const auto coordCursorResult = cursor.GetPosition();
|
||||
VERIFY_ARE_EQUAL(coordCursorExpected,
|
||||
coordCursorResult,
|
||||
L"Cursor adjusted back one tab spot from middle of sample list.");
|
||||
@@ -582,11 +582,11 @@ void TerminalBufferTests::TestGetReverseTab()
|
||||
{
|
||||
cursor.SetXPosition(30);
|
||||
|
||||
COORD coordCursorExpected = cursor.GetPosition();
|
||||
auto coordCursorExpected = cursor.GetPosition();
|
||||
coordCursorExpected.X = inputData.back();
|
||||
|
||||
termSm.ProcessString(nextReverseTab);
|
||||
COORD const coordCursorResult = cursor.GetPosition();
|
||||
const auto coordCursorResult = cursor.GetPosition();
|
||||
VERIFY_ARE_EQUAL(coordCursorExpected,
|
||||
coordCursorResult,
|
||||
L"Cursor adjusted to last item in the sample list from position beyond end.");
|
||||
|
||||
@@ -102,7 +102,7 @@ public:
|
||||
// - an iterator on the first character after the expectedString.
|
||||
static TextBufferCellIterator VerifyExpectedString(const TextBuffer& tb,
|
||||
std::wstring_view expectedString,
|
||||
const COORD pos)
|
||||
const til::point pos)
|
||||
{
|
||||
auto iter = tb.GetCellDataAt(pos);
|
||||
VerifyExpectedString(expectedString, iter);
|
||||
@@ -192,7 +192,7 @@ public:
|
||||
};
|
||||
|
||||
template<class... T>
|
||||
static TextBufferCellIterator VerifyLineContains(const TextBuffer& tb, COORD position, T&&... expectedContent)
|
||||
static TextBufferCellIterator VerifyLineContains(const TextBuffer& tb, til::point position, T&&... expectedContent)
|
||||
{
|
||||
auto actual = tb.GetCellLineDataAt(position);
|
||||
VerifyLineContains(actual, std::forward<T>(expectedContent)...);
|
||||
|
||||
@@ -546,8 +546,8 @@ void AppHost::_HandleCreateWindow(const HWND hwnd, RECT proposedRect, LaunchMode
|
||||
nearestMonitorInfo.cbSize = sizeof(MONITORINFO);
|
||||
// Get monitor dimensions:
|
||||
GetMonitorInfo(hMonNearest, &nearestMonitorInfo);
|
||||
const til::size desktopDimensions{ gsl::narrow<short>(nearestMonitorInfo.rcWork.right - nearestMonitorInfo.rcWork.left),
|
||||
gsl::narrow<short>(nearestMonitorInfo.rcWork.bottom - nearestMonitorInfo.rcWork.top) };
|
||||
const til::size desktopDimensions{ nearestMonitorInfo.rcWork.right - nearestMonitorInfo.rcWork.left,
|
||||
nearestMonitorInfo.rcWork.bottom - nearestMonitorInfo.rcWork.top };
|
||||
|
||||
// GH#10583 - Adjust the position of the rectangle to account for the size
|
||||
// of the invisible borders on the left/right. We DON'T want to adjust this
|
||||
|
||||
@@ -539,14 +539,12 @@ void NonClientIslandWindow::_UpdateIslandPosition(const UINT windowWidth, const
|
||||
// buttons, which will make them clickable. It's perhaps not the right fix,
|
||||
// but it works.
|
||||
// _GetTopBorderHeight() returns 0 when we're maximized.
|
||||
const short topBorderHeight = ::base::saturated_cast<short>((originalTopHeight == 0) ? -1 : originalTopHeight);
|
||||
|
||||
const COORD newIslandPos = { 0, topBorderHeight };
|
||||
const auto topBorderHeight = originalTopHeight == 0 ? -1 : originalTopHeight;
|
||||
|
||||
winrt::check_bool(SetWindowPos(_interopWindowHandle,
|
||||
HWND_BOTTOM,
|
||||
newIslandPos.X,
|
||||
newIslandPos.Y,
|
||||
0,
|
||||
topBorderHeight,
|
||||
windowWidth,
|
||||
windowHeight - topBorderHeight,
|
||||
SWP_SHOWWINDOW | SWP_NOACTIVATE));
|
||||
|
||||
@@ -48,7 +48,7 @@ public:
|
||||
void OnApplicationThemeChanged(const winrt::Windows::UI::Xaml::ElementTheme& requestedTheme) override;
|
||||
|
||||
private:
|
||||
std::optional<COORD> _oldIslandPos;
|
||||
std::optional<til::point> _oldIslandPos;
|
||||
|
||||
winrt::TerminalApp::TitlebarControl _titlebar{ nullptr };
|
||||
winrt::Windows::UI::Xaml::UIElement _clientContent{ nullptr };
|
||||
|
||||
@@ -166,7 +166,7 @@ namespace Microsoft.Terminal.Wpf
|
||||
/// <summary>
|
||||
/// Retains the current size (ignores the cx and cy parameters).
|
||||
/// </summary>
|
||||
SWP_NOSIZE = 0x0001,
|
||||
SWP_NOTilSize = 0x0001,
|
||||
|
||||
/// <summary>
|
||||
/// Retains the current Z order (ignores the hWndInsertAfter parameter).
|
||||
@@ -186,13 +186,13 @@ namespace Microsoft.Terminal.Wpf
|
||||
public static extern void TerminalSendOutput(IntPtr terminal, string lpdata);
|
||||
|
||||
[DllImport("PublicTerminalCore.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.StdCall)]
|
||||
public static extern uint TerminalTriggerResize(IntPtr terminal, short width, short height, out COORD dimensions);
|
||||
public static extern uint TerminalTriggerResize(IntPtr terminal, [MarshalAs(UnmanagedType.Struct)] TilSize windowSize, out TilSize dimensions);
|
||||
|
||||
[DllImport("PublicTerminalCore.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.StdCall)]
|
||||
public static extern uint TerminalTriggerResizeWithDimension(IntPtr terminal, [MarshalAs(UnmanagedType.Struct)] COORD dimensions, out SIZE dimensionsInPixels);
|
||||
public static extern uint TerminalTriggerResizeWithDimension(IntPtr terminal, [MarshalAs(UnmanagedType.Struct)] TilSize dimensions, out TilSize dimensionsInPixels);
|
||||
|
||||
[DllImport("PublicTerminalCore.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.StdCall)]
|
||||
public static extern uint TerminalCalculateResize(IntPtr terminal, short width, short height, out COORD dimensions);
|
||||
public static extern uint TerminalCalculateResize(IntPtr terminal, [MarshalAs(UnmanagedType.Struct)] TilSize windowSize, out TilSize dimensions);
|
||||
|
||||
[DllImport("PublicTerminalCore.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.StdCall)]
|
||||
public static extern void TerminalDpiChanged(IntPtr terminal, int newDpi);
|
||||
@@ -207,10 +207,10 @@ namespace Microsoft.Terminal.Wpf
|
||||
public static extern void TerminalUserScroll(IntPtr terminal, int viewTop);
|
||||
|
||||
[DllImport("PublicTerminalCore.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.StdCall)]
|
||||
public static extern uint TerminalStartSelection(IntPtr terminal, COORD cursorPosition, bool altPressed);
|
||||
public static extern uint TerminalStartSelection(IntPtr terminal, TilPoint cursorPosition, bool altPressed);
|
||||
|
||||
[DllImport("PublicTerminalCore.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.StdCall)]
|
||||
public static extern uint TerminalMoveSelection(IntPtr terminal, COORD cursorPosition);
|
||||
public static extern uint TerminalMoveSelection(IntPtr terminal, TilPoint cursorPosition);
|
||||
|
||||
[DllImport("PublicTerminalCore.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.StdCall)]
|
||||
public static extern void TerminalClearSelection(IntPtr terminal);
|
||||
@@ -272,7 +272,7 @@ namespace Microsoft.Terminal.Wpf
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public struct COORD
|
||||
public struct TilPoint
|
||||
{
|
||||
/// <summary>
|
||||
/// The x-coordinate of the point.
|
||||
@@ -286,17 +286,17 @@ namespace Microsoft.Terminal.Wpf
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public struct SIZE
|
||||
public struct TilSize
|
||||
{
|
||||
/// <summary>
|
||||
/// The x size.
|
||||
/// </summary>
|
||||
public int cx;
|
||||
public int width;
|
||||
|
||||
/// <summary>
|
||||
/// The y size.
|
||||
/// </summary>
|
||||
public int cy;
|
||||
public int height;
|
||||
}
|
||||
}
|
||||
#pragma warning restore SA1600 // Elements should be documented
|
||||
|
||||
@@ -173,15 +173,18 @@ namespace Microsoft.Terminal.Wpf
|
||||
|
||||
NativeMethods.TerminalTriggerResize(
|
||||
this.terminal,
|
||||
Convert.ToInt16(renderSize.Width),
|
||||
Convert.ToInt16(renderSize.Height),
|
||||
out NativeMethods.COORD dimensions);
|
||||
new NativeMethods.TilSize
|
||||
{
|
||||
width = (int)renderSize.Width,
|
||||
height = (int)renderSize.Height,
|
||||
},
|
||||
out NativeMethods.TilSize dimensions);
|
||||
|
||||
this.Rows = dimensions.Y;
|
||||
this.Columns = dimensions.X;
|
||||
this.Rows = dimensions.height;
|
||||
this.Columns = dimensions.width;
|
||||
this.TerminalRendererSize = renderSize;
|
||||
|
||||
this.Connection?.Resize((uint)dimensions.Y, (uint)dimensions.X);
|
||||
this.Connection?.Resize((uint)dimensions.height, (uint)dimensions.width);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -200,25 +203,25 @@ namespace Microsoft.Terminal.Wpf
|
||||
throw new ArgumentException("Terminal column count cannot be 0.", nameof(columns));
|
||||
}
|
||||
|
||||
NativeMethods.SIZE dimensionsInPixels;
|
||||
NativeMethods.COORD dimensions = new NativeMethods.COORD
|
||||
NativeMethods.TilSize dimensionsInPixels;
|
||||
NativeMethods.TilSize dimensions = new NativeMethods.TilSize
|
||||
{
|
||||
X = (short)columns,
|
||||
Y = (short)rows,
|
||||
width = (int)columns,
|
||||
height = (int)rows,
|
||||
};
|
||||
|
||||
NativeMethods.TerminalTriggerResizeWithDimension(this.terminal, dimensions, out dimensionsInPixels);
|
||||
|
||||
this.Columns = dimensions.X;
|
||||
this.Rows = dimensions.Y;
|
||||
this.Columns = dimensions.width;
|
||||
this.Rows = dimensions.height;
|
||||
|
||||
this.TerminalRendererSize = new Size()
|
||||
{
|
||||
Width = dimensionsInPixels.cx,
|
||||
Height = dimensionsInPixels.cy,
|
||||
Width = dimensionsInPixels.width,
|
||||
Height = dimensionsInPixels.height,
|
||||
};
|
||||
|
||||
this.Connection?.Resize((uint)dimensions.Y, (uint)dimensions.X);
|
||||
this.Connection?.Resize((uint)dimensions.height, (uint)dimensions.width);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -228,9 +231,16 @@ namespace Microsoft.Terminal.Wpf
|
||||
/// <returns>Amount of rows and columns that would fit the given size.</returns>
|
||||
internal (uint columns, uint rows) CalculateRowsAndColumns(Size size)
|
||||
{
|
||||
NativeMethods.TerminalCalculateResize(this.terminal, (short)size.Width, (short)size.Height, out NativeMethods.COORD dimensions);
|
||||
NativeMethods.TerminalCalculateResize(
|
||||
this.terminal,
|
||||
new NativeMethods.TilSize
|
||||
{
|
||||
width = (int)size.Width,
|
||||
height = (int)size.Height,
|
||||
},
|
||||
out NativeMethods.TilSize dimensions);
|
||||
|
||||
return ((uint)dimensions.X, (uint)dimensions.Y);
|
||||
return ((uint)dimensions.width, (uint)dimensions.height);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -362,20 +372,27 @@ namespace Microsoft.Terminal.Wpf
|
||||
|
||||
case NativeMethods.WindowMessage.WM_WINDOWPOSCHANGED:
|
||||
var windowpos = (NativeMethods.WINDOWPOS)Marshal.PtrToStructure(lParam, typeof(NativeMethods.WINDOWPOS));
|
||||
if (((NativeMethods.SetWindowPosFlags)windowpos.flags).HasFlag(NativeMethods.SetWindowPosFlags.SWP_NOSIZE)
|
||||
if (((NativeMethods.SetWindowPosFlags)windowpos.flags).HasFlag(NativeMethods.SetWindowPosFlags.SWP_NOTilSize)
|
||||
|| (windowpos.cx == 0 && windowpos.cy == 0))
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
NativeMethods.COORD dimensions;
|
||||
NativeMethods.TilSize dimensions;
|
||||
|
||||
if (this.AutoResize)
|
||||
{
|
||||
NativeMethods.TerminalTriggerResize(this.terminal, (short)windowpos.cx, (short)windowpos.cy, out dimensions);
|
||||
NativeMethods.TerminalTriggerResize(
|
||||
this.terminal,
|
||||
new NativeMethods.TilSize
|
||||
{
|
||||
width = windowpos.cx,
|
||||
height = windowpos.cy,
|
||||
},
|
||||
out dimensions);
|
||||
|
||||
this.Columns = dimensions.X;
|
||||
this.Rows = dimensions.Y;
|
||||
this.Columns = dimensions.width;
|
||||
this.Rows = dimensions.height;
|
||||
|
||||
this.TerminalRendererSize = new Size()
|
||||
{
|
||||
@@ -386,10 +403,17 @@ namespace Microsoft.Terminal.Wpf
|
||||
else
|
||||
{
|
||||
// Calculate the new columns and rows that fit the total control size and alert the control to redraw the margins.
|
||||
NativeMethods.TerminalCalculateResize(this.terminal, (short)this.TerminalControlSize.Width, (short)this.TerminalControlSize.Height, out dimensions);
|
||||
NativeMethods.TerminalCalculateResize(
|
||||
this.terminal,
|
||||
new NativeMethods.TilSize
|
||||
{
|
||||
width = (int)this.TerminalControlSize.Width,
|
||||
height = (int)this.TerminalControlSize.Height,
|
||||
},
|
||||
out dimensions);
|
||||
}
|
||||
|
||||
this.Connection?.Resize((uint)dimensions.Y, (uint)dimensions.X);
|
||||
this.Connection?.Resize((uint)dimensions.height, (uint)dimensions.width);
|
||||
break;
|
||||
|
||||
case NativeMethods.WindowMessage.WM_MOUSEWHEEL:
|
||||
@@ -407,7 +431,7 @@ namespace Microsoft.Terminal.Wpf
|
||||
var altPressed = NativeMethods.GetKeyState((int)NativeMethods.VirtualKey.VK_MENU) < 0;
|
||||
var x = (short)(((int)lParam << 16) >> 16);
|
||||
var y = (short)((int)lParam >> 16);
|
||||
NativeMethods.COORD cursorPosition = new NativeMethods.COORD()
|
||||
NativeMethods.TilPoint cursorPosition = new NativeMethods.TilPoint()
|
||||
{
|
||||
X = x,
|
||||
Y = y,
|
||||
@@ -422,7 +446,7 @@ namespace Microsoft.Terminal.Wpf
|
||||
{
|
||||
var x = (short)(((int)lParam << 16) >> 16);
|
||||
var y = (short)((int)lParam >> 16);
|
||||
NativeMethods.COORD cursorPosition = new NativeMethods.COORD()
|
||||
NativeMethods.TilPoint cursorPosition = new NativeMethods.TilPoint()
|
||||
{
|
||||
X = x,
|
||||
Y = y,
|
||||
|
||||
@@ -118,19 +118,19 @@ public:
|
||||
[[nodiscard]] HRESULT FillConsoleOutputAttributeImpl(IConsoleOutputObject& OutContext,
|
||||
const WORD attribute,
|
||||
const size_t lengthToWrite,
|
||||
const COORD startingCoordinate,
|
||||
const til::point startingCoordinate,
|
||||
size_t& cellsModified) noexcept override;
|
||||
|
||||
[[nodiscard]] HRESULT FillConsoleOutputCharacterAImpl(IConsoleOutputObject& OutContext,
|
||||
const char character,
|
||||
const size_t lengthToWrite,
|
||||
const COORD startingCoordinate,
|
||||
const til::point startingCoordinate,
|
||||
size_t& cellsModified) noexcept override;
|
||||
|
||||
[[nodiscard]] HRESULT FillConsoleOutputCharacterWImpl(IConsoleOutputObject& OutContext,
|
||||
const wchar_t character,
|
||||
const size_t lengthToWrite,
|
||||
const COORD startingCoordinate,
|
||||
const til::point startingCoordinate,
|
||||
size_t& cellsModified,
|
||||
const bool enablePowershellShim = false) noexcept override;
|
||||
|
||||
@@ -162,25 +162,25 @@ public:
|
||||
const CONSOLE_SCREEN_BUFFER_INFOEX& data) noexcept override;
|
||||
|
||||
[[nodiscard]] HRESULT SetConsoleScreenBufferSizeImpl(SCREEN_INFORMATION& context,
|
||||
const COORD size) noexcept override;
|
||||
const til::size size) noexcept override;
|
||||
|
||||
[[nodiscard]] HRESULT SetConsoleCursorPositionImpl(SCREEN_INFORMATION& context,
|
||||
const COORD position) noexcept override;
|
||||
const til::point position) noexcept override;
|
||||
|
||||
void GetLargestConsoleWindowSizeImpl(const SCREEN_INFORMATION& context,
|
||||
COORD& size) noexcept override;
|
||||
|
||||
[[nodiscard]] HRESULT ScrollConsoleScreenBufferAImpl(SCREEN_INFORMATION& context,
|
||||
const SMALL_RECT& source,
|
||||
const COORD target,
|
||||
std::optional<SMALL_RECT> clip,
|
||||
const til::inclusive_rect source,
|
||||
const til::point target,
|
||||
std::optional<til::inclusive_rect> clip,
|
||||
const char fillCharacter,
|
||||
const WORD fillAttribute) noexcept override;
|
||||
|
||||
[[nodiscard]] HRESULT ScrollConsoleScreenBufferWImpl(SCREEN_INFORMATION& context,
|
||||
const SMALL_RECT& source,
|
||||
const COORD target,
|
||||
std::optional<SMALL_RECT> clip,
|
||||
const til::inclusive_rect source,
|
||||
const til::point target,
|
||||
std::optional<til::inclusive_rect> clip,
|
||||
const wchar_t fillCharacter,
|
||||
const WORD fillAttribute,
|
||||
const bool enableCmdShim = false) noexcept override;
|
||||
@@ -190,20 +190,20 @@ public:
|
||||
|
||||
[[nodiscard]] HRESULT SetConsoleWindowInfoImpl(SCREEN_INFORMATION& context,
|
||||
const bool isAbsolute,
|
||||
const SMALL_RECT& windowRect) noexcept override;
|
||||
const til::inclusive_rect windowRect) noexcept override;
|
||||
|
||||
[[nodiscard]] HRESULT ReadConsoleOutputAttributeImpl(const SCREEN_INFORMATION& context,
|
||||
const COORD origin,
|
||||
const til::point origin,
|
||||
gsl::span<WORD> buffer,
|
||||
size_t& written) noexcept override;
|
||||
|
||||
[[nodiscard]] HRESULT ReadConsoleOutputCharacterAImpl(const SCREEN_INFORMATION& context,
|
||||
const COORD origin,
|
||||
const til::point origin,
|
||||
gsl::span<char> buffer,
|
||||
size_t& written) noexcept override;
|
||||
|
||||
[[nodiscard]] HRESULT ReadConsoleOutputCharacterWImpl(const SCREEN_INFORMATION& context,
|
||||
const COORD origin,
|
||||
const til::point origin,
|
||||
gsl::span<wchar_t> buffer,
|
||||
size_t& written) noexcept override;
|
||||
|
||||
@@ -229,17 +229,17 @@ public:
|
||||
|
||||
[[nodiscard]] HRESULT WriteConsoleOutputAttributeImpl(IConsoleOutputObject& OutContext,
|
||||
const gsl::span<const WORD> attrs,
|
||||
const COORD target,
|
||||
const til::point target,
|
||||
size_t& used) noexcept override;
|
||||
|
||||
[[nodiscard]] HRESULT WriteConsoleOutputCharacterAImpl(IConsoleOutputObject& OutContext,
|
||||
const std::string_view text,
|
||||
const COORD target,
|
||||
const til::point target,
|
||||
size_t& used) noexcept override;
|
||||
|
||||
[[nodiscard]] HRESULT WriteConsoleOutputCharacterWImpl(IConsoleOutputObject& OutContext,
|
||||
const std::wstring_view text,
|
||||
const COORD target,
|
||||
const til::point target,
|
||||
size_t& used) noexcept override;
|
||||
|
||||
[[nodiscard]] HRESULT ReadConsoleOutputAImpl(const SCREEN_INFORMATION& context,
|
||||
|
||||
@@ -22,22 +22,21 @@ static constexpr size_t COMMAND_NUMBER_SIZE = 8; // size of command number buffe
|
||||
// - history - the history to look through to measure command sizes
|
||||
// Return Value:
|
||||
// - the proposed size of the popup with the history list taken into account
|
||||
static COORD calculatePopupSize(const CommandHistory& history)
|
||||
static til::point calculatePopupSize(const CommandHistory& history)
|
||||
{
|
||||
// this is the historical size of the popup, so it is now used as a minimum
|
||||
const COORD minSize = { 40, 10 };
|
||||
static constexpr til::point minSize{ 40, 10 };
|
||||
|
||||
// padding is for the command number listing before a command is printed to the window.
|
||||
// ex: |10: echo blah
|
||||
// ^^^^ <- these are the cells that are being accounted for by padding
|
||||
const size_t padding = 4;
|
||||
static constexpr til::CoordType padding = 4;
|
||||
|
||||
// find the widest command history item and use it for the width
|
||||
size_t width = minSize.X;
|
||||
for (size_t i = 0; i < history.GetNumberOfCommands(); ++i)
|
||||
til::CoordType width = minSize.X;
|
||||
for (const auto& historyItem : history.GetCommands())
|
||||
{
|
||||
const auto& historyItem = history.GetNth(gsl::narrow<short>(i));
|
||||
width = std::max(width, historyItem.size() + padding);
|
||||
width = std::max(width, gsl::narrow<til::CoordType>(historyItem.size() + padding));
|
||||
}
|
||||
if (width > SHRT_MAX)
|
||||
{
|
||||
@@ -45,9 +44,9 @@ static COORD calculatePopupSize(const CommandHistory& history)
|
||||
}
|
||||
|
||||
// calculate height, it can range up to 20 rows
|
||||
short height = std::clamp(gsl::narrow<short>(history.GetNumberOfCommands()), minSize.Y, 20i16);
|
||||
const auto height = std::clamp(gsl::narrow<til::CoordType>(history.GetNumberOfCommands()), minSize.Y, 20);
|
||||
|
||||
return { gsl::narrow<short>(width), height };
|
||||
return { width, height };
|
||||
}
|
||||
|
||||
CommandListPopup::CommandListPopup(SCREEN_INFORMATION& screenInfo, const CommandHistory& history) :
|
||||
@@ -139,7 +138,7 @@ void CommandListPopup::_setBottomIndex()
|
||||
{
|
||||
if (_currentCommand < (SHORT)(_history.GetNumberOfCommands() - Height()))
|
||||
{
|
||||
_bottomIndex = std::max(_currentCommand, gsl::narrow<SHORT>(Height() - 1i16));
|
||||
_bottomIndex = std::max(_currentCommand, gsl::narrow<SHORT>(Height() - 1));
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -204,7 +203,7 @@ void CommandListPopup::_setBottomIndex()
|
||||
{
|
||||
auto& history = cookedReadData.History();
|
||||
|
||||
if (history.GetNumberOfCommands() <= 1 || _currentCommand == gsl::narrow<short>(history.GetNumberOfCommands()) - 1i16)
|
||||
if (history.GetNumberOfCommands() <= 1 || _currentCommand == gsl::narrow<short>(history.GetNumberOfCommands()) - 1)
|
||||
{
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
@@ -330,22 +329,22 @@ void CommandListPopup::_DrawContent()
|
||||
void CommandListPopup::_drawList()
|
||||
{
|
||||
// draw empty popup
|
||||
COORD WriteCoord;
|
||||
WriteCoord.X = _region.Left + 1i16;
|
||||
WriteCoord.Y = _region.Top + 1i16;
|
||||
til::point WriteCoord;
|
||||
WriteCoord.X = _region.Left + 1;
|
||||
WriteCoord.Y = _region.Top + 1;
|
||||
size_t lStringLength = Width();
|
||||
for (SHORT i = 0; i < Height(); ++i)
|
||||
{
|
||||
const OutputCellIterator spaces(UNICODE_SPACE, _attributes, lStringLength);
|
||||
const auto result = _screenInfo.Write(spaces, WriteCoord);
|
||||
lStringLength = result.GetCellDistance(spaces);
|
||||
WriteCoord.Y += 1i16;
|
||||
WriteCoord.Y += 1;
|
||||
}
|
||||
|
||||
auto& api = Microsoft::Console::Interactivity::ServiceLocator::LocateGlobals().api;
|
||||
|
||||
WriteCoord.Y = _region.Top + 1i16;
|
||||
SHORT i = std::max(gsl::narrow<SHORT>(_bottomIndex - Height() + 1), 0i16);
|
||||
WriteCoord.Y = _region.Top + 1;
|
||||
auto i = std::max<SHORT>(gsl::narrow<SHORT>(_bottomIndex - Height() + 1), 0);
|
||||
for (; i <= _bottomIndex; i++)
|
||||
{
|
||||
CHAR CommandNumber[COMMAND_NUMBER_SIZE];
|
||||
@@ -377,7 +376,7 @@ void CommandListPopup::_drawList()
|
||||
CommandNumberLength = static_cast<ULONG>(Width());
|
||||
}
|
||||
|
||||
WriteCoord.X = _region.Left + 1i16;
|
||||
WriteCoord.X = _region.Left + 1;
|
||||
|
||||
LOG_IF_FAILED(api.WriteConsoleOutputCharacterAImpl(_screenInfo,
|
||||
{ CommandNumberPtr, CommandNumberLength },
|
||||
@@ -425,7 +424,7 @@ void CommandListPopup::_drawList()
|
||||
// write attributes to screen
|
||||
if (i == _currentCommand)
|
||||
{
|
||||
WriteCoord.X = _region.Left + 1i16;
|
||||
WriteCoord.X = _region.Left + 1;
|
||||
// inverted attributes
|
||||
lStringLength = Width();
|
||||
TextAttribute inverted = _attributes;
|
||||
@@ -454,7 +453,7 @@ void CommandListPopup::_update(const SHORT originalDelta, const bool wrap)
|
||||
{
|
||||
return;
|
||||
}
|
||||
SHORT const Size = Height();
|
||||
const auto Size = Height();
|
||||
|
||||
SHORT CurCmdNum = _currentCommand;
|
||||
SHORT NewCmdNum = CurCmdNum + delta;
|
||||
@@ -468,7 +467,7 @@ void CommandListPopup::_update(const SHORT originalDelta, const bool wrap)
|
||||
{
|
||||
if (NewCmdNum >= gsl::narrow<SHORT>(_history.GetNumberOfCommands()))
|
||||
{
|
||||
NewCmdNum = gsl::narrow<SHORT>(_history.GetNumberOfCommands()) - 1i16;
|
||||
NewCmdNum = gsl::narrow<SHORT>(_history.GetNumberOfCommands()) - 1;
|
||||
}
|
||||
else if (NewCmdNum < 0)
|
||||
{
|
||||
@@ -482,9 +481,9 @@ void CommandListPopup::_update(const SHORT originalDelta, const bool wrap)
|
||||
if (NewCmdNum <= _bottomIndex - Size)
|
||||
{
|
||||
_bottomIndex += delta;
|
||||
if (_bottomIndex < Size - 1i16)
|
||||
if (_bottomIndex < Size - 1)
|
||||
{
|
||||
_bottomIndex = Size - 1i16;
|
||||
_bottomIndex = gsl::narrow<decltype(_bottomIndex)>(Size - 1);
|
||||
}
|
||||
Scroll = true;
|
||||
}
|
||||
@@ -493,7 +492,7 @@ void CommandListPopup::_update(const SHORT originalDelta, const bool wrap)
|
||||
_bottomIndex += delta;
|
||||
if (_bottomIndex >= gsl::narrow<SHORT>(_history.GetNumberOfCommands()))
|
||||
{
|
||||
_bottomIndex = gsl::narrow<SHORT>(_history.GetNumberOfCommands()) - 1i16;
|
||||
_bottomIndex = gsl::narrow<SHORT>(_history.GetNumberOfCommands()) - 1;
|
||||
}
|
||||
Scroll = true;
|
||||
}
|
||||
@@ -518,27 +517,27 @@ void CommandListPopup::_update(const SHORT originalDelta, const bool wrap)
|
||||
// - NewCurrentCommand - The new command to be highlighted.
|
||||
void CommandListPopup::_updateHighlight(const SHORT OldCurrentCommand, const SHORT NewCurrentCommand)
|
||||
{
|
||||
SHORT TopIndex;
|
||||
til::CoordType TopIndex;
|
||||
if (_bottomIndex < Height())
|
||||
{
|
||||
TopIndex = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
TopIndex = _bottomIndex - Height() + 1i16;
|
||||
TopIndex = _bottomIndex - Height() + 1;
|
||||
}
|
||||
COORD WriteCoord;
|
||||
WriteCoord.X = _region.Left + 1i16;
|
||||
til::point WriteCoord;
|
||||
WriteCoord.X = _region.Left + 1;
|
||||
size_t lStringLength = Width();
|
||||
|
||||
WriteCoord.Y = _region.Top + 1i16 + OldCurrentCommand - TopIndex;
|
||||
WriteCoord.Y = _region.Top + 1 + OldCurrentCommand - TopIndex;
|
||||
|
||||
const OutputCellIterator it(_attributes, lStringLength);
|
||||
const auto done = _screenInfo.Write(it, WriteCoord);
|
||||
lStringLength = done.GetCellDistance(it);
|
||||
|
||||
// highlight new command
|
||||
WriteCoord.Y = _region.Top + 1i16 + NewCurrentCommand - TopIndex;
|
||||
WriteCoord.Y = _region.Top + 1 + NewCurrentCommand - TopIndex;
|
||||
|
||||
// inverted attributes
|
||||
TextAttribute inverted = _attributes;
|
||||
|
||||
@@ -100,10 +100,10 @@ void CursorBlinker::TimerRoutine(SCREEN_INFORMATION& ScreenInfo) const noexcept
|
||||
cursor.SetHasMoved(false);
|
||||
|
||||
RECT rc;
|
||||
rc.left = (position.X - viewport.Left()) * fontSize.X;
|
||||
rc.top = (position.Y - viewport.Top()) * fontSize.Y;
|
||||
rc.right = rc.left + fontSize.X;
|
||||
rc.bottom = rc.top + fontSize.Y;
|
||||
rc.left = (position.X - viewport.Left()) * fontSize.width;
|
||||
rc.top = (position.Y - viewport.Top()) * fontSize.height;
|
||||
rc.right = rc.left + fontSize.width;
|
||||
rc.bottom = rc.top + fontSize.height;
|
||||
|
||||
pAccessibilityNotifier->NotifyConsoleCaretEvent(rc);
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@ void ScreenBufferRenderTarget::TriggerRedraw(const Microsoft::Console::Types::Vi
|
||||
}
|
||||
}
|
||||
|
||||
void ScreenBufferRenderTarget::TriggerRedraw(const COORD* const pcoord)
|
||||
void ScreenBufferRenderTarget::TriggerRedraw(const til::point* const pcoord)
|
||||
{
|
||||
auto* pRenderer = ServiceLocator::LocateGlobals().pRender;
|
||||
const auto* pActive = &ServiceLocator::LocateGlobals().getConsoleInformation().GetActiveOutputBuffer().GetActiveBuffer();
|
||||
@@ -31,7 +31,7 @@ void ScreenBufferRenderTarget::TriggerRedraw(const COORD* const pcoord)
|
||||
}
|
||||
}
|
||||
|
||||
void ScreenBufferRenderTarget::TriggerRedrawCursor(const COORD* const pcoord)
|
||||
void ScreenBufferRenderTarget::TriggerRedrawCursor(const til::point* const pcoord)
|
||||
{
|
||||
auto* pRenderer = ServiceLocator::LocateGlobals().pRender;
|
||||
const auto* pActive = &ServiceLocator::LocateGlobals().getConsoleInformation().GetActiveOutputBuffer().GetActiveBuffer();
|
||||
@@ -81,7 +81,7 @@ void ScreenBufferRenderTarget::TriggerScroll()
|
||||
}
|
||||
}
|
||||
|
||||
void ScreenBufferRenderTarget::TriggerScroll(const COORD* const pcoordDelta)
|
||||
void ScreenBufferRenderTarget::TriggerScroll(const til::point* const pcoordDelta)
|
||||
{
|
||||
auto* pRenderer = ServiceLocator::LocateGlobals().pRender;
|
||||
const auto* pActive = &ServiceLocator::LocateGlobals().getConsoleInformation().GetActiveOutputBuffer().GetActiveBuffer();
|
||||
|
||||
@@ -30,13 +30,13 @@ public:
|
||||
ScreenBufferRenderTarget(SCREEN_INFORMATION& owner);
|
||||
|
||||
void TriggerRedraw(const Microsoft::Console::Types::Viewport& region) override;
|
||||
void TriggerRedraw(const COORD* const pcoord) override;
|
||||
void TriggerRedrawCursor(const COORD* const pcoord) override;
|
||||
void TriggerRedraw(const til::point* const pcoord) override;
|
||||
void TriggerRedrawCursor(const til::point* const pcoord) override;
|
||||
void TriggerRedrawAll() override;
|
||||
void TriggerTeardown() noexcept override;
|
||||
void TriggerSelection() override;
|
||||
void TriggerScroll() override;
|
||||
void TriggerScroll(const COORD* const pcoordDelta) override;
|
||||
void TriggerScroll(const til::point* const pcoordDelta) override;
|
||||
void TriggerCircling() override;
|
||||
void TriggerTitleChange() override;
|
||||
|
||||
|
||||
@@ -149,8 +149,8 @@ VtIo::VtIo() :
|
||||
if (IsValidHandle(_hOutput.get()))
|
||||
{
|
||||
Viewport initialViewport = Viewport::FromDimensions({ 0, 0 },
|
||||
gci.GetWindowSize().X,
|
||||
gci.GetWindowSize().Y);
|
||||
gci.GetWindowSize().width,
|
||||
gci.GetWindowSize().height);
|
||||
switch (_IoMode)
|
||||
{
|
||||
case VtIoMode::XTERM_256:
|
||||
@@ -322,7 +322,7 @@ bool VtIo::IsUsingVt() const
|
||||
// Return Value:
|
||||
// - S_OK if we successfully inherited the cursor or did nothing, else an
|
||||
// appropriate HRESULT
|
||||
[[nodiscard]] HRESULT VtIo::SetCursorPosition(const COORD coordCursor)
|
||||
[[nodiscard]] HRESULT VtIo::SetCursorPosition(const til::point coordCursor)
|
||||
{
|
||||
HRESULT hr = S_OK;
|
||||
if (_lookingForCursorPosition)
|
||||
|
||||
@@ -34,7 +34,7 @@ namespace Microsoft::Console::VirtualTerminal
|
||||
[[nodiscard]] static HRESULT ParseIoMode(const std::wstring& VtMode, _Out_ VtIoMode& ioMode);
|
||||
|
||||
[[nodiscard]] HRESULT SuppressResizeRepaint();
|
||||
[[nodiscard]] HRESULT SetCursorPosition(const COORD coordCursor);
|
||||
[[nodiscard]] HRESULT SetCursorPosition(const til::point coordCursor);
|
||||
|
||||
void CloseInput();
|
||||
void CloseOutput();
|
||||
|
||||
@@ -70,7 +70,7 @@ void WriteToScreen(SCREEN_INFORMATION& screenInfo, const Viewport& region)
|
||||
// - S_OK, E_INVALIDARG or similar HRESULT error.
|
||||
[[nodiscard]] HRESULT ApiRoutines::WriteConsoleOutputAttributeImpl(IConsoleOutputObject& OutContext,
|
||||
const gsl::span<const WORD> attrs,
|
||||
const COORD target,
|
||||
const til::point target,
|
||||
size_t& used) noexcept
|
||||
{
|
||||
// Set used to 0 from the beginning in case we exit early.
|
||||
@@ -110,7 +110,7 @@ void WriteToScreen(SCREEN_INFORMATION& screenInfo, const Viewport& region)
|
||||
// - S_OK, E_INVALIDARG or similar HRESULT error.
|
||||
[[nodiscard]] HRESULT ApiRoutines::WriteConsoleOutputCharacterWImpl(IConsoleOutputObject& OutContext,
|
||||
const std::wstring_view chars,
|
||||
const COORD target,
|
||||
const til::point target,
|
||||
size_t& used) noexcept
|
||||
{
|
||||
// Set used to 0 from the beginning in case we exit early.
|
||||
@@ -153,7 +153,7 @@ void WriteToScreen(SCREEN_INFORMATION& screenInfo, const Viewport& region)
|
||||
// - S_OK, E_INVALIDARG or similar HRESULT error.
|
||||
[[nodiscard]] HRESULT ApiRoutines::WriteConsoleOutputCharacterAImpl(IConsoleOutputObject& OutContext,
|
||||
const std::string_view chars,
|
||||
const COORD target,
|
||||
const til::point target,
|
||||
size_t& used) noexcept
|
||||
{
|
||||
// Set used to 0 from the beginning in case we exit early.
|
||||
@@ -195,7 +195,7 @@ void WriteToScreen(SCREEN_INFORMATION& screenInfo, const Viewport& region)
|
||||
[[nodiscard]] HRESULT ApiRoutines::FillConsoleOutputAttributeImpl(IConsoleOutputObject& OutContext,
|
||||
const WORD attribute,
|
||||
const size_t lengthToWrite,
|
||||
const COORD startingCoordinate,
|
||||
const til::point startingCoordinate,
|
||||
size_t& cellsModified) noexcept
|
||||
{
|
||||
// Set modified cells to 0 from the beginning.
|
||||
@@ -253,7 +253,7 @@ void WriteToScreen(SCREEN_INFORMATION& screenInfo, const Viewport& region)
|
||||
[[nodiscard]] HRESULT ApiRoutines::FillConsoleOutputCharacterWImpl(IConsoleOutputObject& OutContext,
|
||||
const wchar_t character,
|
||||
const size_t lengthToWrite,
|
||||
const COORD startingCoordinate,
|
||||
const til::point startingCoordinate,
|
||||
size_t& cellsModified,
|
||||
const bool enablePowershellShim) noexcept
|
||||
{
|
||||
@@ -307,7 +307,7 @@ void WriteToScreen(SCREEN_INFORMATION& screenInfo, const Viewport& region)
|
||||
const til::size currentBufferDimensions{ screenInfo.GetBufferSize().Dimensions() };
|
||||
|
||||
const bool wroteWholeBuffer = lengthToWrite == (currentBufferDimensions.area<size_t>());
|
||||
const bool startedAtOrigin = startingCoordinate == COORD{ 0, 0 };
|
||||
const bool startedAtOrigin = startingCoordinate == til::point{ 0, 0 };
|
||||
const bool wroteSpaces = character == UNICODE_SPACE;
|
||||
|
||||
if (wroteWholeBuffer && startedAtOrigin && wroteSpaces)
|
||||
@@ -334,7 +334,7 @@ void WriteToScreen(SCREEN_INFORMATION& screenInfo, const Viewport& region)
|
||||
[[nodiscard]] HRESULT ApiRoutines::FillConsoleOutputCharacterAImpl(IConsoleOutputObject& OutContext,
|
||||
const char character,
|
||||
const size_t lengthToWrite,
|
||||
const COORD startingCoordinate,
|
||||
const til::point startingCoordinate,
|
||||
size_t& cellsModified) noexcept
|
||||
try
|
||||
{
|
||||
|
||||
@@ -40,38 +40,38 @@ using Microsoft::Console::VirtualTerminal::StateMachine;
|
||||
// - fKeepCursorVisible - TRUE if changing window origin desirable when hit right edge
|
||||
// Return Value:
|
||||
[[nodiscard]] NTSTATUS AdjustCursorPosition(SCREEN_INFORMATION& screenInfo,
|
||||
_In_ COORD coordCursor,
|
||||
_In_ til::point coordCursor,
|
||||
const BOOL fKeepCursorVisible,
|
||||
_Inout_opt_ PSHORT psScrollY)
|
||||
_Inout_opt_ til::CoordType* psScrollY)
|
||||
{
|
||||
const bool inVtMode = WI_IsFlagSet(screenInfo.OutputMode, ENABLE_VIRTUAL_TERMINAL_PROCESSING);
|
||||
const COORD bufferSize = screenInfo.GetBufferSize().Dimensions();
|
||||
const auto bufferSize = screenInfo.GetBufferSize().Dimensions();
|
||||
if (coordCursor.X < 0)
|
||||
{
|
||||
if (coordCursor.Y > 0)
|
||||
{
|
||||
coordCursor.X = (SHORT)(bufferSize.X + coordCursor.X);
|
||||
coordCursor.Y = (SHORT)(coordCursor.Y - 1);
|
||||
coordCursor.X = bufferSize.width + coordCursor.X;
|
||||
coordCursor.Y = coordCursor.Y - 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
coordCursor.X = 0;
|
||||
}
|
||||
}
|
||||
else if (coordCursor.X >= bufferSize.X)
|
||||
else if (coordCursor.X >= bufferSize.width)
|
||||
{
|
||||
// at end of line. if wrap mode, wrap cursor. otherwise leave it where it is.
|
||||
if (screenInfo.OutputMode & ENABLE_WRAP_AT_EOL_OUTPUT)
|
||||
{
|
||||
coordCursor.Y += coordCursor.X / bufferSize.X;
|
||||
coordCursor.X = coordCursor.X % bufferSize.X;
|
||||
coordCursor.Y += coordCursor.X / bufferSize.width;
|
||||
coordCursor.X = coordCursor.X % bufferSize.width;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (inVtMode)
|
||||
{
|
||||
// In VT mode, the cursor must be left in the last column.
|
||||
coordCursor.X = bufferSize.X - 1;
|
||||
coordCursor.X = bufferSize.width - 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -88,9 +88,9 @@ using Microsoft::Console::VirtualTerminal::StateMachine;
|
||||
|
||||
const auto relativeMargins = screenInfo.GetRelativeScrollMargins();
|
||||
auto viewport = screenInfo.GetViewport();
|
||||
SMALL_RECT srMargins = screenInfo.GetAbsoluteScrollMargins().ToInclusive();
|
||||
auto srMargins = screenInfo.GetAbsoluteScrollMargins().ToInclusive();
|
||||
const bool fMarginsSet = srMargins.Bottom > srMargins.Top;
|
||||
COORD currentCursor = screenInfo.GetTextBuffer().GetCursor().GetPosition();
|
||||
auto currentCursor = screenInfo.GetTextBuffer().GetCursor().GetPosition();
|
||||
const int iCurrentCursorY = currentCursor.Y;
|
||||
|
||||
const bool fCursorInMargins = iCurrentCursorY <= srMargins.Bottom && iCurrentCursorY >= srMargins.Top;
|
||||
@@ -119,22 +119,22 @@ using Microsoft::Console::VirtualTerminal::StateMachine;
|
||||
// To do this, we're going to scroll everything starting at the bottom
|
||||
// margin down, then move the viewport down.
|
||||
|
||||
const SHORT delta = coordCursor.Y - srMargins.Bottom;
|
||||
SMALL_RECT scrollRect{ 0 };
|
||||
const auto delta = coordCursor.Y - srMargins.Bottom;
|
||||
til::inclusive_rect scrollRect{ 0 };
|
||||
scrollRect.Left = 0;
|
||||
scrollRect.Top = srMargins.Bottom + 1; // One below margins
|
||||
scrollRect.Bottom = bufferSize.Y - 1; // -1, otherwise this would be an exclusive rect.
|
||||
scrollRect.Right = bufferSize.X - 1; // -1, otherwise this would be an exclusive rect.
|
||||
scrollRect.Bottom = bufferSize.height - 1; // -1, otherwise this would be an exclusive rect.
|
||||
scrollRect.Right = bufferSize.width - 1; // -1, otherwise this would be an exclusive rect.
|
||||
|
||||
// This is the Y position we're moving the contents below the bottom margin to.
|
||||
SHORT moveToYPosition = scrollRect.Top + delta;
|
||||
auto moveToYPosition = scrollRect.Top + delta;
|
||||
|
||||
// This is where the viewport will need to be to give the effect of
|
||||
// scrolling the contents in the margins.
|
||||
SHORT newViewTop = viewport.Top() + delta;
|
||||
auto newViewTop = viewport.Top() + delta;
|
||||
|
||||
// This is how many new lines need to be added to the buffer to support this operation.
|
||||
const SHORT newRows = (viewport.BottomExclusive() + delta) - bufferSize.Y;
|
||||
const auto newRows = viewport.BottomExclusive() + delta - bufferSize.height;
|
||||
|
||||
// If we're near the bottom of the buffer, we might need to insert some
|
||||
// new rows at the bottom.
|
||||
@@ -148,8 +148,8 @@ using Microsoft::Console::VirtualTerminal::StateMachine;
|
||||
scrollRect.Top--;
|
||||
}
|
||||
|
||||
const COORD newPostMarginsOrigin = { 0, moveToYPosition };
|
||||
const COORD newViewOrigin = { 0, newViewTop };
|
||||
const til::point newPostMarginsOrigin{ 0, moveToYPosition };
|
||||
const til::point newViewOrigin{ 0, newViewTop };
|
||||
|
||||
try
|
||||
{
|
||||
@@ -212,17 +212,17 @@ using Microsoft::Console::VirtualTerminal::StateMachine;
|
||||
|
||||
// If we did the above scrollDownAtTop case, then we've already scrolled
|
||||
// the margins content, and we can skip this.
|
||||
if (fScrollUp || (fScrollDown && !scrollDownAtTop))
|
||||
if (fScrollUp || fScrollDown && !scrollDownAtTop)
|
||||
{
|
||||
SHORT diff = coordCursor.Y - (fScrollUp ? srMargins.Top : srMargins.Bottom);
|
||||
auto diff = coordCursor.Y - (fScrollUp ? srMargins.Top : srMargins.Bottom);
|
||||
|
||||
SMALL_RECT scrollRect = { 0 };
|
||||
til::inclusive_rect scrollRect;
|
||||
scrollRect.Top = srMargins.Top;
|
||||
scrollRect.Bottom = srMargins.Bottom;
|
||||
scrollRect.Left = 0; // NOTE: Left/Right Scroll margins don't do anything currently.
|
||||
scrollRect.Right = bufferSize.X - 1; // -1, otherwise this would be an exclusive rect.
|
||||
scrollRect.Right = bufferSize.width - 1; // -1, otherwise this would be an exclusive rect.
|
||||
|
||||
COORD dest;
|
||||
til::point dest;
|
||||
dest.X = scrollRect.Left;
|
||||
dest.Y = scrollRect.Top - diff;
|
||||
|
||||
@@ -246,10 +246,10 @@ using Microsoft::Console::VirtualTerminal::StateMachine;
|
||||
|
||||
NTSTATUS Status = STATUS_SUCCESS;
|
||||
|
||||
if (coordCursor.Y >= bufferSize.Y)
|
||||
if (coordCursor.Y >= bufferSize.height)
|
||||
{
|
||||
// At the end of the buffer. Scroll contents of screen buffer so new position is visible.
|
||||
FAIL_FAST_IF(!(coordCursor.Y == bufferSize.Y));
|
||||
FAIL_FAST_IF(!(coordCursor.Y == bufferSize.height));
|
||||
if (!StreamScrollRegion(screenInfo))
|
||||
{
|
||||
Status = STATUS_NO_MEMORY;
|
||||
@@ -257,9 +257,9 @@ using Microsoft::Console::VirtualTerminal::StateMachine;
|
||||
|
||||
if (nullptr != psScrollY)
|
||||
{
|
||||
*psScrollY += (SHORT)(bufferSize.Y - coordCursor.Y - 1);
|
||||
*psScrollY += bufferSize.height - coordCursor.Y - 1;
|
||||
}
|
||||
coordCursor.Y += (SHORT)(bufferSize.Y - coordCursor.Y - 1);
|
||||
coordCursor.Y += bufferSize.height - coordCursor.Y - 1;
|
||||
}
|
||||
|
||||
const bool cursorMovedPastViewport = coordCursor.Y > screenInfo.GetViewport().BottomInclusive();
|
||||
@@ -269,7 +269,7 @@ using Microsoft::Console::VirtualTerminal::StateMachine;
|
||||
// if at right or bottom edge of window, scroll right or down one char.
|
||||
if (cursorMovedPastViewport)
|
||||
{
|
||||
COORD WindowOrigin;
|
||||
til::point WindowOrigin;
|
||||
WindowOrigin.X = 0;
|
||||
WindowOrigin.Y = coordCursor.Y - screenInfo.GetViewport().BottomInclusive();
|
||||
Status = screenInfo.SetViewportOrigin(false, WindowOrigin, true);
|
||||
@@ -327,16 +327,16 @@ using Microsoft::Console::VirtualTerminal::StateMachine;
|
||||
_In_reads_bytes_(*pcb) const wchar_t* pwchRealUnicode,
|
||||
_Inout_ size_t* const pcb,
|
||||
_Out_opt_ size_t* const pcSpaces,
|
||||
const SHORT sOriginalXPosition,
|
||||
const til::CoordType sOriginalXPosition,
|
||||
const DWORD dwFlags,
|
||||
_Inout_opt_ PSHORT const psScrollY)
|
||||
_Inout_opt_ til::CoordType* const psScrollY)
|
||||
{
|
||||
const CONSOLE_INFORMATION& gci = ServiceLocator::LocateGlobals().getConsoleInformation();
|
||||
TextBuffer& textBuffer = screenInfo.GetTextBuffer();
|
||||
Cursor& cursor = textBuffer.GetCursor();
|
||||
COORD CursorPosition = cursor.GetPosition();
|
||||
auto CursorPosition = cursor.GetPosition();
|
||||
NTSTATUS Status = STATUS_SUCCESS;
|
||||
SHORT XPosition;
|
||||
til::CoordType XPosition;
|
||||
size_t TempNumSpaces = 0;
|
||||
const bool fUnprocessed = WI_IsFlagClear(screenInfo.OutputMode, ENABLE_PROCESSED_OUTPUT);
|
||||
const bool fWrapAtEOL = WI_IsFlagSet(screenInfo.OutputMode, ENABLE_WRAP_AT_EOL_OUTPUT);
|
||||
@@ -350,11 +350,11 @@ using Microsoft::Console::VirtualTerminal::StateMachine;
|
||||
|
||||
const wchar_t* lpString = pwchRealUnicode;
|
||||
|
||||
COORD coordScreenBufferSize = screenInfo.GetBufferSize().Dimensions();
|
||||
auto coordScreenBufferSize = screenInfo.GetBufferSize().Dimensions();
|
||||
// In VT mode, the width at which we wrap is determined by the line rendition attribute.
|
||||
if (WI_IsFlagSet(screenInfo.OutputMode, ENABLE_VIRTUAL_TERMINAL_PROCESSING))
|
||||
{
|
||||
coordScreenBufferSize.X = textBuffer.GetLineWidth(CursorPosition.Y);
|
||||
coordScreenBufferSize.width = textBuffer.GetLineWidth(CursorPosition.Y);
|
||||
}
|
||||
|
||||
static constexpr unsigned int LOCAL_BUFFER_SIZE = 1024;
|
||||
@@ -365,7 +365,7 @@ using Microsoft::Console::VirtualTerminal::StateMachine;
|
||||
// correct for delayed EOL
|
||||
if (cursor.IsDelayedEOLWrap() && fWrapAtEOL)
|
||||
{
|
||||
const COORD coordDelayedAt = cursor.GetDelayedAtPosition();
|
||||
const auto coordDelayedAt = cursor.GetDelayedAtPosition();
|
||||
cursor.ResetDelayEOLWrap();
|
||||
// Only act on a delayed EOL if we didn't move the cursor to a different position from where the EOL was marked.
|
||||
if (coordDelayedAt.X == CursorPosition.X && coordDelayedAt.Y == CursorPosition.Y)
|
||||
@@ -379,16 +379,16 @@ using Microsoft::Console::VirtualTerminal::StateMachine;
|
||||
// In VT mode, we need to recalculate the width when moving to a new line.
|
||||
if (WI_IsFlagSet(screenInfo.OutputMode, ENABLE_VIRTUAL_TERMINAL_PROCESSING))
|
||||
{
|
||||
coordScreenBufferSize.X = textBuffer.GetLineWidth(CursorPosition.Y);
|
||||
coordScreenBufferSize.width = textBuffer.GetLineWidth(CursorPosition.Y);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// As an optimization, collect characters in buffer and print out all at once.
|
||||
XPosition = cursor.GetPosition().X;
|
||||
size_t i = 0;
|
||||
til::CoordType i = 0;
|
||||
wchar_t* LocalBufPtr = LocalBuffer;
|
||||
while (*pcb < BufferSize && i < LOCAL_BUFFER_SIZE && XPosition < coordScreenBufferSize.X)
|
||||
while (*pcb < BufferSize && i < LOCAL_BUFFER_SIZE && XPosition < coordScreenBufferSize.width)
|
||||
{
|
||||
#pragma prefast(suppress : 26019, "Buffer is taken in multiples of 2. Validation is ok.")
|
||||
const wchar_t Char = *lpString;
|
||||
@@ -401,7 +401,7 @@ using Microsoft::Console::VirtualTerminal::StateMachine;
|
||||
// WCL-NOTE: This operates on a single code unit instead of a whole codepoint. It will mis-measure surrogate pairs.
|
||||
if (IsGlyphFullWidth(Char))
|
||||
{
|
||||
if (i < (LOCAL_BUFFER_SIZE - 1) && XPosition < (coordScreenBufferSize.X - 1))
|
||||
if (i < LOCAL_BUFFER_SIZE - 1 && XPosition < coordScreenBufferSize.width - 1)
|
||||
{
|
||||
*LocalBufPtr++ = Char;
|
||||
|
||||
@@ -453,8 +453,8 @@ using Microsoft::Console::VirtualTerminal::StateMachine;
|
||||
case UNICODE_TAB:
|
||||
{
|
||||
const ULONG TabSize = NUMBER_OF_SPACES_IN_TAB(XPosition);
|
||||
XPosition = (SHORT)(XPosition + TabSize);
|
||||
if (XPosition >= coordScreenBufferSize.X)
|
||||
XPosition = XPosition + TabSize;
|
||||
if (XPosition >= coordScreenBufferSize.width)
|
||||
{
|
||||
goto EndWhile;
|
||||
}
|
||||
@@ -547,10 +547,7 @@ using Microsoft::Console::VirtualTerminal::StateMachine;
|
||||
|
||||
// Make sure we don't write past the end of the buffer.
|
||||
// WCL-NOTE: This check uses a code unit count instead of a column count. That is incorrect.
|
||||
if (i > gsl::narrow_cast<size_t>(coordScreenBufferSize.X) - CursorPosition.X)
|
||||
{
|
||||
i = gsl::narrow_cast<size_t>(coordScreenBufferSize.X) - CursorPosition.X;
|
||||
}
|
||||
i = std::min(i, coordScreenBufferSize.width - CursorPosition.X);
|
||||
|
||||
// line was wrapped if we're writing up to the end of the current row
|
||||
OutputCellIterator it(std::wstring_view(LocalBuffer, i), Attributes);
|
||||
@@ -559,7 +556,7 @@ using Microsoft::Console::VirtualTerminal::StateMachine;
|
||||
// Notify accessibility
|
||||
if (screenInfo.HasAccessibilityEventing())
|
||||
{
|
||||
screenInfo.NotifyAccessibilityEventing(CursorPosition.X, CursorPosition.Y, CursorPosition.X + gsl::narrow<SHORT>(i - 1), CursorPosition.Y);
|
||||
screenInfo.NotifyAccessibilityEventing(CursorPosition.X, CursorPosition.Y, CursorPosition.X + i - 1, CursorPosition.Y);
|
||||
}
|
||||
|
||||
// The number of "spaces" or "cells" we have consumed needs to be reported and stored for later
|
||||
@@ -571,10 +568,10 @@ using Microsoft::Console::VirtualTerminal::StateMachine;
|
||||
CursorPosition.X = XPosition;
|
||||
|
||||
// enforce a delayed newline if we're about to pass the end and the WC_DELAY_EOL_WRAP flag is set.
|
||||
if (WI_IsFlagSet(dwFlags, WC_DELAY_EOL_WRAP) && CursorPosition.X >= coordScreenBufferSize.X && fWrapAtEOL)
|
||||
if (WI_IsFlagSet(dwFlags, WC_DELAY_EOL_WRAP) && CursorPosition.X >= coordScreenBufferSize.width && fWrapAtEOL)
|
||||
{
|
||||
// Our cursor position as of this time is going to remain on the last position in this column.
|
||||
CursorPosition.X = coordScreenBufferSize.X - 1;
|
||||
CursorPosition.X = coordScreenBufferSize.width - 1;
|
||||
|
||||
// Update in the structures that we're still pointing to the last character in the row
|
||||
cursor.SetPosition(CursorPosition);
|
||||
@@ -677,12 +674,12 @@ using Microsoft::Console::VirtualTerminal::StateMachine;
|
||||
|
||||
if (LastChar == UNICODE_TAB)
|
||||
{
|
||||
CursorPosition.X -= (SHORT)(RetrieveNumberOfSpaces(sOriginalXPosition,
|
||||
pwchBufferBackupLimit,
|
||||
(ULONG)(pwchBuffer - pwchBufferBackupLimit - 1)));
|
||||
CursorPosition.X -= RetrieveNumberOfSpaces(sOriginalXPosition,
|
||||
pwchBufferBackupLimit,
|
||||
pwchBuffer - pwchBufferBackupLimit - 1);
|
||||
if (CursorPosition.X < 0)
|
||||
{
|
||||
CursorPosition.X = (coordScreenBufferSize.X - 1) / TAB_SIZE;
|
||||
CursorPosition.X = (coordScreenBufferSize.width - 1) / TAB_SIZE;
|
||||
CursorPosition.X *= TAB_SIZE;
|
||||
CursorPosition.X += 1;
|
||||
CursorPosition.Y -= 1;
|
||||
@@ -751,12 +748,12 @@ using Microsoft::Console::VirtualTerminal::StateMachine;
|
||||
if (CheckBisectProcessW(screenInfo,
|
||||
pwchBufferBackupLimit,
|
||||
pwchBuffer + 1 - pwchBufferBackupLimit,
|
||||
gsl::narrow_cast<size_t>(coordScreenBufferSize.X) - sOriginalXPosition,
|
||||
gsl::narrow_cast<size_t>(coordScreenBufferSize.width - sOriginalXPosition),
|
||||
sOriginalXPosition,
|
||||
dwFlags & WC_PRINTABLE_CONTROL_CHARS))
|
||||
{
|
||||
CursorPosition.X = coordScreenBufferSize.X - 1;
|
||||
CursorPosition.Y = (SHORT)(cursor.GetPosition().Y - 1);
|
||||
CursorPosition.X = coordScreenBufferSize.width - 1;
|
||||
CursorPosition.Y = cursor.GetPosition().Y - 1;
|
||||
|
||||
// since you just backspaced yourself back up into the previous row, unset the wrap flag
|
||||
// on the prev row if it was set
|
||||
@@ -769,8 +766,8 @@ using Microsoft::Console::VirtualTerminal::StateMachine;
|
||||
}
|
||||
case UNICODE_TAB:
|
||||
{
|
||||
const size_t TabSize = gsl::narrow_cast<size_t>(NUMBER_OF_SPACES_IN_TAB(cursor.GetPosition().X));
|
||||
CursorPosition.X = (SHORT)(cursor.GetPosition().X + TabSize);
|
||||
const auto TabSize = NUMBER_OF_SPACES_IN_TAB(cursor.GetPosition().X);
|
||||
CursorPosition.X = cursor.GetPosition().X + TabSize;
|
||||
|
||||
// move cursor forward to next tab stop. fill space with blanks.
|
||||
// we get here when the tab extends beyond the right edge of the
|
||||
@@ -780,9 +777,9 @@ using Microsoft::Console::VirtualTerminal::StateMachine;
|
||||
|
||||
TempNumSpaces += TabSize;
|
||||
size_t NumChars = 0;
|
||||
if (CursorPosition.X >= coordScreenBufferSize.X)
|
||||
if (CursorPosition.X >= coordScreenBufferSize.width)
|
||||
{
|
||||
NumChars = gsl::narrow<size_t>(coordScreenBufferSize.X - cursor.GetPosition().X);
|
||||
NumChars = gsl::narrow<size_t>(coordScreenBufferSize.width - cursor.GetPosition().X);
|
||||
CursorPosition.X = 0;
|
||||
CursorPosition.Y = cursor.GetPosition().Y + 1;
|
||||
|
||||
@@ -830,7 +827,7 @@ using Microsoft::Console::VirtualTerminal::StateMachine;
|
||||
CursorPosition.X = 0;
|
||||
}
|
||||
|
||||
CursorPosition.Y = (SHORT)(cursor.GetPosition().Y + 1);
|
||||
CursorPosition.Y = cursor.GetPosition().Y + 1;
|
||||
|
||||
{
|
||||
// since we explicitly just moved down a row, clear the wrap status on the row we just came from
|
||||
@@ -845,10 +842,10 @@ using Microsoft::Console::VirtualTerminal::StateMachine;
|
||||
const wchar_t Char = *lpString;
|
||||
if (Char >= UNICODE_SPACE &&
|
||||
IsGlyphFullWidth(Char) &&
|
||||
XPosition >= (coordScreenBufferSize.X - 1) &&
|
||||
XPosition >= coordScreenBufferSize.width - 1 &&
|
||||
fWrapAtEOL)
|
||||
{
|
||||
const COORD TargetPoint = cursor.GetPosition();
|
||||
const auto TargetPoint = cursor.GetPosition();
|
||||
ROW& Row = textBuffer.GetRowByOffset(TargetPoint.Y);
|
||||
const CharRow& charRow = Row.GetCharRow();
|
||||
|
||||
@@ -874,7 +871,7 @@ using Microsoft::Console::VirtualTerminal::StateMachine;
|
||||
}
|
||||
|
||||
CursorPosition.X = 0;
|
||||
CursorPosition.Y = (SHORT)(TargetPoint.Y + 1);
|
||||
CursorPosition.Y = TargetPoint.Y + 1;
|
||||
|
||||
// since you just moved yourself down onto the next row with 1 character, that sounds like a
|
||||
// forced wrap so set the flag
|
||||
@@ -933,9 +930,9 @@ using Microsoft::Console::VirtualTerminal::StateMachine;
|
||||
_In_reads_bytes_(*pcb) const wchar_t* pwchRealUnicode,
|
||||
_Inout_ size_t* const pcb,
|
||||
_Out_opt_ size_t* const pcSpaces,
|
||||
const SHORT sOriginalXPosition,
|
||||
const til::CoordType sOriginalXPosition,
|
||||
const DWORD dwFlags,
|
||||
_Inout_opt_ PSHORT const psScrollY)
|
||||
_Inout_opt_ til::CoordType* const psScrollY)
|
||||
{
|
||||
if (!WI_IsFlagSet(screenInfo.OutputMode, ENABLE_VIRTUAL_TERMINAL_PROCESSING) ||
|
||||
!WI_IsFlagSet(screenInfo.OutputMode, ENABLE_PROCESSED_OUTPUT))
|
||||
|
||||
@@ -36,9 +36,9 @@ Arguments:
|
||||
Return Value:
|
||||
--*/
|
||||
[[nodiscard]] NTSTATUS AdjustCursorPosition(SCREEN_INFORMATION& screenInfo,
|
||||
_In_ COORD coordCursor,
|
||||
_In_ til::point coordCursor,
|
||||
const BOOL fKeepCursorVisible,
|
||||
_Inout_opt_ PSHORT psScrollY);
|
||||
_Inout_opt_ til::CoordType* psScrollY);
|
||||
|
||||
/*++
|
||||
Routine Description:
|
||||
@@ -73,9 +73,9 @@ Note:
|
||||
_In_reads_bytes_(*pcb) const wchar_t* pwchRealUnicode,
|
||||
_Inout_ size_t* const pcb,
|
||||
_Out_opt_ size_t* const pcSpaces,
|
||||
const SHORT sOriginalXPosition,
|
||||
const til::CoordType sOriginalXPosition,
|
||||
const DWORD dwFlags,
|
||||
_Inout_opt_ PSHORT const psScrollY);
|
||||
_Inout_opt_ til::CoordType* const psScrollY);
|
||||
|
||||
// The new entry point for WriteChars to act as an intercept in case we place a Virtual Terminal processor in the way.
|
||||
[[nodiscard]] NTSTATUS WriteChars(SCREEN_INFORMATION& screenInfo,
|
||||
@@ -84,9 +84,9 @@ Note:
|
||||
_In_reads_bytes_(*pcb) const wchar_t* pwchRealUnicode,
|
||||
_Inout_ size_t* const pcb,
|
||||
_Out_opt_ size_t* const pcSpaces,
|
||||
const SHORT sOriginalXPosition,
|
||||
const til::CoordType sOriginalXPosition,
|
||||
const DWORD dwFlags,
|
||||
_Inout_opt_ PSHORT const psScrollY);
|
||||
_Inout_opt_ til::CoordType* const psScrollY);
|
||||
|
||||
// NOTE: console lock must be held when calling this routine
|
||||
// String has been translated to unicode at this point.
|
||||
|
||||
@@ -205,13 +205,13 @@ void CommandLine::EndAllPopups()
|
||||
void DeleteCommandLine(COOKED_READ_DATA& cookedReadData, const bool fUpdateFields)
|
||||
{
|
||||
size_t CharsToWrite = cookedReadData.VisibleCharCount();
|
||||
COORD coordOriginalCursor = cookedReadData.OriginalCursorPosition();
|
||||
const COORD coordBufferSize = cookedReadData.ScreenInfo().GetBufferSize().Dimensions();
|
||||
auto coordOriginalCursor = cookedReadData.OriginalCursorPosition();
|
||||
const auto coordBufferSize = cookedReadData.ScreenInfo().GetBufferSize().Dimensions();
|
||||
|
||||
// catch the case where the current command has scrolled off the top of the screen.
|
||||
if (coordOriginalCursor.Y < 0)
|
||||
{
|
||||
CharsToWrite += coordBufferSize.X * coordOriginalCursor.Y;
|
||||
CharsToWrite += coordBufferSize.width * coordOriginalCursor.Y;
|
||||
CharsToWrite += cookedReadData.OriginalCursorPosition().X; // account for prompt
|
||||
cookedReadData.OriginalCursorPosition().X = 0;
|
||||
cookedReadData.OriginalCursorPosition().Y = 0;
|
||||
@@ -221,7 +221,7 @@ void DeleteCommandLine(COOKED_READ_DATA& cookedReadData, const bool fUpdateField
|
||||
|
||||
if (!CheckBisectStringW(cookedReadData.BufferStartPtr(),
|
||||
CharsToWrite,
|
||||
coordBufferSize.X - cookedReadData.OriginalCursorPosition().X))
|
||||
coordBufferSize.width - cookedReadData.OriginalCursorPosition().x))
|
||||
{
|
||||
CharsToWrite++;
|
||||
}
|
||||
@@ -247,7 +247,7 @@ void RedrawCommandLine(COOKED_READ_DATA& cookedReadData)
|
||||
// Draw the command line
|
||||
cookedReadData.OriginalCursorPosition() = cookedReadData.ScreenInfo().GetTextBuffer().GetCursor().GetPosition();
|
||||
|
||||
SHORT ScrollY = 0;
|
||||
til::CoordType ScrollY = 0;
|
||||
#pragma prefast(suppress : 28931, "Status is not unused. It's used in debug assertions.")
|
||||
NTSTATUS Status = WriteCharsLegacy(cookedReadData.ScreenInfo(),
|
||||
cookedReadData.BufferStartPtr(),
|
||||
@@ -263,10 +263,10 @@ void RedrawCommandLine(COOKED_READ_DATA& cookedReadData)
|
||||
cookedReadData.OriginalCursorPosition().Y += ScrollY;
|
||||
|
||||
// Move the cursor back to the right position
|
||||
COORD CursorPosition = cookedReadData.OriginalCursorPosition();
|
||||
CursorPosition.X += (SHORT)RetrieveTotalNumberOfSpaces(cookedReadData.OriginalCursorPosition().X,
|
||||
cookedReadData.BufferStartPtr(),
|
||||
cookedReadData.InsertionPoint());
|
||||
auto CursorPosition = cookedReadData.OriginalCursorPosition();
|
||||
CursorPosition.X += RetrieveTotalNumberOfSpaces(cookedReadData.OriginalCursorPosition().x,
|
||||
cookedReadData.BufferStartPtr(),
|
||||
cookedReadData.InsertionPoint());
|
||||
if (CheckBisectStringW(cookedReadData.BufferStartPtr(),
|
||||
cookedReadData.InsertionPoint(),
|
||||
cookedReadData.ScreenInfo().GetBufferSize().Width() - cookedReadData.OriginalCursorPosition().X))
|
||||
@@ -289,7 +289,7 @@ void SetCurrentCommandLine(COOKED_READ_DATA& cookedReadData, _In_ SHORT Index) /
|
||||
FAIL_FAST_IF(!(cookedReadData.BufferStartPtr() == cookedReadData.BufferCurrentPtr()));
|
||||
if (cookedReadData.IsEchoInput())
|
||||
{
|
||||
SHORT ScrollY = 0;
|
||||
til::CoordType ScrollY = 0;
|
||||
FAIL_FAST_IF_NTSTATUS_FAILED(WriteCharsLegacy(cookedReadData.ScreenInfo(),
|
||||
cookedReadData.BufferStartPtr(),
|
||||
cookedReadData.BufferCurrentPtr(),
|
||||
@@ -406,7 +406,7 @@ void SetCurrentCommandLine(COOKED_READ_DATA& cookedReadData, _In_ SHORT Index) /
|
||||
cookedReadData.BeforeDialogCursorPosition() = cookedReadData.ScreenInfo().GetTextBuffer().GetCursor().GetPosition();
|
||||
|
||||
// Move the cursor into the dialog so the user can type multiple characters for the command number
|
||||
const COORD CursorPosition = popup.GetCursorPosition();
|
||||
const auto CursorPosition = popup.GetCursorPosition();
|
||||
LOG_IF_FAILED(cookedReadData.ScreenInfo().SetCursorPosition(CursorPosition, TRUE));
|
||||
|
||||
// Transfer control to the handler routine
|
||||
@@ -453,7 +453,7 @@ void CommandLine::_processHistoryCycling(COOKED_READ_DATA& cookedReadData,
|
||||
FAIL_FAST_IF(!(cookedReadData.BufferStartPtr() == cookedReadData.BufferCurrentPtr()));
|
||||
if (cookedReadData.IsEchoInput())
|
||||
{
|
||||
short ScrollY = 0;
|
||||
til::CoordType ScrollY = 0;
|
||||
FAIL_FAST_IF_NTSTATUS_FAILED(WriteCharsLegacy(cookedReadData.ScreenInfo(),
|
||||
cookedReadData.BufferStartPtr(),
|
||||
cookedReadData.BufferCurrentPtr(),
|
||||
@@ -488,7 +488,7 @@ void CommandLine::_setPromptToOldestCommand(COOKED_READ_DATA& cookedReadData)
|
||||
FAIL_FAST_IF(!(cookedReadData.BufferStartPtr() == cookedReadData.BufferCurrentPtr()));
|
||||
if (cookedReadData.IsEchoInput())
|
||||
{
|
||||
short ScrollY = 0;
|
||||
til::CoordType ScrollY = 0;
|
||||
FAIL_FAST_IF_NTSTATUS_FAILED(WriteCharsLegacy(cookedReadData.ScreenInfo(),
|
||||
cookedReadData.BufferStartPtr(),
|
||||
cookedReadData.BufferCurrentPtr(),
|
||||
@@ -524,7 +524,7 @@ void CommandLine::_setPromptToNewestCommand(COOKED_READ_DATA& cookedReadData)
|
||||
FAIL_FAST_IF(!(cookedReadData.BufferStartPtr() == cookedReadData.BufferCurrentPtr()));
|
||||
if (cookedReadData.IsEchoInput())
|
||||
{
|
||||
short ScrollY = 0;
|
||||
til::CoordType ScrollY = 0;
|
||||
FAIL_FAST_IF_NTSTATUS_FAILED(WriteCharsLegacy(cookedReadData.ScreenInfo(),
|
||||
cookedReadData.BufferStartPtr(),
|
||||
cookedReadData.BufferCurrentPtr(),
|
||||
@@ -570,7 +570,7 @@ void CommandLine::DeletePromptAfterCursor(COOKED_READ_DATA& cookedReadData) noex
|
||||
// - cookedReadData - The cooked read data to operate on
|
||||
// Return Value:
|
||||
// - The new cursor position
|
||||
COORD CommandLine::_deletePromptBeforeCursor(COOKED_READ_DATA& cookedReadData) noexcept
|
||||
til::point CommandLine::_deletePromptBeforeCursor(COOKED_READ_DATA& cookedReadData) noexcept
|
||||
{
|
||||
DeleteCommandLine(cookedReadData, false);
|
||||
cookedReadData.BytesRead() -= cookedReadData.InsertionPoint() * sizeof(WCHAR);
|
||||
@@ -598,15 +598,15 @@ COORD CommandLine::_deletePromptBeforeCursor(COOKED_READ_DATA& cookedReadData) n
|
||||
// - cookedReadData - The cooked read data to operate on
|
||||
// Return Value:
|
||||
// - The new cursor position
|
||||
COORD CommandLine::_moveCursorToEndOfPrompt(COOKED_READ_DATA& cookedReadData) noexcept
|
||||
til::point CommandLine::_moveCursorToEndOfPrompt(COOKED_READ_DATA& cookedReadData) noexcept
|
||||
{
|
||||
cookedReadData.InsertionPoint() = cookedReadData.BytesRead() / sizeof(WCHAR);
|
||||
cookedReadData.SetBufferCurrentPtr(cookedReadData.BufferStartPtr() + cookedReadData.InsertionPoint());
|
||||
COORD cursorPosition{ 0, 0 };
|
||||
cursorPosition.X = (SHORT)(cookedReadData.OriginalCursorPosition().X + cookedReadData.VisibleCharCount());
|
||||
til::point cursorPosition;
|
||||
cursorPosition.X = base::checked_cast<til::CoordType>(cookedReadData.OriginalCursorPosition().x + cookedReadData.VisibleCharCount());
|
||||
cursorPosition.Y = cookedReadData.OriginalCursorPosition().Y;
|
||||
|
||||
const SHORT sScreenBufferSizeX = cookedReadData.ScreenInfo().GetBufferSize().Width();
|
||||
const auto sScreenBufferSizeX = cookedReadData.ScreenInfo().GetBufferSize().Width();
|
||||
if (CheckBisectProcessW(cookedReadData.ScreenInfo(),
|
||||
cookedReadData.BufferStartPtr(),
|
||||
cookedReadData.InsertionPoint(),
|
||||
@@ -625,7 +625,7 @@ COORD CommandLine::_moveCursorToEndOfPrompt(COOKED_READ_DATA& cookedReadData) no
|
||||
// - cookedReadData - The cooked read data to operate on
|
||||
// Return Value:
|
||||
// - The new cursor position
|
||||
COORD CommandLine::_moveCursorToStartOfPrompt(COOKED_READ_DATA& cookedReadData) noexcept
|
||||
til::point CommandLine::_moveCursorToStartOfPrompt(COOKED_READ_DATA& cookedReadData) noexcept
|
||||
{
|
||||
cookedReadData.InsertionPoint() = 0;
|
||||
cookedReadData.SetBufferCurrentPtr(cookedReadData.BufferStartPtr());
|
||||
@@ -638,10 +638,10 @@ COORD CommandLine::_moveCursorToStartOfPrompt(COOKED_READ_DATA& cookedReadData)
|
||||
// - cookedReadData - The cooked read data to operate on
|
||||
// Return Value:
|
||||
// - New cursor position
|
||||
COORD CommandLine::_moveCursorLeftByWord(COOKED_READ_DATA& cookedReadData) noexcept
|
||||
til::point CommandLine::_moveCursorLeftByWord(COOKED_READ_DATA& cookedReadData) noexcept
|
||||
{
|
||||
PWCHAR LastWord;
|
||||
COORD cursorPosition = cookedReadData.ScreenInfo().GetTextBuffer().GetCursor().GetPosition();
|
||||
auto cursorPosition = cookedReadData.ScreenInfo().GetTextBuffer().GetCursor().GetPosition();
|
||||
if (cookedReadData.BufferCurrentPtr() != cookedReadData.BufferStartPtr())
|
||||
{
|
||||
// A bit better word skipping.
|
||||
@@ -699,13 +699,13 @@ COORD CommandLine::_moveCursorLeftByWord(COOKED_READ_DATA& cookedReadData) noexc
|
||||
}
|
||||
cookedReadData.SetBufferCurrentPtr(LastWord);
|
||||
}
|
||||
cookedReadData.InsertionPoint() = (ULONG)(cookedReadData.BufferCurrentPtr() - cookedReadData.BufferStartPtr());
|
||||
cookedReadData.InsertionPoint() = cookedReadData.BufferCurrentPtr() - cookedReadData.BufferStartPtr();
|
||||
cursorPosition = cookedReadData.OriginalCursorPosition();
|
||||
cursorPosition.X = (SHORT)(cursorPosition.X +
|
||||
RetrieveTotalNumberOfSpaces(cookedReadData.OriginalCursorPosition().X,
|
||||
cookedReadData.BufferStartPtr(),
|
||||
cookedReadData.InsertionPoint()));
|
||||
const SHORT sScreenBufferSizeX = cookedReadData.ScreenInfo().GetBufferSize().Width();
|
||||
cursorPosition.X = cursorPosition.X +
|
||||
RetrieveTotalNumberOfSpaces(cookedReadData.OriginalCursorPosition().x,
|
||||
cookedReadData.BufferStartPtr(),
|
||||
cookedReadData.InsertionPoint());
|
||||
const auto sScreenBufferSizeX = cookedReadData.ScreenInfo().GetBufferSize().Width();
|
||||
if (CheckBisectStringW(cookedReadData.BufferStartPtr(),
|
||||
cookedReadData.InsertionPoint() + 1,
|
||||
sScreenBufferSizeX - cookedReadData.OriginalCursorPosition().X))
|
||||
@@ -722,20 +722,20 @@ COORD CommandLine::_moveCursorLeftByWord(COOKED_READ_DATA& cookedReadData) noexc
|
||||
// - cookedReadData - The cooked read data to operate on
|
||||
// Return Value:
|
||||
// - New cursor position
|
||||
COORD CommandLine::_moveCursorLeft(COOKED_READ_DATA& cookedReadData)
|
||||
til::point CommandLine::_moveCursorLeft(COOKED_READ_DATA& cookedReadData)
|
||||
{
|
||||
COORD cursorPosition = cookedReadData.ScreenInfo().GetTextBuffer().GetCursor().GetPosition();
|
||||
auto cursorPosition = cookedReadData.ScreenInfo().GetTextBuffer().GetCursor().GetPosition();
|
||||
if (cookedReadData.BufferCurrentPtr() != cookedReadData.BufferStartPtr())
|
||||
{
|
||||
cookedReadData.SetBufferCurrentPtr(cookedReadData.BufferCurrentPtr() - 1);
|
||||
cookedReadData.InsertionPoint()--;
|
||||
cursorPosition.X = cookedReadData.ScreenInfo().GetTextBuffer().GetCursor().GetPosition().X;
|
||||
cursorPosition.Y = cookedReadData.ScreenInfo().GetTextBuffer().GetCursor().GetPosition().Y;
|
||||
cursorPosition.X = (SHORT)(cursorPosition.X -
|
||||
RetrieveNumberOfSpaces(cookedReadData.OriginalCursorPosition().X,
|
||||
cookedReadData.BufferStartPtr(),
|
||||
cookedReadData.InsertionPoint()));
|
||||
const SHORT sScreenBufferSizeX = cookedReadData.ScreenInfo().GetBufferSize().Width();
|
||||
cursorPosition.X = cursorPosition.X -
|
||||
RetrieveNumberOfSpaces(cookedReadData.OriginalCursorPosition().x,
|
||||
cookedReadData.BufferStartPtr(),
|
||||
cookedReadData.InsertionPoint());
|
||||
const auto sScreenBufferSizeX = cookedReadData.ScreenInfo().GetBufferSize().Width();
|
||||
if (CheckBisectProcessW(cookedReadData.ScreenInfo(),
|
||||
cookedReadData.BufferStartPtr(),
|
||||
cookedReadData.InsertionPoint() + 2,
|
||||
@@ -758,9 +758,9 @@ COORD CommandLine::_moveCursorLeft(COOKED_READ_DATA& cookedReadData)
|
||||
// - cookedReadData - The cooked read data to operate on
|
||||
// Return Value:
|
||||
// - The new cursor position
|
||||
COORD CommandLine::_moveCursorRightByWord(COOKED_READ_DATA& cookedReadData) noexcept
|
||||
til::point CommandLine::_moveCursorRightByWord(COOKED_READ_DATA& cookedReadData) noexcept
|
||||
{
|
||||
COORD cursorPosition = cookedReadData.ScreenInfo().GetTextBuffer().GetCursor().GetPosition();
|
||||
auto cursorPosition = cookedReadData.ScreenInfo().GetTextBuffer().GetCursor().GetPosition();
|
||||
if (cookedReadData.InsertionPoint() < (cookedReadData.BytesRead() / sizeof(WCHAR)))
|
||||
{
|
||||
PWCHAR NextWord = cookedReadData.BufferCurrentPtr();
|
||||
@@ -808,13 +808,13 @@ COORD CommandLine::_moveCursorRightByWord(COOKED_READ_DATA& cookedReadData) noex
|
||||
}
|
||||
|
||||
cookedReadData.SetBufferCurrentPtr(NextWord);
|
||||
cookedReadData.InsertionPoint() = (ULONG)(cookedReadData.BufferCurrentPtr() - cookedReadData.BufferStartPtr());
|
||||
cookedReadData.InsertionPoint() = cookedReadData.BufferCurrentPtr() - cookedReadData.BufferStartPtr();
|
||||
cursorPosition = cookedReadData.OriginalCursorPosition();
|
||||
cursorPosition.X = (SHORT)(cursorPosition.X +
|
||||
RetrieveTotalNumberOfSpaces(cookedReadData.OriginalCursorPosition().X,
|
||||
cookedReadData.BufferStartPtr(),
|
||||
cookedReadData.InsertionPoint()));
|
||||
const SHORT sScreenBufferSizeX = cookedReadData.ScreenInfo().GetBufferSize().Width();
|
||||
cursorPosition.X = cursorPosition.X +
|
||||
RetrieveTotalNumberOfSpaces(cookedReadData.OriginalCursorPosition().x,
|
||||
cookedReadData.BufferStartPtr(),
|
||||
cookedReadData.InsertionPoint());
|
||||
const auto sScreenBufferSizeX = cookedReadData.ScreenInfo().GetBufferSize().Width();
|
||||
if (CheckBisectStringW(cookedReadData.BufferStartPtr(),
|
||||
cookedReadData.InsertionPoint() + 1,
|
||||
sScreenBufferSizeX - cookedReadData.OriginalCursorPosition().X))
|
||||
@@ -831,18 +831,18 @@ COORD CommandLine::_moveCursorRightByWord(COOKED_READ_DATA& cookedReadData) noex
|
||||
// - cookedReadData - The cooked read data to operate on
|
||||
// Return Value:
|
||||
// - The new cursor position
|
||||
COORD CommandLine::_moveCursorRight(COOKED_READ_DATA& cookedReadData) noexcept
|
||||
til::point CommandLine::_moveCursorRight(COOKED_READ_DATA& cookedReadData) noexcept
|
||||
{
|
||||
COORD cursorPosition = cookedReadData.ScreenInfo().GetTextBuffer().GetCursor().GetPosition();
|
||||
const SHORT sScreenBufferSizeX = cookedReadData.ScreenInfo().GetBufferSize().Width();
|
||||
auto cursorPosition = cookedReadData.ScreenInfo().GetTextBuffer().GetCursor().GetPosition();
|
||||
const auto sScreenBufferSizeX = cookedReadData.ScreenInfo().GetBufferSize().Width();
|
||||
// If not at the end of the line, move cursor position right.
|
||||
if (cookedReadData.InsertionPoint() < (cookedReadData.BytesRead() / sizeof(WCHAR)))
|
||||
{
|
||||
cursorPosition = cookedReadData.ScreenInfo().GetTextBuffer().GetCursor().GetPosition();
|
||||
cursorPosition.X = (SHORT)(cursorPosition.X +
|
||||
RetrieveNumberOfSpaces(cookedReadData.OriginalCursorPosition().X,
|
||||
cookedReadData.BufferStartPtr(),
|
||||
cookedReadData.InsertionPoint()));
|
||||
cursorPosition.X = cursorPosition.X +
|
||||
RetrieveNumberOfSpaces(cookedReadData.OriginalCursorPosition().x,
|
||||
cookedReadData.BufferStartPtr(),
|
||||
cookedReadData.InsertionPoint());
|
||||
if (CheckBisectProcessW(cookedReadData.ScreenInfo(),
|
||||
cookedReadData.BufferStartPtr(),
|
||||
cookedReadData.InsertionPoint() + 2,
|
||||
@@ -869,7 +869,7 @@ COORD CommandLine::_moveCursorRight(COOKED_READ_DATA& cookedReadData) noexcept
|
||||
cookedReadData.InsertionPoint()++;
|
||||
if (cookedReadData.IsEchoInput())
|
||||
{
|
||||
short ScrollY = 0;
|
||||
til::CoordType ScrollY = 0;
|
||||
size_t CharsToWrite = sizeof(WCHAR);
|
||||
FAIL_FAST_IF_NTSTATUS_FAILED(WriteCharsLegacy(cookedReadData.ScreenInfo(),
|
||||
cookedReadData.BufferStartPtr(),
|
||||
@@ -912,7 +912,7 @@ void CommandLine::_insertCtrlZ(COOKED_READ_DATA& cookedReadData) noexcept
|
||||
cookedReadData.InsertionPoint()++;
|
||||
if (cookedReadData.IsEchoInput())
|
||||
{
|
||||
short ScrollY = 0;
|
||||
til::CoordType ScrollY = 0;
|
||||
size_t CharsToWrite = sizeof(WCHAR);
|
||||
FAIL_FAST_IF_NTSTATUS_FAILED(WriteCharsLegacy(cookedReadData.ScreenInfo(),
|
||||
cookedReadData.BufferStartPtr(),
|
||||
@@ -963,7 +963,7 @@ void CommandLine::_fillPromptWithPreviousCommandFragment(COOKED_READ_DATA& cooke
|
||||
cookedReadData.BytesRead() = std::max(LastCommand.size() * sizeof(wchar_t), cookedReadData.BytesRead());
|
||||
if (cookedReadData.IsEchoInput())
|
||||
{
|
||||
short ScrollY = 0;
|
||||
til::CoordType ScrollY = 0;
|
||||
FAIL_FAST_IF_NTSTATUS_FAILED(WriteCharsLegacy(cookedReadData.ScreenInfo(),
|
||||
cookedReadData.BufferStartPtr(),
|
||||
cookedReadData.BufferCurrentPtr(),
|
||||
@@ -987,9 +987,9 @@ void CommandLine::_fillPromptWithPreviousCommandFragment(COOKED_READ_DATA& cooke
|
||||
// - cookedReadData - The cooked read data to operate on
|
||||
// Return Value:
|
||||
// - The new cursor position
|
||||
COORD CommandLine::_cycleMatchingCommandHistoryToPrompt(COOKED_READ_DATA& cookedReadData)
|
||||
til::point CommandLine::_cycleMatchingCommandHistoryToPrompt(COOKED_READ_DATA& cookedReadData)
|
||||
{
|
||||
COORD cursorPosition = cookedReadData.ScreenInfo().GetTextBuffer().GetCursor().GetPosition();
|
||||
auto cursorPosition = cookedReadData.ScreenInfo().GetTextBuffer().GetCursor().GetPosition();
|
||||
if (cookedReadData.HasHistory())
|
||||
{
|
||||
SHORT index;
|
||||
@@ -998,19 +998,17 @@ COORD CommandLine::_cycleMatchingCommandHistoryToPrompt(COOKED_READ_DATA& cooked
|
||||
index,
|
||||
CommandHistory::MatchOptions::None))
|
||||
{
|
||||
SHORT CurrentPos;
|
||||
|
||||
// save cursor position
|
||||
CurrentPos = (SHORT)cookedReadData.InsertionPoint();
|
||||
const auto CurrentPos = cookedReadData.InsertionPoint();
|
||||
|
||||
DeleteCommandLine(cookedReadData, true);
|
||||
THROW_IF_FAILED(cookedReadData.History().RetrieveNth((SHORT)index,
|
||||
THROW_IF_FAILED(cookedReadData.History().RetrieveNth(index,
|
||||
cookedReadData.SpanWholeBuffer(),
|
||||
cookedReadData.BytesRead()));
|
||||
FAIL_FAST_IF(!(cookedReadData.BufferStartPtr() == cookedReadData.BufferCurrentPtr()));
|
||||
if (cookedReadData.IsEchoInput())
|
||||
{
|
||||
short ScrollY = 0;
|
||||
til::CoordType ScrollY = 0;
|
||||
FAIL_FAST_IF_NTSTATUS_FAILED(WriteCharsLegacy(cookedReadData.ScreenInfo(),
|
||||
cookedReadData.BufferStartPtr(),
|
||||
cookedReadData.BufferCurrentPtr(),
|
||||
@@ -1039,10 +1037,10 @@ COORD CommandLine::_cycleMatchingCommandHistoryToPrompt(COOKED_READ_DATA& cooked
|
||||
// - cookedReadData - The cooked read data to operate on
|
||||
// Return Value:
|
||||
// - The new cursor position
|
||||
COORD CommandLine::DeleteFromRightOfCursor(COOKED_READ_DATA& cookedReadData) noexcept
|
||||
til::point CommandLine::DeleteFromRightOfCursor(COOKED_READ_DATA& cookedReadData) noexcept
|
||||
{
|
||||
// save cursor position
|
||||
COORD cursorPosition = cookedReadData.ScreenInfo().GetTextBuffer().GetCursor().GetPosition();
|
||||
auto cursorPosition = cookedReadData.ScreenInfo().GetTextBuffer().GetCursor().GetPosition();
|
||||
|
||||
if (!cookedReadData.AtEol())
|
||||
{
|
||||
@@ -1078,7 +1076,7 @@ COORD CommandLine::DeleteFromRightOfCursor(COOKED_READ_DATA& cookedReadData) noe
|
||||
}
|
||||
|
||||
// restore cursor position
|
||||
const SHORT sScreenBufferSizeX = cookedReadData.ScreenInfo().GetBufferSize().Width();
|
||||
const auto sScreenBufferSizeX = cookedReadData.ScreenInfo().GetBufferSize().Width();
|
||||
if (CheckBisectProcessW(cookedReadData.ScreenInfo(),
|
||||
cookedReadData.BufferStartPtr(),
|
||||
cookedReadData.InsertionPoint() + 1,
|
||||
@@ -1104,7 +1102,7 @@ COORD CommandLine::DeleteFromRightOfCursor(COOKED_READ_DATA& cookedReadData) noe
|
||||
const DWORD dwKeyState)
|
||||
{
|
||||
const CONSOLE_INFORMATION& gci = ServiceLocator::LocateGlobals().getConsoleInformation();
|
||||
COORD cursorPosition = cookedReadData.ScreenInfo().GetTextBuffer().GetCursor().GetPosition();
|
||||
auto cursorPosition = cookedReadData.ScreenInfo().GetTextBuffer().GetCursor().GetPosition();
|
||||
NTSTATUS Status;
|
||||
|
||||
const bool altPressed = WI_IsAnyFlagSet(dwKeyState, LEFT_ALT_PRESSED | RIGHT_ALT_PRESSED);
|
||||
|
||||
@@ -88,7 +88,7 @@ public:
|
||||
void EndAllPopups();
|
||||
|
||||
void DeletePromptAfterCursor(COOKED_READ_DATA& cookedReadData) noexcept;
|
||||
COORD DeleteFromRightOfCursor(COOKED_READ_DATA& cookedReadData) noexcept;
|
||||
til::point DeleteFromRightOfCursor(COOKED_READ_DATA& cookedReadData) noexcept;
|
||||
|
||||
protected:
|
||||
CommandLine();
|
||||
@@ -104,17 +104,17 @@ protected:
|
||||
void _processHistoryCycling(COOKED_READ_DATA& cookedReadData, const CommandHistory::SearchDirection searchDirection);
|
||||
void _setPromptToOldestCommand(COOKED_READ_DATA& cookedReadData);
|
||||
void _setPromptToNewestCommand(COOKED_READ_DATA& cookedReadData);
|
||||
COORD _deletePromptBeforeCursor(COOKED_READ_DATA& cookedReadData) noexcept;
|
||||
COORD _moveCursorToEndOfPrompt(COOKED_READ_DATA& cookedReadData) noexcept;
|
||||
COORD _moveCursorToStartOfPrompt(COOKED_READ_DATA& cookedReadData) noexcept;
|
||||
COORD _moveCursorLeftByWord(COOKED_READ_DATA& cookedReadData) noexcept;
|
||||
COORD _moveCursorLeft(COOKED_READ_DATA& cookedReadData);
|
||||
COORD _moveCursorRightByWord(COOKED_READ_DATA& cookedReadData) noexcept;
|
||||
COORD _moveCursorRight(COOKED_READ_DATA& cookedReadData) noexcept;
|
||||
til::point _deletePromptBeforeCursor(COOKED_READ_DATA& cookedReadData) noexcept;
|
||||
til::point _moveCursorToEndOfPrompt(COOKED_READ_DATA& cookedReadData) noexcept;
|
||||
til::point _moveCursorToStartOfPrompt(COOKED_READ_DATA& cookedReadData) noexcept;
|
||||
til::point _moveCursorLeftByWord(COOKED_READ_DATA& cookedReadData) noexcept;
|
||||
til::point _moveCursorLeft(COOKED_READ_DATA& cookedReadData);
|
||||
til::point _moveCursorRightByWord(COOKED_READ_DATA& cookedReadData) noexcept;
|
||||
til::point _moveCursorRight(COOKED_READ_DATA& cookedReadData) noexcept;
|
||||
void _insertCtrlZ(COOKED_READ_DATA& cookedReadData) noexcept;
|
||||
void _deleteCommandHistory(COOKED_READ_DATA& cookedReadData) noexcept;
|
||||
void _fillPromptWithPreviousCommandFragment(COOKED_READ_DATA& cookedReadData) noexcept;
|
||||
COORD _cycleMatchingCommandHistoryToPrompt(COOKED_READ_DATA& cookedReadData);
|
||||
til::point _cycleMatchingCommandHistoryToPrompt(COOKED_READ_DATA& cookedReadData);
|
||||
|
||||
#ifdef UNIT_TESTING
|
||||
friend class CommandLineTests;
|
||||
|
||||
@@ -15,15 +15,15 @@
|
||||
using namespace Microsoft::Console::Types;
|
||||
using Microsoft::Console::Interactivity::ServiceLocator;
|
||||
|
||||
ConversionAreaBufferInfo::ConversionAreaBufferInfo(const COORD coordBufferSize) :
|
||||
ConversionAreaBufferInfo::ConversionAreaBufferInfo(const til::size coordBufferSize) :
|
||||
coordCaBuffer(coordBufferSize),
|
||||
rcViewCaWindow({ 0 }),
|
||||
coordConView({ 0 })
|
||||
{
|
||||
}
|
||||
|
||||
ConversionAreaInfo::ConversionAreaInfo(const COORD bufferSize,
|
||||
const COORD windowSize,
|
||||
ConversionAreaInfo::ConversionAreaInfo(const til::size bufferSize,
|
||||
const til::size windowSize,
|
||||
const TextAttribute& fill,
|
||||
const TextAttribute& popupFill,
|
||||
const FontInfo fontInfo) :
|
||||
@@ -110,7 +110,7 @@ void ConversionAreaInfo::SetAttributes(const TextAttribute& attr)
|
||||
// - text - Text to insert into the conversion area buffer
|
||||
// - column - Column to start at (X position)
|
||||
void ConversionAreaInfo::WriteText(const std::vector<OutputCell>& text,
|
||||
const SHORT column)
|
||||
const til::CoordType column)
|
||||
{
|
||||
gsl::span<const OutputCell> view(text.data(), text.size());
|
||||
_screenBuffer->Write(view, { column, 0 });
|
||||
@@ -131,7 +131,7 @@ void ConversionAreaInfo::ClearArea() noexcept
|
||||
Paint();
|
||||
}
|
||||
|
||||
[[nodiscard]] HRESULT ConversionAreaInfo::Resize(const COORD newSize) noexcept
|
||||
[[nodiscard]] HRESULT ConversionAreaInfo::Resize(const til::size newSize) noexcept
|
||||
{
|
||||
// attempt to resize underlying buffers
|
||||
RETURN_IF_NTSTATUS_FAILED(_screenBuffer->ResizeScreenBuffer(newSize, FALSE));
|
||||
@@ -140,21 +140,18 @@ void ConversionAreaInfo::ClearArea() noexcept
|
||||
_caInfo.coordCaBuffer = newSize;
|
||||
|
||||
// restrict viewport to buffer size.
|
||||
const COORD restriction = { newSize.X - 1i16, newSize.Y - 1i16 };
|
||||
_caInfo.rcViewCaWindow.Left = std::min(_caInfo.rcViewCaWindow.Left, restriction.X);
|
||||
_caInfo.rcViewCaWindow.Right = std::min(_caInfo.rcViewCaWindow.Right, restriction.X);
|
||||
_caInfo.rcViewCaWindow.Top = std::min(_caInfo.rcViewCaWindow.Top, restriction.Y);
|
||||
_caInfo.rcViewCaWindow.Bottom = std::min(_caInfo.rcViewCaWindow.Bottom, restriction.Y);
|
||||
const til::size restriction{ newSize.width - 1, newSize.height - 1 };
|
||||
_caInfo.rcViewCaWindow.Left = std::min(_caInfo.rcViewCaWindow.Left, restriction.width);
|
||||
_caInfo.rcViewCaWindow.Right = std::min(_caInfo.rcViewCaWindow.Right, restriction.width);
|
||||
_caInfo.rcViewCaWindow.Top = std::min(_caInfo.rcViewCaWindow.Top, restriction.height);
|
||||
_caInfo.rcViewCaWindow.Bottom = std::min(_caInfo.rcViewCaWindow.Bottom, restriction.height);
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
void ConversionAreaInfo::SetWindowInfo(const SMALL_RECT view) noexcept
|
||||
void ConversionAreaInfo::SetWindowInfo(const til::inclusive_rect view) noexcept
|
||||
{
|
||||
if (view.Left != _caInfo.rcViewCaWindow.Left ||
|
||||
view.Top != _caInfo.rcViewCaWindow.Top ||
|
||||
view.Right != _caInfo.rcViewCaWindow.Right ||
|
||||
view.Bottom != _caInfo.rcViewCaWindow.Bottom)
|
||||
if (view != _caInfo.rcViewCaWindow)
|
||||
{
|
||||
if (!IsHidden())
|
||||
{
|
||||
@@ -172,7 +169,7 @@ void ConversionAreaInfo::SetWindowInfo(const SMALL_RECT view) noexcept
|
||||
}
|
||||
}
|
||||
|
||||
void ConversionAreaInfo::SetViewPos(const COORD pos) noexcept
|
||||
void ConversionAreaInfo::SetViewPos(const til::point pos) noexcept
|
||||
{
|
||||
if (IsHidden())
|
||||
{
|
||||
@@ -182,7 +179,7 @@ void ConversionAreaInfo::SetViewPos(const COORD pos) noexcept
|
||||
{
|
||||
CONSOLE_INFORMATION& gci = ServiceLocator::LocateGlobals().getConsoleInformation();
|
||||
|
||||
SMALL_RECT OldRegion = _caInfo.rcViewCaWindow;
|
||||
auto OldRegion = _caInfo.rcViewCaWindow;
|
||||
OldRegion.Left += _caInfo.coordConView.X;
|
||||
OldRegion.Right += _caInfo.coordConView.X;
|
||||
OldRegion.Top += _caInfo.coordConView.Y;
|
||||
@@ -191,7 +188,7 @@ void ConversionAreaInfo::SetViewPos(const COORD pos) noexcept
|
||||
|
||||
_caInfo.coordConView = pos;
|
||||
|
||||
SMALL_RECT NewRegion = _caInfo.rcViewCaWindow;
|
||||
auto NewRegion = _caInfo.rcViewCaWindow;
|
||||
NewRegion.Left += _caInfo.coordConView.X;
|
||||
NewRegion.Right += _caInfo.coordConView.X;
|
||||
NewRegion.Top += _caInfo.coordConView.Y;
|
||||
@@ -206,7 +203,7 @@ void ConversionAreaInfo::Paint() const noexcept
|
||||
SCREEN_INFORMATION& ScreenInfo = gci.GetActiveOutputBuffer();
|
||||
const auto viewport = ScreenInfo.GetViewport();
|
||||
|
||||
SMALL_RECT WriteRegion;
|
||||
til::inclusive_rect WriteRegion;
|
||||
WriteRegion.Left = viewport.Left() + _caInfo.coordConView.X + _caInfo.rcViewCaWindow.Left;
|
||||
WriteRegion.Right = WriteRegion.Left + (_caInfo.rcViewCaWindow.Right - _caInfo.rcViewCaWindow.Left);
|
||||
WriteRegion.Top = viewport.Top() + _caInfo.coordConView.Y + _caInfo.rcViewCaWindow.Top;
|
||||
|
||||
@@ -30,18 +30,18 @@ class TextBuffer;
|
||||
class ConversionAreaBufferInfo final
|
||||
{
|
||||
public:
|
||||
COORD coordCaBuffer;
|
||||
SMALL_RECT rcViewCaWindow;
|
||||
COORD coordConView;
|
||||
til::size coordCaBuffer;
|
||||
til::inclusive_rect rcViewCaWindow;
|
||||
til::point coordConView;
|
||||
|
||||
explicit ConversionAreaBufferInfo(const COORD coordBufferSize);
|
||||
explicit ConversionAreaBufferInfo(const til::size coordBufferSize);
|
||||
};
|
||||
|
||||
class ConversionAreaInfo final
|
||||
{
|
||||
public:
|
||||
ConversionAreaInfo(const COORD bufferSize,
|
||||
const COORD windowSize,
|
||||
ConversionAreaInfo(const til::size bufferSize,
|
||||
const til::size windowSize,
|
||||
const TextAttribute& fill,
|
||||
const TextAttribute& popupFill,
|
||||
const FontInfo fontInfo);
|
||||
@@ -55,13 +55,13 @@ public:
|
||||
void SetHidden(const bool fIsHidden) noexcept;
|
||||
void ClearArea() noexcept;
|
||||
|
||||
[[nodiscard]] HRESULT Resize(const COORD newSize) noexcept;
|
||||
[[nodiscard]] HRESULT Resize(const til::size newSize) noexcept;
|
||||
|
||||
void SetViewPos(const COORD pos) noexcept;
|
||||
void SetWindowInfo(const SMALL_RECT view) noexcept;
|
||||
void SetViewPos(const til::point pos) noexcept;
|
||||
void SetWindowInfo(const til::inclusive_rect view) noexcept;
|
||||
void Paint() const noexcept;
|
||||
|
||||
void WriteText(const std::vector<OutputCell>& text, const SHORT column);
|
||||
void WriteText(const std::vector<OutputCell>& text, const til::CoordType column);
|
||||
void SetAttributes(const TextAttribute& attr);
|
||||
|
||||
const TextBuffer& GetTextBuffer() const noexcept;
|
||||
|
||||
@@ -119,7 +119,7 @@ void ConsoleImeInfo::ClearAllAreas()
|
||||
// - newSize - New size for conversion areas
|
||||
// Return Value:
|
||||
// - S_OK or appropriate failure HRESULT.
|
||||
[[nodiscard]] HRESULT ConsoleImeInfo::ResizeAllAreas(const COORD newSize)
|
||||
[[nodiscard]] HRESULT ConsoleImeInfo::ResizeAllAreas(const til::size newSize)
|
||||
{
|
||||
for (auto& area : ConvAreaCompStr)
|
||||
{
|
||||
@@ -145,10 +145,10 @@ void ConsoleImeInfo::ClearAllAreas()
|
||||
{
|
||||
const CONSOLE_INFORMATION& gci = ServiceLocator::LocateGlobals().getConsoleInformation();
|
||||
|
||||
COORD bufferSize = gci.GetActiveOutputBuffer().GetBufferSize().Dimensions();
|
||||
bufferSize.Y = 1;
|
||||
auto bufferSize = gci.GetActiveOutputBuffer().GetBufferSize().Dimensions();
|
||||
bufferSize.height = 1;
|
||||
|
||||
const COORD windowSize = gci.GetActiveOutputBuffer().GetViewport().Dimensions();
|
||||
const auto windowSize = gci.GetActiveOutputBuffer().GetViewport().Dimensions();
|
||||
|
||||
const TextAttribute fill = gci.GetActiveOutputBuffer().GetAttributes();
|
||||
|
||||
@@ -310,7 +310,7 @@ std::vector<OutputCell> ConsoleImeInfo::s_ConvertToCells(const std::wstring_view
|
||||
// If the viewport is deemed too small, we'll skip past it and advance begin past the entire full-width character.
|
||||
std::vector<OutputCell>::const_iterator ConsoleImeInfo::_WriteConversionArea(const std::vector<OutputCell>::const_iterator begin,
|
||||
const std::vector<OutputCell>::const_iterator end,
|
||||
COORD& pos,
|
||||
til::point& pos,
|
||||
const Microsoft::Console::Types::Viewport view,
|
||||
SCREEN_INFORMATION& screenInfo)
|
||||
{
|
||||
@@ -367,7 +367,7 @@ std::vector<OutputCell>::const_iterator ConsoleImeInfo::_WriteConversionArea(con
|
||||
|
||||
// Set the viewport and positioning parameters for the conversion area to describe to the renderer
|
||||
// the appropriate location to overlay this conversion area on top of the main screen buffer inside the viewport.
|
||||
const SMALL_RECT region{ insertionPos.X, 0, gsl::narrow<SHORT>(insertionPos.X + lineVec.size() - 1), 0 };
|
||||
const til::inclusive_rect region{ insertionPos.X, 0, gsl::narrow<til::CoordType>(insertionPos.X + lineVec.size() - 1), 0 };
|
||||
area.SetWindowInfo(region);
|
||||
area.SetViewPos({ 0 - view.Left(), insertionPos.Y - view.Top() });
|
||||
|
||||
@@ -378,7 +378,7 @@ std::vector<OutputCell>::const_iterator ConsoleImeInfo::_WriteConversionArea(con
|
||||
// Notify accessibility that we have updated the text in this display region within the viewport.
|
||||
if (screenInfo.HasAccessibilityEventing())
|
||||
{
|
||||
screenInfo.NotifyAccessibilityEventing(insertionPos.X, insertionPos.Y, gsl::narrow<SHORT>(insertionPos.X + lineVec.size() - 1), insertionPos.Y);
|
||||
screenInfo.NotifyAccessibilityEventing(region.Left, insertionPos.Y, region.Right, insertionPos.Y);
|
||||
}
|
||||
|
||||
// Hand back the iterator representing the end of what we used to be fed into the beginning of the next call.
|
||||
|
||||
@@ -45,7 +45,7 @@ public:
|
||||
void RefreshAreaAttributes();
|
||||
void ClearAllAreas();
|
||||
|
||||
[[nodiscard]] HRESULT ResizeAllAreas(const COORD newSize);
|
||||
[[nodiscard]] HRESULT ResizeAllAreas(const til::size newSize);
|
||||
|
||||
void WriteCompMessage(const std::wstring_view text,
|
||||
const gsl::span<const BYTE> attributes,
|
||||
@@ -79,7 +79,7 @@ private:
|
||||
|
||||
std::vector<OutputCell>::const_iterator _WriteConversionArea(const std::vector<OutputCell>::const_iterator begin,
|
||||
const std::vector<OutputCell>::const_iterator end,
|
||||
COORD& pos,
|
||||
til::point& pos,
|
||||
const Microsoft::Console::Types::Viewport view,
|
||||
SCREEN_INFORMATION& screenInfo);
|
||||
|
||||
|
||||
@@ -27,17 +27,6 @@ Revision History:
|
||||
#define NT_TESTNULL(var) (((var) == nullptr) ? STATUS_NO_MEMORY : STATUS_SUCCESS)
|
||||
#define NT_TESTNULL_GLE(var) (((var) == nullptr) ? NTSTATUS_FROM_WIN32(GetLastError()) : STATUS_SUCCESS);
|
||||
|
||||
/*
|
||||
* Used to store some console attributes for the console. This is a means
|
||||
* to cache the color in the extra-window-bytes, so USER/KERNEL can get
|
||||
* at it for hungapp drawing. The window-offsets are defined in NTUSER\INC.
|
||||
*
|
||||
* The other macros are just convenient means for setting the other window
|
||||
* bytes.
|
||||
*/
|
||||
|
||||
#define PACKCOORD(pt) (MAKELONG(((pt).X), ((pt).Y)))
|
||||
|
||||
typedef struct _CONSOLE_API_CONNECTINFO
|
||||
{
|
||||
Settings ConsoleInfo;
|
||||
|
||||
@@ -26,4 +26,4 @@ void WriteConvRegionToScreen(const SCREEN_INFORMATION& ScreenInfo,
|
||||
const Microsoft::Console::Types::Viewport& convRegion);
|
||||
|
||||
[[nodiscard]] HRESULT ConsoleImeResizeCompStrView();
|
||||
[[nodiscard]] HRESULT ConsoleImeResizeCompStrScreenBuffer(const COORD coordNewScreenSize);
|
||||
[[nodiscard]] HRESULT ConsoleImeResizeCompStrScreenBuffer(const til::size coordNewScreenSize);
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
using namespace Microsoft::Console::Types;
|
||||
using Microsoft::Console::Interactivity::ServiceLocator;
|
||||
|
||||
bool IsValidSmallRect(_In_ PSMALL_RECT const Rect)
|
||||
bool IsValidRect(_In_ til::rect* const Rect)
|
||||
{
|
||||
return (Rect->Right >= Rect->Left && Rect->Bottom >= Rect->Top);
|
||||
}
|
||||
@@ -38,26 +38,26 @@ void WriteConvRegionToScreen(const SCREEN_INFORMATION& ScreenInfo,
|
||||
const auto areaInfo = ConvAreaInfo.GetAreaBufferInfo();
|
||||
|
||||
// Do clipping region
|
||||
SMALL_RECT Region;
|
||||
til::rect Region;
|
||||
Region.Left = currentViewport.Left + areaInfo.rcViewCaWindow.Left + areaInfo.coordConView.X;
|
||||
Region.Right = Region.Left + (areaInfo.rcViewCaWindow.Right - areaInfo.rcViewCaWindow.Left);
|
||||
Region.Top = currentViewport.Top + areaInfo.rcViewCaWindow.Top + areaInfo.coordConView.Y;
|
||||
Region.Bottom = Region.Top + (areaInfo.rcViewCaWindow.Bottom - areaInfo.rcViewCaWindow.Top);
|
||||
|
||||
SMALL_RECT ClippedRegion;
|
||||
til::rect ClippedRegion;
|
||||
ClippedRegion.Left = std::max(Region.Left, currentViewport.Left);
|
||||
ClippedRegion.Top = std::max(Region.Top, currentViewport.Top);
|
||||
ClippedRegion.Right = std::min(Region.Right, currentViewport.Right);
|
||||
ClippedRegion.Bottom = std::min(Region.Bottom, currentViewport.Bottom);
|
||||
|
||||
if (IsValidSmallRect(&ClippedRegion))
|
||||
if (IsValidRect(&ClippedRegion))
|
||||
{
|
||||
Region = ClippedRegion;
|
||||
ClippedRegion.Left = std::max(Region.Left, convRegion.Left());
|
||||
ClippedRegion.Top = std::max(Region.Top, convRegion.Top());
|
||||
ClippedRegion.Right = std::min(Region.Right, convRegion.RightInclusive());
|
||||
ClippedRegion.Bottom = std::min(Region.Bottom, convRegion.BottomInclusive());
|
||||
if (IsValidSmallRect(&ClippedRegion))
|
||||
if (IsValidRect(&ClippedRegion))
|
||||
{
|
||||
// if we have a renderer, we need to update.
|
||||
// we've already confirmed (above with an early return) that we're on conversion areas that are a part of the active (visible/rendered) screen
|
||||
@@ -65,7 +65,7 @@ void WriteConvRegionToScreen(const SCREEN_INFORMATION& ScreenInfo,
|
||||
if (ServiceLocator::LocateGlobals().pRender != nullptr)
|
||||
{
|
||||
// convert inclusive rectangle to exclusive rectangle
|
||||
SMALL_RECT srExclusive = ClippedRegion;
|
||||
auto srExclusive = ClippedRegion;
|
||||
srExclusive.Right++;
|
||||
srExclusive.Bottom++;
|
||||
|
||||
@@ -90,7 +90,7 @@ void WriteConvRegionToScreen(const SCREEN_INFORMATION& ScreenInfo,
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
[[nodiscard]] HRESULT ConsoleImeResizeCompStrScreenBuffer(const COORD coordNewScreenSize)
|
||||
[[nodiscard]] HRESULT ConsoleImeResizeCompStrScreenBuffer(const til::size coordNewScreenSize)
|
||||
{
|
||||
CONSOLE_INFORMATION& gci = ServiceLocator::LocateGlobals().getConsoleInformation();
|
||||
ConsoleImeInfo* const pIme = &gci.ConsoleIme;
|
||||
|
||||
@@ -581,9 +581,9 @@ void EventsToUnicode(_Inout_ std::deque<std::unique_ptr<IInputEvent>>& inEvents,
|
||||
auto tempIter = tempBuffer.cbegin();
|
||||
auto outIter = buffer.begin();
|
||||
|
||||
for (int i = 0; i < size.Y; i++)
|
||||
for (int i = 0; i < size.height; i++)
|
||||
{
|
||||
for (int j = 0; j < size.X; j++)
|
||||
for (int j = 0; j < size.width; j++)
|
||||
{
|
||||
// Any time we see the lead flag, we presume there will be a trailing one following it.
|
||||
// Giving us two bytes of space (one per cell in the ascii part of the character union)
|
||||
@@ -591,7 +591,7 @@ void EventsToUnicode(_Inout_ std::deque<std::unique_ptr<IInputEvent>>& inEvents,
|
||||
if (WI_IsFlagSet(tempIter->Attributes, COMMON_LVB_LEADING_BYTE))
|
||||
{
|
||||
// As long as we're not looking at the exact last column of the buffer...
|
||||
if (j < size.X - 1)
|
||||
if (j < size.width - 1)
|
||||
{
|
||||
// Walk forward one because we're about to consume two cells.
|
||||
j++;
|
||||
@@ -659,9 +659,9 @@ void EventsToUnicode(_Inout_ std::deque<std::unique_ptr<IInputEvent>>& inEvents,
|
||||
const auto size = rectangle.Dimensions();
|
||||
auto outIter = buffer.begin();
|
||||
|
||||
for (int i = 0; i < size.Y; i++)
|
||||
for (int i = 0; i < size.height; i++)
|
||||
{
|
||||
for (int j = 0; j < size.X; j++)
|
||||
for (int j = 0; j < size.width; j++)
|
||||
{
|
||||
// Clear lead/trailing flags. We'll determine it for ourselves versus the given codepage.
|
||||
WI_ClearAllFlags(outIter->Attributes, COMMON_LVB_SBCSDBCS);
|
||||
@@ -670,7 +670,7 @@ void EventsToUnicode(_Inout_ std::deque<std::unique_ptr<IInputEvent>>& inEvents,
|
||||
if (IsDBCSLeadByteConsole(outIter->Char.AsciiChar, &gci.OutputCPInfo))
|
||||
{
|
||||
// If we're not on the last column, we have two cells to use.
|
||||
if (j < size.X - 1)
|
||||
if (j < size.width - 1)
|
||||
{
|
||||
// Mark we're consuming two cells.
|
||||
j++;
|
||||
@@ -728,9 +728,9 @@ void EventsToUnicode(_Inout_ std::deque<std::unique_ptr<IInputEvent>>& inEvents,
|
||||
const auto size = rectangle.Dimensions();
|
||||
auto bufferIter = buffer.begin();
|
||||
|
||||
for (SHORT i = 0; i < size.Y; i++)
|
||||
for (auto i = 0; i < size.height; i++)
|
||||
{
|
||||
for (SHORT j = 0; j < size.X; j++)
|
||||
for (auto j = 0; j < size.width; j++)
|
||||
{
|
||||
// Prepare a candidate charinfo on the output side copying the colors but not the lead/trail information.
|
||||
CHAR_INFO candidate;
|
||||
@@ -741,7 +741,7 @@ void EventsToUnicode(_Inout_ std::deque<std::unique_ptr<IInputEvent>>& inEvents,
|
||||
if (IsGlyphFullWidth(bufferIter->Char.UnicodeChar))
|
||||
{
|
||||
// If we're not on the final cell of the row...
|
||||
if (j < size.X - 1)
|
||||
if (j < size.width - 1)
|
||||
{
|
||||
// Mark that we're consuming two cells.
|
||||
j++;
|
||||
@@ -793,31 +793,30 @@ void EventsToUnicode(_Inout_ std::deque<std::unique_ptr<IInputEvent>>& inEvents,
|
||||
const auto targetSize = requestRectangle.Dimensions();
|
||||
|
||||
// If either dimension of the request is too small, return an empty rectangle as read and exit early.
|
||||
if (targetSize.X <= 0 || targetSize.Y <= 0)
|
||||
if (targetSize.width <= 0 || targetSize.height <= 0)
|
||||
{
|
||||
readRectangle = Viewport::FromDimensions(requestRectangle.Origin(), { 0, 0 });
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
// The buffer given should be big enough to hold the dimensions of the request.
|
||||
size_t targetArea;
|
||||
RETURN_IF_FAILED(SizeTMult(targetSize.X, targetSize.Y, &targetArea));
|
||||
const auto targetArea = targetSize.area<size_t>();
|
||||
RETURN_HR_IF(E_INVALIDARG, targetArea < targetBuffer.size());
|
||||
|
||||
// Clip the request rectangle to the size of the storage buffer
|
||||
SMALL_RECT clip = requestRectangle.ToExclusive();
|
||||
clip.Right = std::min(clip.Right, storageSize.X);
|
||||
clip.Bottom = std::min(clip.Bottom, storageSize.Y);
|
||||
auto clip = requestRectangle.ToExclusive();
|
||||
clip.Right = std::min(clip.Right, storageSize.width);
|
||||
clip.Bottom = std::min(clip.Bottom, storageSize.height);
|
||||
|
||||
// Find the target point (where to write the user's buffer)
|
||||
// It will either be 0,0 or offset into the buffer by the inverse of the negative values.
|
||||
COORD targetPoint;
|
||||
til::point targetPoint;
|
||||
targetPoint.X = clip.Left < 0 ? -clip.Left : 0;
|
||||
targetPoint.Y = clip.Top < 0 ? -clip.Top : 0;
|
||||
|
||||
// The clipped rect must be inside the buffer size, so it has a minimum value of 0. (max of itself and 0)
|
||||
clip.Left = std::max(clip.Left, 0i16);
|
||||
clip.Top = std::max(clip.Top, 0i16);
|
||||
clip.Left = std::max(clip.Left, 0);
|
||||
clip.Top = std::max(clip.Top, 0);
|
||||
|
||||
// The final "request rectangle" or the area inside the buffer we want to read, is the clipped dimensions.
|
||||
const auto clippedRequestRectangle = Viewport::FromExclusive(clip);
|
||||
@@ -828,7 +827,7 @@ void EventsToUnicode(_Inout_ std::deque<std::unique_ptr<IInputEvent>>& inEvents,
|
||||
// Get an iterator to the beginning of the return buffer
|
||||
// We might have to seek this forward or skip around if we clipped the request.
|
||||
auto targetIter = targetBuffer.begin();
|
||||
COORD targetPos = { 0 };
|
||||
til::point targetPos;
|
||||
const auto targetLimit = Viewport::FromDimensions(targetPoint, clippedRequestRectangle.Dimensions());
|
||||
|
||||
// Get an iterator to the beginning of the request inside the screen buffer
|
||||
@@ -855,7 +854,7 @@ void EventsToUnicode(_Inout_ std::deque<std::unique_ptr<IInputEvent>>& inEvents,
|
||||
|
||||
// Increment the target
|
||||
targetPos.X++;
|
||||
if (targetPos.X >= targetSize.X)
|
||||
if (targetPos.X >= targetSize.width)
|
||||
{
|
||||
targetPos.X = 0;
|
||||
targetPos.Y++;
|
||||
@@ -930,7 +929,7 @@ void EventsToUnicode(_Inout_ std::deque<std::unique_ptr<IInputEvent>>& inEvents,
|
||||
const auto sourceSize = requestRectangle.Dimensions();
|
||||
|
||||
// If either dimension of the request is too small, return an empty rectangle as the read and exit early.
|
||||
if (sourceSize.X <= 0 || sourceSize.Y <= 0)
|
||||
if (sourceSize.width <= 0 || sourceSize.height <= 0)
|
||||
{
|
||||
writtenRectangle = Viewport::FromDimensions(requestRectangle.Origin(), { 0, 0 });
|
||||
return S_OK;
|
||||
@@ -938,23 +937,23 @@ void EventsToUnicode(_Inout_ std::deque<std::unique_ptr<IInputEvent>>& inEvents,
|
||||
|
||||
// If the top and left of the destination we're trying to write it outside the buffer,
|
||||
// give the original request rectangle back and exit early OK.
|
||||
if (requestRectangle.Left() >= storageSize.X || requestRectangle.Top() >= storageSize.Y)
|
||||
if (requestRectangle.Left() >= storageSize.width || requestRectangle.Top() >= storageSize.height)
|
||||
{
|
||||
writtenRectangle = requestRectangle;
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
// Do clipping according to the legacy patterns.
|
||||
SMALL_RECT writeRegion = requestRectangle.ToInclusive();
|
||||
SMALL_RECT sourceRect;
|
||||
if (writeRegion.Right > storageSize.X - 1)
|
||||
auto writeRegion = requestRectangle.ToInclusive();
|
||||
til::inclusive_rect sourceRect;
|
||||
if (writeRegion.Right > storageSize.width - 1)
|
||||
{
|
||||
writeRegion.Right = storageSize.X - 1;
|
||||
writeRegion.Right = storageSize.width - 1;
|
||||
}
|
||||
sourceRect.Right = writeRegion.Right - writeRegion.Left;
|
||||
if (writeRegion.Bottom > storageSize.Y - 1)
|
||||
if (writeRegion.Bottom > storageSize.height - 1)
|
||||
{
|
||||
writeRegion.Bottom = storageSize.Y - 1;
|
||||
writeRegion.Bottom = storageSize.height - 1;
|
||||
}
|
||||
sourceRect.Bottom = writeRegion.Bottom - writeRegion.Top;
|
||||
|
||||
@@ -1071,7 +1070,7 @@ void EventsToUnicode(_Inout_ std::deque<std::unique_ptr<IInputEvent>>& inEvents,
|
||||
}
|
||||
|
||||
[[nodiscard]] HRESULT ApiRoutines::ReadConsoleOutputAttributeImpl(const SCREEN_INFORMATION& context,
|
||||
const COORD origin,
|
||||
const til::point origin,
|
||||
gsl::span<WORD> buffer,
|
||||
size_t& written) noexcept
|
||||
{
|
||||
@@ -1092,7 +1091,7 @@ void EventsToUnicode(_Inout_ std::deque<std::unique_ptr<IInputEvent>>& inEvents,
|
||||
}
|
||||
|
||||
[[nodiscard]] HRESULT ApiRoutines::ReadConsoleOutputCharacterAImpl(const SCREEN_INFORMATION& context,
|
||||
const COORD origin,
|
||||
const til::point origin,
|
||||
gsl::span<char> buffer,
|
||||
size_t& written) noexcept
|
||||
{
|
||||
@@ -1121,7 +1120,7 @@ void EventsToUnicode(_Inout_ std::deque<std::unique_ptr<IInputEvent>>& inEvents,
|
||||
}
|
||||
|
||||
[[nodiscard]] HRESULT ApiRoutines::ReadConsoleOutputCharacterWImpl(const SCREEN_INFORMATION& context,
|
||||
const COORD origin,
|
||||
const til::point origin,
|
||||
gsl::span<wchar_t> buffer,
|
||||
size_t& written) noexcept
|
||||
{
|
||||
@@ -1179,7 +1178,7 @@ void EventsToUnicode(_Inout_ std::deque<std::unique_ptr<IInputEvent>>& inEvents,
|
||||
const SCREEN_INFORMATION& siExisting = gci.GetActiveOutputBuffer();
|
||||
|
||||
// Create new screen buffer.
|
||||
COORD WindowSize = siExisting.GetViewport().Dimensions();
|
||||
auto WindowSize = siExisting.GetViewport().Dimensions();
|
||||
const FontInfo& existingFont = siExisting.GetCurrentFont();
|
||||
SCREEN_INFORMATION* ScreenInfo = nullptr;
|
||||
NTSTATUS Status = SCREEN_INFORMATION::CreateInstance(WindowSize,
|
||||
|
||||
@@ -132,7 +132,7 @@ extern "C" __declspec(dllexport) int LLVMFuzzerTestOneInput(const uint8_t* data,
|
||||
auto& gci = Microsoft::Console::Interactivity::ServiceLocator::LocateGlobals().getConsoleInformation();
|
||||
|
||||
const auto u16String{ til::u8u16(std::string_view{ reinterpret_cast<const char*>(data), size }) };
|
||||
SHORT scrollY{};
|
||||
til::CoordType scrollY{};
|
||||
size_t sizeInBytes{ u16String.size() * 2 };
|
||||
gci.LockConsole();
|
||||
auto u = wil::scope_exit([&]() { gci.UnlockConsole(); });
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user