Commit graph

97 commits

Author SHA1 Message Date
Charlie Gordon
f0aa3a4bd8 cosmetics: untabify, remove trailing spaces 2015-08-27 23:03:39 +00:00
Charlie Gordon
581eef3b5d buffers: fix improbable bugs
- make kill buffers system buffers (not displayed in buffer-list)
- only create *scratch* buffer in qe_kill_buffer() if needed
- prevent crash if killing style, log or kill buffers
- display \n as ^J in minibuf
2015-08-27 22:51:56 +00:00
Charlie Gordon
060f860756 fix more linux compilation warnings 2015-08-27 18:59:56 +00:00
Charlie Gordon
9ab179d048 fix linux compile warnings 2015-08-27 18:52:30 +00:00
Charlie Gordon
9331372a54 modes: upgrade mode selection and handling
- separate buffer and window specific mode data management, new API:
   QEModeData *qe_create_buffer_mode_data(EditBuffer *b, ModeDef *m);
   void *qe_get_buffer_mode_data(EditBuffer *b, ModeDef *m, EditState *e);
   QEModeData *qe_create_window_mode_data(EditState *s, ModeDef *m);
   void *qe_get_window_mode_data(EditState *e, ModeDef *m, int status);
   int qe_free_mode_data(QEModeData *md);
- make a list of buffer specific mode data areas so multiple major modes
  can co-exist in different windows for the same buffer
- add mode.mode_free callback to release buffer specific resources
- remove buffer.close callback
- shell state is now buffer specific shell_mode data
- clean up compress and archive mode
- show more buffer modes in buffer-list
- simplify edit_set_mode(), display error message on failure
2015-08-27 15:31:59 +00:00
Charlie Gordon
f408a15503 buffers: misc improvements
- renamed kill_buffer_noconfirm(b) to qe_kill_buffer(b)
- pass extra argument to do_kill_buffer(b, force)
- add buffer name cache to quicken eb_find()
- always make buffer names unique with simpler naming scheme
- small improvement in new_yank_buffer()
2015-08-26 00:53:23 +00:00
Charlie Gordon
bc874d74b7 buffers: improved tracing function
- add EB_TRACE_COMMAND
- change the format of the *trace* buffer
2015-08-26 00:24:14 +00:00
Charlie Gordon
9014b3de79 buffers: clean up, add data_type_name
- rename raw_buffer_load1() to eb_raw_buffer_load1()
- rename log_reset() to eb_free_log_buffer()
- add buffer.data_type_name to display proper handler on modeline
2015-08-25 16:19:42 +00:00
Charlie Gordon
7b996ac907 buffers: changed find_page() low-level routine
- pass offset separately from page_offset return value.
  This will ease the change of int type to support huge files in 64 bits.
- use the page cache also for offsets beyond the page cache.
2015-08-24 12:59:25 +00:00
Charlie Gordon
315147c81f buffers: fixed crash bug and pathological memory fragmentation
- simplify eb_insert_low_level() and eb_insert_buffer() to avoid
  pathological cases of kill/yank sequences loading to catastrophic
  fragmentation. eg: kill a 1 byte region and yank it 1000 times
- mmapped pages are (temporarily) no longer shared between buffers
2015-08-22 20:49:01 +00:00
Charlie Gordon
bccfbef8a0 window handling, bufed/dired: fixed bugs, simplified code
- make show_popup(b) return the window
- pass an extra window argument to find_window() as a default return value
- add check_buffer(EditBuffer **sp) to validate a buffer pointer
- changed eb_find_window(): find a different window attached to a given buffer
- removed edit_find(), use eb_find_window() instead
- change edit_attach():
  take window before which to move arg window, use NULL to append at the end.
  If qs->active_window is NULL, set it to the first window
