Skip to content

Commit

Permalink
Tie everything together.
Browse files Browse the repository at this point in the history
  • Loading branch information
j4james committed Jun 11, 2024
1 parent bbcc945 commit d1e5b6b
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 8 deletions.
1 change: 1 addition & 0 deletions src/terminal/adapter/DispatchTypes.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -535,6 +535,7 @@ namespace Microsoft::Console::VirtualTerminal::DispatchTypes
DECNKM_NumericKeypadMode = DECPrivateMode(66),
DECBKM_BackarrowKeyMode = DECPrivateMode(67),
DECLRMM_LeftRightMarginMode = DECPrivateMode(69),
DECSDM_SixelDisplayMode = DECPrivateMode(80),
DECECM_EraseColorMode = DECPrivateMode(117),
VT200_MOUSE_MODE = DECPrivateMode(1000),
BUTTON_EVENT_MOUSE_MODE = DECPrivateMode(1002),
Expand Down
4 changes: 2 additions & 2 deletions src/terminal/adapter/PageManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -175,11 +175,11 @@ void PageManager::MoveTo(const til::CoordType pageNumber, const bool makeVisible
auto& saveBuffer = _getBuffer(_visiblePageNumber, pageSize);
for (auto i = 0; i < pageSize.height; i++)
{
saveBuffer.GetMutableRowByOffset(i).CopyFrom(visibleBuffer.GetRowByOffset(visibleTop + i));
visibleBuffer.CopyRow(visibleTop + i, i, saveBuffer);
}
for (auto i = 0; i < pageSize.height; i++)
{
visibleBuffer.GetMutableRowByOffset(visibleTop + i).CopyFrom(newBuffer.GetRowByOffset(i));
newBuffer.CopyRow(i, visibleTop + i, visibleBuffer);
}
_visiblePageNumber = newPageNumber;
redrawRequired = true;
Expand Down
45 changes: 40 additions & 5 deletions src/terminal/adapter/adaptDispatch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include "precomp.h"

#include "adaptDispatch.hpp"
#include "SixelParser.hpp"
#include "../../renderer/base/renderer.hpp"
#include "../../types/inc/Viewport.hpp"
#include "../../types/inc/utils.hpp"
Expand Down Expand Up @@ -625,6 +626,8 @@ void AdaptDispatch::_ScrollRectVertically(const Page& page, const til::rect& scr
textBuffer.WriteLine(OutputCellIterator({ &current, 1 }), dstPos);
srcView.WalkInBounds(srcPos, walkDirection);
} while (dstView.WalkInBounds(dstPos, walkDirection));
// Copy any image content in the affected area.
ImageSlice::CopyBlock(textBuffer, srcView.ToExclusive(), textBuffer, dstView.ToExclusive());
}
}

Expand Down Expand Up @@ -675,6 +678,8 @@ void AdaptDispatch::_ScrollRectHorizontally(const Page& page, const til::rect& s
next = OutputCell(*textBuffer.GetCellDataAt(sourcePos));
textBuffer.WriteLine(OutputCellIterator({ &current, 1 }), targetPos);
} while (target.WalkInBounds(targetPos, walkDirection));
// Copy any image content in the affected area.
ImageSlice::CopyBlock(textBuffer, source.ToExclusive(), textBuffer, target.ToExclusive());
}

// Columns revealed by the scroll are filled with standard erase attributes.
Expand Down Expand Up @@ -893,6 +898,8 @@ void AdaptDispatch::_SelectiveEraseRect(const Page& page, const til::rect& erase
{
// The text is cleared but the attributes are left as is.
rowBuffer.ClearCell(col);
// Any image content also needs to be erased.
ImageSlice::EraseCells(rowBuffer, col, col + 1);
page.Buffer().TriggerRedraw(Viewport::FromCoord({ col, row }));
}
}
Expand Down Expand Up @@ -1251,6 +1258,8 @@ bool AdaptDispatch::CopyRectangularArea(const VTInt top, const VTInt left, const
dst.Buffer().WriteLine(OutputCellIterator({ &current, 1 }), dstPos);
}
} while (dstView.WalkInBounds(dstPos, walkDirection));
// Copy any image content in the affected area.
ImageSlice::CopyBlock(src.Buffer(), srcView.ToExclusive(), dst.Buffer(), dstView.ToExclusive());
_api.NotifyAccessibilityChange(dstRect);
}

