571 Commits

Author SHA1 Message Date
Arthur Rosenstein
0a5378134a Add document_undo_clear_stack()
This function clears a single undo/redo stack.
2013-11-09 15:13:34 +02:00
Colomban Wendling
fe0280037d Indentation width detection: try not to get fooled by comments
C-style multiline comments, used among others in C, C++ and Java, are
often continued on next lines with an additional space followed by an
asterisk:

  1.    /* first comment line
  2.     * continuation line (asterisk is aligned with previous line)
  3.     * last line */

This fools the indentation with detection because lines 2 and 3 from
the above example have an extra space in what is considered being the
line indentation.  In this example, the algorithm would detect an
indentation width of 5 rather than 4, because here most lines have an
indent of 5 -- although they actually have an indent of 4 plus a space
for alignment.  This is not a problem in most situations because there
generally are fewer comment continuation lines than actual code lines
which have a indent multiple of the actual indent width, but with some
code with a lot of comments (e.g. short functions with verbose
documentation comments) this might start to fool the algorithm and
give wrong, annoying, results.

So, try to detect these continuation lines and avoid taking them into
account.
2013-06-02 22:42:47 +02:00
Colomban Wendling
f6e9ac094a Remove use of some of our own deprecated Scintilla wrappers
Remove most obvious calls to our very own deprecated Scintilla wrapper
functions sci_get_text(), sci_get_text_range() and
sci_get_selected_text().

Some calls are still left, but they either really benefit from these
functions or the fix would be more complex.
2013-05-22 04:22:53 +02:00
Colomban Wendling
5412a244ba Fix crash with bulk pattern replacements (introduced with c83a93e)
"regex_match_text" and "regex_matches" being globals, performing
several searches and then the replacements separately lead to them
having unexpected values, resulting in incorrect behavior and crash.

Fix this by removing the globals and instead make the search functions
return match details.  Not only this fixes the issue, but also make the
code a lot more maintainable by not having globals introducing side
effects (proof of them being an issue is that c83a93e inadvertently
broke things bad).
2013-04-13 17:06:47 +02:00
Colomban Wendling
e409b70fab Fix various TMTag leaks 2013-03-17 17:31:36 +01:00
Colomban Wendling
35cc441b74 Merge branch 'gtk3-support'
Conflicts:
	src/ui_utils.c
2013-03-10 17:20:25 +01:00
Colomban Wendling
e5245eb053 Increase the number of lines where filename is replaced upon save as
Search the first 4 lines (instead of 3) for Python templates support.
2013-03-05 23:58:04 +01:00
Colomban Wendling
5b23669649 Fix replacing file name in headers upon save as
The code used a Scintilla-specific regex escape (\<) which doesn't work
anymore since the time we switched to full PCRE (which uses \b).  So,
update the regular expression to PCRE.

Also, properly escape the name to search in the unlikely case it has
regular expression escapes in it;  and properly check for word
boundaries even when not searching with an extension.
2013-03-05 23:47:37 +01:00
Colomban Wendling
e0104a4bc2 Port new configurable document status colors to GTK3 2013-02-11 04:47:21 +01:00
Colomban Wendling
36581d6638 Move document status color definition to the gtkrc file
This allows for users to change the colors if needed (may be useful
with some themes or color blind persons).

