marick

marick

I’d like to be able to attach attributes to ranges within a string. Since I’m writing prototypes/spikes in Elixir for an eventual MacOS app, it’d be nice if the capabilities were similar to NSAttributedString - even better, a process that makes a mutable version of that (equivalent to NSMutableAttributedString). However, anything that saves me the trouble of dealing with all the fiddly cases around maintaining attributes as the underlying string changes is more than fine.

Showing Posts 1 to 4

benwilson512

benwilson512

Author of Craft GraphQL APIs in Elixir with Absinthe

In one sense I’m not sure how to answer this question. The entire framing is that you want a thing that doesn’t look anything like an Elixir string in that it has attributes, and those attributes are mutable. Can you expand on the larger problem you are trying to solve, and elaborate on how this specific data structure helps accomplish a solution to that problem?

outlog

outlog

I’m not quite sure I understand the exact problem you are seeking to solve - but have a look at liveview native GitHub - liveview-native/live_view_native: A framework for building native applications with Phoenix LiveView · GitHub - they are doing a bunch of stuff/abstractions around Swift (ui) code/modifiers etc. - so you might find inspiration there..

marick

marick OP

Consider a text editor, which manages a mutable string. Ranges of characters can be assigned particular attributes. Conceptually, every character in the string comes with a key/value map named “attributes”. Some keys are predefined, but apps can define their own custom attributes.

You can ask questions like:

  1. What attributes does the 34th Unicode character in the string have?
  2. What’s the largest contiguous Range of characters that all have the same attributes as character 34?
  3. Is the :italic attribute set for character 34?
  4. For what range around character 34 is the :italic attribute set?

I’m writing an app to explore coding in a style inspired by ecological and embodied cognition. Mainly for fun and to keep me off the streets.

marick

marick OP

In particular: the editing app is conceptualized as (for example) watching a paragraph the way a cat watches a mousehole. More specifically, there’ll be a process focused on a paragraph. I’m imagining implementing that as the text in the paragraph having a :watcher attribute whose value is a process. The stock NSMutableAttributedString code will handle things like adding and deleting characters while keeping the attributes correctly attached. Code wrapped around that will send a changed message to the watcher process (sort of like Observer), which is watching for certain sorts of changes.

For example, if I split a paragraph in two with two blank lines between the chunks, that’s a signal that I’m revising a paragraph. That’s one of the ways I customarily start revisions, and I want the app to asynchronously do certain things to help me out.

So the “paragraph-observer” process will be replaced by a different, “paragraph-editing-observer” process that is alert for different, editing-specific affordances. In particular, it will act to tag internal sentence fragments that will cause the editor display (in the MacOS version) to sweep them off to the side of main editor window. Because I think actions like that will save me hours of frustration at the cost of mere months of coding.

I cover this app in more detail in the last of five Oddly Influenced podcast episodes on ecological and embodied cognition. (Transcript available.)

— All posts loaded —

Where Next? Top

Trending in Questions Top

RSP87
I’m working on a project that simulates the bumbl example in the programming phoenix book. It acts almost like an email client. We have a...
New
nseaSeb
Hello, I know there is an approach for handling lists that allows for optimized traversal, but I can’t recall the specific method (somet...
New
brecabral
Documentation While reading the Scoped Routes section, I noticed that the documentation currently refers to a problem without explainin...
New
RemyXRenard
I’m seeing that a list inside a Kino.DataTable will be interpreted as a charlist, even if the Kino.configure() is set to charlists: :as_l...
New
velrest
So my question is quite simple and i have found no conclusive answer on forum, google or AI. Should we use :erlang.float for Integer to ...
New
samoloth
Hi, I’ve just set up an application with ash_authentication. There is only magic link strategy for now, so there is no confirmation add o...
New
asweet-confluent
I recently noticed that Elixir’s Logger defaults its primary log level to :debug when no :logger, :level application configuration is pre...
New

Other Trending Topics Top

JesseHerrick
Hey, I’m Jesse and I’m the main contributor behind Dexter, a full-featured, lightning-fast Elixir LSP optimized for large codebases. It s...
New
mudasobwa
I am happy to introduce the very α version of the new programming language compiled to BEAM. Welcome Cure. It has literally three kille...
New
marciok
Hi there! We created Gust: A task orchestrator inspired by Airflow. For those who have never heard about Aiflow, it’s a Python-based wor...
New
mhanberg
Hi everyone! The first release candidate for the Expert language server project is now available! We’ve published a press release detai...
New
jimsynz
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
Dmk
Xamal is a deployment tool for Elixir apps that deploys native releases to bare metal servers over SSH. It’s a port of GitHub - basecamp/...
New

Latest on Elixir Forum

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews