I'm trying to achieve a censored text look in SwiftUI. I've been placing a text and it's copy inside a ZStack and added a .background(Color.black) modifier to the front one. This works fine with single line texts. However, it doesn't look so good with multiline texts, as it results in a single black rectangle. Any ideas on how to achieve the look below with rather long, multiline texts?
For the sake of completeness, here's the simple code:
HStack{
Spacer()
.frame(width: 50)
ZStack {
Text("Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et")
.font(.system(.title2, design: .serif))
.foregroundColor(.blue)
.multilineTextAlignment(.trailing)
Text("Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et")
.font(.system(.title2, design: .serif))
.multilineTextAlignment(.trailing)
.background(Color.black)
}
}
As always, any help would be greatly appreciated!
If you’re targeting iOS 14, you could use the redacted(reason:) view modifier, which they added for widgets but works everywhere:
Text("View 0")
.redacted(reason: .placeholder)
Related
I'd need to add the Chapter title in the page's heading of PDF files generated with Asciidoctor-toPDF.
Here is the set of Properties I'm using at the beginning of my doc:
= Book title
:notitle:
:toc: left
:toclevels: 8
:sectnums:
:sectnumlevels: 8
:source-highlighter: coderay
:icons: font
:chapter-label:
:header_recto_content_center: '{section-title}'
Is there any property I am missing or which conflicts with the Header generation?
A few theme-related attributes exist. But header is not one of them unfortunately.
So to style the header of a PDF one must resort to a custom style in YAML format.
Style
For this example the file is named style.yml and placed in our working directory.
extends: default #1
header:
height: 15mm #2
recto: &header #3
center-content: '-- {section-or-chapter-title} --' #4
verso: *header #5
Extends the default asciidoctor-pdf theme with your customized code.
Define the height of the header or the content will not show; also explained here.
Create a YAML anchor to the whole content of recto.
The use of {section-or-chapter-title} is explained and shown at the end of the post.
Reference the content from &header. In plain make verso behave the same as recto.
Document
The content of the adoc file is as shown below. The file is aptly named book.adoc and placed in the same directory as style.yml.
= Book title
:notitle:
:toc: left
:toclevels: 8
:sectnums:
:sectnumlevels: 8
:source-highlighter: coderay
:icons: font
:chapter-label:
== Chapter One
Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy
eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam
voluptua.
== Chapter Two
=== Section One
Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy
eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam
voluptua.
Conversion
PDF conversion is done using the pdf-stylesdir and pdf-style attributes.
asciidoctor-pdf -a pdf-stylesdir=. -a pdf-style=style.yml -d book book.adoc
Result
Chapter one looks then as shown in the screenshot. As there is no section header the chapter is used to populate the header.
Chapter two having both a chapter and a section defined is displaying the section title in the header.
This is my problem:
So, I want to select just a part of one (usually very long) line, and when I only slightly move my mouse down while moving to the right, the next line gets selected, and I can start over again.
Does anyone have a solution for this annoying mouse behavior?
Or would you recommend an altogether different input method? (pen, touch pad, keyboard, etc.)
Click on the start point of the text you want, then with the SHIFT key held down, click on the end point.
That's by design.
If you only wish to mark a part of one line, move mouse left-right only, not down (or up).
There are many possibilities to target your problem.
You can use your Shift-Key and the cursor keys to select.
You can also use your Shift-Key in combination with your End-Key and or Pos1-Key
You can also use your Shift-Key in combination with your mouse like mentioned by another user
Also the problem is not that big when you make shorter lines. In VBA you can use _ to hang lines together and interpret it like one:
txt = "Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet."
is the same as
txt = "Lorem ipsum dolor sit amet, consetetur sadipscing elitr, " _
& "sed diam nonumy eirmod tempor invidunt ut labore et " _
& "dolore magna aliquyam erat, sed diam voluptua. At vero " _
& "eos et accusam et justo duo dolores et ea rebum. Stet " _
& "clita kasd gubergren, no sea takimata sanctus est Lorem " _
& "ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur " _
& "sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut " _
& "labore et dolore magna aliquyam erat, sed diam voluptua. At " _
& "vero eos et accusam et justo duo dolores et ea rebum. Stet " _
& "clita kasd gubergren, no sea takimata sanctus est Lorem ipsum " _
& "dolor sit amet."
To select the whole line you can also click at the white space between the gray bar on the left side of the editor and the first sign in the editor
I hope that helps you.
In emacs, you can use meta-q "fill-paragraph" and in vim you can do gq - reformat paragraph (gggqG to fill the entire buffer)
Is there a similar key binding in sublime text?
Example:
Before fill-paragraph:
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam
After fill-paragraph:
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do
eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad
minim veniam
New Answer
OK, so I misunderstood your original question - as I now understand it, MetaQ-"fill-paragraph" rearranges paragraphs into lines of approximately-equal lengths. There isn't a function that matches this exactly in Sublime, but you can (re)wrap lines quite easily. You can set the ruler in your Preferences.sublime-settings file, using the "wrap_width" setting. Then, using AltQ on Windows/Linux, or ⌘AltQ on OS X, you can wrap selected text to that width (it defaults to 78 characters if "wrap_width" is set to 0). If you want to wrap to other (pre-selected) widths, go to Edit -> Wrap and there are a number of other options. To set a preferred width outside of what is in your preferences, open Preferences -> Key Bindings - User and add the following:
[
// wrap lines at 25 characters
{ "keys": ["ctrl+alt+shift+w"], "command": "wrap_lines", "args": {"width": 25} }
]
You can obviously change the 25 to whatever value suits you. If you have no custom key bindings so far, copy and paste the entire contents above into the file. If you already have some key bindings, omit the outer square brackets, and remember to place a comma at the end of the line if it's not the final entry in the file. Good luck!
I need to insert the line number before each line of text using Vim, and there has to be a space after the line number. For example, if this was TestFile:
Lorem ipsum dolor sit amet, consectetuer adipiscing elit.
Morbi nunc enim, vehicula eget, ultricies vel, nonummy in, turpis.
It should look like this
1 Lorem ipsum dolor sit amet, consectetuer adipiscing elit.
2 Morbi nunc enim, vehicula eget, ultricies vel, nonummy in, turpis.
I have been using the command :%s/^/\line('.')/ with a number of variations, but I cannot figure out how to get the space at the end.
Any ideas?
You were very close!
This substitution will do the job by concatenating the string ' ' to the line number:
%s!^!\=line('.').' '!
This is probably easiest with an external tool:
:%!nl -ba -w1 -s' '
You can use a macro. First make sure you have a 0 before the first line and have your cursor placed on it:
0 Lorem ipsum dolor sit amet, consectetuer adipiscing elit.
Morbi nunc enim, vehicula eget, ultricies vel, nonummy in, turpis.
foo
bar
etc...
Then perform this key sequence to store the right macro in register a: qaywjP0<C-A>q.
Now press #a to execute the macro. Use a quantifier to execute it multiple times.
Type :help q to find out more about recording macro's.
I have long section titles in my document like:
Lorem ipsum dolor sit amet, consectetur adipisicing elit. Proin nibh augue, suscipit a, scelerisque sed, lacinia in, mi.
Now I want to place it in page header but it is to long for it. Is there any way to cut text in LaTeX? I want to have it like that:
Lorem ipsum dolor sit amet, consectetur...
Is that possible?
https://tex.stackexchange.com/questions/6862/how-can-i-display-a-short-chapter-name-in-the-header-and-a-long-chapter-name-in-t