Commit Graph

101 Commits

Author SHA1 Message Date
Campbell Barton ffc4c126f5 Cleanup: move public doc-strings into headers for 'blenkernel'
- Added space below non doc-string comments to make it clear
  these aren't comments for the symbols directly below them.
- Use doxy sections for some headers.
- Minor improvements to doc-strings.

Ref T92709
2021-12-07 17:38:48 +11:00
Campbell Barton 501d2443d0 Cleanup: use const arguments for accessor functions 2021-06-30 16:42:19 +10:00
Campbell Barton 4b9ff3cd42 Cleanup: comment blocks, trailing space in comments 2021-06-24 15:59:34 +10:00
Bastien Montagne 253dbe71dc Refactor: remove `BKE_<id_type>_copy` functions.
Those were only shallow wrappers around `BKE_id_copy`, barely used (even
fully unused in some cases), and we want to get rid of those ID-specific
helpers for the common ID management tasks. Also prevents weird custom
behaviors (like `BKE_object_copy`, who was the only basic ID copy
function to reset user count of the new copy to zero).

Part of 71219.
2020-10-07 18:05:06 +02:00
Sebastian Parborg 2115232a16 Cleanup: Clang-Tidy readability-inconsistent-declaration-parameter-name fix
No functional changes
2020-09-04 21:04:16 +02:00
Jacques Lucke 91694b9b58 Code Style: use "#pragma once" in source directory
This replaces header include guards with `#pragma once`.
A couple of include guards are not removed yet (e.g. `__RNA_TYPES_H__`),
because they are used in other places.

This patch has been generated by P1561 followed by `make format`.

Differential Revision: https://developer.blender.org/D8466
2020-08-07 09:50:34 +02:00
Dalai Felinto 558f449f8c Cleanup: Text: Move to IDTypeInfo and remove unused BKE API. 2020-03-06 20:07:02 +01:00
Bastien Montagne 4bfa256ea4 Refactor ID make local to use a single flag parameter.
Instead of using anonymous booleans flags, also allows to keep the same
behavior in all cases, without needing special handling from calling
code for our beloved oddballs object proxies...
2020-03-04 11:43:31 +01:00
Kai Jægersen bf2d92b277 Text: add Text.select_set(...)
Support setting the selection for a text buffer
with support for negative indices, select_set(1, 1, -1, -1)
selects the entire buffer.
2019-10-04 06:00:08 +10:00
Campbell Barton dcad1eb03c Cleanup: move utf8 offset conversion into BLI_string_utf8
There isn't anything specific to text data with these functions.
2019-08-06 21:59:13 +10:00
Campbell Barton 433eb3f35d Text: toggle comment operator 2019-08-01 20:31:57 +10:00
Campbell Barton 366865dd02 Undo System: replace with simpler binary diffing buffer storage
Applying/undoing incremental changes didn't fit well when
mixed with periodic snapshots from mem-file undo.

This moves to a much simpler undo system.

- Uses array storage with de-duplication from `BLI_array_store`.
- Loads the buffer into existing text data,
  for better performance on large files.
- Has the advantage that Python operators can be supported
  since we don't depend on hard coded undo operations.

Solves T67045, T66695, T65909.
2019-07-17 21:19:22 +10:00
Campbell Barton a7ac40888f Text: buffer from text, optional length return arg
No functional changes (currently unused).
2019-07-11 14:19:55 +10:00
Campbell Barton e12c08e8d1 ClangFormat: apply to source, most of intern
Apply clang format as proposed in T53211.

For details on usage and instructions for migrating branches
without conflicts, see:

https://wiki.blender.org/wiki/Tools/ClangFormat
2019-04-17 06:21:24 +02:00
Campbell Barton de13d0a80c doxygen: add newline after \file
While \file doesn't need an argument, it can't have another doxy
command after it.
2019-02-18 08:22:12 +11:00
Campbell Barton eef4077f18 Cleanup: remove redundant doxygen \file argument
Move \ingroup onto same line to be more compact and
make it clear the file is in the group.
2019-02-06 15:45:22 +11:00
Campbell Barton 4ef09cf937 Cleanup: remove author/date info from doxy headers 2019-02-02 11:58:24 +11:00
Campbell Barton 65ec7ec524 Cleanup: remove redundant, invalid info from headers
BF-admins agree to remove header information that isn't useful,
to reduce noise.

- BEGIN/END license blocks

  Developers should add non license comments as separate comment blocks.
  No need for separator text.

- Contributors

  This is often invalid, outdated or misleading
  especially when splitting files.

  It's more useful to git-blame to find out who has developed the code.

See P901 for script to perform these edits.
2019-02-02 01:36:28 +11:00
Campbell Barton 88a80fcec8 Cleanup: commas at the end of enums
Without this clang-format may wrap them onto a single line.
2019-01-16 00:03:03 +11:00
Jacques Lucke 21744217ce Cleanup: remove some #if 0 blocks
Reviewers: brecht, campbellbarton

Differential Revision: https://developer.blender.org/D3802
2018-10-17 12:43:41 +02:00
Campbell Barton d0e3fbc06b Cleanup: remove undoing access, minor formatting
Access to undoing state isn't needed,
some text insert code was overly compacted.
2018-04-15 10:48:50 +02:00
Campbell Barton ad1ea9a427 Undo: split text undo steps out of the data-block
This moves undo storage into a separate struct which is passed
in from the undo system.
2018-04-05 15:22:33 +02:00
Campbell Barton 9d1de621e2 Cleanup: move undo opcodes out of public header 2018-03-24 12:46:25 +01:00
Bastien Montagne 9da7dfa158 Refactor ID copying (and to some extent, ID freeing).
This will allow much finer controll over how we copy data-blocks, from
full copy in Main database, to "lighter" ones (out of Main, inside an
already allocated datablock, etc.).

This commit also transfers a llot of what was previously handled by
per-ID-type custom code to generic ID handling code in BKE_library.
Hopefully will avoid in future inconsistencies and missing bits we had
all over the codebase in the past.

It also adds missing copying handling for a few types, most notably
Scene (which where using a fully customized handling previously).

Note that the type of allocation used during copying (regular in Main,
allocated but outside of Main, or not allocated by ID handling code at
all) is stored in ID's, which allows to handle them correctly when
freeing. This needs to be taken care of with caution when doing 'weird'
unusual things with ID copying and/or allocation!

As a final note, while rather noisy, this commit will hopefully not
break too much existing branches, old 'API' has been kept for the main
part, as a wrapper around new code. Cleaning it up will happen later.

Design task : T51804
Phab Diff: D2714
2017-08-07 16:39:55 +02:00
Bastien Montagne eeb9e5316a Make whole ID copying code use const source pointer.
Noisy change, but safe, and better do it sooner than later if we are to
rework copying code. Also, previous commit shows this *is* useful to
catch some mistakes.
2017-06-14 22:38:11 +02:00
Bastien Montagne b156674251 Fix missing datablocks types in id_make_local.
Adding make_local for vfont/gpencil/group/freestyle linestyle/mask/scene/sound/text.

Note that there are still some lose ends here, since some type are not handled by id_copy
(Scene, Sound and VFont), which means in case a datablock of that type is used both
directly and indirectly, localization will fail.

Scene copying might be doable though (maybe with a simple new 'full shalow' mode to existing BKE_scene_copy?),
not sure about sounds and vfonts... Situations where this becomes an issue should be very rare corner cases anyway.
2016-07-21 16:54:36 +02:00
Bastien Montagne 1b6cf7a99b Cleanup: get rid of BKE_text_unlink(), replace by usage of generic BKE_libblock_... API. 2016-06-25 18:12:23 +02:00
Campbell Barton 033b0789c8 Text Editor: Auto indent for backspace/delete
Editing with spaces + auto-indent didn't delete indentation as expected.
2016-03-11 00:06:09 +11:00
Campbell Barton de0119d087 BLI_storage: util function BLI_file_read_as_mem
Use for text loading and pasting from file.
2015-12-14 17:16:23 +11:00
Bastien Montagne e5916187e8 First step to handle missing libs/datablocks when reading a file.
Idea is, instead of ignoring completely missing linked datablocks, to
create void placeholders for them.

That way, you can work on your file, save it, and find again your missing data once
lib becomes available again. Or you can edit missing lib's path (in Outliner),
save and reload the file, and you are done.

Also, Outliner now shows broken libraries (and placeholders) with a 'broken lib' icon.

Future plans are also to be able to relocate missing libs and reload them at runtime.

Code notes:
    - Placeholder ID is just a regular datablock of same type as expected linked one,
      with 'default' data, and a LIB_MISSING bitflag set.
    - To allow creation of such datablocks, creation of datablocks in BKE was split in two step:
        + Allocation of memory itself.
        + Setting of all internal data to default values.

See also the design task (T43351).

Reviewed by @campbellbarton, thanks a bunch!

Differential Revision: https://developer.blender.org/D1394
2015-10-20 14:44:57 +02:00
Campbell Barton aca40295e8 Check ftell return values 2015-06-05 11:46:01 +10:00
Campbell Barton b1d758ae6b Cleanup: redundant struct declarations 2015-03-29 03:56:39 +11:00
Bastien Montagne 60e70c0c60 Fix T43159: Copying of linked datablocks using relpath leads to invalid paths in new copies.
Simply have to rebase onto main filepath when copying, if source datablock is lib and path is relative.

Afaict, only affected Image and Text datablocks. MovieClip would also be a candidate, but has
no copy implemented currently.
2015-01-08 14:38:48 +01:00
Campbell Barton 1dddad93c4 Fix Text editor home/end keys when theres a selection 2014-08-29 14:53:12 +10:00
Campbell Barton 617557b08e Code cleanup: remove TRUE/FALSE & WITH_BOOL_COMPAT define 2014-04-01 15:22:28 +11:00
Campbell Barton d900f5be55 Code cleanup: use bools where possible 2014-02-03 19:35:44 +11:00
Campbell Barton 0c6a01ca00 Use includes for blenderplayer stubs
exposes many incorrect and redundant stubs
2014-01-28 01:55:10 +11:00
Campbell Barton b9114cb609 UI: Use bool rather then int/short's where possible 2014-01-04 18:10:01 +11:00
Campbell Barton 26cbf331a8 text editor cursor motion (left/right arrows) with selected text typically jumps to either side of the selection previously the cursor would move and loose the selection too.
text button fields already did this.
2013-09-02 00:47:27 +00:00
Campbell Barton 8bf5ec4f8a code cleanup: de-duplicate BLI_ghashIterator_new/init and disable unused text undo print function. 2013-07-21 17:05:41 +00:00
Tamito Kajiyama d8c2709414 Better API design for making text datablocks after loading.
An optional 'internal' argument was added to the bpy.data.texts.load() operator.  
The changes in revision 57153 were reverted, so that the is_in_memory and is_dirty
properties of text datablocks are not editable again.

In the C API layer, BKE_text_load_ex() was introduced to allow for optionally
making text datablocks internal after loading.
2013-06-02 17:52:06 +00:00
Campbell Barton 9e75d276e3 holding ctrl when using arrow keys in the text editor didn't navigate newlines. 2013-05-01 00:15:22 +00:00
Campbell Barton aff410b558 style cleanup: odd indentation 2013-03-14 05:52:30 +00:00
Irie Shinsuke 5792e77239 Patch [#34373] Use i18n monospace font in Text editor and Python console
This patch allows Blender to display i18n monospace font in the text
editor and the Python interactive console. Wide characters that occupy
multiple columns such as CJK characters can be displayed correctly.
Furthermore, wrapping, selection, suggestion, cursor drawing, and
syntax highlighting should work.

Also fixes a bug [#34543]: In Text Editor false color in comment on cyrillic

To estimate how many columns each character occupies, this patch uses
wcwidth.c written by Markus Kuhn and distributed under MIT-style license:

  http://www.cl.cam.ac.uk/~mgk25/ucs/wcwidth.c

wcwidth.c is stored in extern/wcwidth and used as a static library.

This patch adds new API to blenfont, blenlib and blenkernel:

BLF_get_unifont_mono()
BLF_free_unifont_mono()
BLF_draw_mono()
BLI_wcwidth()
BLI_wcswidth()
BLI_str_utf8_char_width()
BLI_str_utf8_char_width_safe()
txt_utf8_offset_to_column()
txt_utf8_column_to_offset()
2013-03-12 07:25:53 +00:00
Campbell Barton 7f1ae2497b fix [#34275] Text autocomplete cuts words with accents or special characters
autocomplete is now unicode aware, using python api's checks for now. eventually we should have our own.
2013-02-19 16:13:41 +00:00
Campbell Barton ab7ca2dc44 fix for double clicking in the text editor not working usefully (double clicking a pair chars would select 3 - one to the left). 2013-02-14 03:03:12 +00:00
Sergey Sharybin fdfa5910b5 Fix #34040: Moving Normal Node with enabled Cycles Material Preview crashes
Issue was caused by couple of circumstances:

- Normal Map node requires tesselated faces to compute tangent space
- All temporary meshes needed for Cycles export were adding to G.main
- Undo pushes would temporary set meshes tessfaces to NULL
- Moving node will cause undo push and tree re-evaluate fr preview

All this leads to threading conflict between preview render and undo
system.

Solved it in  way that all temporary meshes are adding to that exact
Main which was passed to Cycles via BlendData. This required couple
of mechanic changes like adding extra parameter to *_add() functions
and adding some *_ex() functions to make it possible RNA adds objects
to Main passed to new() RNA function.

This was tricky to pass Main to RNA function and IMO that's not so
nice to pass main to function, so ended up with such decision:

- Object.to_mesh() will add temp mesh to G.main
- Added Main.meshes.new_from_object() which does the same as to_mesh,
  but adds temporary mesh to specified Main.

So now all temporary meshes needed for preview render would be added
to preview_main which does not conflict with undo pushes.

Viewport render shall not be an issue because object sync happens from
main thread in this case.

It could be some issues with final render, but that's not so much
likely to happen, so shall be fine.

Thanks to Brecht for review!
2013-02-05 12:46:15 +00:00
Campbell Barton fe83dc6882 dont add identifiers starting with digits to autocomplete 2013-01-16 04:43:37 +00:00
Campbell Barton dd62a2c375 text autocomplete
- make the popup box line up the X axis with the current word.
- add poll function for the operator
2012-12-31 16:24:49 +00:00
Justin Dailey c407c951a0 Text Editor: remove text marker functionality. Patch [#33251] 2012-11-23 14:33:14 +00:00