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

添加scrollText组件 #29

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open

添加scrollText组件 #29

wants to merge 3 commits into from

Conversation

jimmy-sketch
Copy link
Owner

@jimmy-sketch jimmy-sketch commented Feb 5, 2025

scrollText,一个文本小窗口,能够放置文本
可用于输出日志,可指定宽度高度,自动滚动。

Summary by Sourcery

新功能:

  • 添加了一个可滚动的文本组件,支持指定宽度和高度,并能自动滚动。
Original summary in English

Summary by Sourcery

New Features:

  • Add a scrollable text component that supports specifying width and height and automatically scrolls.

@sourcery-ai review

Copy link

sourcery-ai bot commented Feb 5, 2025

Here's the translation of the review guide to Chinese:

审阅者指南 by Sourcery

此拉取请求主要添加了一个新的 scrollText 组件,提供了一个具有固定宽度和高度的可滚动文本窗口,并支持自动换行。该实现使用队列缓冲行,并填充不完整的行以保持一致的尺寸。此外,PR 在演示应用程序中集成了这个新组件,并包含了几个格式化和重构调整以及小型构建系统更新。

新 scrollText 组件的类图

classDiagram
    class component {
        <<interface>>
        +size_t getWidth() const
        +size_t getHeight() const
        +std::vector<cgui::string> getData() const
    }

    class scrollText {
        -std::queue<cgui::string> lineBufs
        -size_t height
        -size_t width
        +scrollText(size_t height, size_t width)
        +size_t getWidth() const
        +size_t getHeight() const
        +std::vector<cgui::string> getData() const
        +void addLine(cgui::string lineBuf)
        +void clearAll()
    }

    component <|-- scrollText
Loading

文件级变更

变更 详情 文件
新 scrollText 组件的实现
  • 添加了一个继承自组件接口的新 scrollText 类,支持固定尺寸和通过队列缓冲行
  • 实现了添加新文本行(带截断)、清除所有行以及生成带适当填充的格式化输出的方法
  • 确保 getData 返回符合组件宽度和高度约束的输出
src/scrollText.cpp
include/cgui/components/scrollText.h
在演示应用程序中集成 scrollText 组件
  • 在 sandbox/demo.cpp 中实例化了一个 scrollText 对象,用于显示动态添加的行
  • 更新了演示逻辑,定期向 scrollText 组件添加新的文本行,并与其他 UI 元素一起显示
sandbox/demo.cpp
重构和代码格式化改进
  • 重新格式化 demo.cpp 中的函数(如 getImageByLines、bigChar、initFont 和 main),使用一致的大括号样式
  • 标准化 page.cpp 和 demo.cpp 中的循环和条件格式,提高可读性
  • 调整信号处理和输出格式的间距和样式
sandbox/demo.cpp
src/page.cpp
include/cgui/cgui.h
include/cgui/components/basicProgressBar.h
构建系统更新和文件删除
  • 更新 CMakeLists.txt 以提升项目版本,并在构建中包含新的 scrollText 源文件和头文件
  • 删除了与 utils 相关的未使用或已弃用的文件(cgui/utils/utils.h 和 src/utils.cpp)
CMakeLists.txt
include/cgui/utils/utils.h
src/utils.cpp

提示和命令

与 Sourcery 交互

  • 触发新审阅: 在拉取请求中评论 @sourcery-ai review
  • 继续讨论: 直接回复 Sourcery 的审阅评论。
  • 从审阅评论生成 GitHub 问题: 通过回复审阅评论,要求 Sourcery 创建一个问题。您也可以用 @sourcery-ai issue 回复审阅评论来创建问题。
  • 生成拉取请求标题: 在拉取请求标题的任何位置写 @sourcery-ai 以随时生成标题。您也可以在拉取请求中评论 @sourcery-ai title 以随时(重新)生成标题。
  • 生成拉取请求摘要: 在拉取请求正文的任何位置写 @sourcery-ai summary 以在您想要的确切位置生成 PR 摘要。您也可以在拉取请求中评论 @sourcery-ai summary 以随时(重新)生成摘要。
  • 生成审阅者指南: 在拉取请求中评论 @sourcery-ai guide 以随时(重新)生成审阅者指南。
  • 解决所有 Sourcery 评论: 在拉取请求中评论 @sourcery-ai resolve 以解决所有 Sourcery 评论。如果您已经处理了所有评论,不想再看到它们,这很有用。
  • 取消所有 Sourcery 审阅: 在拉取请求中评论 @sourcery-ai dismiss 以取消所有现有的 Sourcery 审阅。特别适用于想要重新开始审阅的情况 - 别忘了评论 @sourcery-ai review 以触发新的审阅!
  • 为问题生成行动计划: 在问题中评论 @sourcery-ai plan 以生成该问题的行动计划。

