mirror of
https://github.com/rizonesoft/Notepad3.git
synced 2025-12-28 16:07:50 +00:00
update Scintilla, fix issue IME zoom
This commit is contained in:
parent
905ea20e21
commit
0589ea292a
@ -387,14 +387,6 @@ void ScintillaCall::SetIMEInteraction(Scintilla::IMEInteraction imeInteraction)
|
||||
Call(Message::SetIMEInteraction, static_cast<uintptr_t>(imeInteraction));
|
||||
}
|
||||
|
||||
bool ScintillaCall::IsIMEOpen() {
|
||||
return Call(Message::IsIMEOpen);
|
||||
}
|
||||
|
||||
bool ScintillaCall::IsIMEModeCJK() {
|
||||
return Call(Message::IsIMEModeCJK);
|
||||
}
|
||||
|
||||
void ScintillaCall::MarkerDefine(int markerNumber, Scintilla::MarkerSymbol markerSymbol) {
|
||||
Call(Message::MarkerDefine, markerNumber, static_cast<intptr_t>(markerSymbol));
|
||||
}
|
||||
|
||||
@ -89,7 +89,7 @@ loop iterates over characters, like this:
|
||||
An alternative would be to use a "state-based" approach. The outer loop
|
||||
would iterate over states, like this:
|
||||
|
||||
lengthDoc = startPos+lenth ;
|
||||
lengthDoc = startPos+length ;
|
||||
for ( unsigned int i = startPos ;; ) {
|
||||
char ch = styler.SafeGetCharAt(i);
|
||||
int new_state = 0 ;
|
||||
|
||||
@ -1444,6 +1444,9 @@ struct Sci_TextRangeFull {
|
||||
<b id="SCI_GETSELECTIONSERIALIZED">SCI_GETSELECTIONSERIALIZED(<unused>, char *selectionString) → position</b><br />
|
||||
Set or query the selection type and positions as a serialized string.
|
||||
The format of this string may change in future versions so should not be persisted beyond the current session.</p>
|
||||
<p>The format is currently<br/><code>[selType:R|L|T] [# mainRange ,] [anchor [v virtualSpace] [- caret [v virtualSpace]]] [, ...]</code>
|
||||
<br/>Example of a multiple selection with virtual space: <code>#1,5v3-2,1</code>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<b id="SC_ELEMENT_SELECTION_ADDITIONAL_TEXT">SC_ELEMENT_SELECTION_ADDITIONAL_TEXT : colouralpha</b><br />
|
||||
@ -2031,7 +2034,7 @@ struct Sci_TextToFindFull {
|
||||
<p><b id="SCI_GETUNDOSEQUENCE">SCI_GETUNDOSEQUENCE → int</b><br />
|
||||
Determine if an undo sequence is active with a positive value indicating that a sequence is active and 0 that there is no current sequence.
|
||||
The value returned is the nesting depth of the sequence, that is, the number of times <code>SCI_BEGINUNDOACTION</code>
|
||||
was called without a correspnding <code>SCI_ENDUNDOACTION</code>.
|
||||
was called without a corresponding <code>SCI_ENDUNDOACTION</code>.
|
||||
A negative value indicates an error.</p>
|
||||
|
||||
<p><b id="SCI_ADDUNDOACTION">SCI_ADDUNDOACTION(int token, int flags)</b><br />
|
||||
@ -3840,8 +3843,8 @@ struct Sci_TextToFindFull {
|
||||
<p><b id="SCI_STYLESETINVISIBLEREPRESENTATION">SCI_STYLESETINVISIBLEREPRESENTATION(int style, const char *representation)</b><br />
|
||||
<b id="SCI_STYLEGETINVISIBLEREPRESENTATION">SCI_STYLEGETINVISIBLEREPRESENTATION(int style, char *representation NUL-terminated) → int</b><br />
|
||||
When a style is made invisible with <a class="seealso" href="#SCI_STYLESETVISIBLE">SCI_STYLESETVISIBLE</a>, text is difficult to edit as
|
||||
the cursor can be at both sides of the invisible text segment. With these messages invisible text segements can be made visible with a single
|
||||
UTF8 characater giving the user an indication if the cursor is left or right of the invisible text. The character is displayed using the current style.</p>
|
||||
the cursor can be at both sides of the invisible text segment. With these messages invisible text segments can be made visible with a single
|
||||
UTF8 character giving the user an indication if the cursor is left or right of the invisible text. The character is displayed using the current style.</p>
|
||||
|
||||
<p>The <code>representation</code> parameter is a zero terminated string holding the one character used to represent the invisible text segment. Only the first character
|
||||
is used, the character is decoded as UTF-8.</p>
|
||||
@ -8274,10 +8277,10 @@ sptr_t CallScintilla(unsigned int iMessage, uptr_t wParam, sptr_t lParam){
|
||||
style is wider than the window then the break occurs after the last character that completely
|
||||
fits on the line. The horizontal scroll bar does not appear when wrap mode is on.</p>
|
||||
|
||||
<p>For wrapped lines Scintilla can draw visual flags (little arrows) at end of a a subline of a
|
||||
wrapped line and at begin of the next subline. These can be enabled individually, but if Scintilla
|
||||
draws the visual flag at the beginning of the next subline this subline will be indented by one char.
|
||||
Independent from drawing a visual flag at the begin the subline can have an indention.</p>
|
||||
<p>For wrapped lines Scintilla can draw visual flags (little arrows) at end of a a subline of a
|
||||
wrapped line and at begin of the next subline. These can be enabled individually, but if Scintilla
|
||||
draws the visual flag at the beginning of the next subline this subline will be indented by one char.
|
||||
Independent from drawing a visual flag at the begin the subline can have an indentation.</p>
|
||||
|
||||
<p>Much of the time used by Scintilla is spent on laying out and drawing text. The same text
|
||||
layout calculations may be performed many times even when the data used in these calculations
|
||||
@ -8441,7 +8444,7 @@ sptr_t CallScintilla(unsigned int iMessage, uptr_t wParam, sptr_t lParam){
|
||||
<a class="message" href="#StyleDefinition"><code>STYLE_DEFAULT</code></a>.
|
||||
There are no limits on indent sizes, but values less than 0 or large values may have
|
||||
undesirable effects.<br />
|
||||
The indention of sublines is independent of visual flags, but if
|
||||
The indentation of sublines is independent of visual flags, but if
|
||||
<code>SC_WRAPVISUALFLAG_START</code> is set an indent of at least 1 is used.
|
||||
</p>
|
||||
|
||||
|
||||
@ -590,9 +590,27 @@
|
||||
<td>8day</td>
|
||||
</tr><tr>
|
||||
<td>Ahmet Sait</td>
|
||||
<td>Sven Ritter</td>
|
||||
</tr>
|
||||
</table>
|
||||
<h2 id="Releases">Releases</h2>
|
||||
<h3>
|
||||
<a href="https://www.scintilla.org/scintilla558.zip">Release 5.5.8</a>
|
||||
</h3>
|
||||
<ul>
|
||||
<li>
|
||||
Released 8 June 2025.
|
||||
</li>
|
||||
<li>
|
||||
Change format for SCI_GETSELECTIONSERIALIZED.
|
||||
<a href="https://sourceforge.net/p/scintilla/feature-requests/1563/">Feature #1563</a>.
|
||||
</li>
|
||||
<li>
|
||||
On Win32, force autocompletion list colours to be opaque.
|
||||
Enlarge bitmap to avoid visible blank background between items.
|
||||
<a href="https://sourceforge.net/p/scintilla/bugs/2482/">Bug #2482</a>.
|
||||
</li>
|
||||
</ul>
|
||||
<h3>
|
||||
<a href="https://www.scintilla.org/scintilla557.zip">Release 5.5.7</a>
|
||||
</h3>
|
||||
@ -1779,7 +1797,7 @@
|
||||
</li>
|
||||
<li>
|
||||
Remove SetLexer, SetLexerLanguage, and LoadLexerLibrary methods.
|
||||
These have been superceded by Lexilla and the SetILexer API.
|
||||
These have been superseded by Lexilla and the SetILexer API.
|
||||
</li>
|
||||
<li>
|
||||
Improve the platform layer interface.
|
||||
|
||||
@ -311,11 +311,6 @@ get IMEInteraction GetIMEInteraction=2678(,)
|
||||
# Choose to display the IME in a window or inline.
|
||||
set void SetIMEInteraction=2679(IMEInteraction imeInteraction,)
|
||||
|
||||
# >>>>>>>>>>>>>>> BEG NON STD SCI PATCH >>>>>>>>>>>>>>>
|
||||
get bool IsIMEOpen=6003(,)
|
||||
get bool IsIMEModeCJK=6004(,)
|
||||
# <<<<<<<<<<<<<<< END NON STD SCI PATCH <<<<<<<<<<<<<<<
|
||||
|
||||
enu Alpha=SC_ALPHA_
|
||||
val SC_ALPHA_TRANSPARENT=0
|
||||
val SC_ALPHA_OPAQUE=255
|
||||
|
||||
@ -142,8 +142,6 @@ public:
|
||||
std::string FontLocale();
|
||||
Scintilla::IMEInteraction IMEInteraction();
|
||||
void SetIMEInteraction(Scintilla::IMEInteraction imeInteraction);
|
||||
bool IsIMEOpen();
|
||||
bool IsIMEModeCJK();
|
||||
void MarkerDefine(int markerNumber, Scintilla::MarkerSymbol markerSymbol);
|
||||
void MarkerSetFore(int markerNumber, Colour fore);
|
||||
void MarkerSetBack(int markerNumber, Colour back);
|
||||
|
||||
@ -71,8 +71,6 @@ enum class Message {
|
||||
GetFontLocale = 2761,
|
||||
GetIMEInteraction = 2678,
|
||||
SetIMEInteraction = 2679,
|
||||
IsIMEOpen = 6003,
|
||||
IsIMEModeCJK = 6004,
|
||||
MarkerDefine = 2040,
|
||||
MarkerSetFore = 2041,
|
||||
MarkerSetBack = 2042,
|
||||
|
||||
@ -181,5 +181,5 @@ def UpdateFileFromLines(path, lines, lineEndToUse):
|
||||
def ReplaceREInFile(path, match, replace, count=1):
|
||||
with codecs.open(path, "r", "utf-8") as f:
|
||||
contents = f.read()
|
||||
contents = re.sub(match, replace, contents, count=count)
|
||||
contents = re.sub(match, replace, contents, count)
|
||||
UpdateFile(path, contents)
|
||||
|
||||
@ -26,7 +26,9 @@
|
||||
|
||||
#include "Debugging.h"
|
||||
|
||||
// >>>>>>>>>>>>>>> BEG NON STD SCI PATCH >>>>>>>>>>>>>>>
|
||||
#include "Scintilla.h"
|
||||
// <<<<<<<<<<<<<<< END NON STD SCI PATCH <<<<<<<<<<<<<<<
|
||||
#include "Position.h"
|
||||
#include "SplitVector.h"
|
||||
#include "Partitioning.h"
|
||||
|
||||
@ -109,7 +109,7 @@ public:
|
||||
virtual ~RegexSearchBase() = default;
|
||||
|
||||
virtual Sci::Position FindText(Document *doc, Sci::Position minPos, Sci::Position maxPos, const char *s,
|
||||
bool caseSensitive, bool word, bool wordStart, Scintilla::FindOption flags, Sci::Position *length) = 0;
|
||||
bool caseSensitive, bool word, bool wordStart, Scintilla::FindOption flags, Sci::Position *length) = 0;
|
||||
|
||||
///@return String with the substitutions, must remain valid until the next call or destruction
|
||||
virtual const char *SubstituteByPosition(Document *doc, const char *text, Sci::Position *length) = 0;
|
||||
|
||||
@ -105,10 +105,6 @@ EditModel::EditModel() : braces{} {
|
||||
highlightGuideColumn = 0;
|
||||
hasFocus = false;
|
||||
primarySelection = true;
|
||||
// >>>>>>>>>>>>>>> BEG NON STD SCI PATCH >>>>>>>>>>>>>>>
|
||||
imeIsOpen = false;
|
||||
imeIsInModeCJK = false;
|
||||
// <<<<<<<<<<<<<<< END NON STD SCI PATCH <<<<<<<<<<<<<<<
|
||||
imeInteraction = IMEInteraction::Windowed;
|
||||
bidirectional = Bidirectional::Disabled;
|
||||
foldFlags = FoldFlag::None;
|
||||
|
||||
@ -68,10 +68,6 @@ public:
|
||||
bool primarySelection;
|
||||
std::string copySeparator;
|
||||
|
||||
// >>>>>>>>>>>>>>> BEG NON STD SCI PATCH >>>>>>>>>>>>>>>
|
||||
bool imeIsOpen;
|
||||
bool imeIsInModeCJK;
|
||||
// <<<<<<<<<<<<<<< END NON STD SCI PATCH <<<<<<<<<<<<<<<
|
||||
Scintilla::IMEInteraction imeInteraction;
|
||||
Scintilla::Bidirectional bidirectional;
|
||||
|
||||
|
||||
@ -400,7 +400,6 @@ void LayoutSegments(IPositionCache *pCache,
|
||||
void EditView::LayoutLine(const EditModel &model, Surface *surface, const ViewStyle &vstyle, LineLayout *ll, int width, bool callerMultiThreaded) {
|
||||
if (!ll)
|
||||
return;
|
||||
|
||||
const Sci::Line line = ll->LineNumber();
|
||||
PLATFORM_ASSERT(line < model.pdoc->LinesTotal());
|
||||
PLATFORM_ASSERT(ll->chars);
|
||||
@ -547,6 +546,7 @@ void EditView::LayoutLine(const EditModel &model, Surface *surface, const ViewSt
|
||||
const TextSegment &ts = segments.back();
|
||||
lastSegItalics = (!ts.representation) && ((ll->chars[ts.end() - 1] != ' ') && vstyle.styles[ll->styles[ts.start]].italic);
|
||||
}
|
||||
|
||||
// Small hack to make lines that end with italics not cut off the edge of the last character
|
||||
if (lastSegItalics) {
|
||||
ll->positions[numCharsInLine] += vstyle.lastSegItalicsOffset;
|
||||
@ -2335,7 +2335,6 @@ void EditView::DrawForeground(Surface *surface, const EditModel &model, const Vi
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void EditView::DrawIndentGuidesOverEmpty(Surface *surface, const EditModel &model, const ViewStyle &vsDraw, const LineLayout *ll,
|
||||
Sci::Line line, int xStart, PRectangle rcLine, int subLine, Sci::Line lineVisible) {
|
||||
|
||||
@ -13,7 +13,9 @@
|
||||
#include <cstdio>
|
||||
#include <cmath>
|
||||
|
||||
// >>>>>>>>>>>>>>> BEG NON STD SCI PATCH >>>>>>>>>>>>>>>
|
||||
#include <ranges>
|
||||
// <<<<<<<<<<<<<<< END NON STD SCI PATCH <<<<<<<<<<<<<<<
|
||||
#include <stdexcept>
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
@ -634,7 +636,7 @@ SelectionRange Editor::LineSelectionRange(SelectionPosition currentPos_, Selecti
|
||||
currentPos_ = SelectionPosition(pdoc->LineStartPosition(currentPos_.Position()));
|
||||
anchor_ = SelectionPosition(pdoc->LineEndPosition(anchor_.Position()));
|
||||
}
|
||||
return {currentPos_, anchor_};
|
||||
return SelectionRange(currentPos_, anchor_);
|
||||
}
|
||||
|
||||
void Editor::SetSelection(SelectionPosition currentPos_, SelectionPosition anchor_) {
|
||||
@ -5981,7 +5983,6 @@ std::unique_ptr<Surface> Editor::CreateMeasurementSurface() const {
|
||||
return surf;
|
||||
}
|
||||
|
||||
// >>>>>>>>>>>>>>> BEG NON STD SCI PATCH >>>>>>>>>>>>>>>
|
||||
std::unique_ptr<Surface> Editor::CreateDrawingSurface(SurfaceID sid, std::optional<Scintilla::Technology> technologyOpt) const {
|
||||
if (!wMain.GetID()) {
|
||||
return {};
|
||||
@ -5991,7 +5992,6 @@ std::unique_ptr<Surface> Editor::CreateDrawingSurface(SurfaceID sid, std::option
|
||||
surf->SetMode(CurrentSurfaceMode());
|
||||
return surf;
|
||||
}
|
||||
// <<<<<<<<<<<<<<< END NON STD SCI PATCH <<<<<<<<<<<<<<<
|
||||
|
||||
Sci::Line Editor::WrapCount(Sci::Line line) {
|
||||
AutoSurface surface(this);
|
||||
@ -7449,14 +7449,6 @@ sptr_t Editor::WndProc(Message iMessage, uptr_t wParam, sptr_t lParam) {
|
||||
case Message::GetIMEInteraction:
|
||||
return static_cast<sptr_t>(imeInteraction);
|
||||
|
||||
// >>>>>>>>>>>>>>> BEG NON STD SCI PATCH >>>>>>>>>>>>>>>
|
||||
case Message::IsIMEOpen:
|
||||
return static_cast<sptr_t>(imeIsOpen);
|
||||
|
||||
case Message::IsIMEModeCJK:
|
||||
return static_cast<sptr_t>(imeIsInModeCJK);
|
||||
// <<<<<<<<<<<<<<< END NON STD SCI PATCH <<<<<<<<<<<<<<<
|
||||
|
||||
case Message::SetBidirectional:
|
||||
// Message::SetBidirectional is implemented on platform subclasses if they support bidirectional text.
|
||||
break;
|
||||
@ -9187,7 +9179,7 @@ sptr_t Editor::WndProc(Message iMessage, uptr_t wParam, sptr_t lParam) {
|
||||
return DefWndProc(iMessage, wParam, lParam);
|
||||
}
|
||||
|
||||
// If there was a change that needs its selection saved and it wasn't explicity saved
|
||||
// If there was a change that needs its selection saved and it wasn't explicitly saved
|
||||
// then do that here.
|
||||
RememberCurrentSelectionForRedoOntoStack();
|
||||
|
||||
|
||||
@ -466,9 +466,7 @@ protected: // ScintillaBase subclass needs access to much of Editor
|
||||
virtual void NotifyChange() = 0;
|
||||
virtual void NotifyFocus(bool focus);
|
||||
virtual void SetCtrlID(int identifier);
|
||||
// >>>>>>>>>>>>>>> BEG NON STD SCI PATCH >>>>>>>>>>>>>>>
|
||||
virtual int GetCtrlID() const noexcept { return ctrlID; }
|
||||
// <<<<<<<<<<<<<<< END NON STD SCI PATCH <<<<<<<<<<<<<<<
|
||||
virtual void NotifyParent(Scintilla::NotificationData scn) = 0;
|
||||
virtual void NotifyStyleToNeeded(Sci::Position endStyleNeeded);
|
||||
void NotifyChar(int ch, Scintilla::CharacterSource charSource);
|
||||
@ -543,9 +541,7 @@ protected: // ScintillaBase subclass needs access to much of Editor
|
||||
void CopyText(size_t length, const char *text);
|
||||
void SetDragPosition(SelectionPosition newPos);
|
||||
virtual void DisplayCursor(Window::Cursor c);
|
||||
// >>>>>>>>>>>>>>> BEG NON STD SCI PATCH >>>>>>>>>>>>>>>
|
||||
virtual bool DragThreshold(Point ptStart, Point ptNow) noexcept;
|
||||
// <<<<<<<<<<<<<<< END NON STD SCI PATCH <<<<<<<<<<<<<<<
|
||||
virtual void StartDrag();
|
||||
void DropAt(SelectionPosition position, const char *value, size_t lengthValue, bool moving, bool rectangular);
|
||||
void DropAt(SelectionPosition position, const char *value, bool moving, bool rectangular);
|
||||
@ -591,11 +587,9 @@ protected: // ScintillaBase subclass needs access to much of Editor
|
||||
virtual void IdleWork();
|
||||
virtual void QueueIdleWork(WorkItems items, Sci::Position upTo=0);
|
||||
|
||||
// >>>>>>>>>>>>>>> BEG NON STD SCI PATCH >>>>>>>>>>>>>>>
|
||||
virtual int SupportsFeature(Scintilla::Supports feature) const noexcept;
|
||||
virtual bool PaintContains(PRectangle rc) const noexcept;
|
||||
bool PaintContainsMargin() const noexcept;
|
||||
// <<<<<<<<<<<<<<< END NON STD SCI PATCH <<<<<<<<<<<<<<<
|
||||
void CheckForChangeOutsidePaint(Range r);
|
||||
void SetBraceHighlight(Sci::Position pos0, Sci::Position pos1, int matchStyle);
|
||||
|
||||
@ -630,9 +624,7 @@ protected: // ScintillaBase subclass needs access to much of Editor
|
||||
virtual std::string UTF8FromEncoded(std::string_view encoded) const = 0;
|
||||
virtual std::string EncodedFromUTF8(std::string_view utf8) const = 0;
|
||||
virtual std::unique_ptr<Surface> CreateMeasurementSurface() const;
|
||||
// >>>>>>>>>>>>>>> BEG NON STD SCI PATCH >>>>>>>>>>>>>>>
|
||||
virtual std::unique_ptr<Surface> CreateDrawingSurface(SurfaceID sid, std::optional<Scintilla::Technology> technologyOpt = {}) const;
|
||||
// <<<<<<<<<<<<<<< END NON STD SCI PATCH <<<<<<<<<<<<<<<
|
||||
|
||||
Sci::Line WrapCount(Sci::Line line);
|
||||
void AddStyledText(const char *buffer, Sci::Position appendLength);
|
||||
|
||||
@ -32,7 +32,8 @@
|
||||
|
||||
using namespace Scintilla::Internal;
|
||||
|
||||
MarkerHandleSet::MarkerHandleSet() = default;
|
||||
MarkerHandleSet::MarkerHandleSet() {
|
||||
}
|
||||
|
||||
bool MarkerHandleSet::Empty() const noexcept {
|
||||
return mhList.empty();
|
||||
|
||||
@ -103,7 +103,7 @@ typedef void *IdlerID;
|
||||
* Font management.
|
||||
*/
|
||||
|
||||
constexpr const char *localeNameDefault = "en-US";
|
||||
constexpr const char *localeNameDefault = "en-us";
|
||||
|
||||
struct FontParameters {
|
||||
const char *faceName;
|
||||
@ -385,6 +385,6 @@ constexpr long LongFromTwoShorts(short a,short b) noexcept {
|
||||
|
||||
}
|
||||
|
||||
} // namespace
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@ -167,22 +167,20 @@ bool LineLayout::InLine(int offset, int line) const noexcept {
|
||||
}
|
||||
|
||||
int LineLayout::SubLineFromPosition(int posInLine, PointEnd pe) const noexcept {
|
||||
if (!lineStarts || (posInLine > maxLineLength)) {
|
||||
if (lines <= 1 || (posInLine >= numCharsBeforeEOL)) {
|
||||
return lines - 1;
|
||||
}
|
||||
|
||||
for (int line = 0; line < lines; line++) {
|
||||
if (FlagSet(pe, PointEnd::subLineEnd)) {
|
||||
// Return subline not start of next
|
||||
if (lineStarts[line + 1] <= posInLine + 1)
|
||||
return line;
|
||||
} else {
|
||||
if (lineStarts[line + 1] <= posInLine)
|
||||
return line;
|
||||
// Return subline not start of next for PointEnd::subLineEnd
|
||||
posInLine -= FlagSet(pe, PointEnd::subLineEnd) ? 1 : 0;
|
||||
int line = 1;
|
||||
for (; line < lines; line++) {
|
||||
if (lineStarts[line] > posInLine) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return lines - 1;
|
||||
return line - 1;
|
||||
}
|
||||
|
||||
void LineLayout::AddLineStart(Sci::Position start) {
|
||||
@ -317,7 +315,7 @@ Interval LineLayout::SpanByte(int index) const noexcept {
|
||||
}
|
||||
|
||||
int LineLayout::EndLineStyle() const noexcept {
|
||||
return styles[numCharsBeforeEOL > 0 ? numCharsBeforeEOL-1 : 0];
|
||||
return styles[std::max(numCharsBeforeEOL - 1, 0)];
|
||||
}
|
||||
|
||||
void LineLayout::WrapLine(const Document *pdoc, Sci::Position posLineStart, Wrap wrapState, XYPOSITION wrapWidth) {
|
||||
|
||||
@ -169,7 +169,6 @@ public:
|
||||
Sci::Line linesOnScreen, Sci::Line linesInDoc);
|
||||
};
|
||||
|
||||
|
||||
class Representation {
|
||||
public:
|
||||
static constexpr size_t maxLength = 200;
|
||||
@ -268,6 +267,7 @@ public:
|
||||
};
|
||||
|
||||
std::unique_ptr<IPositionCache> CreatePositionCache();
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@ -29,23 +29,24 @@ namespace {
|
||||
// Generically convert a string to a integer value throwing if the conversion failed.
|
||||
// Failures include values that are out of range for the destination variable.
|
||||
template <typename T>
|
||||
void ValueFromString(std::string_view sv, T &value) {
|
||||
void ValueFromString(std::string_view &sv, T &value) {
|
||||
const std::from_chars_result res = std::from_chars(sv.data(), sv.data() + sv.size(), value);
|
||||
if (res.ec != std::errc{}) {
|
||||
if (res.ec == std::errc::result_out_of_range)
|
||||
throw std::runtime_error("from_chars out of range.");
|
||||
throw std::runtime_error("from_chars failed.");
|
||||
}
|
||||
sv.remove_prefix(res.ptr - sv.data());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
SelectionPosition::SelectionPosition(std::string_view sv) : position(0) {
|
||||
if (const size_t v = sv.find('v'); v != std::string_view::npos) {
|
||||
ValueFromString(sv.substr(v + 1), virtualSpace);
|
||||
sv = sv.substr(0, v);
|
||||
}
|
||||
SelectionPosition::SelectionPosition(std::string_view &sv) : position(0) {
|
||||
ValueFromString(sv, position);
|
||||
if (!sv.empty() && sv.front() == 'v') {
|
||||
sv.remove_prefix(1);
|
||||
ValueFromString(sv, virtualSpace);
|
||||
}
|
||||
}
|
||||
|
||||
void SelectionPosition::MoveForInsertDelete(bool insertion, Sci::Position startChange, Sci::Position length, bool moveForEqual) noexcept {
|
||||
@ -109,14 +110,13 @@ std::string SelectionPosition::ToString() const {
|
||||
return result;
|
||||
}
|
||||
|
||||
SelectionRange::SelectionRange(std::string_view sv) {
|
||||
const size_t dash = sv.find('-');
|
||||
if (dash == std::string_view::npos) {
|
||||
anchor = SelectionPosition(sv);
|
||||
SelectionRange::SelectionRange(std::string_view &sv) {
|
||||
anchor = SelectionPosition(sv);
|
||||
if (sv.empty() || sv.front() != '-') {
|
||||
caret = anchor;
|
||||
} else {
|
||||
anchor = SelectionPosition(sv.substr(0, dash));
|
||||
caret = SelectionPosition(sv.substr(dash + 1));
|
||||
sv.remove_prefix(1);
|
||||
caret = SelectionPosition(sv);
|
||||
}
|
||||
}
|
||||
|
||||
@ -274,10 +274,13 @@ Selection::Selection(std::string_view sv) : mainRange(0), moveExtends(false), te
|
||||
sv.remove_prefix(1);
|
||||
}
|
||||
|
||||
// Non-zero main index at end after '#'
|
||||
if (const size_t hash = sv.find('#'); hash != std::string_view::npos) {
|
||||
ValueFromString(sv.substr(hash + 1), mainRange);
|
||||
sv = sv.substr(0, hash);
|
||||
// Non-zero main index at start after '#'
|
||||
if (!sv.empty() && sv.front() == '#') {
|
||||
sv.remove_prefix(1);
|
||||
ValueFromString(sv, mainRange);
|
||||
if (!sv.empty() && sv.front() == ',') {
|
||||
sv.remove_prefix(1);
|
||||
}
|
||||
}
|
||||
|
||||
// Remainder is list of ranges
|
||||
@ -288,13 +291,12 @@ Selection::Selection(std::string_view sv) : mainRange(0), moveExtends(false), te
|
||||
ranges.emplace_back(SelectionPosition(0));
|
||||
}
|
||||
} else {
|
||||
size_t comma = sv.find(',');
|
||||
while (comma != std::string_view::npos) {
|
||||
ranges.emplace_back(sv.substr(0, comma));
|
||||
sv.remove_prefix(comma + 1);
|
||||
comma = sv.find(',');
|
||||
while (!sv.empty()) {
|
||||
if (sv.front() == ',') {
|
||||
sv.remove_prefix(1);
|
||||
}
|
||||
ranges.emplace_back(sv);
|
||||
}
|
||||
ranges.emplace_back(sv);
|
||||
if (mainRange >= ranges.size()) {
|
||||
mainRange = ranges.size() - 1;
|
||||
}
|
||||
@ -595,6 +597,11 @@ std::string Selection::ToString() const {
|
||||
// No prefix.
|
||||
break;
|
||||
}
|
||||
if (mainRange > 0) {
|
||||
result += '#';
|
||||
result += std::to_string(mainRange);
|
||||
result += ',';
|
||||
}
|
||||
if (selType == SelTypes::rectangle || selType == SelTypes::thin) {
|
||||
result += rangeRectangular.ToString();
|
||||
} else {
|
||||
@ -606,10 +613,5 @@ std::string Selection::ToString() const {
|
||||
}
|
||||
}
|
||||
|
||||
if (mainRange > 0) {
|
||||
result += '#';
|
||||
result += std::to_string(mainRange);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -20,7 +20,7 @@ public:
|
||||
if (virtualSpace < 0)
|
||||
virtualSpace = 0;
|
||||
}
|
||||
explicit SelectionPosition(std::string_view sv);
|
||||
explicit SelectionPosition(std::string_view &sv);
|
||||
void Reset() noexcept {
|
||||
position = 0;
|
||||
virtualSpace = 0;
|
||||
@ -121,7 +121,7 @@ struct SelectionRange {
|
||||
}
|
||||
constexpr SelectionRange(Sci::Position caret_, Sci::Position anchor_) noexcept : caret(caret_), anchor(anchor_) {
|
||||
}
|
||||
explicit SelectionRange(std::string_view sv);
|
||||
explicit SelectionRange(std::string_view &sv);
|
||||
SelectionSegment AsSegment() const noexcept {
|
||||
return {caret, anchor};
|
||||
}
|
||||
|
||||
@ -74,7 +74,9 @@ Style::Style(const char *fontName_) noexcept :
|
||||
back(white),
|
||||
eolFilled(false),
|
||||
underline(false),
|
||||
// >>>>>>>>>>>>>>> BEG NON STD SCI PATCH >>>>>>>>>>>>>>>
|
||||
strike(false),
|
||||
// <<<<<<<<<<<<<<< END NON STD SCI PATCH <<<<<<<<<<<<<<<
|
||||
caseForce(CaseForce::mixed),
|
||||
visible(true),
|
||||
changeable(true),
|
||||
|
||||
@ -61,10 +61,12 @@ bool MarginStyle::ShowsFolding() const noexcept {
|
||||
|
||||
void FontRealised::Realise(Surface &surface, int zoomLevel, Technology technology, const FontSpecification &fs, const char *localeName) {
|
||||
PLATFORM_ASSERT(fs.fontName);
|
||||
// >>>>>>>>>>>>>>> BEG NON STD SCI PATCH >>>>>>>>>>>>>>>
|
||||
//~measurements.sizeZoomed = fs.size + zoomLevel * FontSizeMultiplier;
|
||||
//~if (measurements.sizeZoomed <= FontSizeMultiplier) // May fail if sizeZoomed < 1
|
||||
//~ measurements.sizeZoomed = FontSizeMultiplier;
|
||||
measurements.sizeZoomed = GetFontSizeZoomed(fs.size, zoomLevel);
|
||||
// <<<<<<<<<<<<<<< END NON STD SCI PATCH <<<<<<<<<<<<<<<
|
||||
|
||||
const float deviceHeight = static_cast<float>(surface.DeviceHeightFont(measurements.sizeZoomed));
|
||||
const FontParameters fp(fs.fontName, deviceHeight / FontSizeMultiplier, fs.weight,
|
||||
|
||||
@ -8,7 +8,9 @@
|
||||
#ifndef VIEWSTYLE_H
|
||||
#define VIEWSTYLE_H
|
||||
|
||||
// >>>>>>>>>>>>>>> BEG NON STD SCI PATCH >>>>>>>>>>>>>>>
|
||||
#include "Scintilla.h"
|
||||
// <<<<<<<<<<<<<<< END NON STD SCI PATCH <<<<<<<<<<<<<<<
|
||||
|
||||
namespace Scintilla::Internal {
|
||||
|
||||
|
||||
@ -77,6 +77,13 @@ void *PtrFromLParam(Scintilla::sptr_t lParam) noexcept {
|
||||
return reinterpret_cast<void *>(lParam);
|
||||
}
|
||||
|
||||
// These are reasonable initial guesses that may be refined by measurement or calls.
|
||||
constexpr SIZE sizeList { 150, 80 };
|
||||
constexpr int commonLineHeight = 10;
|
||||
constexpr unsigned int commonCharacterWidth = 8;
|
||||
constexpr int commonItemLength = 12;
|
||||
constexpr int defaultVisibleRows = 9;
|
||||
|
||||
struct ListItemData {
|
||||
const char *text;
|
||||
int pixId;
|
||||
@ -115,11 +122,11 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
const TCHAR ListBoxX_ClassName[] = TEXT("ListBoxX");
|
||||
const TCHAR *ListBoxX_ClassName = TEXT("ListBoxX");
|
||||
|
||||
ColourRGBA ColourElement(std::optional<ColourRGBA> colour, int nIndex) {
|
||||
if (colour.has_value()) {
|
||||
return colour.value();
|
||||
return colour.value().Opaque();
|
||||
}
|
||||
return ColourFromSys(nIndex);
|
||||
}
|
||||
@ -143,7 +150,7 @@ struct LBGraphics {
|
||||
}
|
||||
|
||||
class ListBoxX : public ListBox {
|
||||
int lineHeight = 10;
|
||||
int lineHeight = commonLineHeight;
|
||||
HFONT fontCopy {};
|
||||
std::unique_ptr<FontWin> fontWin;
|
||||
Technology technology = Technology::Default;
|
||||
@ -152,9 +159,9 @@ class ListBoxX : public ListBox {
|
||||
HWND lb {};
|
||||
bool unicodeMode = false;
|
||||
int codePage = 0;
|
||||
int desiredVisibleRows = 9;
|
||||
int desiredVisibleRows = defaultVisibleRows;
|
||||
int maxItemCharacters = 0;
|
||||
unsigned int aveCharWidth = 8;
|
||||
unsigned int aveCharWidth = commonCharacterWidth;
|
||||
Window *parent = nullptr;
|
||||
WNDPROC prevWndProc{};
|
||||
int ctrlID = 0;
|
||||
@ -248,10 +255,11 @@ void ListBoxX::Create(Window &parent_, int ctrlID_, Point location_, int lineHei
|
||||
HWND hwndParent = HwndFromWindow(*parent);
|
||||
HINSTANCE hinstanceParent = GetWindowInstance(hwndParent);
|
||||
// Window created as popup so not clipped within parent client area
|
||||
constexpr int startPosition = 100; // Arbitrary as will be moved immediately
|
||||
wid = ::CreateWindowEx(
|
||||
WS_EX_WINDOWEDGE, ListBoxX_ClassName, TEXT(""),
|
||||
WS_POPUP | frameStyle,
|
||||
100,100, 150,80, hwndParent,
|
||||
startPosition,startPosition, sizeList.cx,sizeList.cy, hwndParent,
|
||||
{},
|
||||
hinstanceParent,
|
||||
this);
|
||||
@ -272,7 +280,8 @@ void ListBoxX::SetFont(const Font *font) {
|
||||
fontCopy = pfm->HFont();
|
||||
SetWindowFont(lb, fontCopy, 0);
|
||||
fontWin = pfm->Duplicate();
|
||||
codePage = unicodeMode ? CpUtf8 : CodePageFromCharSet(fontWin->GetCharacterSet(), 1252);
|
||||
codePage = unicodeMode ? CpUtf8 :
|
||||
CodePageFromCharSet(fontWin->GetCharacterSet(), codePageWindowsLatin);
|
||||
graphics.Release();
|
||||
}
|
||||
}
|
||||
@ -303,7 +312,6 @@ PRectangle ListBoxX::GetDesiredRect() {
|
||||
|
||||
int width = MinClientWidth();
|
||||
int textSize = 0;
|
||||
int averageCharWidth = 8;
|
||||
|
||||
// Make a measuring surface
|
||||
std::unique_ptr<Surface> surfaceItem(Surface::Allocate(technology));
|
||||
@ -320,7 +328,7 @@ PRectangle ListBoxX::GetDesiredRect() {
|
||||
}
|
||||
|
||||
maxCharWidth = static_cast<int>(std::ceil(surfaceItem->WidthText(fontWin.get(), "W")));
|
||||
averageCharWidth = static_cast<int>(surfaceItem->AverageCharWidth(fontWin.get()));
|
||||
const int averageCharWidth = static_cast<int>(surfaceItem->AverageCharWidth(fontWin.get()));
|
||||
|
||||
width = std::max({ width, textSize, (maxItemCharacters + 1) * averageCharWidth });
|
||||
|
||||
@ -536,16 +544,13 @@ void ListBoxX::AdjustWindowRect(PRectangle *rc, UINT dpiAdjust) const noexcept {
|
||||
}
|
||||
|
||||
int ListBoxX::ItemHeight() const noexcept {
|
||||
int itemHeight = lineHeight + (TextInset.y * 2);
|
||||
const int itemHeight = lineHeight + (TextInset.y * 2);
|
||||
const int pixHeight = images.GetHeight() + (ImageInset.y * 2);
|
||||
if (itemHeight < pixHeight) {
|
||||
itemHeight = pixHeight;
|
||||
}
|
||||
return itemHeight;
|
||||
return std::max(itemHeight, pixHeight);
|
||||
}
|
||||
|
||||
int ListBoxX::MinClientWidth() const noexcept {
|
||||
return 12 * (aveCharWidth+aveCharWidth/3);
|
||||
return commonItemLength * (aveCharWidth+aveCharWidth/3);
|
||||
}
|
||||
|
||||
POINT ListBoxX::MinTrackSize() const noexcept {
|
||||
@ -558,7 +563,7 @@ POINT ListBoxX::MinTrackSize() const noexcept {
|
||||
POINT ListBoxX::MaxTrackSize() const noexcept {
|
||||
PRectangle rc = PRectangle::FromInts(0, 0,
|
||||
std::max<int>(static_cast<unsigned int>(MinClientWidth()),
|
||||
maxCharWidth * maxItemCharacters + TextInset.x * 2 +
|
||||
(maxCharWidth * maxItemCharacters) + (TextInset.x * 2) +
|
||||
TextOffset() + SystemMetricsForDpi(SM_CXVSCROLL, dpi)),
|
||||
ItemHeight() * lti.Count());
|
||||
AdjustWindowRect(&rc, dpi);
|
||||
@ -745,7 +750,7 @@ void ListBoxX::CentreItem(int n) {
|
||||
}
|
||||
|
||||
void ListBoxX::AllocateBitMap() {
|
||||
const SIZE extent { GetClientExtent().x, lineHeight };
|
||||
const SIZE extent { GetClientExtent().x, ItemHeight() };
|
||||
|
||||
graphics.bm.Create({}, extent.cx, -extent.cy, nullptr);
|
||||
if (!graphics.bm) {
|
||||
@ -845,7 +850,7 @@ LRESULT ListBoxX::WndProc(HWND hWnd, UINT iMessage, WPARAM wParam, LPARAM lParam
|
||||
0, WC_LISTBOXW, L"",
|
||||
WS_CHILD | WS_VSCROLL | WS_VISIBLE |
|
||||
LBS_OWNERDRAWFIXED | LBS_NODATA | LBS_NOINTEGRALHEIGHT,
|
||||
0, 0, 150,80, hWnd,
|
||||
0, 0, sizeList.cx, sizeList.cy, hWnd,
|
||||
reinterpret_cast<HMENU>(static_cast<ptrdiff_t>(ctrlID)),
|
||||
hinstanceParent,
|
||||
nullptr);
|
||||
@ -934,10 +939,7 @@ LRESULT ListBoxX::WndProc(HWND hWnd, UINT iMessage, WPARAM wParam, LPARAM lParam
|
||||
const int nRows = GetVisibleRows();
|
||||
int linesToScroll = std::clamp(nRows - 1, 1, 3);
|
||||
linesToScroll *= wheelDelta.Actions();
|
||||
int top = ListBox_GetTopIndex(lb) + linesToScroll;
|
||||
if (top < 0) {
|
||||
top = 0;
|
||||
}
|
||||
const int top = std::max(0, ListBox_GetTopIndex(lb) + linesToScroll);
|
||||
ListBox_SetTopIndex(lb, top);
|
||||
}
|
||||
break;
|
||||
|
||||
@ -18,6 +18,8 @@ constexpr FLOAT dpiDefault = USER_DEFAULT_SCREEN_DPI;
|
||||
// Used for defining font size with LOGFONT
|
||||
constexpr int pointsPerInch = 72;
|
||||
|
||||
constexpr UINT codePageWindowsLatin = 1252;
|
||||
|
||||
extern void Platform_Initialise(void *hInstance) noexcept;
|
||||
|
||||
extern void Platform_Finalise(bool fromDllMain) noexcept;
|
||||
|
||||
@ -86,7 +86,7 @@
|
||||
<WarningLevel>Level4</WarningLevel>
|
||||
<PreprocessorDefinitions>_USRDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<AdditionalIncludeDirectories>..\include;..\src;</AdditionalIncludeDirectories>
|
||||
<BrowseInformation>true</BrowseInformation>
|
||||
<BrowseInformation>false</BrowseInformation>
|
||||
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
||||
<MinimalRebuild>false</MinimalRebuild>
|
||||
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
||||
|
||||
@ -335,9 +335,12 @@ public:
|
||||
|
||||
void SetCompositionFont(const ViewStyle &vs, int style, UINT dpi) const {
|
||||
LOGFONTW lf{};
|
||||
int sizeZoomed = vs.styles[style].size + (vs.zoomLevel * FontSizeMultiplier);
|
||||
if (sizeZoomed <= 2 * FontSizeMultiplier) // Hangs if sizeZoomed <= 1
|
||||
sizeZoomed = 2 * FontSizeMultiplier;
|
||||
// >>>>>>>>>>>>>>> BEG NON STD SCI PATCH >>>>>>>>>>>>>>>
|
||||
//int sizeZoomed = vs.styles[style].size + (vs.zoomLevel * FontSizeMultiplier);
|
||||
//if (sizeZoomed <= 2 * FontSizeMultiplier) // Hangs if sizeZoomed <= 1
|
||||
// sizeZoomed = 2 * FontSizeMultiplier;
|
||||
int const sizeZoomed = GetFontSizeZoomed(vs.styles[style].size, vs.zoomLevel);
|
||||
// <<<<<<<<<<<<<<< END NON STD SCI PATCH <<<<<<<<<<<<<<<
|
||||
// The negative is to allow for leading
|
||||
lf.lfHeight = -::MulDiv(sizeZoomed, dpi, pointsPerInch * FontSizeMultiplier);
|
||||
lf.lfWeight = static_cast<LONG>(vs.styles[style].weight);
|
||||
@ -1638,8 +1641,8 @@ UINT CodePageFromCharSet(CharacterSet characterSet, UINT documentCodePage) noexc
|
||||
return CpUtf8;
|
||||
}
|
||||
switch (characterSet) {
|
||||
case CharacterSet::Ansi: return 1252;
|
||||
case CharacterSet::Default: return documentCodePage ? documentCodePage : 1252;
|
||||
case CharacterSet::Ansi: return codePageWindowsLatin;
|
||||
case CharacterSet::Default: return documentCodePage ? documentCodePage : codePageWindowsLatin;
|
||||
case CharacterSet::Baltic: return 1257;
|
||||
case CharacterSet::ChineseBig5: return 950;
|
||||
case CharacterSet::EastEurope: return 1250;
|
||||
@ -3419,22 +3422,6 @@ void ScintillaWin::ImeStartComposition() {
|
||||
if (stylesValid) {
|
||||
// Since the style creation code has been made platform independent,
|
||||
// The logfont for the IME is recreated here.
|
||||
// >>>>>>>>>>>>>>> BEG NON STD SCI PATCH >>>>>>>>>>>>>>>
|
||||
//const int styleHere = pdoc->StyleIndexAt(sel.MainCaret());
|
||||
//LOGFONTW lf = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, L""};
|
||||
//int sizeZoomed = GetFontSizeZoomed(vs.styles[styleHere].size, vs.zoomLevel);
|
||||
//// The negative is to allow for leading
|
||||
//lf.lfHeight = -::MulDiv(sizeZoomed, dpi, 72*FontSizeMultiplier);
|
||||
//lf.lfWeight = static_cast<LONG>(vs.styles[styleHere].weight);
|
||||
//lf.lfItalic = vs.styles[styleHere].italic ? 1 : 0;
|
||||
//lf.lfCharSet = DEFAULT_CHARSET;
|
||||
//lf.lfFaceName[0] = L'\0';
|
||||
//if (vs.styles[styleHere].fontName) {
|
||||
// const char* fontName = vs.styles[styleHere].fontName;
|
||||
// UTF16FromUTF8(std::string_view(fontName), lf.lfFaceName, LF_FACESIZE);
|
||||
//}
|
||||
// <<<<<<<<<<<<<<< END NON STD SCI PATCH <<<<<<<<<<<<<<<
|
||||
|
||||
imc.SetCompositionFont(vs, pdoc->StyleIndexAt(sel.MainCaret()), dpi);
|
||||
}
|
||||
// Caret is displayed in IME window. So, caret in Scintilla is useless.
|
||||
|
||||
Loading…
Reference in New Issue
Block a user