Expand Down Expand Up @@ -1529,6 +1538,7 @@ bool AdaptDispatch::DeviceAttributes()
// extensions.
//
// 1 = 132 column mode (ConHost only)
// 4 = Sixel Graphics (ConHost only)
// 6 = Selective erase
// 7 = Soft fonts
// 14 = 8-bit interface architecture
Expand All @@ -1546,7 +1556,7 @@ bool AdaptDispatch::DeviceAttributes()
}
else
{
_api.ReturnResponse(L"\x1b[?61;1;6;7;14;21;22;23;24;28;32;42c");
_api.ReturnResponse(L"\x1b[?61;1;4;6;7;14;21;22;23;24;28;32;42c");
}
return true;
}
Expand Down Expand Up @@ -1987,6 +1997,13 @@ bool AdaptDispatch::_ModeParamsHelper(const DispatchTypes::ModeParams param, con
page.Buffer().ResetLineRenditionRange(page.Top(), page.Bottom());
}
return true;
case DispatchTypes::ModeParams::DECSDM_SixelDisplayMode:
_modes.set(Mode::SixelDisplay, enable);
if (_sixelParser)
{
_sixelParser->SetDisplayMode(enable);
}
return true;
case DispatchTypes::ModeParams::DECECM_EraseColorMode:
_modes.set(Mode::EraseColor, enable);
return true;
Expand Down Expand Up @@ -2130,6 +2147,9 @@ bool AdaptDispatch::RequestMode(const DispatchTypes::ModeParams param)
case DispatchTypes::ModeParams::DECLRMM_LeftRightMarginMode:
enabled = _modes.test(Mode::AllowDECSLRM);
break;
case DispatchTypes::ModeParams::DECSDM_SixelDisplayMode:
enabled = _modes.test(Mode::SixelDisplay);
break;
case DispatchTypes::ModeParams::DECECM_EraseColorMode:
enabled = _modes.test(Mode::EraseColor);
break;
Expand Down Expand Up @@ -3138,6 +3158,12 @@ bool AdaptDispatch::SoftReset()
_savedCursorState.at(0).TermOutput = _termOutput;
_savedCursorState.at(1).TermOutput = _termOutput;

// Soft reset the Sixel parser if in use.
if (_sixelParser)
{
_sixelParser->SoftReset();
}

return !_api.IsConsolePty();
}

Expand Down Expand Up @@ -3175,6 +3201,9 @@ bool AdaptDispatch::HardReset()
// Reset all page buffers.
_pages.Reset();

// Reset the Sixel parser.
_sixelParser = nullptr;

// Completely reset the TerminalOutput state.
_termOutput = {};
if (_initialCodePage.has_value())
Expand Down Expand Up @@ -3980,11 +4009,17 @@ bool AdaptDispatch::DoVsCodeAction(const std::wstring_view string)
// - backgroundColor - The color number used for the background (VT240).
// Return Value:
// - a function to receive the pixel data or nullptr if parameters are invalid
ITermDispatch::StringHandler AdaptDispatch::DefineSixelImage(const VTInt /*macroParameter*/,
const DispatchTypes::SixelBackground /*backgroundSelect*/,
const VTParameter /*backgroundColor*/) noexcept
ITermDispatch::StringHandler AdaptDispatch::DefineSixelImage(const VTInt macroParameter,
const DispatchTypes::SixelBackground backgroundSelect,
const VTParameter backgroundColor)
{
return nullptr;
// The sixel parser is created on demand.
if (!_sixelParser)
{
_sixelParser = std::make_unique<SixelParser>(*this, _api.GetStateMachine());
_sixelParser->SetDisplayMode(_modes.test(Mode::SixelDisplay));
}
return _sixelParser->DefineImage(macroParameter, backgroundSelect, backgroundColor);
}

// Method Description:
Expand Down
4 changes: 3 additions & 1 deletion src/terminal/adapter/adaptDispatch.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ namespace Microsoft::Console::VirtualTerminal

StringHandler DefineSixelImage(const VTInt macroParameter,
const DispatchTypes::SixelBackground backgroundSelect,
const VTParameter backgroundColor) noexcept override; // SIXEL
const VTParameter backgroundColor) override; // SIXEL

