如何在 Shoes 中制作一个简单的文本编辑应用程序?

发布于 2024-07-19 08:16:20 字数 219 浏览 6 评论 0原文

我正在尝试使用 Shoes 编写一个简单的工具。 这将为我们使用的一种晦涩的脚本语言缩进代码。 它有一个大文本框和一个按钮。 我的程序在命令行上运行,但我没有运气将其封装在 Shoes 中。 如果有人可以提供一个应用程序的工作示例,该应用程序可以执行以下任务来帮助我启动和运行,那将非常有用。

单击按钮时,我想要:获取文本,拆分为行数组(此处发生缩进),再次连接行并使用新数据刷新文本框。

I am trying to write a simple tool using Shoes. This will indent code for an obscure scripting language we use. It has one large text box and one button. I have the program working on the command line, but am having no luck wrapping this up in Shoes. If anyone could give a working example of an app that does the following tasks to get me up and running that would be very useful.

When the button is clicked I want to: Get the text, split into an array of lines, (indenting happens here), join the lines again and refresh the text box with the new data.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

喜你已久 2024-07-26 08:16:20
Shoes.app :width => 300, :height => 450 do
  @text = edit_box :width => 1.0, :height => 400
  btn = button 'Indent!'
  btn.click do
    ugly_txt = @text.text
    lines = ugly_txt.split $/ #the record separator
    lines.collect! { |line| '  ' + line } #your indentation would replace this
    @text.text = lines.join $/
  end
end
Shoes.app :width => 300, :height => 450 do
  @text = edit_box :width => 1.0, :height => 400
  btn = button 'Indent!'
  btn.click do
    ugly_txt = @text.text
    lines = ugly_txt.split $/ #the record separator
    lines.collect! { |line| '  ' + line } #your indentation would replace this
    @text.text = lines.join $/
  end
end
汹涌人海 2024-07-26 08:16:20

我认为示例文件夹中有一个示例

I think there's an example in the samples folder

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文