Support clearing of buffer lines with command /c or /clear
This commit is contained in:
parent
9f6f598f40
commit
f21cf4c046
2 changed files with 26 additions and 2 deletions
|
@ -427,6 +427,7 @@ function($rootScope,
|
||||||
|
|
||||||
|
|
||||||
var fetchMoreLines = function(numLines) {
|
var fetchMoreLines = function(numLines) {
|
||||||
|
$log.debug('Fetching ', numLines, ' lines');
|
||||||
var buffer = models.getActiveBuffer();
|
var buffer = models.getActiveBuffer();
|
||||||
if (numLines === undefined) {
|
if (numLines === undefined) {
|
||||||
// Math.max(undefined, *) = NaN -> need a number here
|
// Math.max(undefined, *) = NaN -> need a number here
|
||||||
|
@ -506,7 +507,7 @@ weechat.controller('WeechatCtrl', ['$rootScope', '$scope', '$store', '$timeout',
|
||||||
q.push(scope.$$nextSibling);
|
q.push(scope.$$nextSibling);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
console.log(watchers);
|
$log.debug(watchers);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -1208,6 +1209,7 @@ weechat.directive('inputBar', function() {
|
||||||
controller: function($rootScope,
|
controller: function($rootScope,
|
||||||
$scope,
|
$scope,
|
||||||
$element,
|
$element,
|
||||||
|
$log,
|
||||||
connection,
|
connection,
|
||||||
models) {
|
models) {
|
||||||
|
|
||||||
|
@ -1251,11 +1253,23 @@ weechat.directive('inputBar', function() {
|
||||||
$scope.sendMessage = function() {
|
$scope.sendMessage = function() {
|
||||||
|
|
||||||
var input = $scope.getInputNode();
|
var input = $scope.getInputNode();
|
||||||
models.getActiveBuffer().addToHistory(input.value); // log to buffer history
|
var ab = models.getActiveBuffer();
|
||||||
|
|
||||||
|
// log to buffer history
|
||||||
|
ab.addToHistory(input.value);
|
||||||
|
|
||||||
// Split the command into multiple commands based on line breaks
|
// Split the command into multiple commands based on line breaks
|
||||||
_.each($scope.command.split(/\r?\n/), function(line) {
|
_.each($scope.command.split(/\r?\n/), function(line) {
|
||||||
connection.sendMessage(line);
|
connection.sendMessage(line);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Check for /clear command
|
||||||
|
if ($scope.command === '/clear' || $scope.command === '/c') {
|
||||||
|
$log.debug('Clearing lines');
|
||||||
|
ab.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Empty the input after it's sent
|
||||||
input.value = '';
|
input.value = '';
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
10
js/models.js
10
js/models.js
|
@ -19,6 +19,7 @@ models.service('models', ['$rootScope', '$filter', function($rootScope, $filter)
|
||||||
var notify = 3; // Default 3 == message
|
var notify = 3; // Default 3 == message
|
||||||
var lines = [];
|
var lines = [];
|
||||||
var requestedLines = 0;
|
var requestedLines = 0;
|
||||||
|
var allLinesFetched = false;
|
||||||
var nicklist = {};
|
var nicklist = {};
|
||||||
var history = [];
|
var history = [];
|
||||||
var historyPos = 0;
|
var historyPos = 0;
|
||||||
|
@ -197,6 +198,14 @@ models.service('models', ['$rootScope', '$filter', function($rootScope, $filter)
|
||||||
return nicklist.hasOwnProperty('root');
|
return nicklist.hasOwnProperty('root');
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/* Clear all our buffer lines */
|
||||||
|
var clear = function() {
|
||||||
|
while(lines.length > 0) {
|
||||||
|
lines.pop();
|
||||||
|
}
|
||||||
|
requestedLines = 0;
|
||||||
|
};
|
||||||
|
|
||||||
return {
|
return {
|
||||||
id: pointer,
|
id: pointer,
|
||||||
fullName: fullName,
|
fullName: fullName,
|
||||||
|
@ -204,6 +213,7 @@ models.service('models', ['$rootScope', '$filter', function($rootScope, $filter)
|
||||||
number: number,
|
number: number,
|
||||||
title: title,
|
title: title,
|
||||||
lines: lines,
|
lines: lines,
|
||||||
|
clear: clear,
|
||||||
requestedLines: requestedLines,
|
requestedLines: requestedLines,
|
||||||
addLine: addLine,
|
addLine: addLine,
|
||||||
lastSeen: lastSeen,
|
lastSeen: lastSeen,
|
||||||
|
|
Loading…
Reference in a new issue