StringHandler DownloadDRCS(const VTInt fontNumber,
const VTParameter startChar,
Expand Down Expand Up @@ -188,6 +188,7 @@ namespace Microsoft::Console::VirtualTerminal
Column,
AllowDECCOLM,
AllowDECSLRM,
SixelDisplay,
EraseColor,
RectangularChangeExtent,
PageCursorCoupling
Expand Down Expand Up @@ -296,6 +297,7 @@ namespace Microsoft::Console::VirtualTerminal
TerminalOutput _termOutput;
PageManager _pages;
friend class SixelParser;
std::shared_ptr<SixelParser> _sixelParser;
std::unique_ptr<FontBuffer> _fontBuffer;
std::shared_ptr<MacroBuffer> _macroBuffer;
std::optional<unsigned int> _initialCodePage;
Expand Down

1 comment on commit d1e5b6b

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@check-spelling-bot Report

🔴 Please review

See the 📜action log or 📝 job summary for details.

Unrecognized words (15)
algorith
BITMAPINFO
BITMAPINFOHEADER
bmi
DECGCI
DECGCR
DECGNL
DECGRA
DECGRI
DECSDM
possibiliy
RGBQUAD
Sliace
SRCAND
SRCPAINT
Previously acknowledged words that are now absent CRLFs Redir wcsicmp 🫥
To accept these unrecognized words as correct and remove the previously acknowledged and now absent words, you could run the following commands

... in a clone of the [email protected]:j4james/terminal.git repository
on the feature-sixel branch (ℹ️ how do I use this?):

curl -s -S -L 'https://raw.githubusercontent.com/check-spelling/check-spelling/v0.0.22/apply.pl' |
perl - 'https://github.com/j4james/terminal/actions/runs/9458545002/attempts/1'
Available 📚 dictionaries could cover words (expected and unrecognized) not in the 📘 dictionary

This includes both expected items (2213) from .github/actions/spelling/expect/04cdb9b77d6827c0202f51acd4205b017015bfff.txt
.github/actions/spelling/expect/alphabet.txt
.github/actions/spelling/expect/expect.txt
.github/actions/spelling/expect/web.txt and unrecognized words (15)

Dictionary Entries Covers Uniquely
cspell:cpp/src/lang-jargon.txt 11 1 1
cspell:swift/src/swift.txt 53 1 1
cspell:gaming-terms/dict/gaming-terms.txt 59 1 1
cspell:monkeyc/src/monkeyc_keywords.txt 123 1 1
cspell:cryptocurrencies/cryptocurrencies.txt 125 1 1

Consider adding them (in .github/workflows/spelling2.yml) for uses: check-spelling/[email protected] in its with:

      with:
        extra_dictionaries:
          cspell:cpp/src/lang-jargon.txt
          cspell:swift/src/swift.txt
          cspell:gaming-terms/dict/gaming-terms.txt
          cspell:monkeyc/src/monkeyc_keywords.txt
          cspell:cryptocurrencies/cryptocurrencies.txt

To stop checking additional dictionaries, add (in .github/workflows/spelling2.yml) for uses: check-spelling/[email protected] in its with:

check_extra_dictionaries: ''
Errors (2)

See the 📜action log or 📝 job summary for details.

❌ Errors Count
❌ forbidden-pattern 1
❌ ignored-expect-variant 3

See ❌ Event descriptions for more information.

✏️ Contributor please read this

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.

If the listed items are:

  • ... misspelled, then please correct them instead of using the command.
  • ... names, please add them to .github/actions/spelling/allow/names.txt.
  • ... APIs, you can add them to a file in .github/actions/spelling/allow/.
  • ... just things you're using, please add them to an appropriate file in .github/actions/spelling/expect/.
  • ... tokens you only need in one place and shouldn't generally be used, you can add an item in an appropriate file in .github/actions/spelling/patterns/.

See the README.md in each directory for more information.

🔬 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 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. 😉

If the flagged items are 🤯 false positives

If items relate to a ...

  • binary file (or some other file you wouldn't want to check at all).

    Please add a file path to the excludes.txt file matching the containing file.

    File paths are Perl 5 Regular Expressions - you can test 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 (on whichever branch you're using).

  • well-formed pattern.

    If you can write a pattern that would match it,
    try adding it to the patterns.txt file.

    Patterns are Perl 5 Regular Expressions - you can test yours before committing to verify it will match your lines.

    Note that patterns can't match multiline strings.

Please sign in to comment.