Terminal screen drawing protection mode not fully implemented in xtermjs - xtermjs

Protected fields are normally protected from DESCSED erasure to support behaviour like clearing input data or updating areas without having to redraw the whole screen (maybe a throwback to 75 baud accousticly coupled modems).
Xtermjs InputHandler.ts currentlly says "Protection attributes are not supported".
The behaviour is that on an xtermjs session that prints protected and non-protected fields, DECSED will erase the whole screen, including the protected fields.
Is full support for DECSED,DECSEL,DECSCA, etc on the roadmap for xtermjs?

Related

When is localization (or lack of) a bad thing?

The following code returns a message which states whether the input value is a palindrome:
(for the sake of this post, the syntax isn't important, or written in any particular language)
function isPalindrome(
value: string,
successMessage: string = "Is palindrome",
failureMessage: string = "Is not palindrome"): string {
return value.reverse() == value ? successMessage : failureMessage;
}
Notice in the code above, the default messages are written in English, however as they are supplied as parameters, this method could easily be localized, and because the method has default values for the messages, this doesn't force the developer to provide them; for example:
isPalindrome("level") // returns "Is palindrome"
However we can demonstrate localization; for example, in spanish:
isPalindrome("level", "es palíndromo", "no es palíndromo") // returns "es palíndromo"
This got me thinking, when should code be designed with localization in mind?
Another example would be with exceptions; for example:
class PalindromeException : Exception("Is not a palindrome")
function validatePalindrome(value: string): void {
if (value.reverse() != value) {
throw PalindromeException();
}
}
Notice in this example that there is no way to localize the message in the exception. I know this could easily be fixed using the same principles in the first example, but it has been purposefully designed to demonstrate a lack of globalization.
Therefore, when should globalization be applied to code, so that it may be localized? When does it matter, and when does it not?
I believe, there's no ideal answer - everything depends on your architecture and use-cases.
However, I would suggest the following patterns:
All log messages (both server and client) should be in English
All error API responses should always provide a description in English and a unique error code which you can translate into a friendly message on the client side
In order to provide a good UX, all client messages should be in a user's language
In general, it's a good practice to have all technical data (logs, errors, etc) in English. All user-facing data has to be understandable for a user.
It strongly depends on your use-case. I would recommend to localise messages, that are displayed in a frontend, right away. My experience is, it's very costly to do it later. For debugging or monitoring messages I probably would do it just in english, 'cause most of developers are able to read english messages.
The only place where localization should take place is in the UI. If you’re sticking to the MVC principle of separation of concerns (or something similar like MVP or such), then the localization happens exclusively in the View part. Your isPalindrome function sounds more like business logic belonging to the Model part and should therefore not be concerned with i18n at all. Neither should exceptions worry about it, since no exception should ever be printed to the UI as is (except to provide debugging information, which doesn’t need to be/shouldn’t be localized).
Your function should only return true or false, and an entirely separate UI part should translate that into something user facing, potentially localizing it in the process. Same with the exception, it should be caught by something which loads an appropriately localized UI explaining the issue to the user.
All labels needs to be translated.
For this definition, text is an information being read by end user. In that context, a label is a piece of text which at the same time is not user input or user data.
To give an example, in an 'Save as' dialog the file name would be user input, the file content user data and the Save and Cancel labels on the two buttons would be the labels (and therefore in need of an translation).
Given this definition, the rule is as follows:
Only user interface code needs to translate and it translates all labels. On the opposite, business logic code not directly facing end users (such as libraries or backend services) shall not translate at all. Further, neither the business logic implementation nor the business logic API handles text other then user input or user data.
The rule thus also implicates clean separation of business logic code from user interface code. That comes very handy for testing.
For the palindrome example, the function would be business logic, and it would not return a text but something more suitable e.g. an boolean or enum. The user interface code would then evaluate the return and translate it appropriately. The same applies to the exception.

Has disabling TDataset.ObjectView side-effects?

Today I stumbled over the adt field types in Delphi Datasets. We use custom client datasets to bind objects to datasets in our views. With that dataset and our custom derivation of TDbGrid and enabled FastMM4 full debug mode we get an access violation with the following stack trace:
System.Generics.Collections.TListHelper.DoIndexOfFwd4((kein Wert))
System.Classes.TComponent.FreeNotification($7F961CE0)
Vcl.DBGrids.TColumn.SetField($7F971700)
Vcl.DBGrids.TColumn.GetField
Vcl.DBGrids.TCustomDBGrid.Notification($7F971220,???)
System.Classes.TComponent.RemoveFreeNotifications
System.Classes.TComponent.Destroy
Data.DB.TField.Destroy
System.TObject.Free
Data.DB.TFields.ClearBase(True)
Data.DB.TFields.ClearAutomatic`
Data.DB.TDataSet.DestroyFields
Datasnap.DBClient.TCustomClientDataSet.InternalClose
Data.DB.TDataSet.CloseCursor
Datasnap.DBClient.TCustomClientDataSet.CloseCursor
Data.DB.TDataSet.SetActive(???)
After some debugging fun, i found out that the internal FieldList of the Dataset contains a already destroyed field. After doing some more reasearch, I found out that disabling property
DataSet.ObjectView
disables the internal FieldList and the access violation goes away.
As we don't use ADT field types, I suspect disabling it does no harm, but one never knows.
Background
I've had already a lot of problems with TDataSet and TDbGrid, starting with the inherent problems of the flickering scollbar in the grid and ending in corrupt BCD-Parameters for oracle databases. We updated from XE3 to DX10, the access violation did not occur before.
I can not post the code of our custom dataset / custom grid
we are freeing the dataset before the grid

JSF 2.2 Multi Select Custom Component

To support our organization's component library, I would like to create an enhanced selectManyMenu. A requirement is that it resemble the type that features a dropdown menu, whose menu items have checkboxes showing whether they are selected. On top of this, I would like the the top row of the drop down, the area that is always visible to show 'bubbles' for lack of a better term, containing the label of the selected item as well as an 'X' button to remove each one, similar to a 'tag' widget.
I would like to create a JSF custom component, rather than decorating the existing <h:selectManyMenu> with some jQuery plugin that hides it and renders its own widget with a bunch of obfuscated javascript that I have no idea how it works. To be honest, none of the ones I've found fit in very well with our UI, and fundamentally I don't feel as though that is good use of JSF, to slop in some jQuery widget when JSF has such robust custom component features.
To get to my current problem, I have a custom component class set up that extends UIInput and provides the encode*() methods to render a <select> with its <option> tags same as an <h:selectManyMenu> does. I'm having a problem with the decode() method:
#Override
public void decode(FacesContext context) {
Map<String, String> requestParams = context.getExternalContext().getRequestParameterMap();
String clientId = getClientId();
Object param = requestParams.get(clientId);
LOG.debug("param: {}", param);
}
The issue is param ends up being a single string no matter how many items I select. I have verified on the front end the exact same POST request is sent when I use <h:selectManyMenu>, so I am guessing I have to do something different in decode() to all of the values from the request.
For bonus points, can anyone point me to some concise explanation of the source code for, say, even just <h:inputText>. I am able to browse the source for the JSF implementation we are using, Mojarra, but it gets extremely hard to follow since it uses separate renderers, and all sorts of factories and things to select which renderer to use, etc. I have gotten by so far by leaning on composite components, with backing components when necessary, but this one and a few others coming down the pipe I think are beyond what composite components can be used effectively for.
Also, is this the best approach to accomplish what I'm after? Would I be better off creating a custom renderer for the existing <h:selectManyMenu>? That seems like an even more elegant solution since this component basically IS a selectManyMenu just rendered a little differently and having a bit of javascript on the front end.
I gather your question boils down to:
How can I obtain a request parameter with multiple values in JSF?
The answer is: use ExternalContext#getRequestParameterValuesMap().
#Override
public void decode(FacesContext context) {
Map<String, String[]> requestParamValues = context.getExternalContext().getRequestParameterValuesMap();
String clientId = getClientId(context);
String[] params = requestParamValues.get(clientId);
// ...
}
but it gets extremely hard to follow since it uses separate renderers, and all sorts of factories and things to select which renderer to use, etc
Not sure, but perhaps you're looking for What is the relationship between component family, component type and renderer type? or How do I determine the renderer of a built-in component.
Would I be better off creating a custom renderer for the existing <h:selectManyMenu>? That seems like an even more elegant solution since this component basically IS a selectManyMenu just rendered a little differently and having a bit of javascript on the front end.
Makes indeed more sense.

Orchard CMS conditionally hide widget and suppress zone

I am trying to conditionally suppress a widget from its driver. I basically have logic that if met, should display the widget and if not, should suppress it. The widget loads properties from the current page content item, and based on some properties should display or hide. I've got all the logic working, the only part left is suppressing the actual output.
I've tried returning null from the driver, however this simply outputs an empty widget (with its wrapper). How do I completely remove the widget from view?
Finally, the zone that this widget is placed in should suppress if none of the conditional widgets display.
Is this type of flexibility possible in Orchard? Preferably from my custom module not my theme, I'm trying to separate functionality from styling.
EDIT:
Here is the context of my situation and what I am trying to accomplish. I'm sure there is a much cleaner way to do this within Orchard than how I have naively designed it the first go-around: My client's copywriters tag pages as they see fit (using the Tags module/part). I have created 2 custom content types, "Testimonials" and "Offers", both with tags themselves among other properties [these are managed by a different team of copywriters].
On most "inner pages" of the website (I'm using a layer to determine the appropriate pages), the page's sidebar gets a "Testimonial" widget and a "Offer" widget. These widgets both operate the same, although independently of each other:
They grab the tags of the current page, then pull a random [Testimonial|Offer] that has any matching tags as well. There are 4 cases that can happen given any inner page: a testimonial is displayed and the offer is hidden (testimonial tag matched, offer tag didn't), the testimonial is hidden and the offer is displayed, both the testimonial and offer displays, and finally neither displays. The first 3 use cases are working great, the 4th is what I'm having difficulty with, as the sidebar [zone] still displays even if both widgets do not (returning null from their respective drivers).
A bit of context about widgets: widgets are supposed to be pieces of contents that are visible on some or all pages of the site, and that provide information that is not directly related to the main content item on the page (if there is such a thing).
As a consequence, what you are describing should not be implemented as widgets (all that you had to do to make it work attests to that further), because they are really part of the content item. Instead, you should have implemented a part or a field. You can then simply place the shape for this part of field, using placement, by specifying a top-level zone: <place the_shape_name="/the_zone_where_you_want_it:1"/>
Unfortunately I've had to use a bit of a hack so that I could move on with the project as I'm under an aggressive deadline, but if there is a better method and/or solution I'll test as I get the chance and mark as the answer.
To get it to work, I overwrote the Widget.Wrapper.cshtml file within my theme. There, I assigned a variable to the Display(Model.Child) call, and if the result is an empty string simply return. This removes any empty widget wrapping tags. (I personally feel Orchard should behave this way by default):
var child = Display(Model.Child);
// -- NOTE: shape tracing breaks this logic!
if (string.IsNullOrWhiteSpace(child.ToString())) {
return;
}
Then simply replace the #Display(Model.Child) between the header and footer with #(child)
I then added the following method to my Layout.cshtml file.
Func<dynamic, IHtmlString> CollapsableZone = x =>
{
var display = Display(x);
string zoneName = x.ZoneName;
if (string.Equals(display.ToString(), string.Format("<div class=\"zone zone-{0}\"></div>", zoneName.HtmlClassify()), StringComparison.CurrentCultureIgnoreCase))
{
return new HtmlString(string.Empty);
}
return display;
};
Simple function that assigns the display call to a variable, checks if it is an empty zone tag, and returns. I then create variables for each zone assigned to the value of the function above. I replace all the #if (Model.ZoneName != null) with #if (!string.IsNullOrWhiteSpace(zoneVariable)), and replace the calls to #Zone(Model.ZoneName) with #(zoneVariable).
This is working for the time being. It is quite a hack and brittle solution but I've had to move on to other things.

bring the last loaded controls back when i restart the machine

I am working in video application in my application am using many controls for user friendly first i will Load the base from only after that i ll load the other controls based on user need.... here my need is if user load ten controls in this case if he shutdown the machine means when he restart the machine i need to bring the all controls back what he was load the controls before he shutdown. thanks in advance
is there is any possible to achive this without store the current control set, and positions etc..
You need to look at something like
Form and Control Position and Size
Utility
Save and restore Form position and
layout with this component
Basically what it boils down to, is that you need a way to store the current control set, and positions (possibly values too) to some sort of storage (XML file, Registry, Database) when the user exits your form/application.
Then once they reopen the form/application, you need to retrieve these settings for the given user (if any is available) and restore the form/application to that state.
How about making extension methods to Control class?
(Actually, appropriate .NET abstract base class, a sub-class of Control class, depending on UI. Do you use Windows Forms or XAML or ASP.NET?)
Something like:
public static class MyPositionExtensions{
public static void SaveState(this Control c){ /* Save position to xml-file */ }
public static void RestoreState(this Control c){ /* Load from xml-file */ }
}
Then in your closing just loop like
foreach(var c in MyControls)c.SaveState();
and opening like
foreach(var c in MyControls)c.RestoreState();

Resources