+ show zoom level as CallTip

This commit is contained in:
Rainer Kottenhoff 2018-09-03 10:59:03 +02:00
parent 885594179c
commit 37052e1d0f
6 changed files with 60 additions and 45 deletions

View File

@ -114,6 +114,8 @@ extern int g_iTabWidth;
extern int g_iIndentWidth;
extern bool g_bZeroBasedColumnIndex;
extern CALLTIPTYPE g_CallTipType;
extern FR_STATES g_FindReplaceMatchFoundState;
#define ANSI_CAHR_BUFFER 258
@ -4490,13 +4492,13 @@ void EditScrollTo(HWND hwnd, DocLn iScrollToLine, int iSlop)
{
UNUSED(hwnd);
const int iXoff = SciCall_GetXoffset();
const int iXoff = SciCall_GetXOffset();
const DocLn iLinesOnScreen = SciCall_LinesOnScreen();
const DocLn iSlopLines = ((iSlop < 0) || (iSlop >= iLinesOnScreen)) ? (iLinesOnScreen/2) : iSlop;
SciCall_SetVisiblePolicy((VISIBLE_SLOP | VISIBLE_STRICT), iSlopLines);
SciCall_EnsureVisibleEnforcePolicy(iScrollToLine);
SciCall_SetXoffset(iXoff);
SciCall_SetXOffset(iXoff);
}
@ -8298,20 +8300,23 @@ void EditFoldAltArrow(FOLD_MOVE move, FOLD_ACTION action)
//
void EditShowZoomCallTip(HWND hwnd)
{
int const zoom = SciCall_GetZoom();
UNUSED(hwnd);
//Style_GetFon
int const iZoomLevel = SciCall_GetZoom();
float const fSize = Style_GetCurrentFontSize();
int const iZoomPercent = float2int((100.0f * ((float)iZoomLevel + fSize)) / fSize);
char chToolTip[32] = { '\0' };
StringCchPrintfA(chToolTip, COUNTOF(chToolTip), "Zoom: %i pt", zoom);
StringCchPrintfA(chToolTip, COUNTOF(chToolTip), "Zoom: %i%%", iZoomPercent);
//DocPos const iPos = SciCall_PositionFromLine(SciCall_GetFirstVisibleLine());
WININFO const winfo = GetMyWindowPlacement(hwnd, NULL);
POINT ptc; ptc.x = winfo.x + (SciCall_GetXoffset() / (12 + zoom)); ptc.y = winfo.y;
ScreenToClient(hwnd, &ptc); //ptc.x += (SciCall_GetXoffset() / (12+zoom));
DocPos const iPos = SciCall_CharPositionFromPoint(ptc.x, ptc.y);
DocPos const iPos = SciCall_PositionFromLine(SciCall_GetFirstVisibleLine());
int const iXOff = SciCall_GetXOffset();
SciCall_SetXOffset(0);
SciCall_CallTipShow(iPos, chToolTip);
SciCall_SetXOffset(iXOff);
g_CallTipType = CT_ZOOM;
}

View File

@ -161,11 +161,12 @@ static int g_vSBSOrder[STATUS_SECTOR_COUNT] = SBS_INIT_MINUS;
static int g_iStatusbarWidthSpec[STATUS_SECTOR_COUNT] = SBS_INIT_ZERO;
static WCHAR g_tchToolbarBitmap[MAX_PATH] = { L'\0' };
static WCHAR g_tchToolbarBitmapHot[MAX_PATH] = { L'\0' };
static WCHAR g_tchToolbarBitmapDisabled[MAX_PATH] = { L'\0' };
static WININFO g_WinInfo = INIT_WININFO;
static int g_WinCurrentWidth = 0;
int iPathNameFormat;
bool g_bWordWrap;
@ -247,6 +248,8 @@ int iCurrentLineHorizontalSlop = 0;
int iCurrentLineVerticalSlop = 0;
bool g_bChasingDocTail = false;
CALLTIPTYPE g_CallTipType = CT_NONE;
int g_iRenderingTechnology = 0;
const int DirectWriteTechnology[4] = {
@ -273,10 +276,6 @@ const int FontQuality[4] = {
, SC_EFF_QUALITY_LCD_OPTIMIZED
};
static WININFO g_WinInfo = INIT_WININFO;
static int g_WinCurrentWidth = 0;
bool g_bStickyWinPos;
bool bIsAppThemed;
@ -6306,6 +6305,11 @@ LRESULT MsgNotify(HWND hwnd, WPARAM wParam, LPARAM lParam)
case SCN_CHARADDED:
{
if (g_CallTipType == CT_ZOOM) {
SciCall_CallTipCancel();
g_CallTipType = CT_NONE;
}
// Auto indent
if (bAutoIndent && (scn->ch == '\r' || scn->ch == '\n'))
{
@ -8739,6 +8743,7 @@ void UpdateSettingsCmds()
CheckCmd(hmenu, IDM_VIEW_SAVESETTINGS, g_bSaveSettings && g_bEnableSaveSettings);
EnableCmd(hmenu, IDM_VIEW_SAVESETTINGS, hasIniFile && g_bEnableSaveSettings);
EnableCmd(hmenu, IDM_VIEW_SAVESETTINGSNOW, hasIniFile && g_bEnableSaveSettings);
if (SciCall_GetZoom() != 0) { EditShowZoomCallTip(g_hwndEdit); }
}
@ -9330,7 +9335,7 @@ bool FileRevert(LPCWSTR szFileName, bool bIgnoreCmdLnEnc)
const DocPos iCurColumn = SciCall_GetColumn(iCurPos);
const DocLn iVisTopLine = SciCall_GetFirstVisibleLine();
const DocLn iDocTopLine = SciCall_DocLineFromVisible(iVisTopLine);
const int iXOffset = SciCall_GetXoffset();
const int iXOffset = SciCall_GetXOffset();
const bool bIsTail = (iCurPos == iAnchorPos) && (iCurrLine >= (SciCall_GetLineCount() - 1));
if (bIgnoreCmdLnEnc) {
@ -9358,7 +9363,7 @@ bool FileRevert(LPCWSTR szFileName, bool bIgnoreCmdLnEnc)
SciCall_EnsureVisible(iDocTopLine);
const DocLn iNewTopLine = SciCall_GetFirstVisibleLine();
SciCall_LineScroll(0,iVisTopLine - iNewTopLine);
SciCall_SetXoffset(iXOffset);
SciCall_SetXOffset(iXOffset);
}
}
return true;

View File

@ -278,8 +278,8 @@ DeclareSciCallV2(LineScroll, LINESCROLL, DocPos, columns, DocLn, lines)
DeclareSciCallV2(ScrollRange, SCROLLRANGE, DocPos, secondaryPos, DocPos, primaryPos)
DeclareSciCallV1(SetScrollWidth, SETSCROLLWIDTH, int, width)
DeclareSciCallV1(SetEndAtLastLine, SETENDATLASTLINE, bool, flag)
DeclareSciCallR0(GetXoffset, GETXOFFSET, int)
DeclareSciCallV1(SetXoffset, SETXOFFSET, int, offset)
DeclareSciCallR0(GetXOffset, GETXOFFSET, int)
DeclareSciCallV1(SetXOffset, SETXOFFSET, int, offset)
DeclareSciCallV2(SetVisiblePolicy, SETVISIBLEPOLICY, int, flags, DocLn, lines)
DeclareSciCallV0(MoveCaretInsideView, MOVECARETINSIDEVIEW)
@ -321,6 +321,7 @@ DeclareSciCallR2(TextWidth, TEXTWIDTH, int, int, styleNumber, const char*, text)
DeclareSciCallV1(CallTipSetFore, CALLTIPSETFORE, COLORREF, colour)
DeclareSciCallV1(CallTipSetBack, CALLTIPSETBACK, COLORREF, colour)
DeclareSciCallV2(CallTipShow, CALLTIPSHOW, DocPos, position, const char*, text)
DeclareSciCallV0(CallTipCancel, CALLTIPCANCEL)
//=============================================================================

View File

@ -3129,26 +3129,6 @@ static float __fastcall _GetBaseFontSize()
}
//=============================================================================
//
// _SetCurrentFontSize(), _GetCurrentFontSize()
//
static float __fastcall _SetCurrentFontSize(float fSize)
{
static float fCurrentFontSize = INITIAL_BASE_FONT_SIZE;
if (fSize >= 0.0f) {
fCurrentFontSize = Round10th(fSize);
}
return fCurrentFontSize;
}
static float __fastcall _GetCurrentFontSize()
{
return _SetCurrentFontSize(-1.0f);
}
//=============================================================================
//
// Style_RgbAlpha()
@ -3157,8 +3137,28 @@ int __fastcall Style_RgbAlpha(int rgbFore, int rgbBack, int alpha)
{
return (int)RGB(\
(0xFF - alpha) * (int)GetRValue(rgbBack) / 0xFF + alpha * (int)GetRValue(rgbFore) / 0xFF, \
(0xFF - alpha) * (int)GetGValue(rgbBack) / 0xFF + alpha * (int)GetGValue(rgbFore) / 0xFF, \
(0xFF - alpha) * (int)GetBValue(rgbBack) / 0xFF + alpha * (int)GetBValue(rgbFore) / 0xFF);
(0xFF - alpha) * (int)GetGValue(rgbBack) / 0xFF + alpha * (int)GetGValue(rgbFore) / 0xFF, \
(0xFF - alpha) * (int)GetBValue(rgbBack) / 0xFF + alpha * (int)GetBValue(rgbFore) / 0xFF);
}
//=============================================================================
//
// _SetCurrentFontSize(), _GetCurrentFontSize()
//
static float __fastcall _SetCurrentFontSize(float fSize)
{
static float fCurrentFontSize = INITIAL_BASE_FONT_SIZE;
if (signbit(fSize) == 0) {
fCurrentFontSize = max(Round10th(fSize), 0.5f);
}
return fCurrentFontSize;
}
float Style_GetCurrentFontSize()
{
return _SetCurrentFontSize(-1.0f);
}
@ -4676,7 +4676,7 @@ void Style_SetExtraLineSpace(HWND hwnd, LPWSTR lpszStyle, int cch)
if (bHasLnSpaceDef) {
int const iValue = float2int(fValue);
const int iCurFontSizeDbl = float2int(_GetCurrentFontSize() * 2.0f);
const int iCurFontSizeDbl = float2int(Style_GetCurrentFontSize() * 2.0f);
int iValAdj = clampi(iValue, (0 - iCurFontSizeDbl), 256 * iCurFontSizeDbl);
if ((iValAdj != iValue) && (cch > 0)) {
StringCchPrintf(lpszStyle, cch, L"size:%i", iValAdj);
@ -5309,7 +5309,7 @@ bool Style_SelectFont(HWND hwnd,LPWSTR lpszStyle,int cchStyle, LPCWSTR sLexerNam
bool bRelFontSize = (!StrStrI(lpszStyle, L"size:") || StrStrI(lpszStyle, L"size:+") || StrStrI(lpszStyle, L"size:-"));
const float fBaseFontSize = (bGlobalDefaultStyle ? INITIAL_BASE_FONT_SIZE : \
(bCurrentDefaultStyle ? _GetBaseFontSize() : _GetCurrentFontSize()));
(bCurrentDefaultStyle ? _GetBaseFontSize() : Style_GetCurrentFontSize()));
// Font Height
@ -5744,7 +5744,7 @@ void Style_SetStyles(HWND hwnd, int iStyle, LPCWSTR lpszStyle, bool bInitDefault
}
// Size values are relative to BaseFontSize/CurrentFontSize
float fBaseFontSize = _GetCurrentFontSize();
float fBaseFontSize = Style_GetCurrentFontSize();
if (Style_StrGetSize(lpszStyle, &fBaseFontSize)) {
SendMessage(hwnd, SCI_STYLESETSIZEFRACTIONAL, iStyle, (LPARAM)ScaleFractionalFontSize(fBaseFontSize));

View File

@ -65,11 +65,11 @@ typedef struct _editlexer
#define NUMLEXERS 48
#define AVG_NUM_OF_STYLES_PER_LEXER 20
void Style_Load();
void Style_Save();
bool Style_Import(HWND);
bool Style_Export(HWND);
float Style_GetCurrentFontSize();
void Style_SetLexer(HWND,PEDITLEXER);
void Style_SetUrlHotSpot(HWND, bool);
void Style_SetInvisible(HWND, bool);

View File

@ -120,6 +120,10 @@ typedef enum {
// --------------------------------------------------------------------------
typedef enum { CT_NONE = 0, CT_ZOOM } CALLTIPTYPE;
// --------------------------------------------------------------------------
typedef struct _editfindreplace
{
char szFind[FNDRPL_BUFFER];