Skip to content

Commit

Permalink
Change 行間を上揃えではなく下揃えにする
Browse files Browse the repository at this point in the history
  • Loading branch information
niki committed Apr 13, 2024
1 parent 6cfbc53 commit 0291c5e
Show file tree
Hide file tree
Showing 12 changed files with 43 additions and 84 deletions.
13 changes: 3 additions & 10 deletions sakura_core/my_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -161,19 +161,12 @@
#define NKMM_EDITVIEW_H_SCRBAR_REDRAW_TIMING (1) // 水平スクロールバーの更新タイミングを修正

//------------------------------------------------------------------
// 行のマージンは下に挿入する
// 行間を上揃えではなく下揃えにする
// - デフォルトでは行は上揃えになっているので行間は下に付加される
// - キャレットを行間含む高さにする (カーソル行アンダーラインが表示されている場合は交差箇所が消せないので通常処理)
//------------------------------------------------------------------
#define NKMM_LINE_TOP_ADJUST

//------------------------------------------------------------------
// 行を上揃えではなく中央ぞろえにする 20140326 - 20150724
// - デフォルトでは行は上揃えになっているので行間は下に付加される
// - キャレットを行間含む高さにする (カーソル行アンダーラインが表示されている場合は交差箇所が消せないので通常処理)
//------------------------------------------------------------------
//:pending: #define NKMM_LINE_CENTERING
// #define NKMM_CENTERINLG_WITH_CARET_HEIGHT (1) // キャレットの高さを行の高さにする
#define NKMM_LINE_MARGIN_TOP
#define NKMM_LINE_MARGIN_TOP_WITH_CARET_HEIGHT (1) // キャレットの高さを行の高さにする

//------------------------------------------------------------------
// キャレットの幅を入力タイプで変更する (半角:1px, 全角:2px)
Expand Down
32 changes: 7 additions & 25 deletions sakura_core/view/CCaret.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -639,14 +639,8 @@ void CCaret::ShowEditCaret()
int nCaretHeight = 0;
if( 0 == pCommon->m_sGeneral.GetCaretType() ){
nCaretHeight = GetHankakuHeight();
#if defined(NKMM_LINE_CENTERING) && NKMM_CENTERINLG_WITH_CARET_HEIGHT == 1 // Caretの高さ
{ // ※アンダーラインと交差する個所にゴミが残る
// カーソル行アンダーラインが非表示の時はキャレットを行の高さにする
bool bUnderLine = m_pEditView->m_pTypeData->m_ColorInfoArr[COLORIDX_UNDERLINE].m_bDisp;
if (!bUnderLine) {
nCaretHeight += m_pEditView->GetLineSpace();
}
}
#if defined(NKMM_LINE_MARGIN_TOP) && NKMM_LINE_MARGIN_TOP_WITH_CARET_HEIGHT == 1 // Caretの高さ
nCaretHeight += m_pEditView->GetLineMargin();
#endif // NKMM_
if( m_pEditView->IsInsMode() ){
nCaretWidth = 2;
Expand Down Expand Up @@ -676,14 +670,8 @@ void CCaret::ShowEditCaret()
// カーソルのタイプ = win
if( 0 == pCommon->m_sGeneral.GetCaretType() ){
nCaretHeight = GetHankakuHeight(); /* キャレットの高さ */
#if defined(NKMM_LINE_CENTERING) && NKMM_CENTERINLG_WITH_CARET_HEIGHT == 1 // Caretの高さ
{ // ※アンダーラインと交差する個所にゴミが残る
// カーソル行アンダーラインが非表示の時はキャレットを行の高さにする
bool bUnderLine = m_pEditView->m_pTypeData->m_ColorInfoArr[COLORIDX_UNDERLINE].m_bDisp;
if (!bUnderLine) {
nCaretHeight += m_pEditView->GetLineSpace();
}
}
#if defined(NKMM_LINE_MARGIN_TOP) && NKMM_LINE_MARGIN_TOP_WITH_CARET_HEIGHT == 1 // Caretの高さ
nCaretHeight += m_pEditView->GetLineMargin();
#endif // NKMM_
if( m_pEditView->IsInsMode() /* Oct. 2, 2005 genta */ ){
#ifdef NKMM_FIX_CARET_WIDTH
Expand Down Expand Up @@ -1326,17 +1314,11 @@ POINT CCaret::CalcCaretDrawPos(const CLayoutPoint& ptCaretPos) const
nPosY = m_pEditView->GetTextArea().GetAreaTop()
+ (Int)(nY) * m_pEditView->GetTextMetrics().GetHankakuDy()
+ m_pEditView->GetTextMetrics().GetHankakuHeight() - GetCaretSize().cy; //下寄せ
#if defined(NKMM_LINE_CENTERING) && NKMM_CENTERINLG_WITH_CARET_HEIGHT == 1
{ // ※アンダーラインと交差する個所にゴミが残る
// カーソル行アンダーラインが非表示の時はキャレットを行の高さにする
bool bUnderLine = m_pEditView->m_pTypeData->m_ColorInfoArr[COLORIDX_UNDERLINE].m_bDisp;
if (!bUnderLine) {
nPosY += m_pEditView->GetLineSpace();
}
}
#if defined(NKMM_LINE_MARGIN_TOP) && NKMM_LINE_MARGIN_TOP_WITH_CARET_HEIGHT == 1
nPosY += m_pEditView->GetLineMargin();
#endif // NKMM_
}
#if defined(NKMM_LINE_TOP_ADJUST)
#if defined(NKMM_LINE_MARGIN_TOP)
//nPosY += m_pEditView->GetLineMargin(); // 文字の高さにする場合
#endif // NKMM_

Expand Down
20 changes: 5 additions & 15 deletions sakura_core/view/CEditView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2555,7 +2555,7 @@ void CEditView::CaretUnderLineON( bool bDraw, bool bDrawPaint, bool DisalbeUnder
if( bUnderLine ){
nUnderLineY = GetTextArea().GetAreaTop() + (Int)(GetCaret().GetCaretLayoutPos().GetY2() - GetTextArea().GetViewTopLine())
* GetTextMetrics().GetHankakuDy() + GetTextMetrics().GetHankakuHeight();
#ifdef NKMM_LINE_CENTERING
#ifdef NKMM_LINE_MARGIN_TOP
nUnderLineY += GetLineMargin();
#endif // NKMM_
}
Expand Down Expand Up @@ -2622,23 +2622,13 @@ void CEditView::CaretUnderLineOFF( bool bDraw, bool bDrawPaint, bool bResetFlag,
nUnderLineY = -1;
}else if( GetTextArea().m_nViewRowNum < nY ){
nUnderLineY = GetTextArea().GetAreaBottom() + 1;
#ifdef NKMM_LINE_CENTERING
// カーソル行の背景色を表示する場合にセンタリング補正をいれると
// 背景色の描画領域全体に影響してしまう
// アンダーライン処理とごっちゃになっていてわかりにくい
if (!m_pTypeData->m_ColorInfoArr[COLORIDX_CARETLINEBG].m_bDisp) {
nUnderLineY += GetLineMargin();
}
#ifdef NKMM_LINE_MARGIN_TOP
nUnderLineY += GetLineMargin();
#endif // NKMM_
}else{
nUnderLineY = GetTextArea().GetAreaTop() + (Int)(nY) * GetTextMetrics().GetHankakuDy();
#ifdef NKMM_LINE_CENTERING
// カーソル行の背景色を表示する場合にセンタリング補正をいれると
// 背景色の描画領域全体に影響してしまう
// アンダーライン処理とごっちゃになっていてわかりにくい
if (!m_pTypeData->m_ColorInfoArr[COLORIDX_CARETLINEBG].m_bDisp) {
nUnderLineY += GetLineMargin();
}
#ifdef NKMM_LINE_MARGIN_TOP
nUnderLineY += GetLineMargin();
#endif // NKMM_
}

Expand Down
2 changes: 1 addition & 1 deletion sakura_core/view/CEditView.h
Original file line number Diff line number Diff line change
Expand Up @@ -580,7 +580,7 @@ class CEditView
void SetUndoBuffer( bool bPaintLineNumber = false ); // アンドゥバッファの処理
HWND StartProgress();

#ifdef NKMM_LINE_TOP_ADJUST
#ifdef NKMM_LINE_MARGIN_TOP
//! 行間のすきま取得
int GetLineSpace() const {
if (m_pTypeData) {
Expand Down
12 changes: 3 additions & 9 deletions sakura_core/view/CEditView_Ime.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,15 +82,9 @@ void CEditView::SetIMECompFormPos( void )
CompForm.dwStyle = CFS_POINT;
CompForm.ptCurrentPos.x = (long) point.x;
CompForm.ptCurrentPos.y = (long) point.y + GetCaret().GetCaretSize().cy - GetTextMetrics().GetHankakuHeight();
#if defined(NKMM_LINE_CENTERING) && NKMM_CENTERINLG_WITH_CARET_HEIGHT == 1 // 変換位置
{ // ※アンダーラインと交差する個所にゴミが残る
// カーソル行アンダーラインが非表示の時はキャレットを行の高さにする
bool bUnderLine = m_pTypeData->m_ColorInfoArr[COLORIDX_UNDERLINE].m_bDisp;
if (!bUnderLine) {
CompForm.ptCurrentPos.y -= GetLineMargin() +
(GetLineSpace() & 1);
}
}
#if defined(NKMM_LINE_MARGIN_TOP) && NKMM_LINE_MARGIN_TOP_WITH_CARET_HEIGHT == 1 // 変換位置
CompForm.ptCurrentPos.y -= GetLineMargin() +
(GetLineSpace() & 1);
#endif // NKMM_

if ( hIMC ){
Expand Down
6 changes: 3 additions & 3 deletions sakura_core/view/CTextDrawer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ void CTextDrawer::DispText( HDC hdc, DispPos* pDispPos, int marginy, const wchar
::ExtTextOutW_AnyBuild(
hdc,
nDrawX, //X
#ifdef NKMM_LINE_CENTERING
#ifdef NKMM_LINE_MARGIN_TOP
m_pEditView->GetLineMargin() +
#endif // NKMM_
y + marginy, //Y
Expand Down Expand Up @@ -542,7 +542,7 @@ void CTextDrawer::DispLineNumber(
int drawNumTop = (pView->GetTextArea().m_nViewAlignLeftCols - nLineNumCols - 1) * ( nCharWidth );
::ExtTextOutW_AnyBuild( gr,
drawNumTop,
#ifdef NKMM_LINE_CENTERING
#ifdef NKMM_LINE_MARGIN_TOP
pView->GetLineMargin() +
#endif // NKMM_
y,
Expand Down Expand Up @@ -644,7 +644,7 @@ void CTextDrawer::DispLineNumber(
int nHeightMargin = pView->GetTextMetrics().GetCharHeightMarginByFontNo(fontNo);
::ExtTextOutW_AnyBuild( gr,
drawNumTop,
#ifdef NKMM_LINE_CENTERING
#ifdef NKMM_LINE_MARGIN_TOP
pView->GetLineMargin() +
#endif // NKMM_
y + nHeightMargin,
Expand Down
2 changes: 1 addition & 1 deletion sakura_core/view/figures/CFigure_Comma.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ void CFigure_Comma::DispSpace(CGraphics& gr, DispPos* pDispPos, CEditView* pcVie
::ExtTextOutW_AnyBuild(
gr,
sPos.GetDrawPos().x,
#ifdef NKMM_LINE_CENTERING
#ifdef NKMM_LINE_MARGIN_TOP
pcView->GetLineMargin() +
#endif // NKMM_
sPos.GetDrawPos().y,
Expand Down
2 changes: 1 addition & 1 deletion sakura_core/view/figures/CFigure_CtrlCode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ void CFigure_CtrlCode::DispSpaceEx(CGraphics& gr, DispPos* pDispPos, CEditView*
ExtTextOutW_AnyBuild(
gr,
pDispPos->GetDrawPos().x,
#ifdef NKMM_LINE_CENTERING
#ifdef NKMM_LINE_MARGIN_TOP
pcView->GetLineMargin() +
#endif // NKMM_
pDispPos->GetDrawPos().y + nHeightMargin,
Expand Down
18 changes: 9 additions & 9 deletions sakura_core/view/figures/CFigure_Eol.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ void _DispWrap(CGraphics& gr, DispPos* pDispPos, const CEditView* pcView, CLayou
::ExtTextOutW_AnyBuild(
gr,
pDispPos->GetDrawPos().x,
#ifdef NKMM_LINE_CENTERING
#ifdef NKMM_LINE_MARGIN_TOP
pcView->GetLineMargin() +
#endif // NKMM_
pDispPos->GetDrawPos().y + nHeightMargin,
Expand Down Expand Up @@ -301,7 +301,7 @@ void _DispEOF(
void _DrawEOL(
CGraphics& gr,
const CMyRect& rcEol,
#ifdef NKMM_LINE_CENTERING
#ifdef NKMM_LINE_MARGIN_TOP
int nMargin,
#endif // NKMM_
CEol cEol,
Expand All @@ -323,7 +323,7 @@ void _DispEOL(CGraphics& gr, DispPos* pDispPos, CEol cEol, const CEditView* pcVi
::ExtTextOutW_AnyBuild(
gr,
pDispPos->GetDrawPos().x,
#ifdef NKMM_LINE_CENTERING
#ifdef NKMM_LINE_MARGIN_TOP
pcView->GetLineMargin() +
#endif // NKMM_
pDispPos->GetDrawPos().y + nHeightMargin,
Expand All @@ -350,7 +350,7 @@ void _DispEOL(CGraphics& gr, DispPos* pDispPos, CEol cEol, const CEditView* pcVi
// 文字色や太字かどうかを現在の DC から調べる // 2009.05.29 ryoji
// (検索マッチ等の状況に柔軟に対応するため、ここは記号の色指定には決め打ちしない)
// 2013.06.21 novice 文字色、太字をCGraphicsから取得
#ifdef NKMM_LINE_CENTERING
#ifdef NKMM_LINE_MARGIN_TOP
_DrawEOL(gr, rcEol, pcView->GetLineMargin(), cEol, gr.GetCurrentMyFontBold(), gr.GetCurrentTextForeColor());
#else
_DrawEOL(gr, rcEol, cEol, gr.GetCurrentMyFontBold(), gr.GetCurrentTextForeColor());
Expand Down Expand Up @@ -382,7 +382,7 @@ void _DispEOL(CGraphics& gr, DispPos* pDispPos, CEol cEol, const CEditView* pcVi
void _DrawEOL(
CGraphics& gr, //!< Device Context Handle
const CMyRect& rcEol, //!< 描画領域
#ifdef NKMM_LINE_CENTERING
#ifdef NKMM_LINE_MARGIN_TOP
int nMargin,
#endif // NKMM_
CEol cEol, //!< 行末コード種別
Expand All @@ -398,7 +398,7 @@ void _DrawEOL(
{
sx = rcEol.left; //X左端
sy = rcEol.top + ( rcEol.Height() / 2); //Y中心
#ifdef NKMM_LINE_CENTERING
#ifdef NKMM_LINE_MARGIN_TOP
sy += nMargin;
#endif // NKMM_
DWORD pp[] = { 3, 3 };
Expand Down Expand Up @@ -438,7 +438,7 @@ void _DrawEOL(
{
sx = rcEol.left;
sy = rcEol.top + ( rcEol.Height() / 2 );
#ifdef NKMM_LINE_CENTERING
#ifdef NKMM_LINE_MARGIN_TOP
sy += nMargin;
#endif // NKMM_
DWORD pp[] = { 3, 2 };
Expand Down Expand Up @@ -475,7 +475,7 @@ void _DrawEOL(
{
sx = rcEol.left + ( rcEol.Width() / 2 );
sy = rcEol.top + ( rcEol.Height() * 3 / 4 );
#ifdef NKMM_LINE_CENTERING
#ifdef NKMM_LINE_MARGIN_TOP
sy += nMargin;
#endif // NKMM_
DWORD pp[] = { 3, 2 };
Expand Down Expand Up @@ -514,7 +514,7 @@ void _DrawEOL(
// 左下矢印(折れ曲がりなし)
sx = rcEol.left; //X左端
sy = rcEol.top + ( rcEol.Height() * 3 / 4 ); //Y上から3/4
#ifdef NKMM_LINE_CENTERING
#ifdef NKMM_LINE_MARGIN_TOP
sy += nMargin;
#endif // NKMM_
DWORD pp[] = { 2, 3 };
Expand Down
6 changes: 3 additions & 3 deletions sakura_core/view/figures/CFigure_HanSpace.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@ void CFigure_HanSpace::DispSpace(CGraphics& gr, DispPos* pDispPos, CEditView* pc
::ExtTextOutW_AnyBuild(
gr,
pDispPos->GetDrawPos().x,
//#ifdef NKMM_LINE_CENTERING
// pcView->GetLineMargin() +
//#endif // NKMM_LINE_CENTERING
#ifdef NKMM_LINE_MARGIN_TOP
pcView->GetLineMargin() +
#endif // NKMM_
pDispPos->GetDrawPos().y,
ExtTextOutOption() & ~(bTrans? ETO_OPAQUE: 0),
&rcClipBottom,
Expand Down
12 changes: 6 additions & 6 deletions sakura_core/view/figures/CFigure_Tab.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,14 +76,14 @@ void CFigure_Tab::DispSpace(CGraphics& gr, DispPos* pDispPos, CEditView* pcView,
_DrawTabArrow(
gr,
nPosLeft,
//#ifdef NKMM_LINE_CENTERING
// pcView->GetLineMargin() +
//#endif // NKMM_
#ifdef NKMM_LINE_MARGIN_TOP
pcView->GetLineMargin() +
#endif // NKMM_
sPos.GetDrawPos().y,
nCharWidth * tabDispWidth - (nPosLeft - sPos.GetDrawPos().x), // Tab Area一杯に 2013/4/11 Uchi
#ifdef NKMM_LINE_CENTERING
pcView->GetLineSpace() +
#endif // NKMM_LINE_CENTERING
//#ifdef NKMM_LINE_CENTERING
// pcView->GetLineMargin() +
//#endif // NKMM_
pMetrics->GetHankakuHeight(),
gr.GetCurrentMyFontBold() || m_pTypeData->m_ColorInfoArr[COLORIDX_TAB].m_sFontAttr.m_bBoldFont,
gr.GetCurrentTextForeColor()
Expand Down
2 changes: 1 addition & 1 deletion sakura_core/view/figures/CFigure_ZenSpace.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ void CFigure_ZenSpace::DispSpace(CGraphics& gr, DispPos* pDispPos, CEditView* pc
ExtTextOutW_AnyBuild(
gr,
pDispPos->GetDrawPos().x,
#ifdef NKMM_LINE_CENTERING
#ifdef NKMM_LINE_MARGIN_TOP
pcView->GetLineMargin() +
#endif // NKMM_
pDispPos->GetDrawPos().y + nHeightMargin,
Expand Down

0 comments on commit 0291c5e

Please sign in to comment.