Is there any Atom plugin for helping to write HTML files? - atom-editor

I want keystroke bindings and toolbar controls for HTML tags. For example, I want to change a text to hyperlink, I can press Ctrl+L, or click on some toolbar button to add the link. Is there any package for that? Much like what we can find in different blogging websites like blogger.com

As suggested by #Ganzorig autocomplete-html will do the job

How I make links with CTRL+J.
You can select a word or even multiple words in different lines (with CTRL+ALT+DOWN)
File -> Keymap...
'atom-text-editor':
'ctrl-j': 'custom:wrap-with-a-tag'
File -> Init script...
# set multiLine to false to split selections into single line
wrapSelections = (editor, before, after, multiLine = true, cursorDown = true) ->
cursorOffset = before.indexOf '$1'
cursorOffset = before.length if cursorOffset < 0
before = before.replace '$1', ''
after ?= before
editor.transact ->
editor.splitSelectionsIntoLines() unless multiLine
cursorPositions = for selection in editor.getSelections()
cursorPosition = selection.getBufferRange().start.translate [0, cursorOffset]
selection.insertText("#{before}#{selection.getText()}#{after}")
cursorPosition
for cursorPosition, i in cursorPositions
if i == 0
editor.setCursorBufferPosition cursorPosition
editor.moveDown() unless cursorDown
else
editor.addCursorAtBufferPosition cursorPosition
atom.commands.add 'atom-text-editor', 'custom:wrap-with-a-tag', ->
wrapSelections #getModel(), '', '', false, true

Related

How to build a simple widget or app in jupyter notebook/lab to interactively extract a substring from text?

I want iterate over a list of string, output the string as plain text in jupyter lab then interactively highlight a substring to get easily the start index of the substring and the length. The goal is to do a quick annotation of text and get the coordinates of the substring.
Is it easy or even possible to do something like this with jupyter notebook (lab)? If then How?
I had a look at ipywidgets but couldn't find something for this use case.
Here's an example with the RangeSlider:
import ipywidgets
input_string = 'averylongstring'
widg = ipywidgets.IntRangeSlider(
value = [0, len(input_string)],
min=0, max=len(input_string)
)
output_widg = ipywidgets.Text()
display(widg)
display(output_widg)
def chomp_string(widg):
start,end = tuple(widg['new'])
output_widg.value = input_string[start: end]
widg.observe(chomp_string, names='value')
You can implement this using jp_proxy_widgets. See the following screenshot:
Note that there are warnings about compatibility for selection protocols -- I only tested this on Chrome on a Mac. Also I don't know why the indices are off by one
(select_callback(startOffset+1, endOffset+1);)
Please see https://github.com/AaronWatters/jp_proxy_widget for more information
Edit: Here is the pastable text as requested:
import jp_proxy_widget
select_widget = jp_proxy_widget.JSProxyWidget()
txt = """
Never gonna give you up.
Never gonna let you down.
Never gonna run around and
desert you.
"""
selected_text = None
def select_callback(startOffset, endOffset):
global selected_text
selected_text = txt[startOffset: endOffset]
print ("Selected", startOffset, endOffset, repr(selected_text))
select_widget.js_init("""
// (Javascript) Add a text area.
element.empty()
$("<h3>please select text:</h3>").appendTo(element);
var textarea = $('<textarea cols="50" rows="5">' + txt + "</textarea>").appendTo(element);
// Attach a select handler that calls back to select_callback.
var select_handler = function(event) {;
var target = event.target;
var startOffset = target.selectionStart;
var endOffset = target.selectionEnd;
select_callback(startOffset+1, endOffset+1);
};
textarea[0].addEventListener('select', select_handler);
""", txt=txt, select_callback=select_callback)
# display the widget
select_widget.debugging_display()

D365 New Button creates price line with empty line

After adding logic about creating price for object in grid it's always created "one line more" which is empty.
So, if there is need to be created two lines, it will be created 3 lines and that one addition will be empty.
Is there something what I missing in code?
[Control("CommandButton")]
class AreaActionPaneNew
{
void clicked()
{
PMCParameters contractParameters = PMCParameters::find();
PMETmpRentalObjectArea groupedAreaList; // Group by area_type and cost_type
PMERentalObjectPrice priceList;
date workingDate = currWorkingDate.dateValue();
;
super();
// Get grouped area values. Values are summed up by area_type and ancost_type
groupedAreaList = PMERentalObjectAreaCl::getRentalAreaPrCostType(pmeRentalobject.RentalObjectId, userSetting.validFrom(), userSetting.validTo() , workingDate);
ttsbegin;
while select groupedAreaList
{
select forupdate firstonly priceList
where priceList.RentalObjectId == pmeRentalObject.RentalObjectId &&
priceList.RentalCostType == groupedAreaList.RentalCostTypeId &&
priceList.AreaType == groupedAreaList.Areatype && priceList.ValidFrom == pmeRentalObject.ValidFrom;
if (!priceList)
priceList.initValue();
priceList.RentalObjectId = pmeRentalObject.RentalObjectId;
priceList.RentalCostType = groupedAreaList.RentalCostTypeId;
priceList.ValidFrom = pmeRentalobject.ValidFrom;
priceList.AreaType = groupedAreaList.Areatype;
priceList.Amount = groupedAreaList.Price;
priceList.Area = groupedAreaList.AreaValue;
priceList.Quantity = groupedAreaList.RentalQty;
if (!priceList)
priceList.Period = contractParameters.ReportPeriod;
if (priceList)
priceList.update();
else
priceList.insert();
}
ttscommit;
pmeRentalObjectPrice_ds.research();
}
}
The code looks like it only updates/inserts without creating a blank line.
From your attribute, you are using a Command Button (see here), which may have an associated command, such as New, which effectively pushes Ctrl+N, and would explain why you have a blank line.
The simplest way to check is just create a regular Button and override the clicked method, then copy/paste your code and push both buttons and see if they have different behavior.
Check the Command property on the button and see if there's something there. Try commenting out the super(); call.
You should perhaps consider just a Button or a Menu Item Button with an associated object.

OpenEdge 10.2A - How to apply the default RETURN / CURSOR-DOWN on Editor widget even if a general code for RETURN / CURSOR-DOWN with ANYWHERE exists?

I have a code for RETURN / CURSOR-DOWN for all widgets in a window which basically makes it as if TAB is pressed. It works just fine but I want the default functionality of RETURN (Break current line into two lines) / CURSOR-DOWN for EDITOR widgets.
I have tried to add
APPLY "ENTER" TO SELF.
or
APPLY "RETURN" TO SELF.
or
APPLY "CTRL-J" TO SELF. /*Ctrl-Enter*/
for EDITOR widgets but when pressed RETURN / CURSOR-DOWN in an EDITOR it just does not do anything. It stays as if RETURN / CURSOR-DOWN is not pressed.
ON RETURN OF {&WINDOW-NAME} ANYWHERE
DO:
IF SELF:TYPE="EDITOR" THEN
DO:
APPLY "ENTER" TO SELF. /*Does NOT Work*/
END.
ELSE IF SELF:TYPE = "BUTTON" THEN
DO:
APPLY "Choose".
END.
ELSE
DO:
APPLY "Tab".
RETURN NO-APPLY.
END.
END.
ON CURSOR-DOWN OF {&WINDOW-NAME} ANYWHERE
DO:
IF SELF:TYPE="EDITOR" THEN
DO:
APPLY "CURSOR-DOWN" TO SELF. /*Does NOT Work*/
END.
ELSE
DO:
APPLY "Tab".
RETURN NO-APPLY.
END.
END.
Is there a way to do it?
I've tested this in 10.2B08. Here's the main anywhere trigger:
ON RETURN OF {&WINDOW-NAME} ANYWHERE DO:
IF SELF:TYPE = "BUTTON" THEN DO:
APPLY "Choose".
END.
else do:
apply 'tab'.
return no-apply.
end.
end.
ON CURSOR-DOWN OF {&WINDOW-NAME} ANYWHERE DO:
if self:type ne 'EDITOR' then DO:
APPLY "Tab".
RETURN NO-APPLY.
END.
END.
Not much different from what you had.
Now in the editor, add a trigger to RETURN and one to CURSOR-DOWN.
Here's your editor's RETURN trigger:
self:insert-string(chr(13)).
And here's the editor's CURSOR-DOWN trigger:
DEFINE VARIABLE iOffset AS INTEGER NO-UNDO.
assign iOffset = self:cursor-char
self:cursor-line = self:cursor-line + 1
self:cursor-char = ioffset no-error.
do while error-status:get-message(1) begins '**Unable to set attribute CURSOR-CHAR':
assign iOffset = iOffset - 1
self:cursor-char = ioffset no-error.
if iOffset = 1 then leave.
end.
Let me know if this works for you. Seems to be ok for me here.

