DOORS DXL script to strikethrough Object Text while keeping current rich text intact - ibm-doors

I want to select multiple objects and strikethrough all the Object Text while keeping the original rich text intact.
This is my original code:
Module m = current
Object o
for o in m do
{
if (isSelected(o))
{
string t = o."Object Text"
t = "\\strike " t "\\strike0 "
o."Object Text" = richText t
}
}
This code does simply strikethrough all the Object Text, but deletes all the old RTF.
By RTF I mean the part of the rich text that looks something like this:
{\rtf1\ansi\blah\blah\blah{\more\stuff;}
{\*\generator\Blah30 1.45.2768}\more\things\pard\f0\sf20
Example before dxl script:
{\rtf1\ansi\blah\blah\blah{\more\stuff;} \
{\*\generator\Blah30 1.45.2768}\more\things\pard\f0\sf20 This is the object text that I would like to strikethrough. \par
}
After ABOVE dxl script:
\\strike This is the object text that I would like to strikethrough.\\strike0
While this does strikethrough the Object Text I would like to keep the old rich text the same and just add a strikethrough. Any ideas? Would it work to append the \\strike to the beginning and \\strike0 to the end of the rich text?
The IDEAL output would look like this (I got this by actually using the manual strikethrough feature and comparing the differences):
{\rtf1\ansi\blah\blah\blah{\more\stuff;} \
{\*\generator\Blah30 1.45.2768}\more\things\pard\strike\f0\sf20 This is the object text that I would like to strikethrough.\strike0 \strike\par
}

Related

Custom wireshark disector shows value but fieldname is not visible using lua

I am testing some network packets of my Organisation's product. We already have custom plugins. I am trying to add some some more fields into those existing plugins (like conversion of 2 byte code to a string and assign it to a field)
Thankyou in advance for reading my query.
--edit
Wireshark version : 2.4.5 (organization's plugins dont work on latest wireshark application)
--edit
Problem statement:
I am able to add field and show value, but fieldname is not displayed as defined.
I cannot share the entire .lua file but i will try to explain What i did:
Below is the image where I have a field aprint.type. this is a two byte field. In .lua file, for display purpose it is appended with corresponding description using a custom function int_to_enum.
I want to add one more proto field aprint.typetext which will show the text.
What I did:
Added a protofield f_apr_msg_type_txt = ProtoField.string("aprint.typetxt","aprint_type_text") (Tried f_apr_msg_type_txt = ProtoField.string("aprint.typetxt","aprint_type_text",FT_STRING) also)
Below the code where subtree aprint.type is shown, added my required field as subtree:add(f_apr_msg_type_txt, msg_type_string) (Below is image of code extract)
I am able to see the text but field Name is shown as Wireshark Lua text (_ws.lua.text)
Normally displaying strings based on numeric values is accomplished by a value string lookup, so you'd have something like so:
local aprint_type_vals = {
[1] = "Foo",
[2] = "Bar",
[9] = "State alarm"
}
f_apr_msg_type = ProtoField.uint16("aprint.type", "Type", base.DEC, aprint_type_vals)
f_apr_msg_type_txt = ProtoField.string("aprint.typetxt","aprint_type_text", base.ASCII)
... then
local msg_type = tvb(offset, 2):le_uint()
subtree:add_le(f_apr_msg_type, tvb(offset, 2))
subtree:add(f_apr_msg_type_txt, tvb(offset, 2), (aprint_type_vals[msg_type] or "Unknown"))
--[[
Alternatively:
subtree:add(f_apr_msg_type_txt, tvb(offset, 2)):set_text("aprint_type_text: " .. (aprint_type_vals[msg_type] or "Unknown"))
--]]
I'm also not sure why you need the extra field with only the text when the text is already displayed with the existing field, but that's basically how you'd do it.

How to format multiline text for easy pasting into a Google Spreadsheet?

I have multiline text like this:
- foo
- "bar"
- baz\n
- 'hello world'
I am copying this from ag-grid spreadsheet cells (it shouldn't matter that I'm using ag-grid for this question, but just know that I need to figure out how to format the text I get from that cell), which looks like this:
I tried formatting the text from that right column to be like this:
const copyText = (value?: string): string => {
return `"${(value ?? '').replace(/"/gm, '\\"')}"`;
};
I get this when pasting it in the Google Spreadsheet:
How do I need to format the text so I can paste the multiple lines into a single spreadsheet cell? I added \n and " and ' characters in the multiline to just show that the multiline can contain any text basically, so it shouldn't mess up if they include quotes and backslashes and such. I want this basically:
When I copy from the ag-grid, the clipboard pastes this essentially:
L1\t"- foo
- \"bar\"
- baz\n
- 'hello world'
"
So what am I doing wrong in formatting.
You have to use double double quotes:
L1\t"- foo
- ""bar""
- baz\n
- 'hello world'
"

Can't enter space in textfield using forced uppercase textfield-formatter add-on in Vaadin 8

With the TextField Formatter add-on for Vaadin 8, I can do the following to allow only upper-case characters:
Options options = new Options();
options.setBlocks(dataLen);
if (format[1].equalsIgnoreCase("UPPER"))
options.setForceCase(ForceCase.UPPER);
new CustomStringBlockFormatter(options).extend(field);
However, after setting forced uppercase I can't enter space characters any longer. Does anyone how I can allow spaces as well as forced upper case characters?
The TextField Formatter add-on doesn't support arbitrary groupings.The setBlocks in method in Options determines the fixed space-separated groups, so you can specify e.g. options.setBlocks(3,3,2) to allow entering text in the format of XXX XXX XX. If you want to allow only capitals, but spaces allowed in the middle in any position, like so that both HELLO WORLD and HI WORLD are allowed, you can use a CSS trick to set the letters print in all uppercase. Add the following rule in your theme .scss file:
input.upper-textfield {
text-transform:uppercase;
}
and define your TextField without a formatter, like this:
TextField textField = new TextField("only upper");
textField.setStyleName("upper-textfield");
textField.setMaxLength(dataLen);
Now you just need to remember to change the text to uppercase in Java as well when you read it:
String value = textField.getValue();
if (value != null) {
value = value.toUpperCase();
}

Add space between elements using sanitize and truncate in Rails

Working on HTML content and trying to generate some excerpt for every post, I'm using the following code to sanitize and then truncate, but the issue is that the generated text without any spaces.
= sanitize(post.body, tags: []).truncate(155, separator: ' ...').html_safe
The following image form the editor, every word is a single p
element, there may be any HTML element like images, video, .. . I only want to show only text.
The following image is the view, I want to add spaces between theses words (p elements)
Inspector
How I can sanitize, truncate the content and keeping the format
The problem is you dont have spaces around the tags i.e
The text is something like
include ActionView::Helpers::SanitizeHelper
> content = "<p>this</p><p>is</p><p>great</p><p>and</p><p>for</p><p>some</p><p>reason</p>"
> strip_tags(content)
> "thisisgreatandforsomereason"
> content = "<p>this </p><p>is </p><p>great </p><p>and </p><p>for </p><p>some </p><p>reason </p>"
> strip_tags(content)
> "this is great and for some reason"
either try giving spaces around the <p> tag or use regex to create spaces
for ex
> content = "<p>this</p><p>is</p><p>great</p><p>and</p><p>for</p><p>some</p><p>reason</p>"
> strip_tags(content.gsub('</p>', ' </p>')) # Note the space in replaced content
> "this is great and for some reason"

HTML Styles in TextView on Mono for Android

I have this situation in my strings.xml.
<string name="mensagem">Olá <b><i> {0} </i></b>,</string>
And in my code I do this:
string msg = String.Format(Resources.GetString(Resource.String.mensagem).ToString(), cliente.Nome.ToUpper());
lblNome.Text = Html.FromHtml(msg).ToString();
But the style tags (b,i) do not work. I need to concatenate words with and without style, so I need to do it in this way. I cant use setTypeface because I need to style individual words and after that, join those words on a sentence.
What is the way ?
Regards,
Marcelo.
You need to change your code to the following.
string msg = String.Format(Resources.GetString(Resource.String.mensagem).ToString(), cliente.Nome.ToUpper());
lblNome.TextFormatted = Html.FromHtml(msg);
Html.FromHtml(string).ToString() is just converting the formatted ISpannable back to a string so you are losing the formatting.

Resources