- add buffer flags BF_IS_LOG and BF_IS_STYLE
- create style buffers with a meaningful name
- create log buffers with a meaningful name
- add window flag WF_POPLEFT for dired interactive buffers
- no longer create process buffer and find files in dired pop left pane
- remember last buffer upon switch_to_buffer for predict_switch_to_buffer()
- rename do_file1() as extern qe_load_file() and make it return success status
- prevent do_find_file_other_window() from splitting window if too shallow
- fix window fusion algorithm when deleting left pane with split right pane
- prevent delete-other-windows() from minibuf and poups
- use mode structure as signature for bufed-mode, shell-mode
- make list-buffers open an interactive popup window
- toggle full buffer list with '.'
2015-08-19 19:20:57 +00:00
Charlie Gordon
1033a348d8 search: another 35% speed improvement on large files
- improve utf8 handling in eb_prevc() using eb_read_one_byte()
- added utf8_is_trailing_byte(b) to standardize testing for this
- improve hex searching by 50% using eb_read_one_byte()
- improve regular searching by 35% by removing extra calls to eb_nextc()
2015-08-16 23:15:01 +00:00
Charlie Gordon
e80cb5a149 search: another 2.5x speed improvement on large files
- simplify eb_read() and eb_write() primitives
- make eb_write() return number of bytes actually written
- add eb_read_byte(buffer, offset) to read a single byte
- simplify eb_nextc() accordingly
2015-08-16 19:22:01 +00:00
Charlie Gordon
5af9d29a2e searching: many improvements
- clean search and replace code
- fix point position upon matches in forward and backward directions
- prevent reverse search from find overlapping matches
- hilite current match
- add style search-match to hilite the current match in incremental-search
  defaults to cyan / magenta
- C-l centers the window
- C-q quotes next character in incremental search
- C-w grabs the word at point
- C-y grabs from point to next end of line
- A-b cycles unihex hex and normal search
- A-w toggles word matching
- A-y yanks last kill in search string
- add same control keys to query-replace command
- fix searching and replacing in hex and unihex modes
- wrap search after failure
- pass search data as u32 buffer
- add eb_insert_u32_buf(b, offset, buf, len) to insert unicode code points
- add window.offset_end -> offset of first char beyond the window
- add qestate.emulation_flags to select between standard emacs behaviour and
  alternate behaviours in internal commands
- fix do_center_cursor() when point is before window start
- add do_center_cursor_maybe() to center window if point is not visible
- allow C-q to quote DEL key (ASCII 127)
2015-08-15 13:08:41 +00:00
Charlie Gordon
2b5d26028e fixed cr lf translation for older mac files
* when MAC_EOL end of line is used, \n and \r are swapped for internal
  EOL handling and restored, but restored for display in hex and
  what-cursor-position buffer contents display.