Awesome wm keyup and keydown events

I'm using Awesome Window Manager. I want to show my top bar by pressing mod4 and then hide it when I release. I tired passing "keyup Mod4" to awful.key but it does not work. How can I tell it that I want to trigger an event on keyup?
Try
`awful.key({ modkey }, "", nil, function () staff here end)`
3rd param is handler for "release" event when passed.
I wanted the same thing! After some research I came up with:
Use external program to execute echo 'mywibox[1].visible = true' | awesome-client when mod4 is pressed and echo 'mywibox[1].visible = false' | awesome-client when released.
Use other key, not modifier, like Menu (near right Ctrl), because for some reason you can't hook up press and release event to mod4 (or it just doesn't work).
Here is my solution (timer is required because pressed key sends events as long as it is pressed):
-- Put it somewhere at the beginning
presswait = { started = false }
-- Put it in key bindings section (globalkeys = within awful.table.join)
awful.key({ }, "Menu", function()
if presswait.started then
presswait:stop()
else
-- One second to tell if key is released
presswait = timer({ timeout = 1 })
presswait:connect_signal("timeout", function()
presswait:stop()
-- Key is released
for i = 1, screen.count() do
mywibox[i].visible = false
end
end)
-- Key is pressed
for i = 1, screen.count() do
mywibox[i].visible = true
end
end
presswait:start()
end)
You could connect a signal to the key object:
key.connect_signal("press", function(k)
-- Analyze k and act accordingly
end)
More about signals here:
http://awesome.naquadah.org/wiki/Signals
Using the first suggestion from https://stackoverflow.com/a/21837280/2656413
I wrote this python script: https://github.com/grandchild/autohidewibox
What it does is, it runs xinput in the background and parses its output. You could also parse /dev/input/event1 directly in python, but I was lazy.
It then pipes the following lua code to awesome every time the key is pressed or released:
echo 'for i, box in pairs(mywibox) do box.visible = true end' | awesome-client
and
echo 'for i, box in pairs(mywibox) do box.visible = false end' | awesome-client
respectively.
Update:
For awesome 4+ use:
echo "for s in screen do s.mywibox.visible = false end" | awesome-client
or true.

adobe acrobat XI pro javascript

i am calling an javascript function when out of focus on the form field. So what i am tying to do is the if i ticked required this field as required field it will have a red border around it, can i write a script to remove the required option when there are value inside the field?
var thisValue = this.getField("companyName").value;
var regexLetter = /[A-Z]+$/;
var Icon = "0"; //0 — Error (default) // 1 — Warning // 2 — Question // 3 — Status
var Type = "0"; //0 — OK (default) // 1 — OK, Cancel // 2 — Yes, No // 3 — Yes, No, Cancel
if (thisValue == ""){
app.alert({
cMsg:"this is an warning",
cTitle: "thsi is title",
nIcon: Icon,
nType: Type
})
} else if(!regexLetter.test(thisValue)){
app.alert('Type alphanumeric character');
}
This is going to be rather late, but this is how I do it in my documents:
var _companyName = this.getField("CompanyName");
_companyName.required = (_companyName.value === "");
You can also impose other dependencies, like:
var _companyName = this.getField("CompanyName"),
_companyLicense = this.getField("CompanyLicense");
_companyLicense = ((_companyLicense === "")
&& (_companyName !== ""));
Having your scripts split into a couple of files could help. I use a "shared" script which contains a vast majority of the logic and the a "specific" script to round of each individual document. Also, make sure when adding the scripts to just name them 1, 2, 3, etc. in the correct order or Acrobat will be stupid. Hope this helps you.

Resources