selection

Is it possible to restrict the range of select all/Ctrl+A?

 ̄綄美尐妖づ 提交于 2020-01-02 05:21:05
问题 I am working on a website where I would like to be able to display a box containing syntax-highlighted source code for the user to copy. When I click on the box, giving it focus (Chrome shows its focus outline), and type Ctrl+A , the text of the entire page is selected, whereas I would like only the syntax-highlighted source code within the box to be selected. Is it possible to restrict the range of select all/ Ctrl+A to only the text within the box, preferably without using an <iframe>? My

How is nth_element Implemented?

送分小仙女□ 提交于 2019-12-31 10:52:46
问题 There are a lot of claims on StackOverflow and elsewhere that nth_element is O(n) and that it is typically implemented with Introselect: http://en.cppreference.com/w/cpp/algorithm/nth_element I want to know how this can be achieved. I looked at Wikipedia's explanation of Introselect and that just left me more confused. How can an algorithm switch between QSort and Median-of-Medians? I found the Introsort paper here: http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.14.5196&rep=rep1

How is nth_element Implemented?

寵の児 提交于 2019-12-31 10:49:17
问题 There are a lot of claims on StackOverflow and elsewhere that nth_element is O(n) and that it is typically implemented with Introselect: http://en.cppreference.com/w/cpp/algorithm/nth_element I want to know how this can be achieved. I looked at Wikipedia's explanation of Introselect and that just left me more confused. How can an algorithm switch between QSort and Median-of-Medians? I found the Introsort paper here: http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.14.5196&rep=rep1

How is nth_element Implemented?

心不动则不痛 提交于 2019-12-31 10:49:10
问题 There are a lot of claims on StackOverflow and elsewhere that nth_element is O(n) and that it is typically implemented with Introselect: http://en.cppreference.com/w/cpp/algorithm/nth_element I want to know how this can be achieved. I looked at Wikipedia's explanation of Introselect and that just left me more confused. How can an algorithm switch between QSort and Median-of-Medians? I found the Introsort paper here: http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.14.5196&rep=rep1

JavaScript selection/range framework

隐身守侯 提交于 2019-12-31 09:04:11
问题 I've been working with selection/range objects, and because to the incredible amount of inconsistencies between browsers for specific selection/range stuff (even more than the DOM) I was wondering if there was a framework that would help me get through them. 回答1: (Made an answer by request ;) Take a look at IERange: IERange is a feature-complete implementation of W3C DOM Ranges for Internet Explorer, allowing users to write one cross-browser version of their range manipulation code. Supports

How to select item in the list view programmatically

我们两清 提交于 2019-12-31 05:24:11
问题 I have an ArrayList<String> List which contains some items from the listview all_list. How can I select these items in the list view all_list programmatically by checking the ArrayList<String> List contents? for e.g., listview all_list contains [0] apple [1] orange [2] banana In ArrayList<String> List , I have orange so I want item on position 1 on the listview all_list to be selected (highlighted) automatically. I have tried using all_list.setItemChecked() , but it does nothing and shuts

Prevent JavaScript window.getSelection() circular reference

别来无恙 提交于 2019-12-31 03:57:26
问题 See this demo (dependent on selectionchange event which works in Chrome only at this moment): http://jsfiddle.net/fyG3H/ Select some lorem ipsum text and then focus the text input. In the console log you will see that there is a DOMSelection object. It has an anchorNode value of HTMLBodyElement while it should have one of Text . I didn't know why this was happening until I tried stringfying the selection object: http://jsfiddle.net/fyG3H/1/ This gives the following error: Uncaught TypeError:

Android RecyclerView select first Item

拜拜、爱过 提交于 2019-12-30 18:47:13
问题 I'm using a RecyclerView to implement a NavigationDrawer. I got click events working, but I can't figure out how to have the first item selected on App start and following that keep the selected item higlighted even if the drawer is not shown. All I've been able to find is multi-selection in RecyclerView. 回答1: I actually just implemented this in an app I am working on. So this method worked: First create a variable to track the current selected position at the top of your adapter: private int

Save / restore selection on contentEditable AFTER modifying innerHTML

帅比萌擦擦* 提交于 2019-12-30 18:29:18
问题 I know getting / setting cursor position in a contentEditable is damn near impossible. I don't care about knowing this information. I need to be able to save current selection, modify innerHTML of the div, and then restore the selection. I've bee experimenting with the answer provided at contenteditable selected text save and restore . It works after typing in the div, but not after programmatically modifying the innerHTML of the div. Instead, when I call restoreSelection, the caret simply

Selection ranges in webkit (Safari/Chrome)

牧云@^-^@ 提交于 2019-12-30 02:18:26
问题 I'm using a content-editable iframe to create a syntax-highlighter in javascript and one of the most important things is to be able to indent code properly. The following code works just as it should in Firefox: // Create one indent character var range = window.getSelection().getRangeAt(0); var newTextNode = document.createTextNode(Language.tabChar); range.insertNode(newTextNode); range.setStartAfter(newTextNode); It creates a tab char and moves the cursor to the right side of the character.