Guitar
Classes | Public Types | Signals | Public Member Functions | Public Attributes | Protected Member Functions | Private Member Functions | Private Attributes | List of all members
TextEditorView Class Reference

#include <TextEditorView.h>

Inheritance diagram for TextEditorView:
Inheritance graph
[legend]
Collaboration diagram for TextEditorView:
Collaboration graph
[legend]

Classes

class  FormattedLine
 
class  FormattedLines
 
struct  PointInView
 
struct  Private
 

Public Types

enum  ScrollUnit { ScrollByCharacter = 0 }
 
- Public Types inherited from AbstractCharacterBasedApplication
enum  WriteMode { WriteMode::Insert, WriteMode::Overwrite }
 
enum  State { State::Normal, State::Exit }
 
enum  LineFlag { LineChanged = 1 }
 

Signals

void moved (int cur_row, int cur_col, int scr_row, int scr_col)
 
void updateScrollBar ()
 
void idle ()
 

Public Member Functions

void internalUpdateScrollBar ()
 
FormattedLinesfetchLines ()
 ビューに表示されている範囲のテキストを取得 More...
 
int basisCharWidth () const
 基準文字幅 More...
 
 TextEditorView (QWidget *parent=nullptr)
 
 ~TextEditorView () override
 
void setTheme (const TextEditorThemePtr &theme)
 
const TextEditorThemetheme () const
 
int lineHeight () const
 行の高さ More...
 
void updateVisibility (bool ensure_current_line_visible, bool change_col, bool auto_scroll) override
 
bool event (QEvent *event) override
 
void bindScrollBar (QScrollBar *vsb, QScrollBar *hsb)
 
void setupForLogWidget (const TextEditorThemePtr &theme)
 
RowCol mapFromPixel (const QPoint &pt)
 ビューのピクセル座標から行と桁を求める More...
 
QVariant inputMethodQuery (Qt::InputMethodQuery q) const override
 
void inputMethodEvent (QInputMethodEvent *e) override
 
void refrectScrollBar ()
 
void move (int cur_row, int cur_col, int scr_row, int scr_col, bool auto_scroll)
 
void layoutEditor () override
 
void setFocusFrameVisible (bool f)
 
void setScrollUnit (int n)
 
int scrollUnit () const
 
void setTextFont (const QFont &font)
 
void updateLayout ()
 
PointInView pointInView (int row, int col) const
 行と桁からビュー座標を求める More...
 
void setSomethingBadFlag (bool f)
 
- Public Member Functions inherited from AbstractCharacterBasedApplication
QList< FormattedLine2formatLine_ (const Document::Line &line, int tab_span, int anchor_a=-1, int anchor_b=-1) const
 
QList< FormattedLine2formatLine2_ (int row_index) const
 
int currentRow () const
 
int currentCol () const
 
void scrollUp ()
 
void scrollDown ()
 
void moveCursorOut ()
 
void moveCursorHome ()
 
void moveCursorEnd ()
 
void moveCursorUp ()
 
virtual void moveCursorDown ()
 
void moveCursorLeft ()
 
void moveCursorRight ()
 
void movePageUp ()
 
void movePageDown ()
 
void scrollToTop ()
 
 AbstractCharacterBasedApplication ()
 
virtual ~AbstractCharacterBasedApplication ()
 
TextEditorEnginePtr engine () const
 
int screenWidth () const
 
int screenHeight () const
 
void setScreenSize (int w, int h, bool update_layout)
 
void setTextEditorEngine (const TextEditorEnginePtr &e)
 
void openFile (QString const &path)
 
void saveFile (QString const &path)
 
void loadExampleFile ()
 
void pressEnter ()
 
void pressEscape ()
 
State state () const
 
bool isLineNumberVisible () const
 
void showLineNumber (bool show, int left_margin=LEFT_MARGIN)
 
void showHeader (bool f)
 
void showFooter (bool f)
 
void setAutoLayout (bool f)
 
void setDocument (const QList< Document::Line > *source)
 
void setSelectionAnchor (SelectionAnchor::Enabled enabled, bool update_anchor, bool auto_scroll)
 
