Skip to content
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

New function: goto line #114

Merged
merged 2 commits into from Jan 17, 2014
Merged

New function: goto line #114

merged 2 commits into from Jan 17, 2014

Conversation

Slesa
Copy link
Contributor

@Slesa Slesa commented Jan 16, 2014

have two problems:

  • the line number is not calculated correctly when using head lines
  • the input dialog should get current line and maximum line

Cursor movement seems to be rocket science in Qt5.

@cloose cloose mentioned this pull request Jan 16, 2014
{
bool ok;
int line = QInputDialog::getInt(this, tr("Go to..."),
tr("line: "), 1, 1, ui->plainTextEdit->document()->blockCount(), 1, &ok);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • "line: " ==> "Line:"
  • ui->plainTextEdit->document()->blockCount() ==> ui->plainTextEdit->document()->lineCount()
  • maybe introduce local constants to make this more readable:
void MainWindow::editGotoLine()
{
    const int STEP = 1;
    const int MIN_VALUE = 1;
    ...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One thing is left: determine the current line...

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The following code should do the trick:

int currentLine = ui->plainTextEdit->textCursor().blockNumber()+1;

@ghost ghost assigned cloose Jan 17, 2014
cloose added a commit that referenced this pull request Jan 17, 2014
Add "go to line" menu item.

Add a new menu item "Go to Line" that allows the user to position the cursor to a specific line in the Markdown document.
@cloose cloose merged commit 3282a95 into cloose:develop Jan 17, 2014
@Slesa Slesa deleted the feature/GotoLine branch January 23, 2014 06:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants