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

Add strlen extension #16675

Closed
wants to merge 2 commits into from
Closed

Add strlen extension #16675

wants to merge 2 commits into from

Conversation

WeeJeWel
Copy link

@WeeJeWel WeeJeWel commented Jan 28, 2025

Description

This extension shows the length of a string.

Screencast

Screenshot 2025-01-28 at 19 19 28

Checklist

- wip
- feat: Create \'strlen\' plugin to display clipboard string length
@raycastbot raycastbot added the new extension Label for PRs with new extensions label Jan 28, 2025
@raycastbot
Copy link
Collaborator

Congratulations on your new Raycast extension! 🚀

You can expect an initial review within five business days.

Once the PR is approved and merged, the extension will be available on our Store.

@LitoMore
Copy link
Contributor

I think you should use https://github.com/sindresorhus/string-length to calculate the correct length.

Also, it's better to add https://github.com/sindresorhus/string-width for calculating width.

@WeeJeWel
Copy link
Author

I think you should use https://github.com/sindresorhus/string-length to calculate the correct length.

Also, it's better to add https://github.com/sindresorhus/string-width for calculating width.

Hm, might be nice for a second and third field.

- eslint fix
- add other length + width

useEffect(() => {
if (!input) {
Clipboard.read().then(({ text }) => setInput(text));
Copy link
Contributor

Choose a reason for hiding this comment

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

It's better not to read the user's clipboard. You can add a preference option to let the user enable this feature manually.


return (
<List
onSearchTextChange={(value) => setInput(value)}
Copy link
Contributor

Choose a reason for hiding this comment

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

Don't setInput from here. You will get a repeated text while pasting.

Comment on lines +28 to +51
{String(input).length !== stringLength(input) && (
<List.Item
key={"length-corrected"}
icon={{ source: Icon.Hashtag, tintColor: Color.Magenta }}
title={"Length (Corrected)"}
subtitle={{
value: stringLength(input).toString(),
tooltip:
"This string might contain astral symbols. This length reflects the string length with ansi escape codes ignored.",
}}
/>
)}
{String(input).length !== stringWidth(input) && (
<List.Item
key={"width"}
icon={{ source: Icon.Hashtag, tintColor: Color.Magenta }}
title={"Width"}
subtitle={{
value: stringWidth(input).toString(),
tooltip:
"The width of this string differs from its length due to special characters.",
}}
/>
)}
Copy link
Contributor

Choose a reason for hiding this comment

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

You can always show the result of string-length and string-width since they are under different calculation logics.

You can also provide the library link to users to let know why we have three results.

@pernielsentikaer
Copy link
Collaborator

This is also already possible in Clipboard History 🙂

image

@pernielsentikaer pernielsentikaer self-assigned this Feb 3, 2025
@WeeJeWel
Copy link
Author

WeeJeWel commented Feb 3, 2025

Yea but not all strings I want to check are on the clipboard.

Plus, strlen is just easier to remember imho.

@pernielsentikaer
Copy link
Collaborator

What about Toolbox? We might be able to make some support for making quicklinks for a specific view 😊

@WeeJeWel
Copy link
Author

WeeJeWel commented Feb 4, 2025

Why the urge to bundle this into another extension?

I think the Linux philosophy of ‘one tool one job’ is still the best.

@pernielsentikaer
Copy link
Collaborator

It's because our store is massive and we're trying not to add too many with the same purpose

I also found this extension in the store which seems to be what you're looking for with extra options too 🙂

@raycastbot
Copy link
Collaborator

This pull request has been automatically marked as stale because it did not have any recent activity.

It will be closed if no further activity occurs in the next 7 days to keep our backlog clean 😊

@raycastbot raycastbot added the status: stalled Stalled due inactivity label Feb 25, 2025
@raycastbot
Copy link
Collaborator

This issue has been automatically closed due to inactivity.

Feel free to comment in the thread when you're ready to continue working on it 🙂

You can also catch us in Slack if you want to discuss this.

@raycastbot raycastbot closed this Mar 11, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
new extension Label for PRs with new extensions status: stalled Stalled due inactivity
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants