-
Notifications
You must be signed in to change notification settings - Fork 163
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
タブ幅が半角単位8桁を超える場合でも下線が最後まで描画されるようにする #1673
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||
---|---|---|---|---|
|
@@ -28,10 +28,8 @@ | |||
#include "types/CTypeSupport.h" | ||||
#include "apiwrap/StdApi.h" | ||||
|
||||
void _DispTab( CGraphics& gr, DispPos* pDispPos, const CEditView* pcView ); | ||||
|
||||
// -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- // | ||||
// CFigure_Comma // | ||||
// CFigure_Comma // | ||||
// -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- // | ||||
|
||||
bool CFigure_Comma::Match(const wchar_t* pText, int nTextLen) const | ||||
|
@@ -58,51 +56,53 @@ void CFigure_Comma::DispSpace(CGraphics& gr, DispPos* pDispPos, CEditView* pcVie | |||
DispPos& sPos=*pDispPos; | ||||
|
||||
//必要なインターフェース | ||||
const CLayoutMgr& pcLayoutMgr = pcView->GetDocument()->m_cLayoutMgr; | ||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. CLayoutMgrを編集可能な状態でアクセスする必要はないので、const参照経由で使用します。 |
||||
const CTextMetrics* pMetrics=&pcView->GetTextMetrics(); | ||||
const CTextArea* pArea=&pcView->GetTextArea(); | ||||
|
||||
int nLineHeight = pMetrics->GetHankakuDy(); | ||||
int nCharWidth = pMetrics->GetCharPxWidth(); // Layout→Px | ||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 換算方法の見直しで使用されなくなるので除去 |
||||
|
||||
CTypeSupport cTabType(pcView,COLORIDX_TAB); | ||||
|
||||
// これから描画するタブ幅 | ||||
CLayoutXInt tabDispWidthLayout = pcView->m_pcEditDoc->m_cLayoutMgr.GetActualTsvSpace( sPos.GetDrawCol(), L',' ); | ||||
int tabDispWidth = (Int)tabDispWidthLayout; | ||||
CLayoutXInt nTabLayoutWidth = pcLayoutMgr.GetActualTsvSpace(sPos.GetDrawCol(), L','); | ||||
size_t nTabDispWidth = static_cast<Int>(nTabLayoutWidth) / pcLayoutMgr.GetWidthPerKeta(); | ||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 変数名変更 |
||||
if( pcView->m_bMiniMap ){ | ||||
CLayoutMgr mgrTemp; | ||||
mgrTemp.SetTabSpaceInfo(pcView->m_pcEditDoc->m_cLayoutMgr.GetTabSpaceKetas(), | ||||
CLayoutXInt(pcView->GetTextMetrics().GetHankakuWidth()) ); | ||||
tabDispWidthLayout = mgrTemp.GetActualTabSpace(sPos.GetDrawCol()); | ||||
tabDispWidth = (Int)tabDispWidthLayout; | ||||
mgrTemp.SetTabSpaceInfo(pcLayoutMgr.GetTabSpaceKetas(), static_cast<CLayoutXInt>(pMetrics->GetHankakuWidth())); | ||||
nTabLayoutWidth = mgrTemp.GetActualTabSpace(sPos.GetDrawCol()); | ||||
nTabDispWidth = static_cast<Int>(nTabLayoutWidth) / mgrTemp.GetWidthPerKeta(); | ||||
} | ||||
|
||||
// タブ記号領域 | ||||
RECT rcClip2; | ||||
rcClip2.left = sPos.GetDrawPos().x; | ||||
rcClip2.right = rcClip2.left + nCharWidth * tabDispWidth; | ||||
rcClip2.right = rcClip2.left + static_cast<Int>(nTabLayoutWidth); | ||||
Comment on lines
-83
to
+80
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 変更前はタブのピクセル幅に文字のピクセル幅を乗じていました。 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 見直したら2乗にならないことがわかりました。 sakura/sakura_core/view/CTextMetrics.h Line 60 in 6b4f0a8
ただ、tabDispWidthの中身はピクセル単位数値なのだから、この演算をする意味はないと思います。 |
||||
if( rcClip2.left < pArea->GetAreaLeft() ){ | ||||
rcClip2.left = pArea->GetAreaLeft(); | ||||
} | ||||
rcClip2.top = sPos.GetDrawPos().y; | ||||
rcClip2.bottom = sPos.GetDrawPos().y + nLineHeight; | ||||
int nLen = wcslen( m_pTypeData->m_szTabViewString ); | ||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Code Smell:未使用変数の定義・縮小型変換 |
||||
|
||||
if( pArea->IsRectIntersected(rcClip2) ){ | ||||
if( cTabType.IsDisp() ){ //CSVモード | ||||
std::wstring szViewString = L","; | ||||
if (szViewString.length() < nTabDispWidth) { | ||||
szViewString.append(nTabDispWidth - szViewString.length(), L' '); | ||||
} | ||||
::ExtTextOut( | ||||
gr, | ||||
sPos.GetDrawPos().x, | ||||
sPos.GetDrawPos().y, | ||||
ExtTextOutOption() & ~(bTrans? ETO_OPAQUE: 0), | ||||
&rcClip2, | ||||
L", ", | ||||
tabDispWidth <= 8 ? tabDispWidth : 8, // Sep. 22, 2002 genta | ||||
szViewString.c_str(), | ||||
static_cast<UINT>(szViewString.length()), | ||||
pMetrics->GetDxArray_AllHankaku() | ||||
); | ||||
} | ||||
} | ||||
|
||||
//Xを進める | ||||
sPos.ForwardDrawCol(tabDispWidthLayout); | ||||
sPos.ForwardDrawCol(nTabLayoutWidth); | ||||
} |
Original file line number | Diff line number | Diff line change | ||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -61,39 +61,41 @@ void CFigure_Tab::DispSpace(CGraphics& gr, DispPos* pDispPos, CEditView* pcView, | |||||||||||||||
DispPos& sPos=*pDispPos; | ||||||||||||||||
|
||||||||||||||||
//必要なインターフェース | ||||||||||||||||
const CLayoutMgr& pcLayoutMgr = pcView->GetDocument()->m_cLayoutMgr; | ||||||||||||||||
const CTextMetrics* pMetrics=&pcView->GetTextMetrics(); | ||||||||||||||||
const CTextArea* pArea=&pcView->GetTextArea(); | ||||||||||||||||
|
||||||||||||||||
int nLineHeight = pMetrics->GetHankakuDy(); | ||||||||||||||||
int nCharWidth = pMetrics->GetCharPxWidth(); // Layout→Px | ||||||||||||||||
|
||||||||||||||||
CTypeSupport cTabType(pcView,COLORIDX_TAB); | ||||||||||||||||
|
||||||||||||||||
// これから描画するタブ幅 | ||||||||||||||||
CLayoutXInt tabDispWidthLayout = pcView->m_pcEditDoc->m_cLayoutMgr.GetActualTsvSpace( sPos.GetDrawCol(), WCODE::TAB ); | ||||||||||||||||
int tabDispWidth = (Int)tabDispWidthLayout; | ||||||||||||||||
CLayoutXInt nTabLayoutWidth = pcLayoutMgr.GetActualTsvSpace(sPos.GetDrawCol(), WCODE::TAB); | ||||||||||||||||
size_t nTabDispWidth = static_cast<Int>(nTabLayoutWidth) / pcLayoutMgr.GetWidthPerKeta(); | ||||||||||||||||
if( pcView->m_bMiniMap ){ | ||||||||||||||||
CLayoutMgr mgrTemp; | ||||||||||||||||
mgrTemp.SetTabSpaceInfo(pcView->m_pcEditDoc->m_cLayoutMgr.GetTabSpaceKetas(), | ||||||||||||||||
CLayoutXInt(pcView->GetTextMetrics().GetHankakuWidth()) ); | ||||||||||||||||
tabDispWidthLayout = mgrTemp.GetActualTabSpace(sPos.GetDrawCol()); | ||||||||||||||||
tabDispWidth = (Int)tabDispWidthLayout; | ||||||||||||||||
mgrTemp.SetTabSpaceInfo(pcLayoutMgr.GetTabSpaceKetas(), static_cast<CLayoutXInt>(pMetrics->GetHankakuWidth())); | ||||||||||||||||
nTabLayoutWidth = mgrTemp.GetActualTabSpace(sPos.GetDrawCol()); | ||||||||||||||||
nTabDispWidth = static_cast<Int>(nTabLayoutWidth) / mgrTemp.GetWidthPerKeta(); | ||||||||||||||||
} | ||||||||||||||||
|
||||||||||||||||
// タブ記号領域 | ||||||||||||||||
RECT rcClip2; | ||||||||||||||||
rcClip2.left = sPos.GetDrawPos().x; | ||||||||||||||||
rcClip2.right = rcClip2.left + nCharWidth * tabDispWidth; | ||||||||||||||||
rcClip2.right = rcClip2.left + static_cast<Int>(nTabLayoutWidth); | ||||||||||||||||
if( rcClip2.left < pArea->GetAreaLeft() ){ | ||||||||||||||||
rcClip2.left = pArea->GetAreaLeft(); | ||||||||||||||||
} | ||||||||||||||||
rcClip2.top = sPos.GetDrawPos().y; | ||||||||||||||||
rcClip2.bottom = sPos.GetDrawPos().y + nLineHeight; | ||||||||||||||||
int nLen = wcslen( m_pTypeData->m_szTabViewString ); | ||||||||||||||||
|
||||||||||||||||
if( pArea->IsRectIntersected(rcClip2) ){ | ||||||||||||||||
if( cTabType.IsDisp() && TABARROW_STRING == m_pTypeData->m_bTabArrow ){ //タブ通常表示 //@@@ 2003.03.26 MIK | ||||||||||||||||
int fontNo = WCODE::GetFontNo(m_pTypeData->m_szTabViewString[0]); | ||||||||||||||||
std::wstring szForeViewString = m_pTypeData->m_szTabViewString; | ||||||||||||||||
if (szForeViewString.length() < nTabDispWidth) { | ||||||||||||||||
szForeViewString.append(nTabDispWidth - szForeViewString.length(), L' '); | ||||||||||||||||
} | ||||||||||||||||
int fontNo = WCODE::GetFontNo(szForeViewString[0]); | ||||||||||||||||
if( fontNo ){ | ||||||||||||||||
SFONT sFont; | ||||||||||||||||
sFont.m_sFontAttr = gr.GetCurrentMyFontAttr(); | ||||||||||||||||
|
@@ -108,24 +110,24 @@ void CFigure_Tab::DispSpace(CGraphics& gr, DispPos* pDispPos, CEditView* pcView, | |||||||||||||||
sPos.GetDrawPos().y + nHeightMargin, | ||||||||||||||||
ExtTextOutOption() & ~(bTrans? ETO_OPAQUE: 0), | ||||||||||||||||
&rcClip2, | ||||||||||||||||
m_pTypeData->m_szTabViewString, | ||||||||||||||||
// tabDispWidth <= 8 ? tabDispWidth : 8, // Sep. 22, 2002 genta | ||||||||||||||||
nLen, | ||||||||||||||||
szForeViewString.c_str(), | ||||||||||||||||
static_cast<UINT>(szForeViewString.length()), | ||||||||||||||||
pMetrics->GetDxArray_AllHankaku() // FIXME:半角固定? | ||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ここでは半角文字の文字間隔配列を取得していますが、タブ記号には全角文字も設定できるので、 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 指摘ではありませんが、タブ幅の最小値って2なんでしたっけ? 最小値に1以下を指定できるとしたら、この修正内容と関係なく問題ありな気がします。 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. おそらく設定できます。 sakura/sakura_core/typeprop/CPropTypesScreen.cpp Lines 412 to 418 in 0843eb9
タブ幅を1にしている人がいないとも限らないので、GenerateDxArray2を使用するように仕様変更(=このPRには含めない)しましょうか? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. めんどくさそうな感じっすねw TAB幅に1を指定するのは趣味だと思うので、放置しましょう。 TAB幅に1を指定してあるのなら、 TAB幅2未満のときだけ全角文字を無効とする、ないし、TAB描画文字に全角を指定したときは幅を2未満にできないようにする、みたいな修正を入れておくのがベターだと思います。 |
||||||||||||||||
); | ||||||||||||||||
if( fontNo ){ | ||||||||||||||||
gr.PopMyFont(); | ||||||||||||||||
} | ||||||||||||||||
}else{ | ||||||||||||||||
//背景 | ||||||||||||||||
std::wstring szBackViewString(nTabDispWidth, L' '); | ||||||||||||||||
::ExtTextOut( | ||||||||||||||||
gr, | ||||||||||||||||
sPos.GetDrawPos().x, | ||||||||||||||||
sPos.GetDrawPos().y, | ||||||||||||||||
ExtTextOutOption() & ~(bTrans? ETO_OPAQUE: 0), | ||||||||||||||||
&rcClip2, | ||||||||||||||||
L" ", | ||||||||||||||||
8, | ||||||||||||||||
szBackViewString.c_str(), | ||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 不具合修正として直すべき箇所はココだけのように見えました。 |
||||||||||||||||
static_cast<UINT>(szBackViewString.length()), | ||||||||||||||||
pMetrics->GetDxArray_AllHankaku() | ||||||||||||||||
); | ||||||||||||||||
|
||||||||||||||||
|
@@ -154,7 +156,7 @@ void CFigure_Tab::DispSpace(CGraphics& gr, DispPos* pDispPos, CEditView* pcView, | |||||||||||||||
gr, | ||||||||||||||||
nPosLeft, | ||||||||||||||||
sPos.GetDrawPos().y, | ||||||||||||||||
nCharWidth * tabDispWidth - (nPosLeft - sPos.GetDrawPos().x), // Tab Area一杯に 2013/4/11 Uchi | ||||||||||||||||
static_cast<Int>(nTabLayoutWidth) - (nPosLeft - sPos.GetDrawPos().x), // Tab Area一杯に 2013/4/11 Uchi | ||||||||||||||||
Comment on lines
-157
to
+159
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ここもタブのピクセル幅に文字のピクセル幅を乗じていました。 |
||||||||||||||||
pMetrics->GetHankakuHeight(), | ||||||||||||||||
gr.GetCurrentMyFontBold() || m_pTypeData->m_ColorInfoArr[COLORIDX_TAB].m_sFontAttr.m_bBoldFont, | ||||||||||||||||
gr.GetCurrentTextForeColor() | ||||||||||||||||
|
@@ -165,7 +167,7 @@ void CFigure_Tab::DispSpace(CGraphics& gr, DispPos* pDispPos, CEditView* pcView, | |||||||||||||||
} | ||||||||||||||||
|
||||||||||||||||
//Xを進める | ||||||||||||||||
sPos.ForwardDrawCol(tabDispWidthLayout); | ||||||||||||||||
sPos.ForwardDrawCol(nTabLayoutWidth); | ||||||||||||||||
} | ||||||||||||||||
|
||||||||||||||||
/* | ||||||||||||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
CFigure_Tab.cppをコピーした名残だと思われます。
未定義かつ使用されることはないと思うので消してしまいます。