aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormitchell <70453897+667e-11@users.noreply.github.com>2010-04-05 15:57:13 -0400
committermitchell <70453897+667e-11@users.noreply.github.com>2010-04-05 15:57:13 -0400
commit6fe75a3f8fa0939bf2bcbea08b10c5f7d8cb7cc6 (patch)
tree45aa7527586acf68006eaeade3b39d8df7e87b0a
parentc9780bff7285d4bf756c689229add52b4701570b (diff)
downloadtextadept-6fe75a3f8fa0939bf2bcbea08b10c5f7d8cb7cc6.tar.gz
textadept-6fe75a3f8fa0939bf2bcbea08b10c5f7d8cb7cc6.zip
Removed kill-ring.
-rw-r--r--core/ext/key_commands.lua21
-rw-r--r--core/ext/menu.lua19
-rw-r--r--core/locale.conf24
-rw-r--r--modules/textadept/editing.lua77
4 files changed, 10 insertions, 131 deletions
diff --git a/core/ext/key_commands.lua b/core/ext/key_commands.lua
index 162f97a9..05543b4d 100644
--- a/core/ext/key_commands.lua
+++ b/core/ext/key_commands.lua
@@ -166,9 +166,6 @@ if not MAC then
-- TODO: { m_editing.convert_indentation }
-- TODO: { m_editing.smart_cutcopy }
-- TODO: { m_editing.smart_cutcopy, 'copy' }
- -- TODO: { m_editing.smart_paste }
- -- TODO: { m_editing.smart_paste, 'cycle' }
- -- TODO: { m_editing.smart_paste, 'reverse' }
keys.ac = { -- enClose in...
t = { m_editing.enclose, 'tag' },
T = { m_editing.enclose, 'single_tag' },
@@ -282,9 +279,9 @@ else
--[[
C: J M U W X Z
- A: D E H J K L U
+ A: D E H J K L U Y
CS: C D G H I J K L M O Q S T U V W X Y Z
- SA: A B C D H I J K L M N O Q R T U V X
+ SA: A B C D H I J K L M N O Q R T U V X Y
CA: A C E J K L M N O Q R S T U V W X Y Z
CSA: A C D E H J K L M N O P Q R S T U V W X Y Z
]]--
@@ -308,11 +305,11 @@ else
-- Edit
local m_editing = _m.textadept.editing
- keys.az = { 'undo', b }
- keys.aZ = { 'redo', b }
- keys.ax = { 'cut', b }
- keys.ac = { m_editing.smart_cutcopy, 'copy' }
- keys.av = { m_editing.smart_paste }
+ keys.az = { 'undo', b }
+ keys.aZ = { 'redo', b }
+ keys.ax = { 'cut', b }
+ keys.ac = { 'copy', b }
+ keys.av = { 'paste', b }
-- Delete is delete.
keys.aa = { 'select_all', b }
keys.cm = { m_editing.match_brace }
@@ -325,9 +322,7 @@ else
-- TODO: { m_editing.convert_indentation }
keys.ck = { m_editing.smart_cutcopy }
-- TODO: { m_editing.smart_cutcopy, 'copy' }
- keys.cy = { m_editing.smart_paste }
- keys.ay = { m_editing.smart_paste, 'cycle' }
- keys.aY = { m_editing.smart_paste, 'reverse' }
+ keys.cy = { 'paste', b }
keys.cc = { -- enClose in...
t = { m_editing.enclose, 'tag' },
T = { m_editing.enclose, 'single_tag' },
diff --git a/core/ext/menu.lua b/core/ext/menu.lua
index 40b2bdfa..49e46126 100644
--- a/core/ext/menu.lua
+++ b/core/ext/menu.lua
@@ -42,11 +42,6 @@ local ID = {
SQUEEZE = 213,
JOIN_LINES = 245,
CONVERT_INDENTATION = 216,
- CUT_TO_LINE_END = 217,
- COPY_TO_LINE_END = 218,
- PASTE_FROM_RING = 219,
- PASTE_NEXT_FROM_RING = 220,
- PASTE_PREV_FROM_RING = 221,
ENCLOSE_IN_HTML_TAGS = 224,
ENCLOSE_IN_HTML_SINGLE_TAG = 225,
ENCLOSE_IN_DOUBLE_QUOTES = 226,
@@ -170,13 +165,6 @@ local menubar = {
{ l.MENU_EDIT_SQUEEZE, ID.SQUEEZE },
{ l.MENU_EDIT_JOIN_LINES, ID.JOIN_LINES },
{ l.MENU_EDIT_CONVERT_INDENTATION, ID.CONVERT_INDENTATION },
- { title = l.MENU_EDIT_KR_TITLE,
- { l.MENU_EDIT_KR_CUT_TO_LINE_END, ID.CUT_TO_LINE_END },
- { l.MENU_EDIT_KR_COPY_TO_LINE_END, ID.COPY_TO_LINE_END },
- { l.MENU_EDIT_KR_PASTE_FROM, ID.PASTE_FROM_RING },
- { l.MENU_EDIT_KR_PASTE_NEXT_FROM, ID.PASTE_NEXT_FROM_RING },
- { l.MENU_EDIT_KR_PASTE_PREV_FROM, ID.PASTE_PREV_FROM_RING },
- },
{ title = l.MENU_EDIT_SEL_TITLE,
{ title = l.MENU_EDIT_SEL_ENC_TITLE,
{ l.MENU_EDIT_SEL_ENC_HTML_TAGS, ID.ENCLOSE_IN_HTML_TAGS },
@@ -394,12 +382,6 @@ local actions = {
[ID.SQUEEZE] = { m_editing.squeeze },
[ID.JOIN_LINES] = { m_editing.join_lines },
[ID.CONVERT_INDENTATION] = { m_editing.convert_indentation },
- -- Edit -> Kill Ring
- [ID.CUT_TO_LINE_END] = { m_editing.smart_cutcopy },
- [ID.COPY_TO_LINE_END] = { m_editing.smart_cutcopy, 'copy' },
- [ID.PASTE_FROM_RING] = { m_editing.smart_paste },
- [ID.PASTE_NEXT_FROM_RING] = { m_editing.smart_paste, 'cycle' },
- [ID.PASTE_PREV_FROM_RING] = { m_editing.smart_paste, 'reverse' },
-- Edit -> Selection -> Enclose in...
[ID.ENCLOSE_IN_HTML_TAGS] = { m_editing.enclose, 'tag' },
[ID.ENCLOSE_IN_HTML_SINGLE_TAG] = { m_editing.enclose, 'single_tag' },
@@ -494,7 +476,6 @@ local actions = {
_RELEASE, '--no-cancel'
},
}
-if MAC then actions[ID.PASTE] = { m_editing.smart_paste } end -- fix paste issue
-- Most of this handling code comes from keys.lua.
t.events.add_handler('menu_clicked',
diff --git a/core/locale.conf b/core/locale.conf
index f7c1e519..b4abb7ef 100644
--- a/core/locale.conf
+++ b/core/locale.conf
@@ -264,30 +264,6 @@ MENU_EDIT_JOIN_LINES "_Join Lines"
MENU_EDIT_CONVERT_INDENTATION "Convert _Indentation"
% core/ext/menu.lua
-% "_Kill Ring"
-MENU_EDIT_KR_TITLE "_Kill Ring"
-
-% core/ext/menu.lua
-% "_Cut to Line End"
-MENU_EDIT_KR_CUT_TO_LINE_END "_Cut to Line End"
-
-% core/ext/menu.lua
-% "C_opy to Line End"
-MENU_EDIT_KR_COPY_TO_LINE_END "C_opy to Line End"
-
-% core/ext/menu.lua
-% "_Paste From"
-MENU_EDIT_KR_PASTE_FROM "_Paste From"
-
-% core/ext/menu.lua
-% "Paste _Next From"
-MENU_EDIT_KR_PASTE_NEXT_FROM "Paste _Next From"
-
-% core/ext/menu.lua
-% "Paste _Previous From"
-MENU_EDIT_KR_PASTE_PREV_FROM "Paste _Previous From"
-
-% core/ext/menu.lua
% "S_election"
MENU_EDIT_SEL_TITLE "S_election"
diff --git a/modules/textadept/editing.lua b/modules/textadept/editing.lua
index 6803dc40..cc9dcc25 100644
--- a/modules/textadept/editing.lua
+++ b/modules/textadept/editing.lua
@@ -26,10 +26,6 @@ HIGHLIGHT_BRACES = true
AUTOINDENT = true
-- end settings
--- The kill-ring.
--- @field maxn The maximum size of the kill-ring.
-local kill_ring = { pos = 1, maxn = 10 }
-
-- Character matching.
-- Used for auto-matching parentheses, brackets, braces, and quotes.
local char_matches = {
@@ -137,7 +133,6 @@ textadept.events.add_handler('char_added',
end)
-- local functions
-local insert_into_kill_ring, scroll_kill_ring
local get_preceding_number
---
@@ -275,65 +270,18 @@ textadept.events.add_handler('file_before_save', prepare_for_save)
---
-- Cuts or copies text ranges intelligently. (Behaves like Emacs.)
-- If no text is selected, all text from the cursor to the end of the line is
--- cut or copied as indicated by action and pushed onto the kill-ring. If there
--- is text selected, it is cut or copied and pushed onto the kill-ring.
+-- cut or copied as indicated by action. If there is text selected, it is cut or
+-- copied.
-- @param copy If false, the text is cut. Otherwise it is copied.
--- @see insert_into_kill_ring
function smart_cutcopy(copy)
local buffer = buffer
local txt = buffer:get_sel_text()
if #txt == 0 then buffer:line_end_extend() end
txt = buffer:get_sel_text()
- insert_into_kill_ring(txt)
- kill_ring.pos = 1
if copy then buffer:copy() else buffer:cut() end
end
---
--- Retrieves the top item off the kill-ring and pastes it.
--- If an action is specified, the text is kept selected for scrolling through
--- the kill-ring.
--- @param action If given, specifies whether to cycle through the kill-ring in
--- normal or reverse order. A value of 'cycle' cycles through normally,
--- 'reverse' in reverse.
--- @param reindent Flag indicating whether or not to reindent the pasted text.
--- @see scroll_kill_ring
-function smart_paste(action, reindent)
- local buffer = buffer
- local anchor, caret = buffer.anchor, buffer.current_pos
- if caret < anchor then anchor = caret end
- local txt = buffer:get_sel_text()
- if txt == kill_ring[kill_ring.pos] then scroll_kill_ring(action) end
-
- -- If text was copied to the clipboard from other apps, insert it into the
- -- kill-ring so it can be pasted (thanks to Nathan Robinson).
- if #textadept.clipboard_text > 0 then
- local clipboard_text, found = textadept.clipboard_text, false
- for _, ring_txt in ipairs(kill_ring) do
- if clipboard_text == ring_txt then
- found = true
- break
- end
- end
- if not found then insert_into_kill_ring(clipboard_text) end
- end
-
- txt = kill_ring[kill_ring.pos]
- if txt then
- if reindent then
- local indent =
- buffer.line_indentation[buffer:line_from_position(buffer.current_pos)]
- local padding =
- string.rep(buffer.use_tabs and '\t' or ' ',
- buffer.use_tabs and indent / buffer.tab_width or indent)
- txt = txt:gsub('\n', '\n'..padding)
- end
- buffer:replace_sel(txt)
- if action then buffer.anchor = anchor end -- cycle
- end
-end
-
----
-- Selects the current word under the caret and if action indicates, deletes it.
-- @param action Optional action to perform with selected word. If 'delete', it
-- is deleted.
@@ -547,27 +495,6 @@ function convert_indentation()
buffer:end_undo_action()
end
--- Inserts text into kill_ring.
--- If it grows larger than maxn, the oldest inserted text is replaced.
--- @see smart_cutcopy
-insert_into_kill_ring = function(txt)
- table.insert(kill_ring, 1, txt)
- if #kill_ring > kill_ring.maxn then kill_ring[kill_ring.maxn + 1] = nil end
-end
-
--- Scrolls kill_ring in the specified direction.
--- @param direction The direction to scroll: 'forward' (default) or 'reverse'.
--- @see smart_paste
-scroll_kill_ring = function(direction)
- if direction == 'reverse' then
- kill_ring.pos = kill_ring.pos - 1
- if kill_ring.pos < 1 then kill_ring.pos = #kill_ring end
- else
- kill_ring.pos = kill_ring.pos + 1
- if kill_ring.pos > #kill_ring then kill_ring.pos = 1 end
- end
-end
-
-- Returns the number to the left of the caret.
-- This is used for the enclose function.
-- @see enclose