自定义您的体验

访问您的仪表板以:

  • 启用或禁用审阅功能,如 Sourcery 生成的拉取请求摘要、审阅者指南等。
  • 更改审阅语言。
  • 添加、删除或编辑自定义审阅说明。
  • 调整其他审阅设置。

获取帮助

Original review guide in English

Reviewer's Guide by Sourcery

This pull request primarily adds a new scrollText component that provides a scrollable text window with fixed width and height and automatic line scrolling. The implementation uses a queue to buffer lines and pads incomplete lines to maintain consistent dimensions. Additionally, the PR integrates this new component in the demo application and includes several formatting and refactoring adjustments along with small build system updates.

Class diagram for the new scrollText component

classDiagram
    class component {
        <<interface>>
        +size_t getWidth() const
        +size_t getHeight() const
        +std::vector<cgui::string> getData() const
    }

    class scrollText {
        -std::queue<cgui::string> lineBufs
        -size_t height
        -size_t width
        +scrollText(size_t height, size_t width)
        +size_t getWidth() const
        +size_t getHeight() const
        +std::vector<cgui::string> getData() const
        +void addLine(cgui::string lineBuf)
        +void clearAll()
    }

    component <|-- scrollText
Loading

File-Level Changes

Change Details Files
Implementation of the new scrollText component
  • Added a new scrollText class that inherits from the component interface, supporting fixed dimensions and line buffering via a queue
  • Implemented methods to add a new text line (with truncation), clear all lines, and generate formatted output with appropriate padding
  • Ensured that getData returns output fitting the component width and height constraints
src/scrollText.cpp
include/cgui/components/scrollText.h
Integration of the scrollText component into the demo application
  • Instantiated a scrollText object in sandbox/demo.cpp to display dynamically added lines
  • Updated demo logic to periodically add new text lines to the scrollText component and display them along with other UI elements
sandbox/demo.cpp
Refactoring and code formatting improvements
  • Reformatted functions in demo.cpp (such as getImageByLines, bigChar, initFont, and main) to use consistent brace styles
  • Standardized loop and conditional formatting in page.cpp and demo.cpp for better readability
  • Adjusted spacing and style for signal handling and output formatting
sandbox/demo.cpp
src/page.cpp
include/cgui/cgui.h
include/cgui/components/basicProgressBar.h
Build system updates and file removals
  • Updated CMakeLists.txt to bump the project version and include the new scrollText source file and header in the build
  • Removed unused or deprecated files related to utils (cgui/utils/utils.h and src/utils.cpp)
CMakeLists.txt
include/cgui/utils/utils.h
src/utils.cpp

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!
  • Generate a plan of action for an issue: Comment @sourcery-ai plan on
    an issue to generate a plan of action for it.

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jimmy-sketch - 我已经审查了你的更改 - 以下是一些反馈:

整体评论

  • 在 scrollText 构造函数中存在命名不一致:头部使用参数名 'weight',而实现使用 'width'。为避免混淆,请对齐命名。
  • 在 getData() 函数中,你在局部变量 'tmpLine' 中计算了填充版本,但随后又添加了未修改的 'tmp.front()' 到 tgtRet。应使用修改后的 tmpLine,以确保行按预期填充。
以下是我在审查期间查看的内容
  • 🟡 一般性问题:发现2个问题
  • 🟢 安全性:一切看起来都很好
  • 🟢 测试:一切看起来都很好
  • 🟢 复杂性:一切看起来都很好
  • 🟢 文档:一切看起来都很好

Sourcery 对开源项目是免费的 - 如果你喜欢我们的评论,请考虑分享 ✨
帮助我变得更有用!请在每条评论上点击 👍 或 👎,我将使用这些反馈来改进你的评论。
Original comment in English

Hey @jimmy-sketch - I've reviewed your changes - here's some feedback:

Overall Comments:

  • There's a naming inconsistency in the scrollText constructor: the header uses parameter name 'weight' while the implementation uses 'width'. Align the naming to avoid confusion.
  • In the getData() function, you compute a padded version in the local variable 'tmpLine' but then add the unmodified 'tmp.front()' to tgtRet. Use the modified tmpLine instead to ensure the line is padded as intended.
Here's what I looked at during the review
  • 🟡 General issues: 2 issues found
  • 🟢 Security: all looks good
  • 🟢 Testing: all looks good
  • 🟢 Complexity: all looks good
  • 🟢 Documentation: all looks good

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@jimmy-sketch
Copy link
Owner Author

jimmy-sketch commented Feb 8, 2025

@sourcery-ai review

@jimmy-sketch
Copy link
Owner Author

@sourcery-ai guide

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

Successfully merging this pull request may close these issues.

1 participant