void setNormalTextEditorMode (bool f)
 
void setToggleSelectionAnchorEnabled (bool f)
 
void setReadOnly (bool f)
 
bool isReadOnly () const
 
void editPaste ()
 
void editCopy ()
 
void editCut ()
 
void setWriteMode (WriteMode wm)
 
bool isInsertMode () const
 
bool isOverwriteMode () const
 
void setTerminalMode (bool f)
 
bool isTerminalMode () const
 
void moveToTop ()
 
void moveToBottom ()
 
bool isBottom () const
 
void setLineMargin (int n)
 
void write (uint32_t c, bool by_keyboard)
 
void write (char const *ptr, int len, bool by_keyboard)
 
void write (std::string const &text)
 
void write (QKeyEvent *e)
 
void setTextCodec (QTextCodec *codec)
 
void setCursorVisible (bool show)
 
bool isCursorVisible ()
 
void setModifierKeys (Qt::KeyboardModifiers keymod)
 
bool isControlModifierPressed () const
 
bool isShiftModifierPressed () const
 
void clearShiftModifier ()
 
void retrieveLastText (std::vector< char > *out, int maxlen) const
 
bool isChanged () const
 
void setChanged (bool f)
 
void logicalMoveToBottom ()
 
void logicalMoveToBottom2 ()
 
void appendBulk (const char *ptr, int len)
 
void clear ()
 

Public Attributes

int scroll_unit_ = ScrollByCharacter
 
bool something_bad_flag = false
 

Protected Member Functions

void paintEvent (QPaintEvent *) override
 描画 More...
 
void mousePressEvent (QMouseEvent *event) override
 
void mouseReleaseEvent (QMouseEvent *event) override
 
void mouseMoveEvent (QMouseEvent *event) override
 
void wheelEvent (QWheelEvent *event) override
 
void resizeEvent (QResizeEvent *event) override
 
void contextMenuEvent (QContextMenuEvent *event) override
 
QFont textFont () const
 
void drawText (QPainter *painter, int px, int py, QString const &str)
 
void timerEvent (QTimerEvent *) override
 
void setCursorCol (int col) override
 桁位置を変更する More...
 
void setCursorRow (int row, bool auto_scroll, bool by_mouse) override
 行位置を変更する More...
 
- Protected Member Functions inherited from AbstractCharacterBasedApplication
int char_screen_w () const
 
int char_screen_h () const
 
std::vector< Character > * char_screen ()
 
const std::vector< Character > * char_screen () const
 
std::vector< uint8_t > * line_flags ()
 
void initEditor ()
 
void fetchCurrentLine () const
 
QByteArray fetchLine (int row) const
 現在行を取得 More...
 
void clearParsedLine ()
 
int currentColX () const
 
void setCurrentRow (int row)
 
void setCurrentCol (int col)
 
int cursorCol () const
 
int cursorRow () const
 
int editorViewportWidth () const
 
int editorViewportHeight () const
 
virtual int print (int x, int y, QString const &text, Option const &opt)
 
TextEditorContextcx ()
 
const TextEditorContextcx () const
 
Documentdocument ()
 
int documentLines () const
 
bool isSingleLineMode () const
 
void ensureCurrentLineVisible ()
 
int decideColumnScrollPos () const
 
int calcVisualWidth (Document::Line const &line) const
 
int leftMargin_ () const
 
void makeBuffer ()
 
int printArea (const TextEditorContext *cx, SelectionAnchor const *sel_a=nullptr, SelectionAnchor const *sel_b=nullptr)
 
void commitLine (const std::vector< Char > &vec)
 
void doDelete ()
 
void doBackspace ()
 
bool isDialogMode ()
 
void setDialogMode (bool f)
 
void closeDialog (bool result)
 
void setDialogOption (QString const &title, QString const &value, const DialogHandler &handler)
 
void execDialog (QString const &dialog_title, const QString &dialog_value, const DialogHandler &handler)
 
void deselect ()
 
std::vector< Char > * parseCurrentLine (std::vector< Char > *vec, int increase_hint, bool force)
 行のレイアウトを解析 More...
 