On the sidebar, only the color is applied for now.  This is because
it is not possible to style cell renderers through RC files, all having
to be done in the code;  so currently only the color is applied.
2013-02-11 04:46:40 +01:00
Nick Treleaven
6ca889c78b Add Document->Clone keybinding 2012-12-12 14:02:50 +00:00
Quentin Glidic
8c4db25396 Fix file saving behavior with "allow_always_save"
This preference should only be used for UI action, not for other file
saving triggering.
2012-12-02 17:22:06 +01:00
Nick Treleaven
c4b2457761 Fix clashing button mnemonic in detect/reload dialog (#3587465) 2012-11-28 13:50:27 +00:00
Evandro Borracini
3205eeaa71 Reduce unnecessary redraws when typing 2012-11-27 17:05:51 +00:00
Nick Treleaven
535b7a6b6e Copy selected text only (when present) for Document->Clone 2012-11-23 15:39:50 +00:00
Nick Treleaven
5200450b85 Clone line breaking, auto indent, indent type, indent width settings 2012-11-23 15:37:06 +00:00
Nick Treleaven
06661f36a5 Mark cloned documents as modified
This helps avoid accidental data loss.
2012-11-23 15:37:04 +00:00
Nick Treleaven
85006b6d0b Add 'Document->Clone' menu command
This copies the current document text and properties into a new
document, similar to the old Save As 'Open file in a new tab'
option, but easier to understand and decoupled from saving.

One notable difference is that the new document does not copy the
filename - the old behaviour was confusing and error-prone for the
user (e.g. editing two documents with the same filename).
2012-11-23 15:37:00 +00:00
Colomban Wendling
d80bc7ce56 Update FSF address
Closes #3557875.
2012-08-24 19:25:57 +02:00
Colomban Wendling
1c2c455b1d Update copyright information 2012-06-18 01:15:04 +02:00
Nick Treleaven
1a9451bfc4 Fix NULL tags array warning in document_highlight_tags 2012-04-23 16:17:40 +01:00
Matthew Brush
3bcd7fc400 Merge pull request #19 from techee/fixes
Fixes
2012-02-26 21:04:50 -08:00
Nick Treleaven
402249f1b8 Revert "Don't append file truncation warning if file doesn't exist"
This reverts commit 7cc443e1420b77d041815a464fe5b20bc62412f4.

Showing the truncation message only when the file exists doesn't work
when writing to a network file and the connection drops out (thanks to
Lex).
2012-02-06 16:14:42 +00:00
Colomban Wendling
ca340a8aa3 Properly handle remote URIs received through drag 'n drop
Closes #2966770, #3479567.
2012-01-31 15:22:20 +01:00
Nick Treleaven
7cc443e142 Don't append file truncation warning if file doesn't exist
This warning shown after a failed save is unnecessary when the
filename is invalid.
2012-01-26 15:42:06 +00:00
Nick Treleaven
b287553e4a Use 'SETPTR' instead of 'setptr'
This makes it clearer we're using a macro.
2012-01-25 16:26:16 +00:00
Nick Treleaven
21cd7bb213 Add Project overrides for 'Saving files' checkbox options 2012-01-19 18:17:12 +00:00
Jiří Techet
5cc8a96d44 Do not show document change notification dialog when MRU switch is in progress
When switching between MRU documents, Geany pops up a dialog about
document change even for the intermediate non-final documents.
This leads to both reload dialog and document switch dialog displayed
at the same time and termination of document switching because the
newly displayed dialog takes focus.

This patch disables reload checks for the intermediate documents and
forces reload check for the final document.
2012-01-12 00:33:50 +01:00
Matthew Brush
6c31ed4bc0 Re-highlight type keywords on notebook page switch 2012-01-03 10:21:09 -08:00
Colomban Wendling
0aea05d10d Fix various integer signedness and minor styling issues
Most noteworthy change is that all build commands IDs and groups are
now unsigned everywhere negative values aren't explicitly handled with
a special meaning.  This should not change anything in behavior, only
makes clear the index won't underflow.
2011-12-18 00:32:22 +01:00
Dimitar Zhekov
4ffbd8f9ad split "always wrap search and hide find dialog" pref into "always wrap search" and "hide find dialog" 2011-12-05 21:54:38 +01:00
Colomban Wendling
4a0a5f0a09 Don't try to parse 0-length data since TM don't support it 2011-11-23 00:51:46 +01:00
Dimitar Zhekov
6738d43dee --read-only cleanup
Use the global variable only when needed and add an initializer for it
in the default options.
2011-11-21 21:48:32 +01:00
Thomas Martitz
8f280ed884 New --read-only commandline option
This adds a new commandline option --read-only (or -r). It's implemented
according to the behavior agreed on on the mailing list:

--read-only applies to all files on the command line
irrespective of positioning and has no effect on any other files
opened by session or menu (...)

Current behaviour on attempting to re-open a file with different
read-only status is that nothing happens, the already open
file is raised but not changed. (...)
2011-11-17 16:41:51 +01:00
Colomban Wendling
048e6a6c3c Fix an assertion logic 2011-11-15 20:32:36 +01:00
Matthew Brush
d789c4d546 Queue colourise of the Scintilla widget after (re)setting type keywords 2011-11-12 18:15:28 -08:00
Colomban Wendling
8942bc810b Add Objective-C support
Based on a patch from Elias Pschernig, thanks.
Parser was taken from upstream CTags.

Closes patch#3325139.
2011-11-13 01:05:24 +01:00
Matthew Brush
9bffb94cc4 Real-time type keyword highlighting
* Add new function: document_update_tags().
* Refactor the various tag update functions into document_update_tags().
* Remove extra call to update the tags in document_new_file().
2011-11-11 16:08:26 -08:00
Colomban Wendling
3f31453ace Fix various integer sign and size issues 2011-11-06 01:12:42 +01:00
Matthew Brush
c1df8a7263 Use file type instead of lexer to decide if type keywords are supported
Not every filetype for a specific lexer implements type keywords even if the
lexer supports it.
2011-11-04 19:23:55 -07:00
Colomban Wendling
b55a30c2bf Build recent data for GTK ourselves
This prevents GTK of trying to fetch the necessary information like
MIME-type itself, which leads to a significant speedup (> 30%), as
well as using the real MIME-type we use rather than the GIO-guessed
one.
2011-11-04 00:11:21 +01:00
Colomban Wendling
0167f589b3 Small code cleanup
Use foreach_document() in a few places where appropriate and make
some code more consistent.
2011-11-03 19:22:40 +01:00
Matthew Brush
ff663c1678 Remove init_doc_struct() function from documents.c
This function was only used from document_create() and most of this code is
not needed since the memset() and g_new0() calls set the memory to all 0's,
which in this case should suffice to (re)set all the members to 0/NULL/FALSE.

Refactor so all the resetting to defaults code is done in remove_page()
only and then only do the required non-FALSE/NULL initialization in
document_create().

Move the remove_page() prototype to the top of the file and various other
minor changes in remove_page().
2011-11-02 23:24:10 -07:00
Matthew Brush
ea51c487d3 Use Scintilla's buffer directly for parsing tags 2011-11-02 21:50:34 -07:00
Matthew Brush
6ceb5ac164 Remove editor_lexer_get_type_keyword_idx() function
It was used only in one place in document_update_type_keywords() which
already did a similar check using the file type before calling this function.

Update HACKING file and very minor cleanup of other code in
document_update_type_keywords().
2011-11-02 20:18:12 -07:00
Nick Treleaven
de559ef5d4 Make document_save_file() show the Save As dialog when necessary
Previously an error message was shown if doc->file_name is NULL.

The Save As dialog is now shown if the document does not have an
absolute path. This is because the user should confirm where to save
the document in this case.

Although this changes plugin API behaviour, it seems the best way to
ensure the Save As dialog is always shown when needed so the user
knows where the document has been saved.
2011-11-02 15:17:17 +00:00
Nick Treleaven
f31a84869d Minor code cleanup for document_update_type_keywords()
Fix correctly checking result of editor_lexer_get_type_keyword_idx().
Do not check IS_SCINTILLA unnecessarily (this is covered by DOC_VALID).
Do not use G_[UN]LIKELY macros as this complicates code without any
real benefit (unless in a tight loop).
2011-11-01 16:07:52 +00:00
Nick Treleaven
fdd5537cc0 Use g_return_val_if_fail for some invalid NULL arguments 2011-10-31 17:22:39 +00:00
Nick Treleaven
b69198691a Add utils_filenamecmp(). 2011-10-31 17:08:23 +00:00
Matthew Brush
b1b88286cf Simplify updating Scintilla keywords on reload config and tab switch.
Remove type keywords caching function since it doesn't really speed up
anything and we don't care if the keywords change since they can/should
still be reloaded.  This also prevents "leaking" a static GString once
when the application closes and saves a call to g_string_free() when the
type keywords have changed.

Rename document_update_highlighting() to document_update_type_keywords()
since no re-highlighting is needed when updating Scintilla keywords.
Scintilla highlights the new keywords automatically so this saves a call
to queue_colourise().

Remove update_type_keywords() function since this is now all handled
in the document_update_type_keywords() function.  This function had a
comment about updating all documents when sci is NULL but it was never
used in this way since it was only called on document_load_config() which
always operates on a single document and the sci should not be NULL.
2011-10-19 21:39:17 -07:00