2015-06-08 06:54:56 +00:00
Charlie Gordon
ebc8f89a82 prevent strict warnings 2014-05-27 22:59:48 +00:00
Charlie Gordon
061b18655c clean up header, rename some fields 2014-05-26 14:35:37 +00:00
Charlie Gordon
f9f5ef791a fixed bugs in memory mapped buffers
* unmap file upon buffer clear
* fix bug that caused file to be mmapped AND loaded (!)
2014-05-18 11:01:55 +00:00
Charlie Gordon
90971b9861 improve c-mode
* add indent_func method in ModeDef
* make c-indent-region more general as indent-region
* add c-forward-conditional on M-]
* add c-backward-conditional on M-[
* add c-list-conditionals on M-i
* use trick to disambiguate M-[ and CSI sequences
* add eb_is_in_indentation(b, offset)
* fix c-mode indentation of case and default lines
2014-03-23 01:11:34 +00:00
Charlie Gordon
0e9fbc96a1 add tabify / untabify support
* add tabify-buffer and tabify-region
* add untabify-buffer and untabify-region
* make eb_delete and eb_delete_range return actual number of bytes removed
* simplify some deletions with better use of eb_delete_xxx functions
2014-03-21 20:49:30 +00:00
Charlie Gordon
c455dedb3e add global variable backup-inhibited
* do not backup files if backup-inhibited
2014-03-15 23:15:53 +00:00
Charlie Gordon
2841a9dc96 fix tab behaviour
* add eb_insert_spaces(b, offset, count)
* add qe_mode_set_key(m, keystr, cmdname)
* removed duplicated pager_commands, register bindings instead
* use undo to remove spaces inserted by tab if !indent_tabs_mode
* change do_tab to insert indentation with spaces depending on
  indent_tabs_mode and indent_size
2014-03-15 22:52:51 +00:00
Charlie Gordon
bfcb396455 Fix inconsistencies in shell mode
* clear interactive window flag upon mode change
* enable interactive mode upon vertical cursor movement
* add more checks for private data consistency
* free shell data upon process exit in non interactive shell buffers
* added shell-command command on M-!
* make kill_buffer_noconfirm() public to remove buffer safely
2014-03-03 23:35:46 +00:00
Charlie Gordon
b98ba068ff Use more general API to read buffer contents
* add eb_get_region_contents()
* add eb_get_region_content_size()
* implement eb_get_contents() and eb_get_content_size() inline
2014-02-10 21:27:53 +00:00
Charlie Gordon
05ab3dc386 Improve charset detection and handling
* add charset_raw for binary files
* improve charset detection for ambiguous cases
* add do_show_coding_system()
* add do_set_auto_coding() to (re)select the best coding system
* handle BOM mark: display as \ufeff and ignore for syntax coloring
2014-02-10 20:29:26 +00:00
Charlie Gordon
15ab1f9601 improve x11 clipboard support
* add eb_get_content_size() to compute size of buffer contents encoded in utf8
* simplify selection_send()
2014-02-07 15:56:15 +00:00
Charlie Gordon
a7853b3dff add support for end of line types
* support 3 types of end of line: Unix, Dos and old style Mac
* detect eol type automatically in detect_charset
* set buffer eol_type together with charset
* transparently convert eol sequence to \n upon reading buffers
  characters in eb_nextc().
* transparently convert \n to eol sequence in eb_encode_uchar()
* handle eol types in convert-file-buffer-coding-system: either preserve
  current value or force it via charset suffix -unix, -doc and -mac
* change read_charset() to accept eol_type suffix
* add eol_type and eol_char to CharsetDecodeState
* change charset methods to take CharsetDecodeState instead of charset pointers
* display eol_type in mode line if not unix
2014-02-05 00:56:48 +00:00
Charlie Gordon
d0c2e1d3e6 replace unicode_to_charset with eb_encode_uchar
* prepare support for eol_type support by making char encoding buffer specific
* fix small bugs and unsafe cases.
* fix bug in eb_goto_pos for EBCDIC charsets
2014-02-04 22:47:31 +00:00
Charlie Gordon
645b9c1aeb cosmetic changes
* report lack of undo information in do_undo and do_redo
* make region command remove region highlight
2014-01-31 14:50:13 +00:00
Charlie Gordon
87a1d39c9f cosmetic changes in buffer API
* make eb_insert return number of bytes inserted
* make eb_printf return number of bytes inserted (was length of utf8 string)
2014-01-31 12:14:13 +00:00
Charlie Gordon
acf421085a fix compilation warnings 2014-01-25 09:21:48 +00:00
Charlie Gordon
c5f56a0d5b Fix memory leaks and bad references detected by valgrind
* add free_font_cache()
* add css_free_colors()
* add unload_ligatures()
* add --free-all cmd line option to free memory upon exit for valgrind
* tty.c: fix off by 3 size in qe_realloc. Should be typed
* qe.c: fix invalid pointer reference upon destroying transient buffer
2014-01-24 00:46:26 +00:00
Charlie Gordon
e967914b5a improve consistency in new/delete methodology
* use qe_mallocz for all structures
* prevent spurious uses of malloc/free/realloc
* pass pointers to pointers to all deletion functions
* use consistent patterns for list deletions
* add more dependencies in Makefiles
2014-01-23 12:56:22 +00:00
Charlie Gordon
b953aaf811 improve consistency in buffer variables
* change tab-size to tab-width
* make tab-width a buffer variable
* add fill-column buffer variable
* add set-fill-column on C-x f
* add default-tab-width and default-fill-column global variables
* force indent-tabs-mode in makefile mode
* force tab-width to 8 in shell output buffers
2014-01-21 00:01:20 +00:00
Charlie Gordon
c0b4323ef9 merge eb_is_blank_line and eb_is_empty_line, simplify paragraph commands
* simplify eb_is_blank_line
* remove eb_is_empty_linek
* simplify paragraph commands with eb_is_blank_line
2014-01-19 17:25:02 +00:00
Charlie Gordon
571a96441b make new buffers use utf8 charset by default
* added BF_RAW flag for undo and styles buffers
2014-01-16 15:18:44 +00:00
Charlie Gordon
82adc44256 simplify eb_get_strline and fix eb_get_contents
* simplify eb_get_strline using buf_putc_utf8
* fix eb_get_contents for non utf8 buffers
2014-01-16 13:45:04 +00:00
Charlie Gordon
02da1bb7a1 add generic styles buffer from shell color mode
* styles_buffer hold static style info for each character in the buffer
* new buffer flags to create styles buffers with 1, 2 or 4 bytes per char
* copy static styles to the kill_ring and pasted them style enabled buffers
* preserve static styles in convert-buffer-file-coding-system
* display style bytes in bufed list
* add commands set-region-color, set-region-style, drop-styles
2014-01-15 19:44:24 +00:00
Charlie Gordon
c258955d08 improve undo system
* use bit 2 in b->save_log to suspend callbacks and logging during transient
  undo phase.
* dispatch callbacks before buffer modification (eb_delete)
* this fixes bugs in the undo system where some offsets were not properly
  updated, color buffer was shifted, cursor would get lost and sometimes
  crash would follow.
* buffer colors are not undone properly
* pass extra int argument to buffer callbacks
* make eb_offset_callback more generic: handle edge effect via extra arg.
  edge effect causes offset to move upon insertion at current value
* add new log variables log_last_char and last_log.
  use these to coalesce consecutive log records and make undo more efficient
* add new command "redo" on C-x C-_ and C-x r
* fix undo glitches in the process buffer, update cursor correctly upon redo
2014-01-14 03:29:36 +00:00
Charlie Gordon
9b4582fd0d fix undo bugs
* use bit 2 in b->save_log to suspend callbacks and logging during transient
  undo phase.
* dispatch callbacks before buffer modification (eb_delete)
* this fixes bugs in the undo system where some offsets were not properly
  updated, color buffer was shifted, cursor would get lost and sometimes
  crash would follow.
* buffer colors are not undone properly
2014-01-13 23:38:15 +00:00
Charlie Gordon
10584b584e extend eb_skip_chars, eb_delete_chars
* accept negative displacement in eb_skip_chars, eb_delete_chars
2014-01-13 10:31:56 +00:00
Charlie Gordon
82157e67bf extend eb_match_xxx APIs to update end offset 2014-01-11 15:07:14 +00:00
Charlie Gordon
592ab5ebc3 add some buffer APIs
* add buffer APIs for matching and inserting text:
  - eb_insert_str
  - eb_match_uchar
  - eb_match_str
  - eb_match_istr
* simplify eb_insert_utf8_buf: no longer accept -1 len
2014-01-11 14:38:30 +00:00
Charlie Gordon
4fcebb6fbc small fixes in buffer APIs
* fix bug in eb_delete_chars
* pass len=-1 for zero terminated strings in eb_insert_utf8_buf
2014-01-10 01:17:14 +00:00
Charlie Gordon
9a58b44917 new character based APIs for buffers
* add eb_skip_chars
* rename eb_delete_nextc to eb_delete_uchar
* deprecate eb_line_pad
* use char based buffer API in orgmode
2014-01-08 16:26:44 +00:00
Charlie Gordon
d7eb78adc7 fix c89 compilation for Haiku 2014-01-07 00:49:14 +00:00
Charlie Gordon
deb6972ca3 better charset handling
* make eb_insert_buffer return the number of bytes inserted
* reset page bits upon charset change
* add eb_delete_nextc: delete one encoded character at offset
* add eb_insert_uchar: insert a unicode character with encoding
* add eb_insert_utf8_buf: insert a utf8 encoded buffer with conversion
* make eb_printf insert utf8 bytes with conversion
* add eb_insert_buffer_convert: copy chars between buffers with charset
  conversion
* handle charset conversion correctly in various places
* insert wide caracters from hex mode
* create most buffers as BF_UTF8 by default
* set kill-buffer charset to that of kill source
* convert charsets when yanking
* handle charsets in search/replace system
2014-01-06 09:40:20 +00:00
Charlie Gordon
2dbe907a64 move first_buffer_data_type to QEmacsState 2014-01-04 17:32:42 +00:00
Charlie Gordon
b3a709013a improve mode selection, cleanup
* pass ModeDef pointer to mode_probe functions
* add extensions field to mode structure
* rename ascii mode to binary mode
* rename mode variables and fields to more specific names
2014-01-04 17:26:30 +00:00
Charlie Gordon
b9d6113ba3 improve unicode hex display mode
* filter control characters and non BMP1 code points
* new mode specific modeline
* do not space out single width glyphs (not very readable)
* eb_get_char_offset: add validation on offset argument
* eb_get_char_offset: align offset argument on character boundary
2014-01-04 15:54:48 +00:00