📄 selection.txt
字号:
Apr 2003, S.Geerken@ping.deLast update: Dec 2004=========Selection=========The selection module (selection.[ch]) handles selections, as well asactivation of links, which is closely related.General Overview================The selection module defines a structure "Selection", which isassociated to GtkDwViewport, and so to a widget tree. The selectionstate is controlled by "abstract events", which are sent by singlewidgets by calling one of the following functions: a_Selection_button_press for button press events, a_Selection_button_release for button release events, and a_Selection_button_motion for motion events (with pressed mouse button).The widget must construct simple iterators (DwIterator), which will betransferred to extended iterators (DwExtIterator), see below for moredetails. All event handling functions have the same signature, thearguments in detail are: - DwIterator *it the iterator pointing on the item under the mouse pointer, - gint char_pos the exact (character) position within the iterator, - gint link if this item is associated with a link, its number (see DwImage, section "signals" for the meaning), otherwise -1, - GdkEventButton *event the event itself; only the button is used, - gboolean within_content TRUE, if there is some selectable content unter the mouse cursor; if set to FALSE, the "full screen" feature is used on double click.In some cases, char_pos would be difficult to determine. E.g., whenthe DwPage widget decides that the user is pointing on a position_at_the_end_ of an image (DwImage), it constructs a simple iteratorpointing on this image widget. In a simple iterator, that fact thatthe pointer is at the end, would be represented by char_pos == 1. Butwhen transferring this simple iterator into an extended iterator, thissimple iterator is discarded and instead the stack has an iteratorpointing to text at the top. As a result, only the first letter of theALT text would be copied.To avoid this problem, widgets should in this case pass SELECTION_EOW(end of word) as char_pos, which is then automatically reduced to theactual length of the extended(!) iterator.The return value is the same as in DwWidget event handling methods.I.e., in most cases, they should simply return it. The events"link_pressed", "link_released" and "link_clicked" (but not"link_entered") are emitted by these functions, so that widgets whichlet the selection module handle links, should only emit "link_entered"for themselves. (See DwImage.txt for a description of this.)Selection State===============Selection interferes with handling the activation of links, so thelatter is also handled by the selection module. Details are based onfollowing guidelines: 1. It should be simple to select links and to start selection in links. The rule to distinguish between link activation and selection is that the selection starts as soon as the user leaves the link. (This is, IMO, a useful feature. Even after drag and drop has been implemented in dillo, this should be somehow preserved.) 2. The selection should stay as long as possible, i.e., the old selection is only cleared when a new selection is started.The latter leads to a model with two states: the selection state andthe link handling state.The general selection works, for events not pointing on links, likethis (numbers in parantheses after the event denote the button, "n"means arbitrary button): motion(1) ,-----. | | press(1) on non-link V | NONE -----------------------> SELECTING <----------------. ^ | | | | release(1) | | | | press(1) | no V yes | `----------------------- Anything selected? --------> SELECTEDThe selected region is represented by two DwExtIterators.Links are handled by a different state machine: ,-----------------------------. | | | Switch to selection | (SELECTING) for n == 1. | ^ | | no | | yes | Still the same link? --. | ^ | | | | | | motion(n) | V press(n) on links | | NONE ---------------------> PRESSED(n) <-----' ^ | | | release(n) | | | V yes | Still the same link? -----------------. | | | | | no V | V Send "clicked" signal. | Switch to selection | | (SELECTED) for n == 1. | | | | |`----------------------------' | | | `----------------------------------------------------------'Switching to selection simply means that the selection state willeventually be SELECTED/SELECTING, with the original and the actualposition making up the selection region. This happens for button 1,events with buttons other than 1 do not affect selection at all.TODO====* a_Selection_button_motion currently always assumes that button 1 has been pressed (since otherwise it would not do anything). This should be made a bit cleaner.* The selection should be cleared, when the user selects something somewhere else (perhaps switched into "non-active" mode, as some Gtk+ widgets do).
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -