From a94bca69b87f3de5fbe9ee5166a841d351c0a303 Mon Sep 17 00:00:00 2001 From: kamecha Date: Fri, 22 Dec 2023 14:23:03 +0900 Subject: [PATCH 1/6] =?UTF-8?q?ddu=E3=81=AE=E3=82=AB=E3=83=A9=E3=83=A0?= =?UTF-8?q?=E3=81=AE=E3=83=86=E3=83=B3=E3=83=97=E3=83=AC=E3=82=92=E8=BF=BD?= =?UTF-8?q?=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- denops/@ddu-columns/channel.ts | 17 +++++++++++++++++ denops/traqvim/deps.ts | 1 + 2 files changed, 18 insertions(+) create mode 100644 denops/@ddu-columns/channel.ts diff --git a/denops/@ddu-columns/channel.ts b/denops/@ddu-columns/channel.ts new file mode 100644 index 0000000..3d32c04 --- /dev/null +++ b/denops/@ddu-columns/channel.ts @@ -0,0 +1,17 @@ +import { dduVim, dduVimColumn } from "../traqvim/deps.ts"; + +export type Params = Record; + +export class Column extends dduVim.BaseColumn { + getLength({}: dduVimColumn.GetLengthArguments): Promise { + throw new Error("Method not implemented."); + } + getText( + {}: dduVimColumn.GetTextArguments, + ): Promise { + throw new Error("Method not implemented."); + } + params(): Params { + throw new Error("Method not implemented."); + } +} diff --git a/denops/traqvim/deps.ts b/denops/traqvim/deps.ts index e7f2989..f9b3f41 100644 --- a/denops/traqvim/deps.ts +++ b/denops/traqvim/deps.ts @@ -16,4 +16,5 @@ export * as ddcVim from "https://deno.land/x/ddc_vim@v3.4.0/types.ts"; export * as ddcVimSource from "https://deno.land/x/ddc_vim@v3.4.0/base/source.ts"; export * as dduVim from "https://deno.land/x/ddu_vim@v1.13.0/types.ts"; export * as dduVimSource from "https://deno.land/x/ddu_vim@v1.13.0/base/source.ts"; +export * as dduVimColumn from "https://deno.land/x/ddu_vim@v1.13.0/base/column.ts"; export * as traq from "https://esm.sh/@traptitech/traq@3.11.0-3"; From 04db32708faeddd0b6a74ed8766300bc99f10b9b Mon Sep 17 00:00:00 2001 From: kamecha Date: Fri, 22 Dec 2023 15:25:06 +0900 Subject: [PATCH 2/6] =?UTF-8?q?=E3=81=9D=E3=82=8C=E3=81=9E=E3=82=8C?= =?UTF-8?q?=E3=81=AE=E3=83=81=E3=83=A3=E3=83=B3=E3=83=8D=E3=83=AB=E7=94=A8?= =?UTF-8?q?=E3=81=AE=E3=82=A2=E3=82=A4=E3=82=B3=E3=83=B3=E3=82=92Param?= =?UTF-8?q?=E3=81=A8=E3=81=97=E3=81=A6=E8=A8=AD=E5=AE=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- denops/@ddu-columns/channel.ts | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/denops/@ddu-columns/channel.ts b/denops/@ddu-columns/channel.ts index 3d32c04..7defca6 100644 --- a/denops/@ddu-columns/channel.ts +++ b/denops/@ddu-columns/channel.ts @@ -1,6 +1,11 @@ import { dduVim, dduVimColumn } from "../traqvim/deps.ts"; -export type Params = Record; +export type Params = { + collapsedParentIcon: string; + expandedParentIcon: string; + leafIcon: string; + indentationWidth: number; +}; export class Column extends dduVim.BaseColumn { getLength({}: dduVimColumn.GetLengthArguments): Promise { @@ -12,6 +17,11 @@ export class Column extends dduVim.BaseColumn { throw new Error("Method not implemented."); } params(): Params { - throw new Error("Method not implemented."); + return { + collapsedParentIcon: "󱅿", + expandedParentIcon: "󰐤", + leafIcon: "󰐣", + indentationWidth: 2, + }; } } From 1f34f2f2a1735fe0d728c39bbb771a020b01c4b2 Mon Sep 17 00:00:00 2001 From: kamecha Date: Fri, 22 Dec 2023 16:05:41 +0900 Subject: [PATCH 3/6] =?UTF-8?q?ddu=E3=81=A7column=E3=81=8C=E8=A1=A8?= =?UTF-8?q?=E7=A4=BA=E3=81=95=E3=82=8C=E3=82=8B=E3=82=88=E3=81=86=E3=81=AB?= =?UTF-8?q?=E4=B8=80=E5=BF=9C=E3=81=97=E3=81=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- denops/@ddu-columns/channel.ts | 27 +++++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-) diff --git a/denops/@ddu-columns/channel.ts b/denops/@ddu-columns/channel.ts index 7defca6..194c8f2 100644 --- a/denops/@ddu-columns/channel.ts +++ b/denops/@ddu-columns/channel.ts @@ -8,13 +8,32 @@ export type Params = { }; export class Column extends dduVim.BaseColumn { - getLength({}: dduVimColumn.GetLengthArguments): Promise { - throw new Error("Method not implemented."); + // TODO: ↓この関数が何やってるのか調べとく + // 現状0を返してるけど、なんかちゃんと表示されちゃってる + getLength( + args: dduVimColumn.GetLengthArguments, + ): Promise { + const widths: number[] = args.items.map((item) => { + // TODO: ↓ここでdisplayが空文字列になってるので、原因調べとく + const display = item.display ?? item.word; + return display.length; + }); + return Promise.resolve(Math.max(...widths)); } getText( - {}: dduVimColumn.GetTextArguments, + args: dduVimColumn.GetTextArguments, ): Promise { - throw new Error("Method not implemented."); + const parentIcon = args.item.__expanded + ? args.columnParams.expandedParentIcon + : args.columnParams.collapsedParentIcon; + const isParent = args.item.isTree ?? false; + const icon = isParent ? parentIcon : args.columnParams.leafIcon; + const text = + " ".repeat(args.columnParams.indentationWidth * args.item.__level) + + icon + " " + args.item.word; + return Promise.resolve({ + text, + }); } params(): Params { return { From cac9487a233ba0bc8d214518dc4c4a5a4503c97c Mon Sep 17 00:00:00 2001 From: kamecha Date: Fri, 22 Dec 2023 16:14:16 +0900 Subject: [PATCH 4/6] =?UTF-8?q?channel=E3=82=BD=E3=83=BC=E3=82=B9=E3=81=AF?= =?UTF-8?q?=E5=8D=98=E7=B4=94=E3=81=AA=E5=90=8D=E5=89=8D=E3=81=A0=E3=81=91?= =?UTF-8?q?=E3=82=92=E6=8F=90=E4=BE=9B=E3=81=99=E3=82=8B=E3=82=88=E3=81=86?= =?UTF-8?q?=E5=A4=89=E6=9B=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- denops/@ddu-sources/channel.ts | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/denops/@ddu-sources/channel.ts b/denops/@ddu-sources/channel.ts index 7a6b763..805f43a 100644 --- a/denops/@ddu-sources/channel.ts +++ b/denops/@ddu-sources/channel.ts @@ -38,7 +38,7 @@ export class Source extends dduVim.BaseSource { }); parentChannels.forEach((channel: Channel) => { items.push({ - word: channel.path + (channel.children.length === 0 ? "" : "/"), + word: channel.name, action: { id: channel.id, }, @@ -63,8 +63,7 @@ export class Source extends dduVim.BaseSource { return; } items.push({ - word: (childrenChannel.path.split("/").pop() ?? "") + - (childrenChannel.children.length === 0 ? "" : "/"), + word: childrenChannel.name, action: { id: childrenChannel.id, }, From 490b7a15c50d1fa42eeb826018a7b435ffc0e8f7 Mon Sep 17 00:00:00 2001 From: kamecha Date: Fri, 22 Dec 2023 18:07:35 +0900 Subject: [PATCH 5/6] =?UTF-8?q?ddu=E3=81=AEcolmun=E3=81=AB=E3=81=A4?= =?UTF-8?q?=E3=81=84=E3=81=A6=E3=81=A1=E3=82=87=E3=81=A3=E3=81=A8=E8=AA=BF?= =?UTF-8?q?=E3=81=B9=E3=81=9F=E3=81=AE=E3=81=A7=E3=82=B3=E3=83=A1=E3=83=B3?= =?UTF-8?q?=E3=83=88=E8=BF=BD=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- denops/@ddu-columns/channel.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/denops/@ddu-columns/channel.ts b/denops/@ddu-columns/channel.ts index 194c8f2..97cf4c0 100644 --- a/denops/@ddu-columns/channel.ts +++ b/denops/@ddu-columns/channel.ts @@ -8,13 +8,13 @@ export type Params = { }; export class Column extends dduVim.BaseColumn { - // TODO: ↓この関数が何やってるのか調べとく - // 現状0を返してるけど、なんかちゃんと表示されちゃってる + // getTextで使われるendColとかの計算に使われるらしい + // 事前にcolumnの概要だけを計算してるっぽい getLength( args: dduVimColumn.GetLengthArguments, ): Promise { const widths: number[] = args.items.map((item) => { - // TODO: ↓ここでdisplayが空文字列になってるので、原因調べとく + // ddu側がcolumnを一個づつ適用させる時にどんどんdisplayが追加されるらしい const display = item.display ?? item.word; return display.length; }); From 8c22248ff67f4a098e682e4171dab9a2597812b6 Mon Sep 17 00:00:00 2001 From: kamecha Date: Fri, 22 Dec 2023 18:23:53 +0900 Subject: [PATCH 6/6] =?UTF-8?q?getLength=E3=82=92=E5=A4=9A=E5=88=86?= =?UTF-8?q?=E6=AD=A3=E3=81=97=E3=81=8F=E5=AE=9F=E8=A3=85=E3=81=97=E3=81=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- denops/@ddu-columns/channel.ts | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/denops/@ddu-columns/channel.ts b/denops/@ddu-columns/channel.ts index 97cf4c0..90b2859 100644 --- a/denops/@ddu-columns/channel.ts +++ b/denops/@ddu-columns/channel.ts @@ -1,4 +1,4 @@ -import { dduVim, dduVimColumn } from "../traqvim/deps.ts"; +import { dduVim, dduVimColumn, fn } from "../traqvim/deps.ts"; export type Params = { collapsedParentIcon: string; @@ -8,19 +8,24 @@ export type Params = { }; export class Column extends dduVim.BaseColumn { - // getTextで使われるendColとかの計算に使われるらしい - // 事前にcolumnの概要だけを計算してるっぽい getLength( args: dduVimColumn.GetLengthArguments, ): Promise { + const iconWidth = Math.max( + args.columnParams.collapsedParentIcon.length, + args.columnParams.expandedParentIcon.length, + args.columnParams.leafIcon.length, + ); const widths: number[] = args.items.map((item) => { - // ddu側がcolumnを一個づつ適用させる時にどんどんdisplayが追加されるらしい - const display = item.display ?? item.word; - return display.length; + const length = args.columnParams.indentationWidth * item.__level + + iconWidth + + 1 + + item.word.length; + return length; }); return Promise.resolve(Math.max(...widths)); } - getText( + async getText( args: dduVimColumn.GetTextArguments, ): Promise { const parentIcon = args.item.__expanded @@ -31,8 +36,10 @@ export class Column extends dduVim.BaseColumn { const text = " ".repeat(args.columnParams.indentationWidth * args.item.__level) + icon + " " + args.item.word; + const width = await fn.strwidth(args.denops, text) as number; + const padding = " ".repeat(args.endCol - args.startCol - width); return Promise.resolve({ - text, + text: text + padding, }); } params(): Params {