Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

字符串长度计算错误 #8

Open
wardonne opened this issue Apr 21, 2022 · 6 comments
Open

字符串长度计算错误 #8

wardonne opened this issue Apr 21, 2022 · 6 comments

Comments

@wardonne
Copy link

传入的值在使用
https://github.com/gookit/color
渲染上颜色信息后会导致字符长度计算得出的值比实际显示的长度大

看了源码应该是util/strings.go文件中Length方法在计

算时没有去除一些不会在控制台进行显示的字符

目前在我自己的项目中先进行了临时的更改,如下:
K20220421-155036

希望后续可以优化一下这方面

@liushuochen
Copy link
Owner

util.Length函数是为了在表格打印时正确的对齐带有颜色的column,而不是用来返回真实的长度。目前没有API返回column名称的长度。后面会加上这个API。

@wardonne
Copy link
Author

wardonne commented Apr 25, 2022

应该是我的描述不够清楚
其实我遇到的问题是 传入带了颜色信息的字符串后
输出的表格对齐出现了问题
1650889187(1)

@wardonne
Copy link
Author

补上一张我临时修改后的效果图
1650889652(1)

@liushuochen
Copy link
Owner

收到~ 我这边稍后改进一下。是否可以要一下联系邮箱或其他方式呢?

@wardonne
Copy link
Author

邮箱 1730314864@qq.com

@zhashuyu
Copy link

zhashuyu commented May 6, 2023

+1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants