statisticsdialog.js

来自「QT4 gui programming的随书光盘」· JavaScript 代码 · 共 32 行

JS
32
字号
var obj = new Object;obj.text = "&Statistics...";obj.run = function() {    var text = this.textEdit.plainText;    this.dialog.frame.charCountLineEdit.text = text.length;    this.dialog.frame.wordCountLineEdit.text = this.wordCount(text);    this.dialog.frame.lineCountLineEdit.text = this.lineCount(text);    this.dialog.exec();};obj.wordCount = function(text) {    var regExp = new RegExp("\\w+", "g");    var count = 0;    while (regExp.exec(text))        ++count;    return count;};obj.lineCount = function(text) {    var count = 0;    var pos = 0;    while ((pos = text.indexOf("\n", pos)) != -1) {        ++count;        ++pos;    }    return count + 1;};return obj;

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?