Permalink
Browse files

Merge pull request #964 from lorenzhs/nick-completer-settings

Parse some of WeeChat's completion settings
  • Loading branch information...
lorenzhs committed Oct 9, 2017
2 parents a52a637 + d4d7a97 commit 84018d4bec3d17cd9edafcd55843054959b9d992
Showing with 16 additions and 6 deletions.
  1. +5 −1 js/connection.js
  2. +4 −1 js/inputbar.js
  3. +7 −4 js/irc-utils.js
View
@@ -212,7 +212,11 @@ weechat.factory('connection',
function() {
// Will set models.wconfig['weechat.look.buffer_time_format']
_parseWeechatTimeFormat();
});
});
// Fetch nick completion config
fetchConfValue('weechat.completion.nick_completer');
fetchConfValue('weechat.completion.nick_add_space');
_requestSync();
$log.info("Connected to relay");
View
@@ -89,8 +89,11 @@ weechat.directive('inputBar', function() {
var input = $scope.command || '';
// complete nick
var completion_suffix = models.wconfig['weechat.completion.nick_completer'];
var add_space = models.wconfig['weechat.completion.nick_add_space'];
var nickComp = IrcUtils.completeNick(input, caretPos, $scope.iterCandidate,
activeBuffer.getNicklistByTime(), ':');
activeBuffer.getNicklistByTime(),
completion_suffix, add_space);
// remember iteration candidate
$scope.iterCandidate = nickComp.iterCandidate;
View
@@ -106,17 +106,20 @@ IrcUtils.service('IrcUtils', [function() {
* @param iterCandidate Current iteration candidate (null if not iterating)
* @param nickList Array of current nicks
* @param suf Custom suffix (at least one character, escaped for regex)
* @param addSpace Whether to add a space after nick completion in the middle
* @return Object with following properties:
* text: new complete replacement text
* caretPos: new caret position within new text
* foundNick: completed nick (or null if not possible)
* iterCandidate: current iterating candidate
*/
var completeNick = function(text, caretPos, iterCandidate, nickList, suf) {
var completeNick = function(text, caretPos, iterCandidate, nickList, suf, addSpace) {
var doIterate = (iterCandidate !== null);
if (suf === null) {
if (suf === undefined) {
suf = ':';
}
// addSpace defaults to true
var addSpaceChar = (addSpace === undefined || addSpace === true) ? ' ' : '';
// new nick list to search in
var searchNickList = _ciNickList(nickList);
@@ -182,7 +185,7 @@ IrcUtils.service('IrcUtils', [function() {
if (doIterate) {
// try iterating
newNick = _nextNick(iterCandidate, m[2], searchNickList);
beforeCaret = m[1] + newNick + ' ';
beforeCaret = m[1] + newNick + addSpaceChar;
return {
text: beforeCaret + afterCaret,
caretPos: beforeCaret.length,
@@ -204,7 +207,7 @@ IrcUtils.service('IrcUtils', [function() {
// no match
return ret;
}
beforeCaret = m[1] + newNick + ' ';
beforeCaret = m[1] + newNick + addSpaceChar;
if (afterCaret[0] === ' ') {
// swallow first space after caret if any
afterCaret = afterCaret.substring(1);

0 comments on commit 84018d4

Please sign in to comment.