Skip to content

Commit

Permalink
fix termview.js coding style
Browse files Browse the repository at this point in the history
  • Loading branch information
poying committed Aug 1, 2015
1 parent 651d300 commit b627485
Showing 1 changed file with 20 additions and 17 deletions.
37 changes: 20 additions & 17 deletions lib/termview.js
Original file line number Diff line number Diff line change
Expand Up @@ -128,14 +128,14 @@ function setTimer(repeat, func, timelimit) {
cancel: function() {
clearInterval(this.timer);
}
}
};
} else {
return {
timer: setTimeout(func, timelimit),
cancel: function() {
clearTimeout(this.timer);
}
}
};
}
}

Expand Down Expand Up @@ -381,7 +381,8 @@ TermView.prototype={
if(e.ctrlKey && !e.altKey && !e.shiftKey) {
// Ctrl + @, NUL, is not handled here
if( e.charCode >= 65 && e.charCode <=90 ) { // A-Z
if(e.charCode = 67 && this.selection.hasSelection())
e.charCode = 67;

This comment has been minimized.

Copy link
@kidwm

kidwm Aug 1, 2015

Member

@poying 你確定這裡原本不是寫錯的?
@czchen 你怎麼看?

This comment has been minimized.

Copy link
@kidwm

kidwm Aug 1, 2015

Member

是說有時候遇到問題可以去看 pcman-firefox 那邊的比對一下,因為這裡的是從 pcman-chrome 多過了一手來的。

This comment has been minimized.

Copy link
@czchen

czchen Aug 1, 2015

Member

覺得有問題的都先發 issue,等到要補 unit test 時再看看行為對不對。

This comment has been minimized.

Copy link
@poying

poying Aug 2, 2015

Author Contributor

還沒細看程式碼,只是先調 coding style 而已

This comment has been minimized.

Copy link
@u881831

u881831 Aug 23, 2015

這邊是我先前寫錯了,應該是 == 。

if(this.selection.hasSelection())
conn.listener.copy(); // ctrl+c
else
conn.send( String.fromCharCode(e.charCode - 64) );
Expand All @@ -390,7 +391,8 @@ TermView.prototype={
return;
}
else if( e.charCode >= 97 && e.charCode <=122 ) { // a-z
if(e.charCode = 67 && this.selection.hasSelection())

This comment has been minimized.

Copy link
@jessy1092

jessy1092 Aug 23, 2015

Contributor

@u881831 這邊呢? 如果是 == ,看起來是無法走到。

感覺是 e.charCode === 99 小寫 c

This comment has been minimized.

Copy link
@u881831

u881831 Jul 3, 2016

這邊也是寫錯了,應該是 99 。不同瀏覽器用不同代碼的話就容易沒測到這些 bugs , pcman-chrome 那邊的程式碼可能需要重構。

e.charCode = 67;
if(this.selection.hasSelection())
conn.listener.copy(); // ctrl+c
else
conn.send( String.fromCharCode(e.charCode - 96) );
Expand Down Expand Up @@ -661,7 +663,7 @@ TermView.prototype={
},

drawCursor: function(){
if(this.chh == 0 || this.chw == 0)
if(this.chh === 0 || this.chw === 0)
return;

var ctx=this.ctx;
Expand All @@ -674,11 +676,11 @@ TermView.prototype={

if(this.cursorShow) {
if(this.buf) {
var line = this.buf.lines[row];
let line = this.buf.lines[row];
if(!line)
return;
var ch=line[col];
var fg=ch.getFg();
let ch=line[col];
let fg=ch.getFg();
ctx.save();
ctx.fillStyle=termColors[fg];
ctx.fillRect(this.cursorX, this.cursorY, this.cursorW, this.cursorH);
Expand All @@ -690,16 +692,17 @@ TermView.prototype={
}
else {
if(this.buf) {
var line = this.buf.lines[row];
let line = this.buf.lines[row];
if(!line)
return;
var ch = line[col];
let ch = line[col];
if(!ch.needUpdate)
this.doDrawChar(line, ch, row, col, this.cursorX, row * this.chh);
if(line.uris) { // has URI in this line
var n=line.uris.length;
for(var i=0; i<n;++i) {
var uri=line.uris[i];
let n=line.uris.length;
let i = 0;
for(; i < n; ++i) {
let uri = line.uris[i];
if(uri[0] <= col && uri[1] > col) { // the char is part of a URI
// draw underline for URI.
ctx.strokeStyle = uriColor;
Expand Down Expand Up @@ -763,7 +766,7 @@ TermView.prototype={
//if(this.conn.listener.menu.onclick(event.pageX, event.pageY))
// return; // let context menu handle it

if(event.button == 0) { // left button
if(event.button === 0) { // left button
var cursor = this.mouseToColRow(event.pageX, event.pageY);
if(!cursor) return;
// FIXME: only handle left button
Expand Down Expand Up @@ -798,7 +801,7 @@ TermView.prototype={
var cursor = this.mouseToColRow(event.pageX, event.pageY);
if(!cursor) return;

if(event.button == 0) { // left button
if(event.button === 0) { // left button
if(this.selection.isSelecting)
this.selection.selEnd(cursor.col, cursor.row);
} else if(event.button == 1) { // middle button
Expand All @@ -821,7 +824,7 @@ TermView.prototype={

var uri = this.checkURI(cursor, true);
if(uri) {
if(event.button == 0) // left button
if(event.button === 0) // left button
this.opener(uri);
else if(event.button == 1) // middle button
this.opener(uri);
Expand Down Expand Up @@ -864,6 +867,6 @@ TermView.prototype={
removeEventListener: function() {
this.inputHandler.unload();
}
}
};

module.exports = TermView;

0 comments on commit b627485

Please sign in to comment.