-
Notifications
You must be signed in to change notification settings - Fork 199
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
Add text statistics next to the cursor position #268
Conversation
Sorry for the delay with reviewing your requests.
Also, did you perform any performance checks? How slow is it on large (or huge) documents? I can look at these issues myself, but in this case you will need to wait a bit more. |
Hi, good idea about the translation, I'm going to add it. I thought about the performance issue, and might add an option to enable / disable this feature. |
fe42a94
to
8f5d437
Compare
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.
-
How about using a common class from which LineNumberArea and StatsArea can inherit, to avoid duplicating code?
-
The word count currently shows a number less by one from the actual word count. I.e. if my document is “foo bar”, not ending with a space, it shows 1 instead of 2.
ReText/editor.py
Outdated
self.setPalette(palette) | ||
|
||
def mousePressEvent(self, event): | ||
pos = self.mapToParent(event.pos()) | ||
pos.setX(pos.x() - self.editor.lineNumberAreaWidth()) | ||
newEvent = QMouseEvent(event.type(), pos, | ||
event.button(), event.buttons(), |
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.
This file uses tabs for indentation, but spaces for alignment. Please do not change this.
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.
✔️
ReText/editor.py
Outdated
wordCount += 1 | ||
wasWordCharacter = isWordCharacter | ||
end = time.clock() | ||
value = int((end - start) * 1000) |
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.
Are these start / end / value lines a leftover debug? Can you please share your time measurements?
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.
Yes they were left over, sorry.
On my laptop, for a 100k document (100'000 characters, 3500 lines), I get an average of 40ms to compute the stats
ReText/editor.py
Outdated
def getText(self): | ||
if not globalSettings.documentStatsEnabled: | ||
return | ||
template = '%d w : %d a : %d c' |
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.
Please make this translatable.
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.
✔️
This adds a word count, alpha numeric character count and all character count in the bottom left corner This option can be disabled from the Preferences dialog (by default it's off). The statistic is only updated when the content changes (to avoid recomputing when scrolling or resizing the window). On my lapop, the computing only takes 40ms for a 100'000 characters markdown document (roughly 15'000 words, 3'500 lines). Fixes retext-project#164
I updated the PR with your recommendation : a base class for additional information (LineInfo / Text Info), and updated the text analysis to correct the word count |
Thank you! |
This adds a word count, alpha numeric character count and all character
count in the bottom right corner, with the cursor line and column
position
Fixes #164