void parseLine (int row, std::vector< Char > *vec) const
 行の桁位置を求める More...
 
void setCursorPosByMouse (RowCol pos, QPoint pt)
 
void setCursorPos (int row, int col)
 
int nextTabStop (int x) const
 
int scrollBottomLimit () const
 
int scrollBottomLimit2 () const
 
bool isPaintingSuppressed () const
 
void setPaintingSuppressed (bool f)
 
void addNewLineToBottom ()
 
void appendNewLine (std::vector< Char > *vec)
 
void writeNewLine ()
 
void updateCursorPos (bool auto_scroll)
 
QString statusLine () const
 
void preparePaintScreen ()
 
void setRecentlyUsedPath (QString const &path)
 
QString recentlyUsedPath ()
 
void clearRect (int x, int y, int w, int h)
 
void paintLineNumbers (std::function< void(int, QString const &, Document::Line const *)> const &draw)
 
bool isAutoLayout () const
 
void invalidateArea (int top_y=0)
 
void savePos ()
 
void restorePos ()
 
void write_ (char const *ptr, bool by_keyboard)
 
void write_ (QString const &text, bool by_keyboard)
 
void makeColumnPosList (std::vector< int > *out)
 現在行の桁座標リストを作成する More...
 
bool isValidRowIndex (int row_index) const
 
bool hasSelection () const
 
void updateSelectionAnchor1 (bool auto_scroll)
 
void updateSelectionAnchor2 (bool auto_scroll)
 

Private Member Functions

void paintScreen (QPainter *painter)
 描画(CharacterMode用) More...
 
void drawCursor (int row, int col, QPainter *pr, QColor const &color)
 カーソルを描画 More...
 
void drawCursor (QPainter *pr)
 現在位置にカーソルを描画 More...
 
void drawFocusFrame (QPainter *pr)
 
void updateCursorRect (bool auto_scroll)
 
QColor defaultForegroundColor ()
 
QColor defaultBackgroundColor ()
 
QColor colorForIndex (CharAttr const &attr, bool foreground)
 
void internalUpdateVisibility (bool ensure_current_line_visible, bool change_col, bool auto_scroll)
 
void moveCursorByMouse ()
 
int calcPixelPosX (int row, int col, bool adjust_scroll, std::vector< Char > *chars) const
 行と桁位置からピクセルX座標を求める More...
 
void parse (int row, std::vector< Char > *chars) const
 
int scrollPosX () const
 水平スクロール位置のピクセル値を取得 More...
 
void calcPixelPosX (std::vector< Char > *chars, const QFontMetrics &fm) const
 全文字のX座標を計算する More...
 
int view_y_from_row (int row) const
 

Private Attributes

Privatem
 

Additional Inherited Members

- Static Public Member Functions inherited from AbstractCharacterBasedApplication
static int charWidth (uint32_t c)
 
- Static Public Attributes inherited from AbstractCharacterBasedApplication
static const int LEFT_MARGIN = 8
 
static const int RIGHT_MARGIN = 10
 
- Protected Attributes inherited from AbstractCharacterBasedApplication
SelectionAnchor selection_start
 
SelectionAnchor selection_end
 
const int reference_char_width_ = 1
 
std::shared_ptr< TextEditorContexteditor_cx
 
std::shared_ptr< TextEditorContextdialog_cx
 

Member Enumeration Documentation

◆ ScrollUnit

Enumerator
ScrollByCharacter 

Constructor & Destructor Documentation

◆ TextEditorView()

TextEditorView::TextEditorView ( QWidget *  parent = nullptr)
explicit
Here is the call graph for this function:

◆ ~TextEditorView()

TextEditorView::~TextEditorView ( )
override

Member Function Documentation

◆ basisCharWidth()

int TextEditorView::basisCharWidth ( ) const

基準文字幅

Returns

◆ bindScrollBar()

void TextEditorView::bindScrollBar ( QScrollBar *  vsb,
QScrollBar *  hsb 
)

◆ calcPixelPosX() [1/2]

int TextEditorView::calcPixelPosX ( int  row,
int  col,
bool  adjust_scroll,
std::vector< Char > *  chars 
) const
private

行と桁位置からピクセルX座標を求める

Parameters
row
col
adjust_scroll
chars(nullptr可)
Returns
Here is the call graph for this function:

◆ calcPixelPosX() [2/2]

void TextEditorView::calcPixelPosX ( std::vector< Char > *  chars,
const QFontMetrics &  fm 
) const
private

全文字のX座標を計算する

Parameters
chars
fm
Here is the call graph for this function:

◆ colorForIndex()

QColor TextEditorView::colorForIndex ( CharAttr const &  attr,
bool  foreground 
)
private
Here is the call graph for this function:

◆ contextMenuEvent()

void TextEditorView::contextMenuEvent ( QContextMenuEvent *  event)
overrideprotected
Here is the call graph for this function:

◆ defaultBackgroundColor()

QColor TextEditorView::defaultBackgroundColor ( )
private
Here is the call graph for this function:

◆ defaultForegroundColor()

QColor TextEditorView::defaultForegroundColor ( )
private
Here is the call graph for this function:

◆ drawCursor() [1/2]

void TextEditorView::drawCursor ( int  row,
int  col,
QPainter *  pr,
QColor const &  color 
)
private

カーソルを描画

Parameters
row
col
pr
color
Here is the call graph for this function:

◆ drawCursor() [2/2]

void TextEditorView::drawCursor ( QPainter *  pr)
private

現在位置にカーソルを描画

Parameters
pr
color
Here is the call graph for this function:

◆ drawFocusFrame()

void TextEditorView::drawFocusFrame ( QPainter *  pr)
private
Here is the call graph for this function:

◆ drawText()

void TextEditorView::drawText ( QPainter *  painter,
int  px,
int  py,
QString const &  str 
)
protected
Here is the call graph for this function:

◆ event()

bool TextEditorView::event ( QEvent *  event)
override
Here is the call graph for this function:

◆ fetchLines()

TextEditorView::FormattedLines * TextEditorView::fetchLines ( )

ビューに表示されている範囲のテキストを取得

Returns
Here is the call graph for this function:

◆ idle

void TextEditorView::idle ( )
signal

◆ inputMethodEvent()

void TextEditorView::inputMethodEvent ( QInputMethodEvent *  e)
override
Here is the call graph for this function:

◆ inputMethodQuery()

QVariant TextEditorView::inputMethodQuery ( Qt::InputMethodQuery  q) const
override
Here is the call graph for this function:

◆ internalUpdateScrollBar()

void TextEditorView::internalUpdateScrollBar ( )
Here is the call graph for this function:

◆ internalUpdateVisibility()

void TextEditorView::internalUpdateVisibility ( bool  ensure_current_line_visible,
bool  change_col,
bool  auto_scroll 
)
private
Here is the call graph for this function:

◆ layoutEditor()

void TextEditorView::layoutEditor ( )
overridevirtual

Reimplemented from AbstractCharacterBasedApplication.

Here is the call graph for this function:

◆ lineHeight()

int TextEditorView::lineHeight ( ) const

行の高さ

Returns

◆ mapFromPixel()

RowCol TextEditorView::mapFromPixel ( const QPoint &  pt)

ビューのピクセル座標から行と桁を求める

Parameters
pt
Returns
Here is the call graph for this function:

◆ mouseMoveEvent()

void TextEditorView::mouseMoveEvent ( QMouseEvent *  event)
overrideprotected
Here is the call graph for this function:

◆ mousePressEvent()

void TextEditorView::mousePressEvent ( QMouseEvent *  event)
overrideprotected
Here is the call graph for this function:

◆ mouseReleaseEvent()

void TextEditorView::mouseReleaseEvent ( QMouseEvent *  event)
overrideprotected
Here is the call graph for this function:

◆ move()

void TextEditorView::move ( int  cur_row,
int  cur_col,
int  scr_row,
int  scr_col,
bool  auto_scroll 
)
Here is the call graph for this function:

◆ moveCursorByMouse()

void TextEditorView::moveCursorByMouse ( )
private
Here is the call graph for this function:

◆ moved

void TextEditorView::moved ( int  cur_row,
int  cur_col,
int  scr_row,
int  scr_col 
)
signal

◆ paintEvent()

void TextEditorView::paintEvent ( QPaintEvent *  )
overrideprotected

描画

テキストの描画前に fetchLines() を呼ぶこと
Here is the call graph for this function:

◆ paintScreen()

void TextEditorView::paintScreen ( QPainter *  painter)
private

描画(CharacterMode用)

Parameters
painter
Here is the call graph for this function:

◆ parse()

void TextEditorView::parse ( int  row,
std::vector< Char > *  chars 
) const
private
Here is the call graph for this function:

◆ pointInView()

TextEditorView::PointInView TextEditorView::pointInView ( int  row,
int  col 
) const

行と桁からビュー座標を求める

Parameters
row
col
Returns
Here is the call graph for this function:

◆ refrectScrollBar()

void TextEditorView::refrectScrollBar ( )
Here is the call graph for this function:

◆ resizeEvent()

void TextEditorView::resizeEvent ( QResizeEvent *  event)
overrideprotected
Here is the call graph for this function:

◆ scrollPosX()

int TextEditorView::scrollPosX ( ) const
private

水平スクロール位置のピクセル値を取得

Returns
Here is the call graph for this function:

◆ scrollUnit()

int TextEditorView::scrollUnit ( ) const

◆ setCursorCol()

void TextEditorView::setCursorCol ( int  col)
overrideprotectedvirtual

桁位置を変更する

Parameters
col

Reimplemented from AbstractCharacterBasedApplication.

Here is the call graph for this function:

◆ setCursorRow()

void TextEditorView::setCursorRow ( int  row,
bool  auto_scroll,
bool  by_mouse 
)
overrideprotectedvirtual

行位置を変更する

Parameters
row
auto_scroll
by_mouse

Reimplemented from AbstractCharacterBasedApplication.

Here is the call graph for this function:

◆ setFocusFrameVisible()

void TextEditorView::setFocusFrameVisible ( bool  f)

◆ setScrollUnit()

void TextEditorView::setScrollUnit ( int  n)

◆ setSomethingBadFlag()

void TextEditorView::setSomethingBadFlag ( bool  f)
inline

◆ setTextFont()

void TextEditorView::setTextFont ( const QFont &  font)

◆ setTheme()

void TextEditorView::setTheme ( const TextEditorThemePtr theme)
Here is the call graph for this function:

◆ setupForLogWidget()

void TextEditorView::setupForLogWidget ( const TextEditorThemePtr theme)
Here is the call graph for this function:

◆ textFont()

QFont TextEditorView::textFont ( ) const
protected

◆ theme()

const TextEditorTheme * TextEditorView::theme ( ) const
Here is the call graph for this function:

◆ timerEvent()

void TextEditorView::timerEvent ( QTimerEvent *  )
overrideprotected
Here is the call graph for this function:

◆ updateCursorRect()

void TextEditorView::updateCursorRect ( bool  auto_scroll)
private
Here is the call graph for this function:

◆ updateLayout()

void TextEditorView::updateLayout ( )
Here is the call graph for this function:

◆ updateScrollBar

void TextEditorView::updateScrollBar ( )
signal

◆ updateVisibility()

void TextEditorView::updateVisibility ( bool  ensure_current_line_visible,
bool  change_col,
bool  auto_scroll 
)
overridevirtual

Implements AbstractCharacterBasedApplication.

Here is the call graph for this function:

◆ view_y_from_row()

int TextEditorView::view_y_from_row ( int  row) const
private
Here is the call graph for this function:

◆ wheelEvent()

void TextEditorView::wheelEvent ( QWheelEvent *  event)
overrideprotected

Member Data Documentation

◆ m

Private* TextEditorView::m
private

◆ scroll_unit_

int TextEditorView::scroll_unit_ = ScrollByCharacter

◆ something_bad_flag

bool TextEditorView::something_bad_flag = false

The documentation for this class was generated from the following files: